- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / file_manager / file_manager_browsertest.cc
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.
4
5 // Browser test for basic Chrome OS file manager functionality:
6 //  - The file list is updated when a file is added externally to the Downloads
7 //    folder.
8 //  - Selecting a file and copy-pasting it with the keyboard copies the file.
9 //  - Selecting a file and pressing delete deletes it.
10
11 #include <deque>
12 #include <string>
13
14 #include "base/bind.h"
15 #include "base/callback.h"
16 #include "base/file_util.h"
17 #include "base/files/file_path.h"
18 #include "base/json/json_reader.h"
19 #include "base/json/json_value_converter.h"
20 #include "base/json/json_writer.h"
21 #include "base/strings/string_piece.h"
22 #include "base/time/time.h"
23 #include "chrome/browser/chrome_notification_types.h"
24 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
25 #include "chrome/browser/chromeos/drive/file_system_interface.h"
26 #include "chrome/browser/chromeos/drive/test_util.h"
27 #include "chrome/browser/chromeos/file_manager/drive_test_util.h"
28 #include "chrome/browser/drive/fake_drive_service.h"
29 #include "chrome/browser/extensions/api/test/test_api.h"
30 #include "chrome/browser/extensions/component_loader.h"
31 #include "chrome/browser/extensions/extension_apitest.h"
32 #include "chrome/browser/extensions/extension_test_message_listener.h"
33 #include "chrome/browser/google_apis/gdata_wapi_parser.h"
34 #include "chrome/browser/google_apis/test_util.h"
35 #include "chrome/browser/profiles/profile.h"
36 #include "chrome/common/chrome_switches.h"
37 #include "chrome/common/extensions/extension.h"
38 #include "chromeos/chromeos_switches.h"
39 #include "content/public/browser/browser_context.h"
40 #include "content/public/browser/notification_service.h"
41 #include "content/public/test/test_utils.h"
42 #include "net/test/embedded_test_server/embedded_test_server.h"
43 #include "webkit/browser/fileapi/external_mount_points.h"
44
45 namespace file_manager {
46 namespace {
47
48 enum EntryType {
49   FILE,
50   DIRECTORY,
51 };
52
53 enum TargetVolume {
54   LOCAL_VOLUME,
55   DRIVE_VOLUME,
56 };
57
58 enum SharedOption {
59   NONE,
60   SHARED,
61 };
62
63 enum GuestMode {
64   NOT_IN_GUEST_MODE,
65   IN_GUEST_MODE,
66 };
67
68 // This global operator is used from Google Test to format error messages.
69 std::ostream& operator<<(std::ostream& os, const GuestMode& guest_mode) {
70   return os << (guest_mode == IN_GUEST_MODE ?
71                 "IN_GUEST_MODE" : "NOT_IN_GUEST_MODE");
72 }
73
74 // Maps the given string to EntryType. Returns true on success.
75 bool MapStringToEntryType(const base::StringPiece& value, EntryType* output) {
76   if (value == "file")
77     *output = FILE;
78   else if (value == "directory")
79     *output = DIRECTORY;
80   else
81     return false;
82   return true;
83 }
84
85 // Maps the given string to SharedOption. Returns true on success.
86 bool MapStringToSharedOption(const base::StringPiece& value,
87                              SharedOption* output) {
88   if (value == "shared")
89     *output = SHARED;
90   else if (value == "none")
91     *output = NONE;
92   else
93     return false;
94   return true;
95 }
96
97 // Maps the given string to TargetVolume. Returns true on success.
98 bool MapStringToTargetVolume(const base::StringPiece& value,
99                              TargetVolume* output) {
100   if (value == "drive")
101     *output = DRIVE_VOLUME;
102   else if (value == "local")
103     *output = LOCAL_VOLUME;
104   else
105     return false;
106   return true;
107 }
108
109 // Maps the given string to base::Time. Returns true on success.
110 bool MapStringToTime(const base::StringPiece& value, base::Time* time) {
111   return base::Time::FromString(value.as_string().c_str(), time);
112 }
113
114 // Test data of file or directory.
115 struct TestEntryInfo {
116   TestEntryInfo() : type(FILE), shared_option(NONE) {}
117
118   TestEntryInfo(EntryType type,
119                 const std::string& source_file_name,
120                 const std::string& target_path,
121                 const std::string& mime_type,
122                 SharedOption shared_option,
123                 const base::Time& last_modified_time) :
124       type(type),
125       source_file_name(source_file_name),
126       target_path(target_path),
127       mime_type(mime_type),
128       shared_option(shared_option),
129       last_modified_time(last_modified_time) {
130   }
131
132   EntryType type;
133   std::string source_file_name;  // Source file name to be used as a prototype.
134   std::string target_path;  // Target file or directory path.
135   std::string mime_type;
136   SharedOption shared_option;
137   base::Time last_modified_time;
138
139   // Registers the member information to the given converter.
140   static void RegisterJSONConverter(
141       base::JSONValueConverter<TestEntryInfo>* converter);
142 };
143
144 // static
145 void TestEntryInfo::RegisterJSONConverter(
146     base::JSONValueConverter<TestEntryInfo>* converter) {
147   converter->RegisterCustomField("type",
148                                  &TestEntryInfo::type,
149                                  &MapStringToEntryType);
150   converter->RegisterStringField("sourceFileName",
151                                  &TestEntryInfo::source_file_name);
152   converter->RegisterStringField("targetPath", &TestEntryInfo::target_path);
153   converter->RegisterStringField("mimeType", &TestEntryInfo::mime_type);
154   converter->RegisterCustomField("sharedOption",
155                                  &TestEntryInfo::shared_option,
156                                  &MapStringToSharedOption);
157   converter->RegisterCustomField("lastModifiedTime",
158                                  &TestEntryInfo::last_modified_time,
159                                  &MapStringToTime);
160 }
161
162 // Message from JavaScript to add entries.
163 struct AddEntriesMessage {
164   // Target volume to be added the |entries|.
165   TargetVolume volume;
166
167   // Entries to be added.
168   ScopedVector<TestEntryInfo> entries;
169
170   // Registers the member information to the given converter.
171   static void RegisterJSONConverter(
172       base::JSONValueConverter<AddEntriesMessage>* converter);
173 };
174
175
176 // static
177 void AddEntriesMessage::RegisterJSONConverter(
178     base::JSONValueConverter<AddEntriesMessage>* converter) {
179   converter->RegisterCustomField("volume",
180                                  &AddEntriesMessage::volume,
181                                  &MapStringToTargetVolume);
182   converter->RegisterRepeatedMessage<TestEntryInfo>(
183       "entries",
184       &AddEntriesMessage::entries);
185 }
186
187 // The local volume class for test.
188 // This class provides the operations for a test volume that simulates local
189 // drive.
190 class LocalTestVolume {
191  public:
192   // Adds this volume to the file system as a local volume. Returns true on
193   // success.
194   bool Mount(Profile* profile) {
195     const std::string kDownloads = "Downloads";
196
197     if (local_path_.empty()) {
198       if (!tmp_dir_.CreateUniqueTempDir())
199         return false;
200       local_path_ = tmp_dir_.path().Append(kDownloads);
201     }
202     fileapi::ExternalMountPoints* const mount_points =
203         content::BrowserContext::GetMountPoints(profile);
204     mount_points->RevokeFileSystem(kDownloads);
205
206     return mount_points->RegisterFileSystem(
207         kDownloads, fileapi::kFileSystemTypeNativeLocal, local_path_) &&
208         file_util::CreateDirectory(local_path_);
209   }
210
211   void CreateEntry(const TestEntryInfo& entry) {
212     const base::FilePath target_path =
213         local_path_.AppendASCII(entry.target_path);
214
215     entries_.insert(std::make_pair(target_path, entry));
216     switch (entry.type) {
217       case FILE: {
218         const base::FilePath source_path =
219             google_apis::test_util::GetTestFilePath("chromeos/file_manager").
220             AppendASCII(entry.source_file_name);
221         ASSERT_TRUE(base::CopyFile(source_path, target_path))
222             << "Copy from " << source_path.value()
223             << " to " << target_path.value() << " failed.";
224         break;
225       }
226       case DIRECTORY:
227         ASSERT_TRUE(file_util::CreateDirectory(target_path)) <<
228             "Failed to create a directory: " << target_path.value();
229         break;
230     }
231     ASSERT_TRUE(UpdateModifiedTime(entry));
232   }
233
234  private:
235   // Updates ModifiedTime of the entry and its parents by referring
236   // TestEntryInfo. Returns true on success.
237   bool UpdateModifiedTime(const TestEntryInfo& entry) {
238     const base::FilePath path = local_path_.AppendASCII(entry.target_path);
239     if (!file_util::SetLastModifiedTime(path, entry.last_modified_time))
240       return false;
241
242     // Update the modified time of parent directories because it may be also
243     // affected by the update of child items.
244     if (path.DirName() != local_path_) {
245       const std::map<base::FilePath, const TestEntryInfo>::iterator it =
246           entries_.find(path.DirName());
247       if (it == entries_.end())
248         return false;
249       return UpdateModifiedTime(it->second);
250     }
251     return true;
252   }
253
254   base::FilePath local_path_;
255   base::ScopedTempDir tmp_dir_;
256   std::map<base::FilePath, const TestEntryInfo> entries_;
257 };
258
259 // The drive volume class for test.
260 // This class provides the operations for a test volume that simulates Google
261 // drive.
262 class DriveTestVolume {
263  public:
264   DriveTestVolume() : fake_drive_service_(NULL),
265                       integration_service_(NULL) {
266   }
267
268   // Sends request to add this volume to the file system as Google drive.
269   // This method must be calld at SetUp method of FileManagerBrowserTestBase.
270   // Returns true on success.
271   bool SetUp() {
272     if (!test_cache_root_.CreateUniqueTempDir())
273       return false;
274     drive::DriveIntegrationServiceFactory::SetFactoryForTest(
275         base::Bind(&DriveTestVolume::CreateDriveIntegrationService,
276                    base::Unretained(this)));
277     return true;
278   }
279
280   void CreateEntry(const TestEntryInfo& entry) {
281     const base::FilePath path =
282         base::FilePath::FromUTF8Unsafe(entry.target_path);
283     const std::string target_name = path.BaseName().AsUTF8Unsafe();
284
285     // Obtain the parent entry.
286     drive::FileError error = drive::FILE_ERROR_OK;
287     scoped_ptr<drive::ResourceEntry> parent_entry(new drive::ResourceEntry);
288     integration_service_->file_system()->GetResourceEntryByPath(
289         drive::util::GetDriveMyDriveRootPath().Append(path).DirName(),
290         google_apis::test_util::CreateCopyResultCallback(
291             &error, &parent_entry));
292     drive::test_util::RunBlockingPoolTask();
293     ASSERT_EQ(drive::FILE_ERROR_OK, error);
294     ASSERT_TRUE(parent_entry);
295
296     switch (entry.type) {
297       case FILE:
298         CreateFile(entry.source_file_name,
299                    parent_entry->resource_id(),
300                    target_name,
301                    entry.mime_type,
302                    entry.shared_option == SHARED,
303                    entry.last_modified_time);
304         break;
305       case DIRECTORY:
306         CreateDirectory(parent_entry->resource_id(),
307                         target_name,
308                         entry.last_modified_time);
309         break;
310     }
311   }
312
313   // Creates an empty directory with the given |name| and |modification_time|.
314   void CreateDirectory(const std::string& parent_id,
315                        const std::string& target_name,
316                        const base::Time& modification_time) {
317     google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
318     scoped_ptr<google_apis::ResourceEntry> resource_entry;
319     fake_drive_service_->AddNewDirectory(
320         parent_id,
321         target_name,
322         google_apis::test_util::CreateCopyResultCallback(&error,
323                                                          &resource_entry));
324     base::MessageLoop::current()->RunUntilIdle();
325     ASSERT_EQ(google_apis::HTTP_CREATED, error);
326     ASSERT_TRUE(resource_entry);
327
328     fake_drive_service_->SetLastModifiedTime(
329         resource_entry->resource_id(),
330         modification_time,
331         google_apis::test_util::CreateCopyResultCallback(&error,
332                                                          &resource_entry));
333     base::MessageLoop::current()->RunUntilIdle();
334     ASSERT_TRUE(error == google_apis::HTTP_SUCCESS);
335     ASSERT_TRUE(resource_entry);
336     CheckForUpdates();
337   }
338
339   // Creates a test file with the given spec.
340   // Serves |test_file_name| file. Pass an empty string for an empty file.
341   void CreateFile(const std::string& source_file_name,
342                   const std::string& parent_id,
343                   const std::string& target_name,
344                   const std::string& mime_type,
345                   bool shared_with_me,
346                   const base::Time& modification_time) {
347     google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
348
349     std::string content_data;
350     if (!source_file_name.empty()) {
351       base::FilePath source_file_path =
352           google_apis::test_util::GetTestFilePath("chromeos/file_manager").
353               AppendASCII(source_file_name);
354       ASSERT_TRUE(base::ReadFileToString(source_file_path, &content_data));
355     }
356
357     scoped_ptr<google_apis::ResourceEntry> resource_entry;
358     fake_drive_service_->AddNewFile(
359         mime_type,
360         content_data,
361         parent_id,
362         target_name,
363         shared_with_me,
364         google_apis::test_util::CreateCopyResultCallback(&error,
365                                                          &resource_entry));
366     base::MessageLoop::current()->RunUntilIdle();
367     ASSERT_EQ(google_apis::HTTP_CREATED, error);
368     ASSERT_TRUE(resource_entry);
369
370     fake_drive_service_->SetLastModifiedTime(
371         resource_entry->resource_id(),
372         modification_time,
373         google_apis::test_util::CreateCopyResultCallback(&error,
374                                                          &resource_entry));
375     base::MessageLoop::current()->RunUntilIdle();
376     ASSERT_EQ(google_apis::HTTP_SUCCESS, error);
377     ASSERT_TRUE(resource_entry);
378
379     CheckForUpdates();
380   }
381
382   // Notifies FileSystem that the contents in FakeDriveService are
383   // changed, hence the new contents should be fetched.
384   void CheckForUpdates() {
385     if (integration_service_ && integration_service_->file_system()) {
386       integration_service_->file_system()->CheckForUpdates();
387     }
388   }
389
390   // Sets the url base for the test server to be used to generate share urls
391   // on the files and directories.
392   void ConfigureShareUrlBase(const GURL& share_url_base) {
393     fake_drive_service_->set_share_url_base(share_url_base);
394   }
395
396   drive::DriveIntegrationService* CreateDriveIntegrationService(
397       Profile* profile) {
398     fake_drive_service_ = new drive::FakeDriveService;
399     fake_drive_service_->LoadResourceListForWapi(
400         "gdata/empty_feed.json");
401     fake_drive_service_->LoadAccountMetadataForWapi(
402         "gdata/account_metadata.json");
403     fake_drive_service_->LoadAppListForDriveApi("drive/applist.json");
404     integration_service_ = new drive::DriveIntegrationService(
405         profile, NULL, fake_drive_service_, test_cache_root_.path(), NULL);
406     return integration_service_;
407   }
408
409  private:
410   base::ScopedTempDir test_cache_root_;
411   drive::FakeDriveService* fake_drive_service_;
412   drive::DriveIntegrationService* integration_service_;
413 };
414
415 // Listener to obtain the test relative messages synchronously.
416 class FileManagerTestListener : public content::NotificationObserver {
417  public:
418   struct Message {
419     int type;
420     std::string message;
421     extensions::TestSendMessageFunction* function;
422   };
423
424   FileManagerTestListener() {
425     registrar_.Add(this,
426                    chrome::NOTIFICATION_EXTENSION_TEST_PASSED,
427                    content::NotificationService::AllSources());
428     registrar_.Add(this,
429                    chrome::NOTIFICATION_EXTENSION_TEST_FAILED,
430                    content::NotificationService::AllSources());
431     registrar_.Add(this,
432                    chrome::NOTIFICATION_EXTENSION_TEST_MESSAGE,
433                    content::NotificationService::AllSources());
434   }
435
436   Message GetNextMessage() {
437     if (messages_.empty())
438       content::RunMessageLoop();
439     const Message entry = messages_.front();
440     messages_.pop_front();
441     return entry;
442   }
443
444   virtual void Observe(int type,
445                        const content::NotificationSource& source,
446                        const content::NotificationDetails& details) OVERRIDE {
447     Message entry;
448     entry.type = type;
449     entry.message = type != chrome::NOTIFICATION_EXTENSION_TEST_PASSED ?
450         *content::Details<std::string>(details).ptr() :
451         std::string();
452     entry.function = type == chrome::NOTIFICATION_EXTENSION_TEST_MESSAGE ?
453         content::Source<extensions::TestSendMessageFunction>(source).ptr() :
454         NULL;
455     messages_.push_back(entry);
456     base::MessageLoopForUI::current()->Quit();
457   }
458
459  private:
460   std::deque<Message> messages_;
461   content::NotificationRegistrar registrar_;
462 };
463
464 // Parameter of FileManagerBrowserTest.
465 // The second value is the case name of JavaScript.
466 typedef std::tr1::tuple<GuestMode, const char*> TestParameter;
467
468 // The base test class.
469 class FileManagerBrowserTest :
470       public ExtensionApiTest,
471       public ::testing::WithParamInterface<TestParameter> {
472  protected:
473   FileManagerBrowserTest() :
474       local_volume_(new LocalTestVolume),
475       drive_volume_(std::tr1::get<0>(GetParam()) != IN_GUEST_MODE ?
476                     new DriveTestVolume() : NULL) {}
477
478   virtual void SetUp() OVERRIDE {
479     // TODO(danakj): The GPU Video Decoder needs real GL bindings.
480     // crbug.com/269087
481     UseRealGLBindings();
482
483     ExtensionApiTest::SetUp();
484   }
485
486   virtual void SetUpInProcessBrowserTestFixture() OVERRIDE;
487
488   virtual void SetUpOnMainThread() OVERRIDE;
489
490   // Adds an incognito and guest-mode flags for tests in the guest mode.
491   virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
492
493   // Loads our testing extension and sends it a string identifying the current
494   // test.
495   void StartTest();
496
497   const scoped_ptr<LocalTestVolume> local_volume_;
498   const scoped_ptr<DriveTestVolume> drive_volume_;
499 };
500
501 void FileManagerBrowserTest::SetUpInProcessBrowserTestFixture() {
502   ExtensionApiTest::SetUpInProcessBrowserTestFixture();
503   extensions::ComponentLoader::EnableBackgroundExtensionsForTesting();
504   if (drive_volume_)
505     ASSERT_TRUE(drive_volume_->SetUp());
506 }
507
508 void FileManagerBrowserTest::SetUpOnMainThread() {
509   ExtensionApiTest::SetUpOnMainThread();
510   ASSERT_TRUE(local_volume_->Mount(browser()->profile()));
511
512   if (drive_volume_) {
513     // Install the web server to serve the mocked share dialog.
514     ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
515     const GURL share_url_base(embedded_test_server()->GetURL(
516         "/chromeos/file_manager/share_dialog_mock/index.html"));
517     drive_volume_->ConfigureShareUrlBase(share_url_base);
518     test_util::WaitUntilDriveMountPointIsAdded(browser()->profile());
519   }
520 }
521
522 void FileManagerBrowserTest::SetUpCommandLine(CommandLine* command_line) {
523   if (std::tr1::get<0>(GetParam()) == IN_GUEST_MODE) {
524     command_line->AppendSwitch(chromeos::switches::kGuestSession);
525     command_line->AppendSwitchNative(chromeos::switches::kLoginUser, "");
526     command_line->AppendSwitch(switches::kIncognito);
527   }
528   // TODO(yoshiki): Remove the flag when the feature is launched.
529   if (std::tr1::get<1>(GetParam()) == std::string("suggestAppDialog")) {
530     command_line->AppendSwitch(
531         chromeos::switches::kFileManagerEnableWebstoreIntegration);
532   }
533   ExtensionApiTest::SetUpCommandLine(command_line);
534 }
535
536 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTest, Test) {
537   // Launch the extension.
538   base::FilePath path = test_data_dir_.AppendASCII("file_manager_browsertest");
539   const extensions::Extension* extension = LoadExtensionAsComponent(path);
540   ASSERT_TRUE(extension);
541
542   // Handle the messages from JavaScript.
543   // The while loop is break when the test is passed or failed.
544   FileManagerTestListener listener;
545   base::JSONValueConverter<AddEntriesMessage> add_entries_message_converter;
546   while (true) {
547     FileManagerTestListener::Message entry = listener.GetNextMessage();
548     if (entry.type == chrome::NOTIFICATION_EXTENSION_TEST_PASSED) {
549       // Test succeed.
550       break;
551     } else if (entry.type == chrome::NOTIFICATION_EXTENSION_TEST_FAILED) {
552       // Test failed.
553       ADD_FAILURE() << entry.message;
554       break;
555     }
556
557     // Parse the message value as JSON.
558     const scoped_ptr<const base::Value> value(
559         base::JSONReader::Read(entry.message));
560
561     // If the message is not the expected format, just ignore it.
562     const base::DictionaryValue* message_dictionary = NULL;
563     std::string name;
564     if (!value || !value->GetAsDictionary(&message_dictionary) ||
565         !message_dictionary->GetString("name", &name))
566       continue;
567
568     if (name == "getTestName") {
569       // Pass the test case name.
570       entry.function->Reply(std::tr1::get<1>(GetParam()));
571     } else if (name == "isInGuestMode") {
572       // Obtain whether the test is in guest mode or not.
573       entry.function->Reply(std::tr1::get<0>(GetParam()) ? "true" : "false");
574     } else if (name == "getCwsWidgetContainerMockUrl") {
575       // Obtain whether the test is in guest mode or not.
576       const GURL url = embedded_test_server()->GetURL(
577             "/chromeos/file_manager/cws_container_mock/index.html");
578       std::string origin = url.GetOrigin().spec();
579
580       // Removes trailing a slash.
581       if (*origin.rbegin() == '/')
582         origin.resize(origin.length() - 1);
583
584       const scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue());
585       res->SetString("url", url.spec());
586       res->SetString("origin", origin);
587       std::string jsonString;
588       base::JSONWriter::Write(res.get(), &jsonString);
589       entry.function->Reply(jsonString);
590     } else if (name == "addEntries") {
591       // Add entries to the specified volume.
592       AddEntriesMessage message;
593       if (!add_entries_message_converter.Convert(*value.get(), &message)) {
594         entry.function->Reply("onError");
595         continue;
596       }
597       for (size_t i = 0; i < message.entries.size(); ++i) {
598         switch (message.volume) {
599           case LOCAL_VOLUME:
600             local_volume_->CreateEntry(*message.entries[i]);
601             break;
602           case DRIVE_VOLUME:
603             if (drive_volume_)
604               drive_volume_->CreateEntry(*message.entries[i]);
605             break;
606           default:
607             NOTREACHED();
608             break;
609         }
610       }
611       entry.function->Reply("onEntryAdded");
612     }
613   }
614 }
615
616 INSTANTIATE_TEST_CASE_P(
617     FileDisplay,
618     FileManagerBrowserTest,
619     ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "fileDisplayDownloads"),
620                       TestParameter(IN_GUEST_MODE, "fileDisplayDownloads"),
621                       TestParameter(NOT_IN_GUEST_MODE, "fileDisplayDrive")));
622
623 INSTANTIATE_TEST_CASE_P(
624     OpenSpecialTypes,
625     FileManagerBrowserTest,
626     ::testing::Values(TestParameter(IN_GUEST_MODE, "videoOpenDownloads"),
627                       TestParameter(NOT_IN_GUEST_MODE, "videoOpenDownloads"),
628                       TestParameter(NOT_IN_GUEST_MODE, "videoOpenDrive"),
629                       TestParameter(IN_GUEST_MODE, "audioOpenDownloads"),
630                       TestParameter(NOT_IN_GUEST_MODE, "audioOpenDownloads"),
631                       TestParameter(NOT_IN_GUEST_MODE, "audioOpenDrive"),
632                       TestParameter(IN_GUEST_MODE, "galleryOpenDownloads"),
633                       TestParameter(NOT_IN_GUEST_MODE,
634                                     "galleryOpenDownloads"),
635                       TestParameter(NOT_IN_GUEST_MODE, "galleryOpenDrive")));
636
637 INSTANTIATE_TEST_CASE_P(
638     KeyboardOperations,
639     FileManagerBrowserTest,
640     ::testing::Values(TestParameter(IN_GUEST_MODE, "keyboardDeleteDownloads"),
641                       TestParameter(NOT_IN_GUEST_MODE,
642                                     "keyboardDeleteDownloads"),
643                       TestParameter(NOT_IN_GUEST_MODE, "keyboardDeleteDrive"),
644                       TestParameter(IN_GUEST_MODE, "keyboardCopyDownloads"),
645                       TestParameter(NOT_IN_GUEST_MODE, "keyboardCopyDownloads"),
646                       TestParameter(NOT_IN_GUEST_MODE, "keyboardCopyDrive")));
647
648 INSTANTIATE_TEST_CASE_P(
649     DriveSpecific,
650     FileManagerBrowserTest,
651     ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "openSidebarRecent"),
652                       TestParameter(NOT_IN_GUEST_MODE, "openSidebarOffline"),
653                       TestParameter(NOT_IN_GUEST_MODE,
654                                     "openSidebarSharedWithMe"),
655                       TestParameter(NOT_IN_GUEST_MODE, "autocomplete")));
656
657 INSTANTIATE_TEST_CASE_P(
658     Transfer,
659     FileManagerBrowserTest,
660     ::testing::Values(TestParameter(NOT_IN_GUEST_MODE,
661                                     "transferFromDriveToDownloads"),
662                       TestParameter(NOT_IN_GUEST_MODE,
663                                     "transferFromDownloadsToDrive"),
664                       TestParameter(NOT_IN_GUEST_MODE,
665                                     "transferFromSharedToDownloads"),
666                       TestParameter(NOT_IN_GUEST_MODE,
667                                     "transferFromSharedToDrive"),
668                       TestParameter(NOT_IN_GUEST_MODE,
669                                     "transferFromRecentToDownloads"),
670                       TestParameter(NOT_IN_GUEST_MODE,
671                                     "transferFromRecentToDrive"),
672                       TestParameter(NOT_IN_GUEST_MODE,
673                                     "transferFromOfflineToDownloads"),
674                       TestParameter(NOT_IN_GUEST_MODE,
675                                     "transferFromOfflineToDrive")));
676
677 INSTANTIATE_TEST_CASE_P(
678      HideSearchBox,
679      FileManagerBrowserTest,
680      ::testing::Values(TestParameter(IN_GUEST_MODE, "hideSearchBox"),
681                        TestParameter(NOT_IN_GUEST_MODE, "hideSearchBox")));
682
683 INSTANTIATE_TEST_CASE_P(
684     RestorePrefs,
685     FileManagerBrowserTest,
686     ::testing::Values(TestParameter(IN_GUEST_MODE, "restoreSortColumn"),
687                       TestParameter(NOT_IN_GUEST_MODE, "restoreSortColumn"),
688                       TestParameter(IN_GUEST_MODE, "restoreCurrentView"),
689                       TestParameter(NOT_IN_GUEST_MODE, "restoreCurrentView")));
690
691 INSTANTIATE_TEST_CASE_P(
692     ShareDialog,
693     FileManagerBrowserTest,
694     ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "shareFile"),
695                       TestParameter(NOT_IN_GUEST_MODE, "shareDirectory")));
696
697 INSTANTIATE_TEST_CASE_P(
698     restoreGeometry,
699     FileManagerBrowserTest,
700     ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "restoreGeometry"),
701                       TestParameter(IN_GUEST_MODE, "restoreGeometry")));
702
703 INSTANTIATE_TEST_CASE_P(
704     Traverse,
705     FileManagerBrowserTest,
706     ::testing::Values(TestParameter(IN_GUEST_MODE, "traverseDownloads"),
707                       TestParameter(NOT_IN_GUEST_MODE, "traverseDownloads"),
708                       TestParameter(NOT_IN_GUEST_MODE, "traverseDrive")));
709
710 INSTANTIATE_TEST_CASE_P(
711     SuggestAppDialog,
712     FileManagerBrowserTest,
713     ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "suggestAppDialog")));
714
715 INSTANTIATE_TEST_CASE_P(
716     NavigationList,
717     FileManagerBrowserTest,
718     ::testing::Values(TestParameter(NOT_IN_GUEST_MODE,
719                                     "traverseNavigationList")));
720
721 INSTANTIATE_TEST_CASE_P(
722     TabIndex,
723     FileManagerBrowserTest,
724     ::testing::Values(TestParameter(NOT_IN_GUEST_MODE,
725                                     "searchBoxFocus")));
726
727 }  // namespace
728 }  // namespace file_manager