Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / chromeos / file_manager / file_manager_browsertest.cc
blobb72569f2ad716957ea126b61a038ed8eb3068356
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) {
36 StartTest();
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
52 #else
53 #define MAYBE_FileDisplay FileDisplay
54 #endif
55 WRAPPED_INSTANTIATE_TEST_CASE_P(
56 MAYBE_FileDisplay,
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
69 #else
70 #define MAYBE_OpenVideoFiles OpenVideoFiles
71 #endif
72 WRAPPED_INSTANTIATE_TEST_CASE_P(
73 MAYBE_OpenVideoFiles,
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
82 #else
83 #define MAYBE_OpenAudioFiles OpenAudioFiles
84 #endif
85 WRAPPED_INSTANTIATE_TEST_CASE_P(
86 MAYBE_OpenAudioFiles,
87 FileManagerBrowserTest,
88 ::testing::Values(
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
101 #else
102 #define MAYBE_OpenImageFiles OpenImageFiles
103 #endif
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
113 #else
114 #define MAYBE_CreateNewFolder CreateNewFolder
115 #endif
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
131 #else
132 #define MAYBE_KeyboardOperations KeyboardOperations
133 #endif
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
156 #else
157 #define MAYBE_Delete Delete
158 #endif
159 WRAPPED_INSTANTIATE_TEST_CASE_P(
160 MAYBE_Delete,
161 FileManagerBrowserTest,
162 ::testing::Values(
163 TestParameter(NOT_IN_GUEST_MODE,
164 "deleteMenuItemIsDisabledWhenNoItemIsSelected"),
165 TestParameter(NOT_IN_GUEST_MODE, "deleteOneItemFromToolbar")));
167 // Fails on official build. http://crbug.com/429294
168 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
169 #define MAYBE_DriveSpecific DISABLED_DriveSpecific
170 #else
171 #define MAYBE_DriveSpecific DriveSpecific
172 #endif
173 WRAPPED_INSTANTIATE_TEST_CASE_P(
174 MAYBE_DriveSpecific,
175 FileManagerBrowserTest,
176 ::testing::Values(
177 TestParameter(NOT_IN_GUEST_MODE, "openSidebarRecent"),
178 TestParameter(NOT_IN_GUEST_MODE, "openSidebarOffline"),
179 TestParameter(NOT_IN_GUEST_MODE, "openSidebarSharedWithMe"),
180 TestParameter(NOT_IN_GUEST_MODE, "autocomplete"),
181 TestParameter(NOT_IN_GUEST_MODE, "pinFileOnMobileNetwork"),
182 TestParameter(NOT_IN_GUEST_MODE, "clickFirstSearchResult"),
183 TestParameter(NOT_IN_GUEST_MODE, "pressEnterToSearch")));
185 // Fails on official build. http://crbug.com/429294
186 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
187 #define MAYBE_Transfer DISABLED_Transfer
188 #else
189 #define MAYBE_Transfer Transfer
190 #endif
191 WRAPPED_INSTANTIATE_TEST_CASE_P(
192 MAYBE_Transfer,
193 FileManagerBrowserTest,
194 ::testing::Values(
195 TestParameter(NOT_IN_GUEST_MODE, "transferFromDriveToDownloads"),
196 TestParameter(NOT_IN_GUEST_MODE, "transferFromDownloadsToDrive"),
197 TestParameter(NOT_IN_GUEST_MODE, "transferFromSharedToDownloads"),
198 TestParameter(NOT_IN_GUEST_MODE, "transferFromSharedToDrive"),
199 TestParameter(NOT_IN_GUEST_MODE, "transferFromRecentToDownloads"),
200 TestParameter(NOT_IN_GUEST_MODE, "transferFromRecentToDrive"),
201 TestParameter(NOT_IN_GUEST_MODE, "transferFromOfflineToDownloads"),
202 TestParameter(NOT_IN_GUEST_MODE, "transferFromOfflineToDrive")));
204 // Fails on official build. http://crbug.com/429294
205 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
206 #define MAYBE_RestorePrefs DISABLED_RestorePrefs
207 #else
208 #define MAYBE_RestorePrefs RestorePrefs
209 #endif
210 WRAPPED_INSTANTIATE_TEST_CASE_P(
211 MAYBE_RestorePrefs,
212 FileManagerBrowserTest,
213 ::testing::Values(TestParameter(IN_GUEST_MODE, "restoreSortColumn"),
214 TestParameter(NOT_IN_GUEST_MODE, "restoreSortColumn"),
215 TestParameter(IN_GUEST_MODE, "restoreCurrentView"),
216 TestParameter(NOT_IN_GUEST_MODE, "restoreCurrentView")));
218 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
219 #define MAYBE_ShareDialog DISABLED_ShareDialog
220 #else
221 #define MAYBE_ShareDialog ShareDialog
222 #endif
223 WRAPPED_INSTANTIATE_TEST_CASE_P(
224 MAYBE_ShareDialog,
225 FileManagerBrowserTest,
226 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "shareFile"),
227 TestParameter(NOT_IN_GUEST_MODE, "shareDirectory")));
229 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
230 #define MAYBE_RestoreGeometry DISABLED_RestoreGeometry
231 #else
232 #define MAYBE_RestoreGeometry RestoreGeometry
233 #endif
234 WRAPPED_INSTANTIATE_TEST_CASE_P(
235 MAYBE_RestoreGeometry,
236 FileManagerBrowserTest,
237 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "restoreGeometry"),
238 TestParameter(IN_GUEST_MODE, "restoreGeometry"),
239 TestParameter(NOT_IN_GUEST_MODE,
240 "restoreGeometryMaximizedState")));
242 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
243 #define MAYBE_Traverse DISABLED_Traverse
244 #else
245 #define MAYBE_Traverse Traverse
246 #endif
247 WRAPPED_INSTANTIATE_TEST_CASE_P(
248 MAYBE_Traverse,
249 FileManagerBrowserTest,
250 ::testing::Values(TestParameter(IN_GUEST_MODE, "traverseDownloads"),
251 TestParameter(NOT_IN_GUEST_MODE, "traverseDownloads"),
252 TestParameter(NOT_IN_GUEST_MODE, "traverseDrive")));
254 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
255 #define MAYBE_SuggestAppDialog DISABLED_SuggestAppDialog
256 #else
257 #define MAYBE_SuggestAppDialog SuggestAppDialog
258 #endif
259 WRAPPED_INSTANTIATE_TEST_CASE_P(
260 MAYBE_SuggestAppDialog,
261 FileManagerBrowserTest,
262 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "suggestAppDialog")));
264 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
265 #define MAYBE_ExecuteDefaultTaskOnDownloads \
266 DISABLED_ExecuteDefaultTaskOnDownloads
267 #else
268 #define MAYBE_ExecuteDefaultTaskOnDownloads ExecuteDefaultTaskOnDownloads
269 #endif
270 WRAPPED_INSTANTIATE_TEST_CASE_P(
271 MAYBE_ExecuteDefaultTaskOnDownloads,
272 FileManagerBrowserTest,
273 ::testing::Values(
274 TestParameter(NOT_IN_GUEST_MODE, "executeDefaultTaskOnDownloads"),
275 TestParameter(IN_GUEST_MODE, "executeDefaultTaskOnDownloads")));
277 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
278 #define MAYBE_ExecuteDefaultTaskOnDrive DISABLED_ExecuteDefaultTaskOnDrive
279 #else
280 #define MAYBE_ExecuteDefaultTaskOnDrive ExecuteDefaultTaskOnDrive
281 #endif
282 INSTANTIATE_TEST_CASE_P(
283 MAYBE_ExecuteDefaultTaskOnDrive,
284 FileManagerBrowserTest,
285 ::testing::Values(
286 TestParameter(NOT_IN_GUEST_MODE, "executeDefaultTaskOnDrive")));
288 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
289 #define MAYBE_DefaultActionDialog DISABLED_DefaultActionDialog
290 #else
291 #define MAYBE_DefaultActionDialog DefaultActionDialog
292 #endif
293 WRAPPED_INSTANTIATE_TEST_CASE_P(
294 MAYBE_DefaultActionDialog,
295 FileManagerBrowserTest,
296 ::testing::Values(
297 TestParameter(NOT_IN_GUEST_MODE, "defaultActionDialogOnDownloads"),
298 TestParameter(IN_GUEST_MODE, "defaultActionDialogOnDownloads"),
299 TestParameter(NOT_IN_GUEST_MODE, "defaultActionDialogOnDrive")));
301 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
302 #define MAYBE_GenericTask DISABLED_GenericTask
303 #else
304 #define MAYBE_GenericTask GenericTask
305 #endif
306 WRAPPED_INSTANTIATE_TEST_CASE_P(
307 MAYBE_GenericTask,
308 FileManagerBrowserTest,
309 ::testing::Values(
310 TestParameter(NOT_IN_GUEST_MODE, "genericTaskIsNotExecuted"),
311 TestParameter(NOT_IN_GUEST_MODE, "genericAndNonGenericTasksAreMixed")));
313 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
314 #define MAYBE_FolderShortcuts DISABLED_FolderShortcuts
315 #else
316 #define MAYBE_FolderShortcuts FolderShortcuts
317 #endif
318 WRAPPED_INSTANTIATE_TEST_CASE_P(
319 MAYBE_FolderShortcuts,
320 FileManagerBrowserTest,
321 ::testing::Values(
322 TestParameter(NOT_IN_GUEST_MODE, "traverseFolderShortcuts"),
323 TestParameter(NOT_IN_GUEST_MODE, "addRemoveFolderShortcuts")));
325 // Fails on official build. http://crbug.com/429294
326 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
327 #define MAYBE_SortColumns DISABLED_SortColumns
328 #else
329 #define MAYBE_SortColumns SortColumns
330 #endif
331 WRAPPED_INSTANTIATE_TEST_CASE_P(
332 MAYBE_SortColumns,
333 FileManagerBrowserTest,
334 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "sortColumns"),
335 TestParameter(IN_GUEST_MODE, "sortColumns")));
337 INSTANTIATE_TEST_CASE_P(
338 TabIndex,
339 FileManagerBrowserTest,
340 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "searchBoxFocus")));
342 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
343 #define MAYBE_TabindexFocus DISABLED_TabindexFocus
344 #else
345 #define MAYBE_TabindexFocus TabindexFocus
346 #endif
347 WRAPPED_INSTANTIATE_TEST_CASE_P(
348 MAYBE_TabindexFocus,
349 FileManagerBrowserTest,
350 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "tabindexFocus")));
352 INSTANTIATE_TEST_CASE_P(
353 TabindexFocusDownloads,
354 FileManagerBrowserTest,
355 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE,
356 "tabindexFocusDownloads"),
357 TestParameter(IN_GUEST_MODE, "tabindexFocusDownloads")));
359 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
360 #define MAYBE_TabindexFocusDirectorySelected \
361 DISABLED_TabindexFocusDirectorySelected
362 #else
363 #define MAYBE_TabindexFocusDirectorySelected TabindexFocusDirectorySelected
364 #endif
365 WRAPPED_INSTANTIATE_TEST_CASE_P(
366 MAYBE_TabindexFocusDirectorySelected,
367 FileManagerBrowserTest,
368 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE,
369 "tabindexFocusDirectorySelected")));
371 // Fails on official cros trunk build. http://crbug.com/480491
372 #if defined(OFFICIAL_BUILD)
373 #define MAYBE_TabindexOpenDialog DISABLED_TabindexOpenDialog
374 #else
375 #define MAYBE_TabindexOpenDialog TabindexOpenDialog
376 #endif
377 WRAPPED_INSTANTIATE_TEST_CASE_P(
378 MAYBE_TabindexOpenDialog,
379 FileManagerBrowserTest,
380 ::testing::Values(
381 TestParameter(NOT_IN_GUEST_MODE, "tabindexOpenDialogDrive"),
382 TestParameter(NOT_IN_GUEST_MODE, "tabindexOpenDialogDownloads"),
383 TestParameter(IN_GUEST_MODE, "tabindexOpenDialogDownloads")));
385 // Fails on official build. http://crbug.com/482121.
386 #if defined(OFFICIAL_BUILD)
387 #define MAYBE_TabindexSaveFileDialog DISABLED_TabindexSaveFileDialog
388 #else
389 #define MAYBE_TabindexSaveFileDialog TabindexSaveFileDialog
390 #endif
391 WRAPPED_INSTANTIATE_TEST_CASE_P(
392 MAYBE_TabindexSaveFileDialog,
393 FileManagerBrowserTest,
394 ::testing::Values(
395 TestParameter(NOT_IN_GUEST_MODE, "tabindexSaveFileDialogDrive"),
396 TestParameter(NOT_IN_GUEST_MODE, "tabindexSaveFileDialogDownloads"),
397 TestParameter(IN_GUEST_MODE, "tabindexSaveFileDialogDownloads")));
399 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
400 #define MAYBE_OpenFileDialog DISABLED_OpenFileDialog
401 #else
402 #define MAYBE_OpenFileDialog OpenFileDialog
403 #endif
404 WRAPPED_INSTANTIATE_TEST_CASE_P(
405 MAYBE_OpenFileDialog,
406 FileManagerBrowserTest,
407 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE,
408 "openFileDialogOnDownloads"),
409 TestParameter(IN_GUEST_MODE,
410 "openFileDialogOnDownloads"),
411 TestParameter(NOT_IN_GUEST_MODE,
412 "openFileDialogOnDrive"),
413 TestParameter(IN_INCOGNITO,
414 "openFileDialogOnDownloads"),
415 TestParameter(IN_INCOGNITO,
416 "openFileDialogOnDrive"),
417 TestParameter(NOT_IN_GUEST_MODE,
418 "unloadFileDialog")));
420 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
421 #define MAYBE_CopyBetweenWindows DISABLED_CopyBetweenWindows
422 #else
423 // flaky: http://crbug.com/500966
424 #define MAYBE_CopyBetweenWindows DISABLED_CopyBetweenWindows
425 #endif
426 WRAPPED_INSTANTIATE_TEST_CASE_P(
427 MAYBE_CopyBetweenWindows,
428 FileManagerBrowserTest,
429 ::testing::Values(
430 TestParameter(NOT_IN_GUEST_MODE, "copyBetweenWindowsLocalToDrive"),
431 TestParameter(NOT_IN_GUEST_MODE, "copyBetweenWindowsLocalToUsb"),
432 TestParameter(NOT_IN_GUEST_MODE, "copyBetweenWindowsUsbToDrive"),
433 TestParameter(NOT_IN_GUEST_MODE, "copyBetweenWindowsDriveToLocal"),
434 TestParameter(NOT_IN_GUEST_MODE, "copyBetweenWindowsDriveToUsb"),
435 TestParameter(NOT_IN_GUEST_MODE, "copyBetweenWindowsUsbToLocal")));
437 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
438 #define MAYBE_ShowGridView DISABLED_ShowGridView
439 #else
440 #define MAYBE_ShowGridView ShowGridView
441 #endif
442 WRAPPED_INSTANTIATE_TEST_CASE_P(
443 MAYBE_ShowGridView,
444 FileManagerBrowserTest,
445 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "showGridViewDownloads"),
446 TestParameter(IN_GUEST_MODE, "showGridViewDownloads"),
447 TestParameter(NOT_IN_GUEST_MODE, "showGridViewDrive")));
449 WRAPPED_INSTANTIATE_TEST_CASE_P(
450 Providers,
451 FileManagerBrowserTest,
452 ::testing::Values(
453 TestParameter(NOT_IN_GUEST_MODE, "requestMount"),
454 TestParameter(NOT_IN_GUEST_MODE, "requestMountMultipleMounts"),
455 TestParameter(NOT_IN_GUEST_MODE, "requestMountSourceDevice"),
456 TestParameter(NOT_IN_GUEST_MODE, "requestMountSourceFile")));
458 // Structure to describe an account info.
459 struct TestAccountInfo {
460 const char* const gaia_id;
461 const char* const email;
462 const char* const hash;
463 const char* const display_name;
466 enum {
467 DUMMY_ACCOUNT_INDEX = 0,
468 PRIMARY_ACCOUNT_INDEX = 1,
469 SECONDARY_ACCOUNT_INDEX_START = 2,
472 static const TestAccountInfo kTestAccounts[] = {
473 {"gaia-id-d", "__dummy__@invalid.domain", "hashdummy", "Dummy Account"},
474 {"gaia-id-a", "alice@invalid.domain", "hashalice", "Alice"},
475 {"gaia-id-b", "bob@invalid.domain", "hashbob", "Bob"},
476 {"gaia-id-c", "charlie@invalid.domain", "hashcharlie", "Charlie"},
479 // Test fixture class for testing multi-profile features.
480 class MultiProfileFileManagerBrowserTest : public FileManagerBrowserTestBase {
481 protected:
482 // Enables multi-profiles.
483 void SetUpCommandLine(base::CommandLine* command_line) override {
484 FileManagerBrowserTestBase::SetUpCommandLine(command_line);
485 // Logs in to a dummy profile (For making MultiProfileWindowManager happy;
486 // browser test creates a default window and the manager tries to assign a
487 // user for it, and we need a profile connected to a user.)
488 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser,
489 kTestAccounts[DUMMY_ACCOUNT_INDEX].email);
490 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile,
491 kTestAccounts[DUMMY_ACCOUNT_INDEX].hash);
494 // Logs in to the primary profile of this test.
495 void SetUpOnMainThread() override {
496 const TestAccountInfo& info = kTestAccounts[PRIMARY_ACCOUNT_INDEX];
498 AddUser(info, true);
499 FileManagerBrowserTestBase::SetUpOnMainThread();
502 // Loads all users to the current session and sets up necessary fields.
503 // This is used for preparing all accounts in PRE_ test setup, and for testing
504 // actual login behavior.
505 void AddAllUsers() {
506 for (size_t i = 0; i < arraysize(kTestAccounts); ++i)
507 AddUser(kTestAccounts[i], i >= SECONDARY_ACCOUNT_INDEX_START);
510 // Returns primary profile (if it is already created.)
511 Profile* profile() override {
512 Profile* const profile = chromeos::ProfileHelper::GetProfileByUserIdHash(
513 kTestAccounts[PRIMARY_ACCOUNT_INDEX].hash);
514 return profile ? profile : FileManagerBrowserTestBase::profile();
517 // Sets the test case name (used as a function name in test_cases.js to call.)
518 void set_test_case_name(const std::string& name) { test_case_name_ = name; }
520 // Adds a new user for testing to the current session.
521 void AddUser(const TestAccountInfo& info, bool log_in) {
522 user_manager::UserManager* const user_manager =
523 user_manager::UserManager::Get();
524 if (log_in)
525 user_manager->UserLoggedIn(info.email, info.hash, false);
526 user_manager->SaveUserDisplayName(info.email,
527 base::UTF8ToUTF16(info.display_name));
528 SigninManagerFactory::GetForProfile(
529 chromeos::ProfileHelper::GetProfileByUserIdHash(info.hash))
530 ->SetAuthenticatedAccountInfo(info.gaia_id, info.email);
533 private:
534 GuestMode GetGuestModeParam() const override { return NOT_IN_GUEST_MODE; }
535 const char* GetTestManifestName() const override {
536 return "file_manager_test_manifest.json";
538 const char* GetTestCaseNameParam() const override {
539 return test_case_name_.c_str();
542 std::string test_case_name_;
545 // Fails on official build. http://crbug.com/429294
546 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
547 #define MAYBE_PRE_BasicDownloads DISABLED_PRE_BasicDownloads
548 #define MAYBE_BasicDownloads DISABLED_BasicDownloads
549 #else
550 #define MAYBE_PRE_BasicDownloads PRE_BasicDownloads
551 #define MAYBE_BasicDownloads BasicDownloads
552 #endif
553 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest,
554 MAYBE_PRE_BasicDownloads) {
555 AddAllUsers();
558 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest,
559 MAYBE_BasicDownloads) {
560 AddAllUsers();
562 // Sanity check that normal operations work in multi-profile setting as well.
563 set_test_case_name("keyboardCopyDownloads");
564 StartTest();
567 // Fails on official build. http://crbug.com/429294
568 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
569 #define MAYBE_PRE_BasicDrive DISABLED_PRE_BasicDrive
570 #define MAYBE_BasicDrive DISABLED_BasicDrive
571 #else
572 #define MAYBE_PRE_BasicDrive PRE_BasicDrive
573 #define MAYBE_BasicDrive BasicDrive
574 #endif
575 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest,
576 MAYBE_PRE_BasicDrive) {
577 AddAllUsers();
580 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest, MAYBE_BasicDrive) {
581 AddAllUsers();
583 // Sanity check that normal operations work in multi-profile setting as well.
584 set_test_case_name("keyboardCopyDrive");
585 StartTest();
588 } // namespace file_manager