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")));
184 // Fails on official build. http://crbug.com/429294
185 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
186 #define MAYBE_DriveSpecific DISABLED_DriveSpecific
188 #define MAYBE_DriveSpecific DriveSpecific
190 WRAPPED_INSTANTIATE_TEST_CASE_P(
192 FileManagerBrowserTest
,
194 TestParameter(NOT_IN_GUEST_MODE
, "openSidebarRecent"),
195 TestParameter(NOT_IN_GUEST_MODE
, "openSidebarOffline"),
196 TestParameter(NOT_IN_GUEST_MODE
, "openSidebarSharedWithMe"),
197 TestParameter(NOT_IN_GUEST_MODE
, "autocomplete"),
198 TestParameter(NOT_IN_GUEST_MODE
, "pinFileOnMobileNetwork"),
199 TestParameter(NOT_IN_GUEST_MODE
, "clickFirstSearchResult"),
200 TestParameter(NOT_IN_GUEST_MODE
, "pressEnterToSearch")));
202 // Fails on official build. http://crbug.com/429294
203 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
204 #define MAYBE_Transfer DISABLED_Transfer
206 #define MAYBE_Transfer Transfer
208 WRAPPED_INSTANTIATE_TEST_CASE_P(
210 FileManagerBrowserTest
,
212 TestParameter(NOT_IN_GUEST_MODE
, "transferFromDriveToDownloads"),
213 TestParameter(NOT_IN_GUEST_MODE
, "transferFromDownloadsToDrive"),
214 TestParameter(NOT_IN_GUEST_MODE
, "transferFromSharedToDownloads"),
215 TestParameter(NOT_IN_GUEST_MODE
, "transferFromSharedToDrive"),
216 TestParameter(NOT_IN_GUEST_MODE
, "transferFromRecentToDownloads"),
217 TestParameter(NOT_IN_GUEST_MODE
, "transferFromRecentToDrive"),
218 TestParameter(NOT_IN_GUEST_MODE
, "transferFromOfflineToDownloads"),
219 TestParameter(NOT_IN_GUEST_MODE
, "transferFromOfflineToDrive")));
221 // Fails on official build. http://crbug.com/429294
222 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
223 #define MAYBE_RestorePrefs DISABLED_RestorePrefs
225 #define MAYBE_RestorePrefs RestorePrefs
227 WRAPPED_INSTANTIATE_TEST_CASE_P(
229 FileManagerBrowserTest
,
230 ::testing::Values(TestParameter(IN_GUEST_MODE
, "restoreSortColumn"),
231 TestParameter(NOT_IN_GUEST_MODE
, "restoreSortColumn"),
232 TestParameter(IN_GUEST_MODE
, "restoreCurrentView"),
233 TestParameter(NOT_IN_GUEST_MODE
, "restoreCurrentView")));
235 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
236 #define MAYBE_ShareDialog DISABLED_ShareDialog
238 #define MAYBE_ShareDialog ShareDialog
240 WRAPPED_INSTANTIATE_TEST_CASE_P(
242 FileManagerBrowserTest
,
243 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
, "shareFile"),
244 TestParameter(NOT_IN_GUEST_MODE
, "shareDirectory")));
246 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
247 #define MAYBE_RestoreGeometry DISABLED_RestoreGeometry
249 #define MAYBE_RestoreGeometry RestoreGeometry
251 WRAPPED_INSTANTIATE_TEST_CASE_P(
252 MAYBE_RestoreGeometry
,
253 FileManagerBrowserTest
,
254 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
, "restoreGeometry"),
255 TestParameter(IN_GUEST_MODE
, "restoreGeometry"),
256 TestParameter(NOT_IN_GUEST_MODE
,
257 "restoreGeometryMaximizedState")));
259 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
260 #define MAYBE_Traverse DISABLED_Traverse
262 #define MAYBE_Traverse Traverse
264 WRAPPED_INSTANTIATE_TEST_CASE_P(
266 FileManagerBrowserTest
,
267 ::testing::Values(TestParameter(IN_GUEST_MODE
, "traverseDownloads"),
268 TestParameter(NOT_IN_GUEST_MODE
, "traverseDownloads"),
269 TestParameter(NOT_IN_GUEST_MODE
, "traverseDrive")));
271 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
272 #define MAYBE_SuggestAppDialog DISABLED_SuggestAppDialog
274 #define MAYBE_SuggestAppDialog SuggestAppDialog
276 WRAPPED_INSTANTIATE_TEST_CASE_P(
277 MAYBE_SuggestAppDialog
,
278 FileManagerBrowserTest
,
279 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
, "suggestAppDialog")));
281 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
282 #define MAYBE_ExecuteDefaultTaskOnDownloads \
283 DISABLED_ExecuteDefaultTaskOnDownloads
285 #define MAYBE_ExecuteDefaultTaskOnDownloads ExecuteDefaultTaskOnDownloads
287 WRAPPED_INSTANTIATE_TEST_CASE_P(
288 MAYBE_ExecuteDefaultTaskOnDownloads
,
289 FileManagerBrowserTest
,
291 TestParameter(NOT_IN_GUEST_MODE
, "executeDefaultTaskOnDownloads"),
292 TestParameter(IN_GUEST_MODE
, "executeDefaultTaskOnDownloads")));
294 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
295 #define MAYBE_ExecuteDefaultTaskOnDrive DISABLED_ExecuteDefaultTaskOnDrive
297 #define MAYBE_ExecuteDefaultTaskOnDrive ExecuteDefaultTaskOnDrive
299 WRAPPED_INSTANTIATE_TEST_CASE_P(
300 MAYBE_ExecuteDefaultTaskOnDrive
,
301 FileManagerBrowserTest
,
302 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
,
303 "executeDefaultTaskOnDrive")));
305 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
306 #define MAYBE_DefaultActionDialog DISABLED_DefaultActionDialog
308 #define MAYBE_DefaultActionDialog DefaultActionDialog
310 WRAPPED_INSTANTIATE_TEST_CASE_P(
311 MAYBE_DefaultActionDialog
,
312 FileManagerBrowserTest
,
314 TestParameter(NOT_IN_GUEST_MODE
, "defaultActionDialogOnDownloads"),
315 TestParameter(IN_GUEST_MODE
, "defaultActionDialogOnDownloads"),
316 TestParameter(NOT_IN_GUEST_MODE
, "defaultActionDialogOnDrive")));
318 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
319 #define MAYBE_GenericTask DISABLED_GenericTask
321 #define MAYBE_GenericTask GenericTask
323 WRAPPED_INSTANTIATE_TEST_CASE_P(
325 FileManagerBrowserTest
,
327 TestParameter(NOT_IN_GUEST_MODE
, "genericTaskIsNotExecuted"),
328 TestParameter(NOT_IN_GUEST_MODE
, "genericAndNonGenericTasksAreMixed")));
330 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
331 #define MAYBE_FolderShortcuts DISABLED_FolderShortcuts
333 #define MAYBE_FolderShortcuts FolderShortcuts
335 WRAPPED_INSTANTIATE_TEST_CASE_P(
336 MAYBE_FolderShortcuts
,
337 FileManagerBrowserTest
,
339 TestParameter(NOT_IN_GUEST_MODE
, "traverseFolderShortcuts"),
340 TestParameter(NOT_IN_GUEST_MODE
, "addRemoveFolderShortcuts")));
342 // Fails on official build. http://crbug.com/429294
343 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
344 #define MAYBE_SortColumns DISABLED_SortColumns
346 #define MAYBE_SortColumns SortColumns
348 WRAPPED_INSTANTIATE_TEST_CASE_P(
350 FileManagerBrowserTest
,
351 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
, "sortColumns"),
352 TestParameter(IN_GUEST_MODE
, "sortColumns")));
354 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
355 #define MAYBE_TabIndex DISABLED_TabIndex
357 #define MAYBE_TabIndex TabIndex
359 WRAPPED_INSTANTIATE_TEST_CASE_P(
361 FileManagerBrowserTest
,
362 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
, "searchBoxFocus")));
364 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
365 #define MAYBE_TabindexFocus DISABLED_TabindexFocus
367 #define MAYBE_TabindexFocus TabindexFocus
369 WRAPPED_INSTANTIATE_TEST_CASE_P(
371 FileManagerBrowserTest
,
372 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
, "tabindexFocus")));
374 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
375 #define MAYBE_TabindexFocusDownloads DISABLED_TabindexFocusDownloads
377 #define MAYBE_TabindexFocusDownloads TabindexFocusDownloads
379 WRAPPED_INSTANTIATE_TEST_CASE_P(
380 MAYBE_TabindexFocusDownloads
,
381 FileManagerBrowserTest
,
382 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
,
383 "tabindexFocusDownloads"),
384 TestParameter(IN_GUEST_MODE
, "tabindexFocusDownloads")));
386 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
387 #define MAYBE_TabindexFocusDirectorySelected \
388 DISABLED_TabindexFocusDirectorySelected
390 #define MAYBE_TabindexFocusDirectorySelected TabindexFocusDirectorySelected
392 WRAPPED_INSTANTIATE_TEST_CASE_P(
393 MAYBE_TabindexFocusDirectorySelected
,
394 FileManagerBrowserTest
,
395 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
,
396 "tabindexFocusDirectorySelected")));
398 // Fails on official cros trunk build. http://crbug.com/480491
399 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
400 #define MAYBE_TabindexOpenDialog DISABLED_TabindexOpenDialog
402 #define MAYBE_TabindexOpenDialog TabindexOpenDialog
404 WRAPPED_INSTANTIATE_TEST_CASE_P(
405 MAYBE_TabindexOpenDialog
,
406 FileManagerBrowserTest
,
408 TestParameter(NOT_IN_GUEST_MODE
, "tabindexOpenDialogDrive"),
409 TestParameter(NOT_IN_GUEST_MODE
, "tabindexOpenDialogDownloads"),
410 TestParameter(IN_GUEST_MODE
, "tabindexOpenDialogDownloads")));
412 // Fails on official build. http://crbug.com/482121.
413 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
414 #define MAYBE_TabindexSaveFileDialog DISABLED_TabindexSaveFileDialog
416 #define MAYBE_TabindexSaveFileDialog TabindexSaveFileDialog
418 WRAPPED_INSTANTIATE_TEST_CASE_P(
419 MAYBE_TabindexSaveFileDialog
,
420 FileManagerBrowserTest
,
422 TestParameter(NOT_IN_GUEST_MODE
, "tabindexSaveFileDialogDrive"),
423 TestParameter(NOT_IN_GUEST_MODE
, "tabindexSaveFileDialogDownloads"),
424 TestParameter(IN_GUEST_MODE
, "tabindexSaveFileDialogDownloads")));
426 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
427 #define MAYBE_OpenFileDialog DISABLED_OpenFileDialog
429 #define MAYBE_OpenFileDialog OpenFileDialog
431 WRAPPED_INSTANTIATE_TEST_CASE_P(
432 MAYBE_OpenFileDialog
,
433 FileManagerBrowserTest
,
434 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
,
435 "openFileDialogOnDownloads"),
436 TestParameter(IN_GUEST_MODE
,
437 "openFileDialogOnDownloads"),
438 TestParameter(NOT_IN_GUEST_MODE
,
439 "openFileDialogOnDrive"),
440 TestParameter(IN_INCOGNITO
,
441 "openFileDialogOnDownloads"),
442 TestParameter(IN_INCOGNITO
,
443 "openFileDialogOnDrive"),
444 TestParameter(NOT_IN_GUEST_MODE
,
445 "unloadFileDialog")));
447 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
448 #define MAYBE_CopyBetweenWindows DISABLED_CopyBetweenWindows
450 // flaky: http://crbug.com/500966
451 #define MAYBE_CopyBetweenWindows DISABLED_CopyBetweenWindows
453 WRAPPED_INSTANTIATE_TEST_CASE_P(
454 MAYBE_CopyBetweenWindows
,
455 FileManagerBrowserTest
,
457 TestParameter(NOT_IN_GUEST_MODE
, "copyBetweenWindowsLocalToDrive"),
458 TestParameter(NOT_IN_GUEST_MODE
, "copyBetweenWindowsLocalToUsb"),
459 TestParameter(NOT_IN_GUEST_MODE
, "copyBetweenWindowsUsbToDrive"),
460 TestParameter(NOT_IN_GUEST_MODE
, "copyBetweenWindowsDriveToLocal"),
461 TestParameter(NOT_IN_GUEST_MODE
, "copyBetweenWindowsDriveToUsb"),
462 TestParameter(NOT_IN_GUEST_MODE
, "copyBetweenWindowsUsbToLocal")));
464 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
465 #define MAYBE_ShowGridView DISABLED_ShowGridView
467 #define MAYBE_ShowGridView ShowGridView
469 WRAPPED_INSTANTIATE_TEST_CASE_P(
471 FileManagerBrowserTest
,
472 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE
, "showGridViewDownloads"),
473 TestParameter(IN_GUEST_MODE
, "showGridViewDownloads"),
474 TestParameter(NOT_IN_GUEST_MODE
, "showGridViewDrive")));
476 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
477 #define MAYBE_Providers DISABLED_Providers
479 #define MAYBE_Providers Providers
481 WRAPPED_INSTANTIATE_TEST_CASE_P(
483 FileManagerBrowserTest
,
485 TestParameter(NOT_IN_GUEST_MODE
, "requestMount"),
486 TestParameter(NOT_IN_GUEST_MODE
, "requestMountMultipleMounts"),
487 TestParameter(NOT_IN_GUEST_MODE
, "requestMountSourceDevice"),
488 TestParameter(NOT_IN_GUEST_MODE
, "requestMountSourceFile")));
490 // Structure to describe an account info.
491 struct TestAccountInfo
{
492 const char* const gaia_id
;
493 const char* const email
;
494 const char* const hash
;
495 const char* const display_name
;
499 DUMMY_ACCOUNT_INDEX
= 0,
500 PRIMARY_ACCOUNT_INDEX
= 1,
501 SECONDARY_ACCOUNT_INDEX_START
= 2,
504 static const TestAccountInfo kTestAccounts
[] = {
505 {"gaia-id-d", "__dummy__@invalid.domain", "hashdummy", "Dummy Account"},
506 {"gaia-id-a", "alice@invalid.domain", "hashalice", "Alice"},
507 {"gaia-id-b", "bob@invalid.domain", "hashbob", "Bob"},
508 {"gaia-id-c", "charlie@invalid.domain", "hashcharlie", "Charlie"},
511 // Test fixture class for testing multi-profile features.
512 class MultiProfileFileManagerBrowserTest
: public FileManagerBrowserTestBase
{
514 // Enables multi-profiles.
515 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
516 FileManagerBrowserTestBase::SetUpCommandLine(command_line
);
517 // Logs in to a dummy profile (For making MultiProfileWindowManager happy;
518 // browser test creates a default window and the manager tries to assign a
519 // user for it, and we need a profile connected to a user.)
520 command_line
->AppendSwitchASCII(chromeos::switches::kLoginUser
,
521 kTestAccounts
[DUMMY_ACCOUNT_INDEX
].email
);
522 command_line
->AppendSwitchASCII(chromeos::switches::kLoginProfile
,
523 kTestAccounts
[DUMMY_ACCOUNT_INDEX
].hash
);
526 // Logs in to the primary profile of this test.
527 void SetUpOnMainThread() override
{
528 const TestAccountInfo
& info
= kTestAccounts
[PRIMARY_ACCOUNT_INDEX
];
531 FileManagerBrowserTestBase::SetUpOnMainThread();
534 // Loads all users to the current session and sets up necessary fields.
535 // This is used for preparing all accounts in PRE_ test setup, and for testing
536 // actual login behavior.
538 for (size_t i
= 0; i
< arraysize(kTestAccounts
); ++i
)
539 AddUser(kTestAccounts
[i
], i
>= SECONDARY_ACCOUNT_INDEX_START
);
542 // Returns primary profile (if it is already created.)
543 Profile
* profile() override
{
544 Profile
* const profile
= chromeos::ProfileHelper::GetProfileByUserIdHash(
545 kTestAccounts
[PRIMARY_ACCOUNT_INDEX
].hash
);
546 return profile
? profile
: FileManagerBrowserTestBase::profile();
549 // Sets the test case name (used as a function name in test_cases.js to call.)
550 void set_test_case_name(const std::string
& name
) { test_case_name_
= name
; }
552 // Adds a new user for testing to the current session.
553 void AddUser(const TestAccountInfo
& info
, bool log_in
) {
554 user_manager::UserManager
* const user_manager
=
555 user_manager::UserManager::Get();
557 user_manager
->UserLoggedIn(info
.email
, info
.hash
, false);
558 user_manager
->SaveUserDisplayName(info
.email
,
559 base::UTF8ToUTF16(info
.display_name
));
560 SigninManagerFactory::GetForProfile(
561 chromeos::ProfileHelper::GetProfileByUserIdHash(info
.hash
))
562 ->SetAuthenticatedAccountInfo(info
.gaia_id
, info
.email
);
566 GuestMode
GetGuestModeParam() const override
{ return NOT_IN_GUEST_MODE
; }
567 const char* GetTestManifestName() const override
{
568 return "file_manager_test_manifest.json";
570 const char* GetTestCaseNameParam() const override
{
571 return test_case_name_
.c_str();
574 std::string test_case_name_
;
577 // Fails on official build. http://crbug.com/429294
578 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
579 #define MAYBE_PRE_BasicDownloads DISABLED_PRE_BasicDownloads
580 #define MAYBE_BasicDownloads DISABLED_BasicDownloads
582 #define MAYBE_PRE_BasicDownloads PRE_BasicDownloads
583 #define MAYBE_BasicDownloads BasicDownloads
585 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest
,
586 MAYBE_PRE_BasicDownloads
) {
590 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest
,
591 MAYBE_BasicDownloads
) {
594 // Sanity check that normal operations work in multi-profile setting as well.
595 set_test_case_name("keyboardCopyDownloads");
599 // Fails on official build. http://crbug.com/429294
600 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
601 #define MAYBE_PRE_BasicDrive DISABLED_PRE_BasicDrive
602 #define MAYBE_BasicDrive DISABLED_BasicDrive
604 #define MAYBE_PRE_BasicDrive PRE_BasicDrive
605 #define MAYBE_BasicDrive BasicDrive
607 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest
,
608 MAYBE_PRE_BasicDrive
) {
612 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest
, MAYBE_BasicDrive
) {
615 // Sanity check that normal operations work in multi-profile setting as well.
616 set_test_case_name("keyboardCopyDrive");
620 } // namespace file_manager