1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 fileSystem = new MockFileSystem('fake-media-volume');
10 '/DCIM/photos0/IMG00001.jpg',
11 '/DCIM/photos0/IMG00002.jpg',
12 '/DCIM/photos0/IMG00003.jpg',
13 '/DCIM/photos0/MyNote.txt',
14 '/DCIM/photos0/.HiddenFile.jpg',
15 '/DCIM/photos1/IMG00001.jpg',
16 '/DCIM/photos1/IMG00002.jpg',
17 '/DCIM/photos1/IMG00003.jpg'
19 fileSystem.populate(filenames);
22 function testcreateEntrySet(callback) {
23 var emptySelectionPromise = GalleryUtil.createEntrySet([
24 ]).then(function(results) {
25 assertEquals(0, results.length);
28 var singleSelectionPromise = GalleryUtil.createEntrySet([
29 fileSystem.entries['/DCIM/photos0/IMG00002.jpg']
30 ]).then(function(results) {
31 assertEquals(3, results.length);
32 assertEquals('/DCIM/photos0/IMG00001.jpg', results[0].fullPath);
33 assertEquals('/DCIM/photos0/IMG00002.jpg', results[1].fullPath);
34 assertEquals('/DCIM/photos0/IMG00003.jpg', results[2].fullPath);
37 // If a hidden file is selected directly by users, includes it.
38 var singleHiddenSelectionPromise = GalleryUtil.createEntrySet([
39 fileSystem.entries['/DCIM/photos0/.HiddenFile.jpg']
40 ]).then(function(results) {
41 assertEquals(4, results.length);
42 assertEquals('/DCIM/photos0/.HiddenFile.jpg', results[0].fullPath);
43 assertEquals('/DCIM/photos0/IMG00001.jpg', results[1].fullPath);
44 assertEquals('/DCIM/photos0/IMG00002.jpg', results[2].fullPath);
45 assertEquals('/DCIM/photos0/IMG00003.jpg', results[3].fullPath);
48 var multipleSelectionPromise = GalleryUtil.createEntrySet([
49 fileSystem.entries['/DCIM/photos0/IMG00001.jpg'],
50 fileSystem.entries['/DCIM/photos0/IMG00002.jpg'],
51 ]).then(function(results) {
52 assertEquals(2, results.length);
53 assertEquals('/DCIM/photos0/IMG00001.jpg', results[0].fullPath);
54 assertEquals('/DCIM/photos0/IMG00002.jpg', results[1].fullPath);
57 var multipleSelectionReverseOrderPromise = GalleryUtil.createEntrySet([
58 fileSystem.entries['/DCIM/photos0/IMG00002.jpg'],
59 fileSystem.entries['/DCIM/photos0/IMG00001.jpg'],
60 ]).then(function(results) {
61 assertEquals(2, results.length);
62 assertEquals('/DCIM/photos0/IMG00001.jpg', results[0].fullPath);
63 assertEquals('/DCIM/photos0/IMG00002.jpg', results[1].fullPath);
66 var multipleHiddenSelectionPromise = GalleryUtil.createEntrySet([
67 fileSystem.entries['/DCIM/photos0/IMG00001.jpg'],
68 fileSystem.entries['/DCIM/photos0/.HiddenFile.jpg']
69 ]).then(function(results) {
70 assertEquals(2, results.length);
71 assertEquals('/DCIM/photos0/.HiddenFile.jpg', results[0].fullPath);
72 assertEquals('/DCIM/photos0/IMG00001.jpg', results[1].fullPath);
75 reportPromise(Promise.all([
76 emptySelectionPromise,
77 singleSelectionPromise,
78 singleHiddenSelectionPromise,
79 multipleSelectionPromise,
80 multipleSelectionReverseOrderPromise,
81 multipleHiddenSelectionPromise