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 opening the "Recent" on the sidebar navigation by clicking the icon,
9 * and verifies the directory contents. We test if there are only files, since
10 * directories are not allowed in "Recent". This test is only available for
13 testcase.openSidebarRecent = function() {
17 setupAndWaitUntilReady(null, RootPath.DRIVE, this.next);
19 // Click the icon of the Recent volume.
22 remoteCall.callRemoteTestUtil(
23 'selectVolume', appId, ['drive_recent'], this.next);
25 // Wait until the file list is updated.
27 chrome.test.assertFalse(!result);
28 remoteCall.waitForFileListChange(appId, BASIC_DRIVE_ENTRY_SET.length).
31 // Verify the file list.
32 function(actualFilesAfter) {
34 TestEntryInfo.getExpectedRows(RECENT_ENTRY_SET).sort(),
36 checkIfNoErrorsOccured(this.next);
42 * Tests opening the "Offline" on the sidebar navigation by clicking the icon,
43 * and checks contenets of the file list. Only the entries "available offline"
44 * should be shown. "Available offline" entires are hosted documents and the
45 * entries cached by DriveCache.
47 testcase.openSidebarOffline = function() {
51 setupAndWaitUntilReady(null, RootPath.DRIVE, this.next);
53 // Click the icon of the Offline volume.
56 remoteCall.callRemoteTestUtil(
57 'selectVolume', appId, ['drive_offline'], this.next);
59 // Wait until the file list is updated.
61 chrome.test.assertFalse(!result);
62 remoteCall.waitForFileListChange(appId, BASIC_DRIVE_ENTRY_SET.length).
65 // Verify the file list.
66 function(actualFilesAfter) {
68 TestEntryInfo.getExpectedRows(OFFLINE_ENTRY_SET).sort(),
70 checkIfNoErrorsOccured(this.next);
76 * Tests opening the "Shared with me" on the sidebar navigation by clicking the
77 * icon, and checks contents of the file list. Only the entries labeled with
78 * "shared-with-me" should be shown.
80 testcase.openSidebarSharedWithMe = function() {
84 setupAndWaitUntilReady(null, RootPath.DRIVE, this.next);
86 // Click the icon of the Shared With Me volume.
89 // Use the icon for a click target.
90 remoteCall.callRemoteTestUtil('selectVolume',
92 ['drive_shared_with_me'], this.next);
94 // Wait until the file list is updated.
96 chrome.test.assertFalse(!result);
97 remoteCall.waitForFileListChange(appId, BASIC_DRIVE_ENTRY_SET.length).
100 // Verify the file list.
101 function(actualFilesAfter) {
102 chrome.test.assertEq(
103 TestEntryInfo.getExpectedRows(SHARED_WITH_ME_ENTRY_SET).sort(),
105 checkIfNoErrorsOccured(this.next);
111 * Tests autocomplete with a query 'hello'. This test is only available for
114 testcase.autocomplete = function() {
115 var EXPECTED_AUTOCOMPLETE_LIST = [
116 '\'hello\' - search Drive',
123 setupAndWaitUntilReady(null, RootPath.DRIVE, this.next);
125 // Focus the search box.
126 function(inAppId, list) {
128 remoteCall.callRemoteTestUtil('fakeEvent',
130 ['#search-box input', 'focus'],
135 chrome.test.assertTrue(result);
136 remoteCall.callRemoteTestUtil('inputText',
138 ['#search-box input', 'hello'],
141 // Notify the element of the input.
143 remoteCall.callRemoteTestUtil('fakeEvent',
145 ['#search-box input', 'input'],
148 // Wait for the auto complete list getting the expected contents.
150 chrome.test.assertTrue(result);
151 repeatUntil(function() {
152 return remoteCall.callRemoteTestUtil('queryAllElements',
154 ['#autocomplete-list li']).
155 then(function(elements) {
156 var list = elements.map(
157 function(element) { return element.text; });
158 return chrome.test.checkDeepEq(EXPECTED_AUTOCOMPLETE_LIST, list) ?
160 pending('Current auto complete list: %j.', list);
166 checkIfNoErrorsOccured(this.next);
172 * Tests pinning a file on mobile network.
174 testcase.pinFileOnMobileNetwork = function() {
175 testPromise(setupAndWaitUntilReady(null, RootPath.DRIVE).then(
177 return sendTestMessage(
178 {name: 'useCellularNetwork'}).then(function(result) {
179 return remoteCall.callRemoteTestUtil(
180 'selectFile', windowId, ['hello.txt']);
182 return repeatUntil(function() {
183 return navigator.connection.type != 'cellular' ?
184 pending('Network state is not changed to cellular.') : null;
187 return remoteCall.waitForElement(windowId, ['.table-row[selected]']);
189 return remoteCall.callRemoteTestUtil(
190 'fakeMouseRightClick', windowId, ['.table-row[selected]']);
191 }).then(function(result) {
192 chrome.test.assertTrue(result);
193 return remoteCall.waitForElement(
194 windowId, '#file-context-menu:not([hidden])');
196 return remoteCall.callRemoteTestUtil(
197 'fakeMouseClick', windowId, ['[command="#toggle-pinned"]']);
198 }).then(function(result) {
199 return remoteCall.waitForElement(
200 windowId, '#file-context-menu[hidden]');
202 return remoteCall.callRemoteTestUtil(
203 'fakeEvent', windowId, ['#file-list', 'contextmenu']);
204 }).then(function(result) {
205 chrome.test.assertTrue(result);
206 return remoteCall.waitForElement(
207 windowId, '[command="#toggle-pinned"][checked]');
209 return repeatUntil(function() {
210 return remoteCall.callRemoteTestUtil(
211 'getNotificationIDs', null, []).then(function(idSet) {
212 return !idSet['disabled-mobile-sync'] ?
213 pending('Sync disable notification is not found.') : null;
217 return sendTestMessage({
218 name: 'clickNotificationButton',
219 extensionId: FILE_MANAGER_EXTENSIONS_ID,
220 notificationId: 'disabled-mobile-sync',
224 return repeatUntil(function() {
225 return remoteCall.callRemoteTestUtil(
226 'getPreferences', null, []).then(function(preferences) {
227 return preferences.cellularDisabled ?
228 pending('Drive sync is still disabled.') : null;