Run canExecute before executing delete command.
[chromium-blink-merge.git] / chrome / browser / chromeos / file_manager / file_manager_browsertest.cc
blob588d5d91e6277beeb36624b5a7ce87226362c443
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")));
240 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
241 #define MAYBE_Traverse DISABLED_Traverse
242 #else
243 #define MAYBE_Traverse Traverse
244 #endif
245 WRAPPED_INSTANTIATE_TEST_CASE_P(
246 MAYBE_Traverse,
247 FileManagerBrowserTest,
248 ::testing::Values(TestParameter(IN_GUEST_MODE, "traverseDownloads"),
249 TestParameter(NOT_IN_GUEST_MODE, "traverseDownloads"),
250 TestParameter(NOT_IN_GUEST_MODE, "traverseDrive")));
252 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
253 #define MAYBE_SuggestAppDialog DISABLED_SuggestAppDialog
254 #else
255 #define MAYBE_SuggestAppDialog SuggestAppDialog
256 #endif
257 WRAPPED_INSTANTIATE_TEST_CASE_P(
258 MAYBE_SuggestAppDialog,
259 FileManagerBrowserTest,
260 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "suggestAppDialog")));
262 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
263 #define MAYBE_ExecuteDefaultTaskOnDownloads \
264 DISABLED_ExecuteDefaultTaskOnDownloads
265 #else
266 #define MAYBE_ExecuteDefaultTaskOnDownloads ExecuteDefaultTaskOnDownloads
267 #endif
268 WRAPPED_INSTANTIATE_TEST_CASE_P(
269 MAYBE_ExecuteDefaultTaskOnDownloads,
270 FileManagerBrowserTest,
271 ::testing::Values(
272 TestParameter(NOT_IN_GUEST_MODE, "executeDefaultTaskOnDownloads"),
273 TestParameter(IN_GUEST_MODE, "executeDefaultTaskOnDownloads")));
275 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
276 #define MAYBE_ExecuteDefaultTaskOnDrive DISABLED_ExecuteDefaultTaskOnDrive
277 #else
278 #define MAYBE_ExecuteDefaultTaskOnDrive ExecuteDefaultTaskOnDrive
279 #endif
280 INSTANTIATE_TEST_CASE_P(
281 MAYBE_ExecuteDefaultTaskOnDrive,
282 FileManagerBrowserTest,
283 ::testing::Values(
284 TestParameter(NOT_IN_GUEST_MODE, "executeDefaultTaskOnDrive")));
286 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
287 #define MAYBE_DefaultActionDialog DISABLED_DefaultActionDialog
288 #else
289 #define MAYBE_DefaultActionDialog DefaultActionDialog
290 #endif
291 WRAPPED_INSTANTIATE_TEST_CASE_P(
292 MAYBE_DefaultActionDialog,
293 FileManagerBrowserTest,
294 ::testing::Values(
295 TestParameter(NOT_IN_GUEST_MODE, "defaultActionDialogOnDownloads"),
296 TestParameter(IN_GUEST_MODE, "defaultActionDialogOnDownloads"),
297 TestParameter(NOT_IN_GUEST_MODE, "defaultActionDialogOnDrive")));
299 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
300 #define MAYBE_GenericTask DISABLED_GenericTask
301 #else
302 #define MAYBE_GenericTask GenericTask
303 #endif
304 WRAPPED_INSTANTIATE_TEST_CASE_P(
305 MAYBE_GenericTask,
306 FileManagerBrowserTest,
307 ::testing::Values(
308 TestParameter(NOT_IN_GUEST_MODE, "genericTaskIsNotExecuted"),
309 TestParameter(NOT_IN_GUEST_MODE, "genericAndNonGenericTasksAreMixed")));
311 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
312 #define MAYBE_FolderShortcuts DISABLED_FolderShortcuts
313 #else
314 #define MAYBE_FolderShortcuts FolderShortcuts
315 #endif
316 WRAPPED_INSTANTIATE_TEST_CASE_P(
317 MAYBE_FolderShortcuts,
318 FileManagerBrowserTest,
319 ::testing::Values(
320 TestParameter(NOT_IN_GUEST_MODE, "traverseFolderShortcuts"),
321 TestParameter(NOT_IN_GUEST_MODE, "addRemoveFolderShortcuts")));
323 // Fails on official build. http://crbug.com/429294
324 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
325 #define MAYBE_SortColumns DISABLED_SortColumns
326 #else
327 #define MAYBE_SortColumns SortColumns
328 #endif
329 WRAPPED_INSTANTIATE_TEST_CASE_P(
330 MAYBE_SortColumns,
331 FileManagerBrowserTest,
332 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "sortColumns"),
333 TestParameter(IN_GUEST_MODE, "sortColumns")));
335 INSTANTIATE_TEST_CASE_P(
336 TabIndex,
337 FileManagerBrowserTest,
338 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "searchBoxFocus")));
340 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
341 #define MAYBE_TabindexFocus DISABLED_TabindexFocus
342 #else
343 #define MAYBE_TabindexFocus TabindexFocus
344 #endif
345 WRAPPED_INSTANTIATE_TEST_CASE_P(
346 MAYBE_TabindexFocus,
347 FileManagerBrowserTest,
348 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "tabindexFocus")));
350 INSTANTIATE_TEST_CASE_P(
351 TabindexFocusDownloads,
352 FileManagerBrowserTest,
353 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE,
354 "tabindexFocusDownloads"),
355 TestParameter(IN_GUEST_MODE, "tabindexFocusDownloads")));
357 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
358 #define MAYBE_TabindexFocusDirectorySelected \
359 DISABLED_TabindexFocusDirectorySelected
360 #else
361 #define MAYBE_TabindexFocusDirectorySelected TabindexFocusDirectorySelected
362 #endif
363 WRAPPED_INSTANTIATE_TEST_CASE_P(
364 MAYBE_TabindexFocusDirectorySelected,
365 FileManagerBrowserTest,
366 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE,
367 "tabindexFocusDirectorySelected")));
369 // Fails on official cros trunk build. http://crbug.com/480491
370 #if defined(OFFICIAL_BUILD)
371 #define MAYBE_TabindexOpenDialog DISABLED_TabindexOpenDialog
372 #else
373 #define MAYBE_TabindexOpenDialog TabindexOpenDialog
374 #endif
375 WRAPPED_INSTANTIATE_TEST_CASE_P(
376 MAYBE_TabindexOpenDialog,
377 FileManagerBrowserTest,
378 ::testing::Values(
379 TestParameter(NOT_IN_GUEST_MODE, "tabindexOpenDialogDrive"),
380 TestParameter(NOT_IN_GUEST_MODE, "tabindexOpenDialogDownloads"),
381 TestParameter(IN_GUEST_MODE, "tabindexOpenDialogDownloads")));
383 // Fails on official build. http://crbug.com/482121.
384 #if defined(OFFICIAL_BUILD)
385 #define MAYBE_TabindexSaveFileDialog DISABLED_TabindexSaveFileDialog
386 #else
387 #define MAYBE_TabindexSaveFileDialog TabindexSaveFileDialog
388 #endif
389 WRAPPED_INSTANTIATE_TEST_CASE_P(
390 MAYBE_TabindexSaveFileDialog,
391 FileManagerBrowserTest,
392 ::testing::Values(
393 TestParameter(NOT_IN_GUEST_MODE, "tabindexSaveFileDialogDrive"),
394 TestParameter(NOT_IN_GUEST_MODE, "tabindexSaveFileDialogDownloads"),
395 TestParameter(IN_GUEST_MODE, "tabindexSaveFileDialogDownloads")));
397 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
398 #define MAYBE_OpenFileDialog DISABLED_OpenFileDialog
399 #else
400 #define MAYBE_OpenFileDialog OpenFileDialog
401 #endif
402 WRAPPED_INSTANTIATE_TEST_CASE_P(
403 MAYBE_OpenFileDialog,
404 FileManagerBrowserTest,
405 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE,
406 "openFileDialogOnDownloads"),
407 TestParameter(IN_GUEST_MODE,
408 "openFileDialogOnDownloads"),
409 TestParameter(NOT_IN_GUEST_MODE,
410 "openFileDialogOnDrive"),
411 TestParameter(IN_INCOGNITO,
412 "openFileDialogOnDownloads"),
413 TestParameter(IN_INCOGNITO,
414 "openFileDialogOnDrive"),
415 TestParameter(NOT_IN_GUEST_MODE,
416 "unloadFileDialog")));
418 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
419 #define MAYBE_CopyBetweenWindows DISABLED_CopyBetweenWindows
420 #else
421 // flaky: http://crbug.com/500966
422 #define MAYBE_CopyBetweenWindows DISABLED_CopyBetweenWindows
423 #endif
424 WRAPPED_INSTANTIATE_TEST_CASE_P(
425 MAYBE_CopyBetweenWindows,
426 FileManagerBrowserTest,
427 ::testing::Values(
428 TestParameter(NOT_IN_GUEST_MODE, "copyBetweenWindowsLocalToDrive"),
429 TestParameter(NOT_IN_GUEST_MODE, "copyBetweenWindowsLocalToUsb"),
430 TestParameter(NOT_IN_GUEST_MODE, "copyBetweenWindowsUsbToDrive"),
431 TestParameter(NOT_IN_GUEST_MODE, "copyBetweenWindowsDriveToLocal"),
432 TestParameter(NOT_IN_GUEST_MODE, "copyBetweenWindowsDriveToUsb"),
433 TestParameter(NOT_IN_GUEST_MODE, "copyBetweenWindowsUsbToLocal")));
435 #if defined(DISABLE_SLOW_FILESAPP_TESTS)
436 #define MAYBE_ShowGridView DISABLED_ShowGridView
437 #else
438 #define MAYBE_ShowGridView ShowGridView
439 #endif
440 WRAPPED_INSTANTIATE_TEST_CASE_P(
441 MAYBE_ShowGridView,
442 FileManagerBrowserTest,
443 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "showGridViewDownloads"),
444 TestParameter(IN_GUEST_MODE, "showGridViewDownloads"),
445 TestParameter(NOT_IN_GUEST_MODE, "showGridViewDrive")));
447 WRAPPED_INSTANTIATE_TEST_CASE_P(
448 Providers,
449 FileManagerBrowserTest,
450 ::testing::Values(
451 TestParameter(NOT_IN_GUEST_MODE, "requestMount"),
452 TestParameter(NOT_IN_GUEST_MODE, "requestMountMultipleMounts"),
453 TestParameter(NOT_IN_GUEST_MODE, "requestMountSourceDevice"),
454 TestParameter(NOT_IN_GUEST_MODE, "requestMountSourceFile")));
456 // Structure to describe an account info.
457 struct TestAccountInfo {
458 const char* const gaia_id;
459 const char* const email;
460 const char* const hash;
461 const char* const display_name;
464 enum {
465 DUMMY_ACCOUNT_INDEX = 0,
466 PRIMARY_ACCOUNT_INDEX = 1,
467 SECONDARY_ACCOUNT_INDEX_START = 2,
470 static const TestAccountInfo kTestAccounts[] = {
471 {"gaia-id-d", "__dummy__@invalid.domain", "hashdummy", "Dummy Account"},
472 {"gaia-id-a", "alice@invalid.domain", "hashalice", "Alice"},
473 {"gaia-id-b", "bob@invalid.domain", "hashbob", "Bob"},
474 {"gaia-id-c", "charlie@invalid.domain", "hashcharlie", "Charlie"},
477 // Test fixture class for testing multi-profile features.
478 class MultiProfileFileManagerBrowserTest : public FileManagerBrowserTestBase {
479 protected:
480 // Enables multi-profiles.
481 void SetUpCommandLine(base::CommandLine* command_line) override {
482 FileManagerBrowserTestBase::SetUpCommandLine(command_line);
483 // Logs in to a dummy profile (For making MultiProfileWindowManager happy;
484 // browser test creates a default window and the manager tries to assign a
485 // user for it, and we need a profile connected to a user.)
486 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser,
487 kTestAccounts[DUMMY_ACCOUNT_INDEX].email);
488 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile,
489 kTestAccounts[DUMMY_ACCOUNT_INDEX].hash);
492 // Logs in to the primary profile of this test.
493 void SetUpOnMainThread() override {
494 const TestAccountInfo& info = kTestAccounts[PRIMARY_ACCOUNT_INDEX];
496 AddUser(info, true);
497 FileManagerBrowserTestBase::SetUpOnMainThread();
500 // Loads all users to the current session and sets up necessary fields.
501 // This is used for preparing all accounts in PRE_ test setup, and for testing
502 // actual login behavior.
503 void AddAllUsers() {
504 for (size_t i = 0; i < arraysize(kTestAccounts); ++i)
505 AddUser(kTestAccounts[i], i >= SECONDARY_ACCOUNT_INDEX_START);
508 // Returns primary profile (if it is already created.)
509 Profile* profile() override {
510 Profile* const profile = chromeos::ProfileHelper::GetProfileByUserIdHash(
511 kTestAccounts[PRIMARY_ACCOUNT_INDEX].hash);
512 return profile ? profile : FileManagerBrowserTestBase::profile();
515 // Sets the test case name (used as a function name in test_cases.js to call.)
516 void set_test_case_name(const std::string& name) { test_case_name_ = name; }
518 // Adds a new user for testing to the current session.
519 void AddUser(const TestAccountInfo& info, bool log_in) {
520 user_manager::UserManager* const user_manager =
521 user_manager::UserManager::Get();
522 if (log_in)
523 user_manager->UserLoggedIn(info.email, info.hash, false);
524 user_manager->SaveUserDisplayName(info.email,
525 base::UTF8ToUTF16(info.display_name));
526 SigninManagerFactory::GetForProfile(
527 chromeos::ProfileHelper::GetProfileByUserIdHash(info.hash))
528 ->SetAuthenticatedAccountInfo(info.gaia_id, info.email);
531 private:
532 GuestMode GetGuestModeParam() const override { return NOT_IN_GUEST_MODE; }
533 const char* GetTestManifestName() const override {
534 return "file_manager_test_manifest.json";
536 const char* GetTestCaseNameParam() const override {
537 return test_case_name_.c_str();
540 std::string test_case_name_;
543 // Fails on official build. http://crbug.com/429294
544 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
545 #define MAYBE_PRE_BasicDownloads DISABLED_PRE_BasicDownloads
546 #define MAYBE_BasicDownloads DISABLED_BasicDownloads
547 #else
548 #define MAYBE_PRE_BasicDownloads PRE_BasicDownloads
549 #define MAYBE_BasicDownloads BasicDownloads
550 #endif
551 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest,
552 MAYBE_PRE_BasicDownloads) {
553 AddAllUsers();
556 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest,
557 MAYBE_BasicDownloads) {
558 AddAllUsers();
560 // Sanity check that normal operations work in multi-profile setting as well.
561 set_test_case_name("keyboardCopyDownloads");
562 StartTest();
565 // Fails on official build. http://crbug.com/429294
566 #if defined(DISABLE_SLOW_FILESAPP_TESTS) || defined(OFFICIAL_BUILD)
567 #define MAYBE_PRE_BasicDrive DISABLED_PRE_BasicDrive
568 #define MAYBE_BasicDrive DISABLED_BasicDrive
569 #else
570 #define MAYBE_PRE_BasicDrive PRE_BasicDrive
571 #define MAYBE_BasicDrive BasicDrive
572 #endif
573 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest,
574 MAYBE_PRE_BasicDrive) {
575 AddAllUsers();
578 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest, MAYBE_BasicDrive) {
579 AddAllUsers();
581 // Sanity check that normal operations work in multi-profile setting as well.
582 set_test_case_name("keyboardCopyDrive");
583 StartTest();
586 } // namespace file_manager