Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / chromeos / file_manager / file_manager_browsertest.cc
blob15d21597e4c243b24c35dea2d94bc6dee5848650
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 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
168 #define MAYBE_DirectoryTreeContextMenu DISABLED_DirectoryTreeContextMenu
169 #else
170 #define MAYBE_DirectoryTreeContextMenu DirectoryTreeContextMenu
171 #endif
172 WRAPPED_INSTANTIATE_TEST_CASE_P(
173 MAYBE_DirectoryTreeContextMenu,
174 FileManagerBrowserTest,
175 ::testing::Values(
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
187 #else
188 #define MAYBE_DriveSpecific DriveSpecific
189 #endif
190 WRAPPED_INSTANTIATE_TEST_CASE_P(
191 MAYBE_DriveSpecific,
192 FileManagerBrowserTest,
193 ::testing::Values(
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
205 #else
206 #define MAYBE_Transfer Transfer
207 #endif
208 WRAPPED_INSTANTIATE_TEST_CASE_P(
209 MAYBE_Transfer,
210 FileManagerBrowserTest,
211 ::testing::Values(
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
224 #else
225 #define MAYBE_RestorePrefs RestorePrefs
226 #endif
227 WRAPPED_INSTANTIATE_TEST_CASE_P(
228 MAYBE_RestorePrefs,
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
237 #else
238 #define MAYBE_ShareDialog ShareDialog
239 #endif
240 WRAPPED_INSTANTIATE_TEST_CASE_P(
241 MAYBE_ShareDialog,
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
248 #else
249 #define MAYBE_RestoreGeometry RestoreGeometry
250 #endif
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
261 #else
262 #define MAYBE_Traverse Traverse
263 #endif
264 WRAPPED_INSTANTIATE_TEST_CASE_P(
265 MAYBE_Traverse,
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
273 #else
274 #define MAYBE_SuggestAppDialog SuggestAppDialog
275 #endif
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
284 #else
285 #define MAYBE_ExecuteDefaultTaskOnDownloads ExecuteDefaultTaskOnDownloads
286 #endif
287 WRAPPED_INSTANTIATE_TEST_CASE_P(
288 MAYBE_ExecuteDefaultTaskOnDownloads,
289 FileManagerBrowserTest,
290 ::testing::Values(
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
296 #else
297 #define MAYBE_ExecuteDefaultTaskOnDrive ExecuteDefaultTaskOnDrive
298 #endif
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
307 #else
308 #define MAYBE_DefaultActionDialog DefaultActionDialog
309 #endif
310 WRAPPED_INSTANTIATE_TEST_CASE_P(
311 MAYBE_DefaultActionDialog,
312 FileManagerBrowserTest,
313 ::testing::Values(
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
320 #else
321 #define MAYBE_GenericTask GenericTask
322 #endif
323 WRAPPED_INSTANTIATE_TEST_CASE_P(
324 MAYBE_GenericTask,
325 FileManagerBrowserTest,
326 ::testing::Values(
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
332 #else
333 #define MAYBE_FolderShortcuts FolderShortcuts
334 #endif
335 WRAPPED_INSTANTIATE_TEST_CASE_P(
336 MAYBE_FolderShortcuts,
337 FileManagerBrowserTest,
338 ::testing::Values(
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
345 #else
346 #define MAYBE_SortColumns SortColumns
347 #endif
348 WRAPPED_INSTANTIATE_TEST_CASE_P(
349 MAYBE_SortColumns,
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
356 #else
357 #define MAYBE_TabIndex TabIndex
358 #endif
359 WRAPPED_INSTANTIATE_TEST_CASE_P(
360 MAYBE_TabIndex,
361 FileManagerBrowserTest,
362 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "searchBoxFocus")));
364 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
365 #define MAYBE_TabindexFocus DISABLED_TabindexFocus
366 #else
367 #define MAYBE_TabindexFocus TabindexFocus
368 #endif
369 WRAPPED_INSTANTIATE_TEST_CASE_P(
370 MAYBE_TabindexFocus,
371 FileManagerBrowserTest,
372 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "tabindexFocus")));
374 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
375 #define MAYBE_TabindexFocusDownloads DISABLED_TabindexFocusDownloads
376 #else
377 #define MAYBE_TabindexFocusDownloads TabindexFocusDownloads
378 #endif
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
389 #else
390 #define MAYBE_TabindexFocusDirectorySelected TabindexFocusDirectorySelected
391 #endif
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
401 #else
402 #define MAYBE_TabindexOpenDialog TabindexOpenDialog
403 #endif
404 WRAPPED_INSTANTIATE_TEST_CASE_P(
405 MAYBE_TabindexOpenDialog,
406 FileManagerBrowserTest,
407 ::testing::Values(
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
415 #else
416 #define MAYBE_TabindexSaveFileDialog TabindexSaveFileDialog
417 #endif
418 WRAPPED_INSTANTIATE_TEST_CASE_P(
419 MAYBE_TabindexSaveFileDialog,
420 FileManagerBrowserTest,
421 ::testing::Values(
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
428 #else
429 #define MAYBE_OpenFileDialog OpenFileDialog
430 #endif
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
449 #else
450 // flaky: http://crbug.com/500966
451 #define MAYBE_CopyBetweenWindows DISABLED_CopyBetweenWindows
452 #endif
453 WRAPPED_INSTANTIATE_TEST_CASE_P(
454 MAYBE_CopyBetweenWindows,
455 FileManagerBrowserTest,
456 ::testing::Values(
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
466 #else
467 #define MAYBE_ShowGridView ShowGridView
468 #endif
469 WRAPPED_INSTANTIATE_TEST_CASE_P(
470 MAYBE_ShowGridView,
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
478 #else
479 #define MAYBE_Providers Providers
480 #endif
481 WRAPPED_INSTANTIATE_TEST_CASE_P(
482 MAYBE_Providers,
483 FileManagerBrowserTest,
484 ::testing::Values(
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;
498 enum {
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 {
513 protected:
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];
530 AddUser(info, true);
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.
537 void AddAllUsers() {
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();
556 if (log_in)
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);
565 private:
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
581 #else
582 #define MAYBE_PRE_BasicDownloads PRE_BasicDownloads
583 #define MAYBE_BasicDownloads BasicDownloads
584 #endif
585 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest,
586 MAYBE_PRE_BasicDownloads) {
587 AddAllUsers();
590 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest,
591 MAYBE_BasicDownloads) {
592 AddAllUsers();
594 // Sanity check that normal operations work in multi-profile setting as well.
595 set_test_case_name("keyboardCopyDownloads");
596 StartTest();
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
603 #else
604 #define MAYBE_PRE_BasicDrive PRE_BasicDrive
605 #define MAYBE_BasicDrive BasicDrive
606 #endif
607 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest,
608 MAYBE_PRE_BasicDrive) {
609 AddAllUsers();
612 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest, MAYBE_BasicDrive) {
613 AddAllUsers();
615 // Sanity check that normal operations work in multi-profile setting as well.
616 set_test_case_name("keyboardCopyDrive");
617 StartTest();
620 } // namespace file_manager