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 emptrySelectionPromise
= createEntrySet([]).then(function(results
) {
24 assertEquals(0, results
.length
);
27 var singleSelectionPromise
= createEntrySet([
28 fileSystem
.entries
['/DCIM/photos0/IMG00002.jpg']
29 ]).then(function(results
) {
30 assertEquals(3, results
.length
);
31 assertEquals('/DCIM/photos0/IMG00001.jpg', results
[0].fullPath
);
32 assertEquals('/DCIM/photos0/IMG00002.jpg', results
[1].fullPath
);
33 assertEquals('/DCIM/photos0/IMG00003.jpg', results
[2].fullPath
);
36 // If a hidden file is selected directly by users, includes it.
37 var singleHiddenSelectionPromise
= createEntrySet([
38 fileSystem
.entries
['/DCIM/photos0/.HiddenFile.jpg']
39 ]).then(function(results
) {
40 assertEquals(4, results
.length
);
41 assertEquals('/DCIM/photos0/.HiddenFile.jpg', results
[0].fullPath
);
42 assertEquals('/DCIM/photos0/IMG00001.jpg', results
[1].fullPath
);
43 assertEquals('/DCIM/photos0/IMG00002.jpg', results
[2].fullPath
);
44 assertEquals('/DCIM/photos0/IMG00003.jpg', results
[3].fullPath
);
47 var multipleSelectionPromise
= createEntrySet([
48 fileSystem
.entries
['/DCIM/photos0/IMG00001.jpg'],
49 fileSystem
.entries
['/DCIM/photos0/IMG00002.jpg'],
50 ]).then(function(results
) {
51 assertEquals(2, results
.length
);
52 assertEquals('/DCIM/photos0/IMG00001.jpg', results
[0].fullPath
);
53 assertEquals('/DCIM/photos0/IMG00002.jpg', results
[1].fullPath
);
56 var multipleSelectionReverseOrderPromise
= createEntrySet([
57 fileSystem
.entries
['/DCIM/photos0/IMG00002.jpg'],
58 fileSystem
.entries
['/DCIM/photos0/IMG00001.jpg'],
59 ]).then(function(results
) {
60 assertEquals(2, results
.length
);
61 assertEquals('/DCIM/photos0/IMG00001.jpg', results
[0].fullPath
);
62 assertEquals('/DCIM/photos0/IMG00002.jpg', results
[1].fullPath
);
65 var multipleHiddenSelectionPromise
= createEntrySet([
66 fileSystem
.entries
['/DCIM/photos0/IMG00001.jpg'],
67 fileSystem
.entries
['/DCIM/photos0/.HiddenFile.jpg']
68 ]).then(function(results
) {
69 assertEquals(2, results
.length
);
70 assertEquals('/DCIM/photos0/.HiddenFile.jpg', results
[0].fullPath
);
71 assertEquals('/DCIM/photos0/IMG00001.jpg', results
[1].fullPath
);
74 reportPromise(Promise
.all([
75 emptrySelectionPromise
,
76 singleSelectionPromise
,
77 singleHiddenSelectionPromise
,
78 multipleSelectionPromise
,
79 multipleSelectionReverseOrderPromise
,
80 multipleHiddenSelectionPromise