| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 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. | |
| 4 | |
| 5 'use strict'; | |
| 6 | |
| 7 /** | |
| 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 | |
| 11 * Drive. | |
| 12 */ | |
| 13 testcase.openSidebarRecent = function() { | |
| 14 var appId; | |
| 15 StepsRunner.run([ | |
| 16 function() { | |
| 17 setupAndWaitUntilReady(null, RootPath.DRIVE, this.next); | |
| 18 }, | |
| 19 // Click the icon of the Recent volume. | |
| 20 function(inAppId) { | |
| 21 appId = inAppId; | |
| 22 callRemoteTestUtil( | |
| 23 'selectVolume', appId, ['drive_recent'], this.next); | |
| 24 }, | |
| 25 // Wait until the file list is updated. | |
| 26 function(result) { | |
| 27 chrome.test.assertFalse(!result); | |
| 28 waitForFileListChange(appId, BASIC_DRIVE_ENTRY_SET.length). | |
| 29 then(this.next); | |
| 30 }, | |
| 31 // Verify the file list. | |
| 32 function(actualFilesAfter) { | |
| 33 chrome.test.assertEq( | |
| 34 TestEntryInfo.getExpectedRows(RECENT_ENTRY_SET).sort(), | |
| 35 actualFilesAfter); | |
| 36 checkIfNoErrorsOccured(this.next); | |
| 37 } | |
| 38 ]); | |
| 39 }; | |
| 40 | |
| 41 /** | |
| 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. | |
| 46 */ | |
| 47 testcase.openSidebarOffline = function() { | |
| 48 var appId; | |
| 49 StepsRunner.run([ | |
| 50 function() { | |
| 51 setupAndWaitUntilReady(null, RootPath.DRIVE, this.next); | |
| 52 }, | |
| 53 // Click the icon of the Offline volume. | |
| 54 function(inAppId) { | |
| 55 appId = inAppId; | |
| 56 callRemoteTestUtil( | |
| 57 'selectVolume', appId, ['drive_offline'], this.next); | |
| 58 }, | |
| 59 // Wait until the file list is updated. | |
| 60 function(result) { | |
| 61 chrome.test.assertFalse(!result); | |
| 62 waitForFileListChange(appId, BASIC_DRIVE_ENTRY_SET.length). | |
| 63 then(this.next); | |
| 64 }, | |
| 65 // Verify the file list. | |
| 66 function(actualFilesAfter) { | |
| 67 chrome.test.assertEq( | |
| 68 TestEntryInfo.getExpectedRows(OFFLINE_ENTRY_SET).sort(), | |
| 69 actualFilesAfter); | |
| 70 checkIfNoErrorsOccured(this.next); | |
| 71 } | |
| 72 ]); | |
| 73 }; | |
| 74 | |
| 75 /** | |
| 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. | |
| 79 */ | |
| 80 testcase.openSidebarSharedWithMe = function() { | |
| 81 var appId; | |
| 82 StepsRunner.run([ | |
| 83 function() { | |
| 84 setupAndWaitUntilReady(null, RootPath.DRIVE, this.next); | |
| 85 }, | |
| 86 // Click the icon of the Shared With Me volume. | |
| 87 function(inAppId) { | |
| 88 appId = inAppId; | |
| 89 // Use the icon for a click target. | |
| 90 callRemoteTestUtil('selectVolume', | |
| 91 appId, | |
| 92 ['drive_shared_with_me'], this.next); | |
| 93 }, | |
| 94 // Wait until the file list is updated. | |
| 95 function(result) { | |
| 96 chrome.test.assertFalse(!result); | |
| 97 waitForFileListChange(appId, BASIC_DRIVE_ENTRY_SET.length). | |
| 98 then(this.next); | |
| 99 }, | |
| 100 // Verify the file list. | |
| 101 function(actualFilesAfter) { | |
| 102 chrome.test.assertEq( | |
| 103 TestEntryInfo.getExpectedRows(SHARED_WITH_ME_ENTRY_SET).sort(), | |
| 104 actualFilesAfter); | |
| 105 checkIfNoErrorsOccured(this.next); | |
| 106 } | |
| 107 ]); | |
| 108 }; | |
| 109 | |
| 110 /** | |
| 111 * Tests autocomplete with a query 'hello'. This test is only available for | |
| 112 * Drive. | |
| 113 */ | |
| 114 testcase.autocomplete = function() { | |
| 115 var EXPECTED_AUTOCOMPLETE_LIST = [ | |
| 116 '\'hello\' - search Drive', | |
| 117 'hello.txt', | |
| 118 ]; | |
| 119 var appId; | |
| 120 | |
| 121 StepsRunner.run([ | |
| 122 function() { | |
| 123 setupAndWaitUntilReady(null, RootPath.DRIVE, this.next); | |
| 124 }, | |
| 125 // Focus the search box. | |
| 126 function(inAppId, list) { | |
| 127 appId = inAppId; | |
| 128 callRemoteTestUtil('fakeEvent', | |
| 129 appId, | |
| 130 ['#search-box input', 'focus'], | |
| 131 this.next); | |
| 132 }, | |
| 133 // Input a text. | |
| 134 function(result) { | |
| 135 chrome.test.assertTrue(result); | |
| 136 callRemoteTestUtil('inputText', | |
| 137 appId, | |
| 138 ['#search-box input', 'hello'], | |
| 139 this.next); | |
| 140 }, | |
| 141 // Notify the element of the input. | |
| 142 function() { | |
| 143 callRemoteTestUtil('fakeEvent', | |
| 144 appId, | |
| 145 ['#search-box input', 'input'], | |
| 146 this.next); | |
| 147 }, | |
| 148 // Wait for the auto complete list getting the expected contents. | |
| 149 function(result) { | |
| 150 chrome.test.assertTrue(result); | |
| 151 repeatUntil(function() { | |
| 152 return callRemoteTestUtil('queryAllElements', | |
| 153 appId, | |
| 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) ? | |
| 159 undefined : | |
| 160 pending('Current auto complete list: %j.', list); | |
| 161 }); | |
| 162 }). | |
| 163 then(this.next); | |
| 164 }, | |
| 165 function() { | |
| 166 checkIfNoErrorsOccured(this.next); | |
| 167 } | |
| 168 ]); | |
| 169 }; | |
| OLD | NEW |