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 * Tests if the files initially added by the C++ side are displayed, and
9 * that a subsequently added file shows up.
11 * @param {string} path Directory path to be tested.
13 function fileDisplay(path) {
16 var expectedFilesBefore =
17 TestEntryInfo.getExpectedRows(path == RootPath.DRIVE ?
18 BASIC_DRIVE_ENTRY_SET : BASIC_LOCAL_ENTRY_SET).sort();
20 var expectedFilesAfter =
21 expectedFilesBefore.concat([ENTRIES.newlyAdded.getExpectedRow()]).sort();
25 setupAndWaitUntilReady(null, path, this.next);
27 // Notify that the list has been verified and a new file can be added
28 // in file_manager_browsertest.cc.
29 function(inAppId, actualFilesBefore) {
31 chrome.test.assertEq(expectedFilesBefore, actualFilesBefore);
32 addEntries(['local', 'drive'], [ENTRIES.newlyAdded], this.next);
35 chrome.test.assertTrue(result);
36 remoteCall.waitForFileListChange(appId, expectedFilesBefore.length).
39 // Confirm the file list.
40 function(actualFilesAfter) {
41 chrome.test.assertEq(expectedFilesAfter, actualFilesAfter);
42 checkIfNoErrorsOccured(this.next);
47 testcase.fileDisplayDownloads = function() {
48 fileDisplay(RootPath.DOWNLOADS);
51 testcase.fileDisplayDrive = function() {
52 fileDisplay(RootPath.DRIVE);
55 testcase.fileDisplayMtp = function() {
57 var MTP_VOLUME_QUERY = '#directory-tree > .tree-item > .tree-row > ' +
58 '.volume-icon[volume-type-icon="mtp"]';
62 setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next);
64 // Mount a fake MTP volume.
65 function(inAppId, files) {
67 chrome.test.sendMessage(JSON.stringify({name: 'mountFakeMtp'}),
70 // Wait for the mount.
72 remoteCall.waitForElement(appId, MTP_VOLUME_QUERY).then(this.next);
74 // Click the MTP volume.
76 remoteCall.callRemoteTestUtil(
77 'fakeMouseClick', appId, [MTP_VOLUME_QUERY], this.next);
79 // Wait for the file list to change.
81 remoteCall.waitForFiles(
83 TestEntryInfo.getExpectedRows(BASIC_FAKE_ENTRY_SET),
84 {ignoreLastModifiedTime: true}).then(this.next);
87 checkIfNoErrorsOccured(this.next);