Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: chrome/test/data/extensions/api_test/file_manager_browsertest/test_cases.js

Issue 24026003: Files.app: Introduce TestEntryInfo class to JavaScript code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed the comments. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/file_manager/file_manager_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 'use strict';
6
7 /**
8 * @enum {string}
9 * @const
10 */
11 var EntryType = Object.freeze({
12 FILE: 'file',
13 DIRECTORY: 'directory'
14 });
15
16 /**
17 * @enum {string}
18 * @const
19 */
20 var SharedOption = Object.freeze({
21 NONE: 'none',
22 SHARED: 'shared'
23 });
24
25 /**
26 * File system entry information for tests.
27 *
28 * @param {EntryType} entryType Entry type.
29 * @param {string} sourceFileName Source file name that provides file contents.
30 * @param {string} targetName Name of entry on the test file system.
31 * @param {string} mimeType Mime type.
32 * @param {string} typeText Type name to be shown in the type column.
33 * @param {string} sizeText Size text to be shown in the size column.
34 * @param {SharedOption} sharedOption Shared option.
35 * @param {string} lastModifiedTime Last modified time as a text to be shown in
36 * the last modified column.
37 * @constructor
38 */
39 var TestEntryInfo = function(entryType,
40 sourceFileName,
41 targetName,
42 mimeType,
43 typeText,
44 sizeText,
45 sharedOption,
46 lastModifiedTime) {
47 this.entryType = entryType;
48 this.sourceFileName = sourceFileName;
49 this.targetName = targetName;
50 this.mimeType = mimeType;
51 this.typeText = typeText;
52 this.sizeText = sizeText;
53 this.sharedOption = sharedOption;
54 this.lastModifiedTime = lastModifiedTime;
55 Object.freeze(this);
56 };
57
58 /**
59 * Obtains a expected row contents of the file in the file list.
60 */
61 TestEntryInfo.prototype.getExpectedRow = function() {
62 return [this.targetName, this.sizeText, this.typeText, this.lastModifiedTime];
63 };
64
5 /** 65 /**
6 * Expected files before tests are performed. Entries for Local tests. 66 * Expected files before tests are performed. Entries for Local tests.
7 * @type {Array.<Array.<string>>} 67 * @type {Array.<Array.<string>>}
8 * @const 68 * @const
9 */ 69 */
10 var EXPECTED_FILES_BEFORE_LOCAL = [ 70 var EXPECTED_FILES_BEFORE_LOCAL = [
11 ['hello.txt', '51 bytes', 'Plain text', 'Sep 4, 1998 12:34 PM'], 71 ['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'], 72 ['world.ogv', '59 KB', 'OGG video', 'Jul 4, 2012 10:35 AM'],
13 ['My Desktop Background.png', '272 bytes', 'PNG image', 73 ['My Desktop Background.png', '272 bytes', 'PNG image',
14 'Jan 18, 2038 1:02 AM'], 74 'Jan 18, 2038 1:02 AM'],
(...skipping 12 matching lines...) Expand all
27 ['world.ogv', '59 KB', 'OGG video', 'Jul 4, 2012 10:35 AM'], 87 ['world.ogv', '59 KB', 'OGG video', 'Jul 4, 2012 10:35 AM'],
28 ['My Desktop Background.png', '272 bytes', 'PNG image', 88 ['My Desktop Background.png', '272 bytes', 'PNG image',
29 'Jan 18, 2038 1:02 AM'], 89 'Jan 18, 2038 1:02 AM'],
30 ['Beautiful Song.ogg', '14 KB', 'OGG audio', 'Nov 12, 2086 12:00 PM'], 90 ['Beautiful Song.ogg', '14 KB', 'OGG audio', 'Nov 12, 2086 12:00 PM'],
31 ['photos', '--', 'Folder', 'Jan 1, 1980 11:59 PM'], 91 ['photos', '--', 'Folder', 'Jan 1, 1980 11:59 PM'],
32 ['Test Document.gdoc','--','Google document','Apr 10, 2013 4:20 PM'], 92 ['Test Document.gdoc','--','Google document','Apr 10, 2013 4:20 PM'],
33 ['Test Shared Document.gdoc','--','Google document','Mar 20, 2013 10:40 PM'] 93 ['Test Shared Document.gdoc','--','Google document','Mar 20, 2013 10:40 PM']
34 ].sort(); 94 ].sort();
35 95
36 /** 96 /**
37 * Expected files added during some tests. 97 * Filesystem entries used by the test cases.
38 * @type {Array.<Array.<string>>} 98 * @type {Object.<string, TestEntryInfo>}
39 * @const 99 * @const
40 */ 100 */
41 var EXPECTED_NEWLY_ADDED_FILE = [ 101 var ENTRIES = {
42 ['newly added file.ogg', '14 KB', 'OGG audio', 'Sep 4, 1998 12:00 AM'] 102 newlyAdded: new TestEntryInfo(
43 ]; 103 EntryType.FILE, 'music.ogg', 'newly added file.ogg',
104 'audio/ogg', 'OGG audio', '14 KB', SharedOption.NONE,
105 'Sep 4, 1998 12:00 AM')
106 };
44 107
45 /** 108 /**
46 * @param {boolean} isDrive True if the test is for Drive. 109 * @param {boolean} isDrive True if the test is for Drive.
47 * @return {Array.<Array.<string>>} A sorted list of expected entries at the 110 * @return {Array.<Array.<string>>} A sorted list of expected entries at the
48 * initial state. 111 * initial state.
49 */ 112 */
50 function getExpectedFilesBefore(isDrive) { 113 function getExpectedFilesBefore(isDrive) {
51 return isDrive ? 114 return isDrive ?
52 EXPECTED_FILES_BEFORE_DRIVE : 115 EXPECTED_FILES_BEFORE_DRIVE :
53 EXPECTED_FILES_BEFORE_LOCAL; 116 EXPECTED_FILES_BEFORE_LOCAL;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 * Tests if the files initially added by the C++ side are displayed, and 222 * Tests if the files initially added by the C++ side are displayed, and
160 * that a subsequently added file shows up. 223 * that a subsequently added file shows up.
161 * 224 *
162 * @param {string} path Directory path to be tested. 225 * @param {string} path Directory path to be tested.
163 */ 226 */
164 testcase.intermediate.fileDisplay = function(path) { 227 testcase.intermediate.fileDisplay = function(path) {
165 var appId; 228 var appId;
166 229
167 var expectedFilesBefore = getExpectedFilesBefore(path == '/drive/root'); 230 var expectedFilesBefore = getExpectedFilesBefore(path == '/drive/root');
168 var expectedFilesAfter = 231 var expectedFilesAfter =
169 expectedFilesBefore.concat(EXPECTED_NEWLY_ADDED_FILE).sort(); 232 expectedFilesBefore.concat([ENTRIES.newlyAdded.getExpectedRow()]).sort();
170 233
171 StepsRunner.run([ 234 StepsRunner.run([
172 function() { 235 function() {
173 setupAndWaitUntilReady(path, this.next); 236 setupAndWaitUntilReady(path, this.next);
174 }, 237 },
175 // Notify that the list has been verified and a new file can be added 238 // Notify that the list has been verified and a new file can be added
176 // in file_manager_browsertest.cc. 239 // in file_manager_browsertest.cc.
177 function(inAppId, actualFilesBefore) { 240 function(inAppId, actualFilesBefore) {
178 appId = inAppId; 241 appId = inAppId;
179 chrome.test.assertEq(expectedFilesBefore, actualFilesBefore); 242 chrome.test.assertEq(expectedFilesBefore, actualFilesBefore);
180 addEntries(['local', 'drive'], [{ 243 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 }, 244 },
189 function(result) { 245 function(result) {
190 chrome.test.assertTrue(result); 246 chrome.test.assertTrue(result);
191 callRemoteTestUtil( 247 callRemoteTestUtil(
192 'waitForFileListChange', 248 'waitForFileListChange',
193 appId, 249 appId,
194 [expectedFilesBefore.length], 250 [expectedFilesBefore.length],
195 this.next); 251 this.next);
196 }, 252 },
197 // Confirm the file list. 253 // Confirm the file list.
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 appId2, 1270 appId2,
1215 [650, 490], 1271 [650, 490],
1216 this.next); 1272 this.next);
1217 }, 1273 },
1218 // Check for errors. 1274 // Check for errors.
1219 function() { 1275 function() {
1220 checkIfNoErrorsOccured(this.next); 1276 checkIfNoErrorsOccured(this.next);
1221 } 1277 }
1222 ]); 1278 ]);
1223 }; 1279 };
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/file_manager/file_manager_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698