OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @enum {string} | |
7 * @const | |
8 */ | |
9 var EntryType = { | |
yoshiki
2013/09/10 04:38:55
Object.freeze?
hirono
2013/09/10 04:56:02
Done.
| |
10 FILE: 'file', | |
11 DIRECTORY: 'directory' | |
12 }; | |
13 | |
14 /** | |
15 * @enum {string} | |
16 * @const | |
17 */ | |
18 var SharedOption = { | |
yoshiki
2013/09/10 04:38:55
ditto
hirono
2013/09/10 04:56:02
Done.
| |
19 NONE: 'none', | |
20 SHARED: 'shared' | |
21 }; | |
22 | |
23 | |
24 /** | |
25 * File system entry information for tests. | |
26 * | |
27 * @param {EntryType} entryType Entry type. | |
28 * @param {string} sourceFileName Source file name that provides file contents. | |
29 * @param {string} targetName Name of entry on the test file system. | |
30 * @param {string} mimeType Mime type. | |
31 * @param {string} typeText Type name to be shown in the type column. | |
32 * @param {string} sizeText Size text to be shown in the size column. | |
33 * @param {SharedOption} sharedOption Shared option. | |
34 * @param {string} lastModifiedTime Last modified time as a text to be shown in | |
35 * the last modified column. | |
36 * @constructor | |
37 */ | |
38 var TestEntryInfo = function(entryType, | |
39 sourceFileName, | |
40 targetName, | |
41 mimeType, | |
42 typeText, | |
43 sizeText, | |
44 sharedOption, | |
45 lastModifiedTime) { | |
46 this.entryType = entryType; | |
47 this.sourceFileName = sourceFileName; | |
48 this.targetName = targetName; | |
49 this.mimeType = mimeType; | |
50 this.typeText = typeText; | |
51 this.sizeText = sizeText; | |
52 this.sharedOption = sharedOption; | |
53 this.lastModifiedTime = lastModifiedTime; | |
54 }; | |
yoshiki
2013/09/10 04:38:55
Object.seal(this)?
hirono
2013/09/10 04:56:02
This object is immutable, so we can freeze this.
| |
55 | |
56 /** | |
57 * Obtains a expected row contents of the file in the file list. | |
58 */ | |
59 TestEntryInfo.prototype.getExpectedRow = function() { | |
60 return [this.targetName, this.sizeText, this.typeText, this.lastModifiedTime]; | |
61 }; | |
62 | |
63 /** | |
6 * Expected files before tests are performed. Entries for Local tests. | 64 * Expected files before tests are performed. Entries for Local tests. |
7 * @type {Array.<Array.<string>>} | 65 * @type {Array.<Array.<string>>} |
8 * @const | 66 * @const |
9 */ | 67 */ |
10 var EXPECTED_FILES_BEFORE_LOCAL = [ | 68 var EXPECTED_FILES_BEFORE_LOCAL = [ |
11 ['hello.txt', '51 bytes', 'Plain text', 'Sep 4, 1998 12:34 PM'], | 69 ['hello.txt', '51 bytes', 'Plain text', 'Sep 4, 1998 12:34 PM'], |
12 ['world.ogv', '59 KB', 'OGG video', 'Jul 4, 2012 10:35 AM'], | 70 ['world.ogv', '59 KB', 'OGG video', 'Jul 4, 2012 10:35 AM'], |
13 ['My Desktop Background.png', '272 bytes', 'PNG image', | 71 ['My Desktop Background.png', '272 bytes', 'PNG image', |
14 'Jan 18, 2038 1:02 AM'], | 72 'Jan 18, 2038 1:02 AM'], |
15 ['Beautiful Song.ogg', '14 KB', 'OGG audio', 'Nov 12, 2086 12:00 PM'], | 73 ['Beautiful Song.ogg', '14 KB', 'OGG audio', 'Nov 12, 2086 12:00 PM'], |
(...skipping 11 matching lines...) Expand all Loading... | |
27 ['world.ogv', '59 KB', 'OGG video', 'Jul 4, 2012 10:35 AM'], | 85 ['world.ogv', '59 KB', 'OGG video', 'Jul 4, 2012 10:35 AM'], |
28 ['My Desktop Background.png', '272 bytes', 'PNG image', | 86 ['My Desktop Background.png', '272 bytes', 'PNG image', |
29 'Jan 18, 2038 1:02 AM'], | 87 'Jan 18, 2038 1:02 AM'], |
30 ['Beautiful Song.ogg', '14 KB', 'OGG audio', 'Nov 12, 2086 12:00 PM'], | 88 ['Beautiful Song.ogg', '14 KB', 'OGG audio', 'Nov 12, 2086 12:00 PM'], |
31 ['photos', '--', 'Folder', 'Jan 1, 1980 11:59 PM'], | 89 ['photos', '--', 'Folder', 'Jan 1, 1980 11:59 PM'], |
32 ['Test Document.gdoc','--','Google document','Apr 10, 2013 4:20 PM'], | 90 ['Test Document.gdoc','--','Google document','Apr 10, 2013 4:20 PM'], |
33 ['Test Shared Document.gdoc','--','Google document','Mar 20, 2013 10:40 PM'] | 91 ['Test Shared Document.gdoc','--','Google document','Mar 20, 2013 10:40 PM'] |
34 ].sort(); | 92 ].sort(); |
35 | 93 |
36 /** | 94 /** |
37 * Expected files added during some tests. | 95 * Filesystem entries used by the test cases. |
38 * @type {Array.<Array.<string>>} | 96 * @type {Object.<string, TestEntryInfo>} |
39 * @const | 97 * @const |
40 */ | 98 */ |
41 var EXPECTED_NEWLY_ADDED_FILE = [ | 99 var ENTRIES = { |
42 ['newly added file.ogg', '14 KB', 'OGG audio', 'Sep 4, 1998 12:00 AM'] | 100 newlyAdded: new TestEntryInfo( |
43 ]; | 101 EntryType.FILE, 'music.ogg', 'newly added file.ogg', |
102 'audio/ogg', 'OGG audio', '14 KB', SharedOption.NONE, | |
103 'Sep 4, 1998 12:00 AM') | |
104 }; | |
44 | 105 |
45 /** | 106 /** |
46 * @param {boolean} isDrive True if the test is for Drive. | 107 * @param {boolean} isDrive True if the test is for Drive. |
47 * @return {Array.<Array.<string>>} A sorted list of expected entries at the | 108 * @return {Array.<Array.<string>>} A sorted list of expected entries at the |
48 * initial state. | 109 * initial state. |
49 */ | 110 */ |
50 function getExpectedFilesBefore(isDrive) { | 111 function getExpectedFilesBefore(isDrive) { |
51 return isDrive ? | 112 return isDrive ? |
52 EXPECTED_FILES_BEFORE_DRIVE : | 113 EXPECTED_FILES_BEFORE_DRIVE : |
53 EXPECTED_FILES_BEFORE_LOCAL; | 114 EXPECTED_FILES_BEFORE_LOCAL; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 * Tests if the files initially added by the C++ side are displayed, and | 220 * Tests if the files initially added by the C++ side are displayed, and |
160 * that a subsequently added file shows up. | 221 * that a subsequently added file shows up. |
161 * | 222 * |
162 * @param {string} path Directory path to be tested. | 223 * @param {string} path Directory path to be tested. |
163 */ | 224 */ |
164 testcase.intermediate.fileDisplay = function(path) { | 225 testcase.intermediate.fileDisplay = function(path) { |
165 var appId; | 226 var appId; |
166 | 227 |
167 var expectedFilesBefore = getExpectedFilesBefore(path == '/drive/root'); | 228 var expectedFilesBefore = getExpectedFilesBefore(path == '/drive/root'); |
168 var expectedFilesAfter = | 229 var expectedFilesAfter = |
169 expectedFilesBefore.concat(EXPECTED_NEWLY_ADDED_FILE).sort(); | 230 expectedFilesBefore.concat([ENTRIES.newlyAdded.getExpectedRow()]).sort(); |
170 | 231 |
171 StepsRunner.run([ | 232 StepsRunner.run([ |
172 function() { | 233 function() { |
173 setupAndWaitUntilReady(path, this.next); | 234 setupAndWaitUntilReady(path, this.next); |
174 }, | 235 }, |
175 // Notify that the list has been verified and a new file can be added | 236 // Notify that the list has been verified and a new file can be added |
176 // in file_manager_browsertest.cc. | 237 // in file_manager_browsertest.cc. |
177 function(inAppId, actualFilesBefore) { | 238 function(inAppId, actualFilesBefore) { |
178 appId = inAppId; | 239 appId = inAppId; |
179 chrome.test.assertEq(expectedFilesBefore, actualFilesBefore); | 240 chrome.test.assertEq(expectedFilesBefore, actualFilesBefore); |
180 addEntries(['local', 'drive'], [{ | 241 addEntries(['local', 'drive'], [ENTRIES.newlyAdded], this.next); |
181 type: 'file', | |
182 source_file_name: 'music.ogg', | |
183 target_name: 'newly added file.ogg', | |
184 mime_type: 'audio/ogg', | |
185 shared_option: 'none', | |
186 last_modified_time: '4 Sep 1998 00:00:00' | |
187 }], this.next); | |
188 }, | 242 }, |
189 function(result) { | 243 function(result) { |
190 chrome.test.assertTrue(result); | 244 chrome.test.assertTrue(result); |
191 callRemoteTestUtil( | 245 callRemoteTestUtil( |
192 'waitForFileListChange', | 246 'waitForFileListChange', |
193 appId, | 247 appId, |
194 [expectedFilesBefore.length], | 248 [expectedFilesBefore.length], |
195 this.next); | 249 this.next); |
196 }, | 250 }, |
197 // Confirm the file list. | 251 // Confirm the file list. |
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1214 appId2, | 1268 appId2, |
1215 [650, 490], | 1269 [650, 490], |
1216 this.next); | 1270 this.next); |
1217 }, | 1271 }, |
1218 // Check for errors. | 1272 // Check for errors. |
1219 function() { | 1273 function() { |
1220 checkIfNoErrorsOccured(this.next); | 1274 checkIfNoErrorsOccured(this.next); |
1221 } | 1275 } |
1222 ]); | 1276 ]); |
1223 }; | 1277 }; |
OLD | NEW |