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
3 // found in the LICENSE file.
5 #include "base/strings/utf_string_conversions.h"
6 #include "chrome/browser/chromeos/drive/file_system_util.h"
7 #include "chrome/browser/chromeos/file_manager/file_manager_browsertest_base.h"
8 #include "chrome/browser/chromeos/profiles/profile_helper.h"
9 #include "chrome/browser/signin/signin_manager_factory.h"
10 #include "chromeos/chromeos_switches.h"
11 #include "components/signin/core/browser/signin_manager.h"
12 #include "components/user_manager/user_manager.h"
14 namespace file_manager
{
16 // Parameter of FileManagerBrowserTest.
17 // The second value is the case name of JavaScript.
18 typedef std::tr1::tuple
<GuestMode
, const char*> TestParameter
;
20 // Test fixture class for normal (not multi-profile related) tests.
21 class FileManagerBrowserTest
:
22 public FileManagerBrowserTestBase
,
23 public ::testing::WithParamInterface
<TestParameter
> {
24 GuestMode
GetGuestModeParam() const override
{
25 return std::tr1::get
<0>(GetParam());
27 const char* GetTestManifestName() const override
{
28 return "file_manager_test_manifest.json";
30 const char* GetTestCaseNameParam() const override
{
31 return std::tr1::get
<1>(GetParam());
35 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTest
, Test
) {
39 // Unlike TEST/TEST_F, which are macros that expand to further macros,
40 // INSTANTIATE_TEST_CASE_P is a macro that expands directly to code that
41 // stringizes the arguments. As a result, macros passed as parameters (such as
42 // prefix or test_case_name) will not be expanded by the preprocessor. To work
43 // around this, indirect the macro for INSTANTIATE_TEST_CASE_P, so that the
44 // pre-processor will expand macros such as MAYBE_test_name before
45 // instantiating the test.
46 #define WRAPPED_INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator) \
47 INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator)
49 // Fails on official build. http://crbug.com/429294
50 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
51 #define MAYBE_FileDisplay DISABLED_FileDisplay
53 #define MAYBE_FileDisplay FileDisplay
55 WRAPPED_INSTANTIATE_TEST_CASE_P(
57 FileManagerBrowserTest
,
58 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
, "fileDisplayDownloads"),
59 TestParameter(IN_GUEST_MODE
, "fileDisplayDownloads"),
60 TestParameter(NOT_IN_GUEST_MODE
, "fileDisplayDrive"),
61 TestParameter(NOT_IN_GUEST_MODE
, "fileDisplayMtp"),
62 TestParameter(NOT_IN_GUEST_MODE
, "searchNormal"),
63 TestParameter(NOT_IN_GUEST_MODE
, "searchCaseInsensitive"),
64 TestParameter(NOT_IN_GUEST_MODE
, "searchNotFound")));
66 // Fails on official build. http://crbug.com/429294
67 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
68 #define MAYBE_OpenVideoFiles DISABLED_OpenVideoFiles
70 #define MAYBE_OpenVideoFiles OpenVideoFiles
72 WRAPPED_INSTANTIATE_TEST_CASE_P(
74 FileManagerBrowserTest
,
75 ::testing::Values(TestParameter(IN_GUEST_MODE
, "videoOpenDownloads"),
76 TestParameter(NOT_IN_GUEST_MODE
, "videoOpenDownloads"),
77 TestParameter(NOT_IN_GUEST_MODE
, "videoOpenDrive")));
79 // Fails on official build. http://crbug.com/429294
80 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
81 #define MAYBE_OpenAudioFiles DISABLED_OpenAudioFiles
83 #define MAYBE_OpenAudioFiles OpenAudioFiles
85 WRAPPED_INSTANTIATE_TEST_CASE_P(
87 FileManagerBrowserTest
,
89 TestParameter(IN_GUEST_MODE
, "audioOpenDownloads"),
90 TestParameter(NOT_IN_GUEST_MODE
, "audioOpenDownloads"),
91 TestParameter(NOT_IN_GUEST_MODE
, "audioOpenDrive"),
92 TestParameter(NOT_IN_GUEST_MODE
, "audioAutoAdvanceDrive"),
93 TestParameter(NOT_IN_GUEST_MODE
, "audioRepeatSingleFileDrive"),
94 TestParameter(NOT_IN_GUEST_MODE
, "audioNoRepeatSingleFileDrive"),
95 TestParameter(NOT_IN_GUEST_MODE
, "audioRepeatMultipleFileDrive"),
96 TestParameter(NOT_IN_GUEST_MODE
, "audioNoRepeatMultipleFileDrive")));
98 // Fails on official build. http://crbug.com/429294
99 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
100 #define MAYBE_OpenImageFiles DISABLED_OpenImageFiles
102 #define MAYBE_OpenImageFiles OpenImageFiles
104 WRAPPED_INSTANTIATE_TEST_CASE_P(
105 MAYBE_OpenImageFiles
,
106 FileManagerBrowserTest
,
107 ::testing::Values(TestParameter(IN_GUEST_MODE
, "imageOpenDownloads"),
108 TestParameter(NOT_IN_GUEST_MODE
, "imageOpenDownloads"),
109 TestParameter(NOT_IN_GUEST_MODE
, "imageOpenDrive")));
111 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
112 #define MAYBE_CreateNewFolder DISABLED_CreateNewFolder
114 #define MAYBE_CreateNewFolder CreateNewFolder
116 WRAPPED_INSTANTIATE_TEST_CASE_P(
117 MAYBE_CreateNewFolder
,
118 FileManagerBrowserTest
,
119 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
,
120 "createNewFolderAfterSelectFile"),
121 TestParameter(IN_GUEST_MODE
,
122 "createNewFolderDownloads"),
123 TestParameter(NOT_IN_GUEST_MODE
,
124 "createNewFolderDownloads"),
125 TestParameter(NOT_IN_GUEST_MODE
,
126 "createNewFolderDrive")));
128 // Fails on official build. http://crbug.com/429294
129 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
130 #define MAYBE_KeyboardOperations DISABLED_KeyboardOperations
132 #define MAYBE_KeyboardOperations KeyboardOperations
134 WRAPPED_INSTANTIATE_TEST_CASE_P(
135 MAYBE_KeyboardOperations
,
136 FileManagerBrowserTest
,
137 ::testing::Values(TestParameter(IN_GUEST_MODE
, "keyboardDeleteDownloads"),
138 TestParameter(NOT_IN_GUEST_MODE
,
139 "keyboardDeleteDownloads"),
140 TestParameter(NOT_IN_GUEST_MODE
, "keyboardDeleteDrive"),
141 TestParameter(IN_GUEST_MODE
, "keyboardCopyDownloads"),
142 TestParameter(NOT_IN_GUEST_MODE
, "keyboardCopyDownloads"),
143 TestParameter(NOT_IN_GUEST_MODE
, "keyboardCopyDrive"),
144 TestParameter(IN_GUEST_MODE
, "renameFileDownloads"),
145 TestParameter(NOT_IN_GUEST_MODE
, "renameFileDownloads"),
146 TestParameter(NOT_IN_GUEST_MODE
, "renameFileDrive"),
147 TestParameter(IN_GUEST_MODE
,
148 "renameNewDirectoryDownloads"),
149 TestParameter(NOT_IN_GUEST_MODE
,
150 "renameNewDirectoryDownloads"),
151 TestParameter(NOT_IN_GUEST_MODE
,
152 "renameNewDirectoryDrive")));
154 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
155 #define MAYBE_Delete DISABLED_Delete
157 #define MAYBE_Delete Delete
159 WRAPPED_INSTANTIATE_TEST_CASE_P(
161 FileManagerBrowserTest
,
163 TestParameter(NOT_IN_GUEST_MODE
,
164 "deleteMenuItemIsDisabledWhenNoItemIsSelected"),
165 TestParameter(NOT_IN_GUEST_MODE
, "deleteOneItemFromToolbar")));
167 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
168 #define MAYBE_DirectoryTreeContextMenu DISABLED_DirectoryTreeContextMenu
170 #define MAYBE_DirectoryTreeContextMenu DirectoryTreeContextMenu
172 WRAPPED_INSTANTIATE_TEST_CASE_P(
173 MAYBE_DirectoryTreeContextMenu
,
174 FileManagerBrowserTest
,
176 TestParameter(NOT_IN_GUEST_MODE
,
177 "copyFromDirectoryTreeWithContextMenu"),
178 TestParameter(IN_GUEST_MODE
, "copyFromDirectoryTreeWithContextMenu"),
179 TestParameter(NOT_IN_GUEST_MODE
,
180 "copyFromDirectoryTreeWithKeyboardShortcut"),
181 TestParameter(IN_GUEST_MODE
,
182 "copyFromDirectoryTreeWithKeyboardShortcut"),
183 TestParameter(NOT_IN_GUEST_MODE
, "cutFromDirectoryTreeWithContextMenu"),
184 TestParameter(IN_GUEST_MODE
, "cutFromDirectoryTreeWithContextMenu"),
185 TestParameter(NOT_IN_GUEST_MODE
,
186 "cutFromDirectoryTreeWithKeyboardShortcut"),
187 TestParameter(IN_GUEST_MODE
,
188 "cutFromDirectoryTreeWithKeyboardShortcut"),
189 TestParameter(NOT_IN_GUEST_MODE
,
190 "pasteIntoFolderFromDirectoryTreeWithContextMenu"),
191 TestParameter(IN_GUEST_MODE
,
192 "pasteIntoFolderFromDirectoryTreeWithContextMenu"),
193 TestParameter(NOT_IN_GUEST_MODE
,
194 "renameDirectoryFromDirectoryTreeWithContextMenu"),
195 TestParameter(IN_GUEST_MODE
,
196 "renameDirectoryFromDirectoryTreeWithContextMenu"),
197 TestParameter(NOT_IN_GUEST_MODE
,
198 "renameDirectoryFromDirectoryTreeWithKeyboardShortcut"),
199 TestParameter(IN_GUEST_MODE
,
200 "renameDirectoryFromDirectoryTreeWithKeyboardShortcut"),
201 TestParameter(NOT_IN_GUEST_MODE
,
202 "renameDirectoryToEmptyStringFromDirectoryTree"),
203 TestParameter(IN_GUEST_MODE
,
204 "renameDirectoryToEmptyStringFromDirectoryTree"),
205 TestParameter(NOT_IN_GUEST_MODE
,
206 "renameDirectoryToExistingOneFromDirectoryTree"),
207 TestParameter(IN_GUEST_MODE
,
208 "renameDirectoryToExistingOneFromDirectoryTree")));
210 // Fails on official build. http://crbug.com/429294
211 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
212 #define MAYBE_DriveSpecific DISABLED_DriveSpecific
214 #define MAYBE_DriveSpecific DriveSpecific
216 WRAPPED_INSTANTIATE_TEST_CASE_P(
218 FileManagerBrowserTest
,
220 TestParameter(NOT_IN_GUEST_MODE
, "openSidebarRecent"),
221 TestParameter(NOT_IN_GUEST_MODE
, "openSidebarOffline"),
222 TestParameter(NOT_IN_GUEST_MODE
, "openSidebarSharedWithMe"),
223 TestParameter(NOT_IN_GUEST_MODE
, "autocomplete"),
224 TestParameter(NOT_IN_GUEST_MODE
, "pinFileOnMobileNetwork"),
225 TestParameter(NOT_IN_GUEST_MODE
, "clickFirstSearchResult"),
226 TestParameter(NOT_IN_GUEST_MODE
, "pressEnterToSearch")));
228 // Fails on official build. http://crbug.com/429294
229 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
230 #define MAYBE_Transfer DISABLED_Transfer
232 #define MAYBE_Transfer Transfer
234 WRAPPED_INSTANTIATE_TEST_CASE_P(
236 FileManagerBrowserTest
,
238 TestParameter(NOT_IN_GUEST_MODE
, "transferFromDriveToDownloads"),
239 TestParameter(NOT_IN_GUEST_MODE
, "transferFromDownloadsToDrive"),
240 TestParameter(NOT_IN_GUEST_MODE
, "transferFromSharedToDownloads"),
241 TestParameter(NOT_IN_GUEST_MODE
, "transferFromSharedToDrive"),
242 TestParameter(NOT_IN_GUEST_MODE
, "transferFromRecentToDownloads"),
243 TestParameter(NOT_IN_GUEST_MODE
, "transferFromRecentToDrive"),
244 TestParameter(NOT_IN_GUEST_MODE
, "transferFromOfflineToDownloads"),
245 TestParameter(NOT_IN_GUEST_MODE
, "transferFromOfflineToDrive")));
247 // Fails on official build. http://crbug.com/429294
248 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
249 #define MAYBE_RestorePrefs DISABLED_RestorePrefs
251 #define MAYBE_RestorePrefs RestorePrefs
253 WRAPPED_INSTANTIATE_TEST_CASE_P(
255 FileManagerBrowserTest
,
256 ::testing::Values(TestParameter(IN_GUEST_MODE
, "restoreSortColumn"),
257 TestParameter(NOT_IN_GUEST_MODE
, "restoreSortColumn"),
258 TestParameter(IN_GUEST_MODE
, "restoreCurrentView"),
259 TestParameter(NOT_IN_GUEST_MODE
, "restoreCurrentView")));
261 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
262 #define MAYBE_ShareDialog DISABLED_ShareDialog
264 #define MAYBE_ShareDialog ShareDialog
266 WRAPPED_INSTANTIATE_TEST_CASE_P(
268 FileManagerBrowserTest
,
269 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
, "shareFile"),
270 TestParameter(NOT_IN_GUEST_MODE
, "shareDirectory")));
272 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
273 #define MAYBE_RestoreGeometry DISABLED_RestoreGeometry
275 #define MAYBE_RestoreGeometry RestoreGeometry
277 WRAPPED_INSTANTIATE_TEST_CASE_P(
278 MAYBE_RestoreGeometry
,
279 FileManagerBrowserTest
,
280 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
, "restoreGeometry"),
281 TestParameter(IN_GUEST_MODE
, "restoreGeometry"),
282 TestParameter(NOT_IN_GUEST_MODE
,
283 "restoreGeometryMaximizedState")));
285 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
286 #define MAYBE_Traverse DISABLED_Traverse
288 #define MAYBE_Traverse Traverse
290 WRAPPED_INSTANTIATE_TEST_CASE_P(
292 FileManagerBrowserTest
,
293 ::testing::Values(TestParameter(IN_GUEST_MODE
, "traverseDownloads"),
294 TestParameter(NOT_IN_GUEST_MODE
, "traverseDownloads"),
295 TestParameter(NOT_IN_GUEST_MODE
, "traverseDrive")));
297 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
298 #define MAYBE_SuggestAppDialog DISABLED_SuggestAppDialog
300 #define MAYBE_SuggestAppDialog SuggestAppDialog
302 WRAPPED_INSTANTIATE_TEST_CASE_P(
303 MAYBE_SuggestAppDialog
,
304 FileManagerBrowserTest
,
305 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
, "suggestAppDialog")));
307 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
308 #define MAYBE_ExecuteDefaultTaskOnDownloads \
309 DISABLED_ExecuteDefaultTaskOnDownloads
311 #define MAYBE_ExecuteDefaultTaskOnDownloads ExecuteDefaultTaskOnDownloads
313 WRAPPED_INSTANTIATE_TEST_CASE_P(
314 MAYBE_ExecuteDefaultTaskOnDownloads
,
315 FileManagerBrowserTest
,
317 TestParameter(NOT_IN_GUEST_MODE
, "executeDefaultTaskOnDownloads"),
318 TestParameter(IN_GUEST_MODE
, "executeDefaultTaskOnDownloads")));
320 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
321 #define MAYBE_ExecuteDefaultTaskOnDrive DISABLED_ExecuteDefaultTaskOnDrive
323 #define MAYBE_ExecuteDefaultTaskOnDrive ExecuteDefaultTaskOnDrive
325 WRAPPED_INSTANTIATE_TEST_CASE_P(
326 MAYBE_ExecuteDefaultTaskOnDrive
,
327 FileManagerBrowserTest
,
328 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
,
329 "executeDefaultTaskOnDrive")));
331 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
332 #define MAYBE_DefaultActionDialog DISABLED_DefaultActionDialog
334 #define MAYBE_DefaultActionDialog DefaultActionDialog
336 WRAPPED_INSTANTIATE_TEST_CASE_P(
337 MAYBE_DefaultActionDialog
,
338 FileManagerBrowserTest
,
340 TestParameter(NOT_IN_GUEST_MODE
, "defaultActionDialogOnDownloads"),
341 TestParameter(IN_GUEST_MODE
, "defaultActionDialogOnDownloads"),
342 TestParameter(NOT_IN_GUEST_MODE
, "defaultActionDialogOnDrive")));
344 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
345 #define MAYBE_GenericTask DISABLED_GenericTask
347 #define MAYBE_GenericTask GenericTask
349 WRAPPED_INSTANTIATE_TEST_CASE_P(
351 FileManagerBrowserTest
,
353 TestParameter(NOT_IN_GUEST_MODE
, "genericTaskIsNotExecuted"),
354 TestParameter(NOT_IN_GUEST_MODE
, "genericAndNonGenericTasksAreMixed")));
356 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
357 #define MAYBE_FolderShortcuts DISABLED_FolderShortcuts
359 #define MAYBE_FolderShortcuts FolderShortcuts
361 WRAPPED_INSTANTIATE_TEST_CASE_P(
362 MAYBE_FolderShortcuts
,
363 FileManagerBrowserTest
,
365 TestParameter(NOT_IN_GUEST_MODE
, "traverseFolderShortcuts"),
366 TestParameter(NOT_IN_GUEST_MODE
, "addRemoveFolderShortcuts")));
368 // Fails on official build. http://crbug.com/429294
369 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
370 #define MAYBE_SortColumns DISABLED_SortColumns
372 #define MAYBE_SortColumns SortColumns
374 WRAPPED_INSTANTIATE_TEST_CASE_P(
376 FileManagerBrowserTest
,
377 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
, "sortColumns"),
378 TestParameter(IN_GUEST_MODE
, "sortColumns")));
380 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
381 #define MAYBE_TabIndex DISABLED_TabIndex
383 #define MAYBE_TabIndex TabIndex
385 WRAPPED_INSTANTIATE_TEST_CASE_P(
387 FileManagerBrowserTest
,
388 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
, "searchBoxFocus")));
390 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
391 #define MAYBE_TabindexFocus DISABLED_TabindexFocus
393 #define MAYBE_TabindexFocus TabindexFocus
395 WRAPPED_INSTANTIATE_TEST_CASE_P(
397 FileManagerBrowserTest
,
398 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
, "tabindexFocus")));
400 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
401 #define MAYBE_TabindexFocusDownloads DISABLED_TabindexFocusDownloads
403 #define MAYBE_TabindexFocusDownloads TabindexFocusDownloads
405 WRAPPED_INSTANTIATE_TEST_CASE_P(
406 MAYBE_TabindexFocusDownloads
,
407 FileManagerBrowserTest
,
408 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
,
409 "tabindexFocusDownloads"),
410 TestParameter(IN_GUEST_MODE
, "tabindexFocusDownloads")));
412 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
413 #define MAYBE_TabindexFocusDirectorySelected \
414 DISABLED_TabindexFocusDirectorySelected
416 #define MAYBE_TabindexFocusDirectorySelected TabindexFocusDirectorySelected
418 WRAPPED_INSTANTIATE_TEST_CASE_P(
419 MAYBE_TabindexFocusDirectorySelected
,
420 FileManagerBrowserTest
,
421 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
,
422 "tabindexFocusDirectorySelected")));
424 // Fails on official cros trunk build. http://crbug.com/480491
425 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
426 #define MAYBE_TabindexOpenDialog DISABLED_TabindexOpenDialog
428 #define MAYBE_TabindexOpenDialog TabindexOpenDialog
430 WRAPPED_INSTANTIATE_TEST_CASE_P(
431 MAYBE_TabindexOpenDialog
,
432 FileManagerBrowserTest
,
434 TestParameter(NOT_IN_GUEST_MODE
, "tabindexOpenDialogDrive"),
435 TestParameter(NOT_IN_GUEST_MODE
, "tabindexOpenDialogDownloads"),
436 TestParameter(IN_GUEST_MODE
, "tabindexOpenDialogDownloads")));
438 // Fails on official build. http://crbug.com/482121.
439 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
440 #define MAYBE_TabindexSaveFileDialog DISABLED_TabindexSaveFileDialog
442 #define MAYBE_TabindexSaveFileDialog TabindexSaveFileDialog
444 WRAPPED_INSTANTIATE_TEST_CASE_P(
445 MAYBE_TabindexSaveFileDialog
,
446 FileManagerBrowserTest
,
448 TestParameter(NOT_IN_GUEST_MODE
, "tabindexSaveFileDialogDrive"),
449 TestParameter(NOT_IN_GUEST_MODE
, "tabindexSaveFileDialogDownloads"),
450 TestParameter(IN_GUEST_MODE
, "tabindexSaveFileDialogDownloads")));
452 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
453 #define MAYBE_OpenFileDialog DISABLED_OpenFileDialog
455 #define MAYBE_OpenFileDialog OpenFileDialog
457 WRAPPED_INSTANTIATE_TEST_CASE_P(
458 MAYBE_OpenFileDialog
,
459 FileManagerBrowserTest
,
460 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
,
461 "openFileDialogOnDownloads"),
462 TestParameter(IN_GUEST_MODE
,
463 "openFileDialogOnDownloads"),
464 TestParameter(NOT_IN_GUEST_MODE
,
465 "openFileDialogOnDrive"),
466 TestParameter(IN_INCOGNITO
,
467 "openFileDialogOnDownloads"),
468 TestParameter(IN_INCOGNITO
,
469 "openFileDialogOnDrive"),
470 TestParameter(NOT_IN_GUEST_MODE
,
471 "unloadFileDialog")));
473 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
474 #define MAYBE_CopyBetweenWindows DISABLED_CopyBetweenWindows
476 // flaky: http://crbug.com/500966
477 #define MAYBE_CopyBetweenWindows DISABLED_CopyBetweenWindows
479 WRAPPED_INSTANTIATE_TEST_CASE_P(
480 MAYBE_CopyBetweenWindows
,
481 FileManagerBrowserTest
,
483 TestParameter(NOT_IN_GUEST_MODE
, "copyBetweenWindowsLocalToDrive"),
484 TestParameter(NOT_IN_GUEST_MODE
, "copyBetweenWindowsLocalToUsb"),
485 TestParameter(NOT_IN_GUEST_MODE
, "copyBetweenWindowsUsbToDrive"),
486 TestParameter(NOT_IN_GUEST_MODE
, "copyBetweenWindowsDriveToLocal"),
487 TestParameter(NOT_IN_GUEST_MODE
, "copyBetweenWindowsDriveToUsb"),
488 TestParameter(NOT_IN_GUEST_MODE
, "copyBetweenWindowsUsbToLocal")));
490 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
491 #define MAYBE_ShowGridView DISABLED_ShowGridView
493 #define MAYBE_ShowGridView ShowGridView
495 WRAPPED_INSTANTIATE_TEST_CASE_P(
497 FileManagerBrowserTest
,
498 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
, "showGridViewDownloads"),
499 TestParameter(IN_GUEST_MODE
, "showGridViewDownloads"),
500 TestParameter(NOT_IN_GUEST_MODE
, "showGridViewDrive")));
502 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
503 #define MAYBE_Providers DISABLED_Providers
505 #define MAYBE_Providers Providers
507 WRAPPED_INSTANTIATE_TEST_CASE_P(
509 FileManagerBrowserTest
,
511 TestParameter(NOT_IN_GUEST_MODE
, "requestMount"),
512 TestParameter(NOT_IN_GUEST_MODE
, "requestMountMultipleMounts"),
513 TestParameter(NOT_IN_GUEST_MODE
, "requestMountSourceDevice"),
514 TestParameter(NOT_IN_GUEST_MODE
, "requestMountSourceFile")));
516 // Structure to describe an account info.
517 struct TestAccountInfo
{
518 const char* const gaia_id
;
519 const char* const email
;
520 const char* const hash
;
521 const char* const display_name
;
525 DUMMY_ACCOUNT_INDEX
= 0,
526 PRIMARY_ACCOUNT_INDEX
= 1,
527 SECONDARY_ACCOUNT_INDEX_START
= 2,
530 static const TestAccountInfo kTestAccounts
[] = {
531 {"gaia-id-d", "__dummy__@invalid.domain", "hashdummy", "Dummy Account"},
532 {"gaia-id-a", "alice@invalid.domain", "hashalice", "Alice"},
533 {"gaia-id-b", "bob@invalid.domain", "hashbob", "Bob"},
534 {"gaia-id-c", "charlie@invalid.domain", "hashcharlie", "Charlie"},
537 // Test fixture class for testing multi-profile features.
538 class MultiProfileFileManagerBrowserTest
: public FileManagerBrowserTestBase
{
540 // Enables multi-profiles.
541 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
542 FileManagerBrowserTestBase::SetUpCommandLine(command_line
);
543 // Logs in to a dummy profile (For making MultiProfileWindowManager happy;
544 // browser test creates a default window and the manager tries to assign a
545 // user for it, and we need a profile connected to a user.)
546 command_line
->AppendSwitchASCII(chromeos::switches::kLoginUser
,
547 kTestAccounts
[DUMMY_ACCOUNT_INDEX
].email
);
548 command_line
->AppendSwitchASCII(chromeos::switches::kLoginProfile
,
549 kTestAccounts
[DUMMY_ACCOUNT_INDEX
].hash
);
552 // Logs in to the primary profile of this test.
553 void SetUpOnMainThread() override
{
554 const TestAccountInfo
& info
= kTestAccounts
[PRIMARY_ACCOUNT_INDEX
];
557 FileManagerBrowserTestBase::SetUpOnMainThread();
560 // Loads all users to the current session and sets up necessary fields.
561 // This is used for preparing all accounts in PRE_ test setup, and for testing
562 // actual login behavior.
564 for (size_t i
= 0; i
< arraysize(kTestAccounts
); ++i
)
565 AddUser(kTestAccounts
[i
], i
>= SECONDARY_ACCOUNT_INDEX_START
);
568 // Returns primary profile (if it is already created.)
569 Profile
* profile() override
{
570 Profile
* const profile
= chromeos::ProfileHelper::GetProfileByUserIdHash(
571 kTestAccounts
[PRIMARY_ACCOUNT_INDEX
].hash
);
572 return profile
? profile
: FileManagerBrowserTestBase::profile();
575 // Sets the test case name (used as a function name in test_cases.js to call.)
576 void set_test_case_name(const std::string
& name
) { test_case_name_
= name
; }
578 // Adds a new user for testing to the current session.
579 void AddUser(const TestAccountInfo
& info
, bool log_in
) {
580 user_manager::UserManager
* const user_manager
=
581 user_manager::UserManager::Get();
583 user_manager
->UserLoggedIn(info
.email
, info
.hash
, false);
584 user_manager
->SaveUserDisplayName(info
.email
,
585 base::UTF8ToUTF16(info
.display_name
));
586 SigninManagerFactory::GetForProfile(
587 chromeos::ProfileHelper::GetProfileByUserIdHash(info
.hash
))
588 ->SetAuthenticatedAccountInfo(info
.gaia_id
, info
.email
);
592 GuestMode
GetGuestModeParam() const override
{ return NOT_IN_GUEST_MODE
; }
593 const char* GetTestManifestName() const override
{
594 return "file_manager_test_manifest.json";
596 const char* GetTestCaseNameParam() const override
{
597 return test_case_name_
.c_str();
600 std::string test_case_name_
;
603 // Fails on official build. http://crbug.com/429294
604 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
605 #define MAYBE_PRE_BasicDownloads DISABLED_PRE_BasicDownloads
606 #define MAYBE_BasicDownloads DISABLED_BasicDownloads
608 #define MAYBE_PRE_BasicDownloads PRE_BasicDownloads
609 #define MAYBE_BasicDownloads BasicDownloads
611 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest
,
612 MAYBE_PRE_BasicDownloads
) {
616 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest
,
617 MAYBE_BasicDownloads
) {
620 // Sanity check that normal operations work in multi-profile setting as well.
621 set_test_case_name("keyboardCopyDownloads");
625 // Fails on official build. http://crbug.com/429294
626 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
627 #define MAYBE_PRE_BasicDrive DISABLED_PRE_BasicDrive
628 #define MAYBE_BasicDrive DISABLED_BasicDrive
630 #define MAYBE_PRE_BasicDrive PRE_BasicDrive
631 #define MAYBE_BasicDrive BasicDrive
633 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest
,
634 MAYBE_PRE_BasicDrive
) {
638 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest
, MAYBE_BasicDrive
) {
641 // Sanity check that normal operations work in multi-profile setting as well.
642 set_test_case_name("keyboardCopyDrive");
646 } // namespace file_manager