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/profiles/profile.h"
34#include "chrome/common/chrome_switches.h"
35#include "chromeos/chromeos_switches.h"
36#include "content/public/browser/browser_context.h"
37#include "content/public/browser/notification_service.h"
38#include "content/public/test/test_utils.h"
39#include "extensions/common/extension.h"
40#include "google_apis/drive/gdata_wapi_parser.h"
41#include "google_apis/drive/test_util.h"
42#include "net/test/embedded_test_server/embedded_test_server.h"
43#include "webkit/browser/fileapi/external_mount_points.h"
44
45namespace file_manager {
46namespace {
47
48enum EntryType {
49  FILE,
50  DIRECTORY,
51};
52
53enum TargetVolume {
54  LOCAL_VOLUME,
55  DRIVE_VOLUME,
56};
57
58enum SharedOption {
59  NONE,
60  SHARED,
61};
62
63enum 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.
69std::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.
75bool 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.
86bool 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.
98bool 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.
110bool 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.
115struct 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
145void 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.
163struct 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
177void 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.
190class 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,
208        fileapi::kFileSystemTypeNativeLocal,
209        fileapi::FileSystemMountOption(),
210        local_path_) &&
211        base::CreateDirectory(local_path_);
212  }
213
214  void CreateEntry(const TestEntryInfo& entry) {
215    const base::FilePath target_path =
216        local_path_.AppendASCII(entry.target_path);
217
218    entries_.insert(std::make_pair(target_path, entry));
219    switch (entry.type) {
220      case FILE: {
221        const base::FilePath source_path =
222            google_apis::test_util::GetTestFilePath("chromeos/file_manager").
223            AppendASCII(entry.source_file_name);
224        ASSERT_TRUE(base::CopyFile(source_path, target_path))
225            << "Copy from " << source_path.value()
226            << " to " << target_path.value() << " failed.";
227        break;
228      }
229      case DIRECTORY:
230        ASSERT_TRUE(base::CreateDirectory(target_path)) <<
231            "Failed to create a directory: " << target_path.value();
232        break;
233    }
234    ASSERT_TRUE(UpdateModifiedTime(entry));
235  }
236
237 private:
238  // Updates ModifiedTime of the entry and its parents by referring
239  // TestEntryInfo. Returns true on success.
240  bool UpdateModifiedTime(const TestEntryInfo& entry) {
241    const base::FilePath path = local_path_.AppendASCII(entry.target_path);
242    if (!base::TouchFile(path, entry.last_modified_time,
243                         entry.last_modified_time))
244      return false;
245
246    // Update the modified time of parent directories because it may be also
247    // affected by the update of child items.
248    if (path.DirName() != local_path_) {
249      const std::map<base::FilePath, const TestEntryInfo>::iterator it =
250          entries_.find(path.DirName());
251      if (it == entries_.end())
252        return false;
253      return UpdateModifiedTime(it->second);
254    }
255    return true;
256  }
257
258  base::FilePath local_path_;
259  base::ScopedTempDir tmp_dir_;
260  std::map<base::FilePath, const TestEntryInfo> entries_;
261};
262
263// The drive volume class for test.
264// This class provides the operations for a test volume that simulates Google
265// drive.
266class DriveTestVolume {
267 public:
268  DriveTestVolume() : fake_drive_service_(NULL),
269                      integration_service_(NULL) {
270  }
271
272  // Sends request to add this volume to the file system as Google drive.
273  // This method must be calld at SetUp method of FileManagerBrowserTestBase.
274  // Returns true on success.
275  bool SetUp() {
276    if (!test_cache_root_.CreateUniqueTempDir())
277      return false;
278    drive::DriveIntegrationServiceFactory::SetFactoryForTest(
279        base::Bind(&DriveTestVolume::CreateDriveIntegrationService,
280                   base::Unretained(this)));
281    return true;
282  }
283
284  void CreateEntry(const TestEntryInfo& entry) {
285    const base::FilePath path =
286        base::FilePath::FromUTF8Unsafe(entry.target_path);
287    const std::string target_name = path.BaseName().AsUTF8Unsafe();
288
289    // Obtain the parent entry.
290    drive::FileError error = drive::FILE_ERROR_OK;
291    scoped_ptr<drive::ResourceEntry> parent_entry(new drive::ResourceEntry);
292    integration_service_->file_system()->GetResourceEntry(
293        drive::util::GetDriveMyDriveRootPath().Append(path).DirName(),
294        google_apis::test_util::CreateCopyResultCallback(
295            &error, &parent_entry));
296    drive::test_util::RunBlockingPoolTask();
297    ASSERT_EQ(drive::FILE_ERROR_OK, error);
298    ASSERT_TRUE(parent_entry);
299
300    switch (entry.type) {
301      case FILE:
302        CreateFile(entry.source_file_name,
303                   parent_entry->resource_id(),
304                   target_name,
305                   entry.mime_type,
306                   entry.shared_option == SHARED,
307                   entry.last_modified_time);
308        break;
309      case DIRECTORY:
310        CreateDirectory(parent_entry->resource_id(),
311                        target_name,
312                        entry.last_modified_time);
313        break;
314    }
315  }
316
317  // Creates an empty directory with the given |name| and |modification_time|.
318  void CreateDirectory(const std::string& parent_id,
319                       const std::string& target_name,
320                       const base::Time& modification_time) {
321    google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
322    scoped_ptr<google_apis::ResourceEntry> resource_entry;
323    fake_drive_service_->AddNewDirectory(
324        parent_id,
325        target_name,
326        google_apis::test_util::CreateCopyResultCallback(&error,
327                                                         &resource_entry));
328    base::MessageLoop::current()->RunUntilIdle();
329    ASSERT_EQ(google_apis::HTTP_CREATED, error);
330    ASSERT_TRUE(resource_entry);
331
332    fake_drive_service_->SetLastModifiedTime(
333        resource_entry->resource_id(),
334        modification_time,
335        google_apis::test_util::CreateCopyResultCallback(&error,
336                                                         &resource_entry));
337    base::MessageLoop::current()->RunUntilIdle();
338    ASSERT_TRUE(error == google_apis::HTTP_SUCCESS);
339    ASSERT_TRUE(resource_entry);
340    CheckForUpdates();
341  }
342
343  // Creates a test file with the given spec.
344  // Serves |test_file_name| file. Pass an empty string for an empty file.
345  void CreateFile(const std::string& source_file_name,
346                  const std::string& parent_id,
347                  const std::string& target_name,
348                  const std::string& mime_type,
349                  bool shared_with_me,
350                  const base::Time& modification_time) {
351    google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
352
353    std::string content_data;
354    if (!source_file_name.empty()) {
355      base::FilePath source_file_path =
356          google_apis::test_util::GetTestFilePath("chromeos/file_manager").
357              AppendASCII(source_file_name);
358      ASSERT_TRUE(base::ReadFileToString(source_file_path, &content_data));
359    }
360
361    scoped_ptr<google_apis::ResourceEntry> resource_entry;
362    fake_drive_service_->AddNewFile(
363        mime_type,
364        content_data,
365        parent_id,
366        target_name,
367        shared_with_me,
368        google_apis::test_util::CreateCopyResultCallback(&error,
369                                                         &resource_entry));
370    base::MessageLoop::current()->RunUntilIdle();
371    ASSERT_EQ(google_apis::HTTP_CREATED, error);
372    ASSERT_TRUE(resource_entry);
373
374    fake_drive_service_->SetLastModifiedTime(
375        resource_entry->resource_id(),
376        modification_time,
377        google_apis::test_util::CreateCopyResultCallback(&error,
378                                                         &resource_entry));
379    base::MessageLoop::current()->RunUntilIdle();
380    ASSERT_EQ(google_apis::HTTP_SUCCESS, error);
381    ASSERT_TRUE(resource_entry);
382
383    CheckForUpdates();
384  }
385
386  // Notifies FileSystem that the contents in FakeDriveService are
387  // changed, hence the new contents should be fetched.
388  void CheckForUpdates() {
389    if (integration_service_ && integration_service_->file_system()) {
390      integration_service_->file_system()->CheckForUpdates();
391    }
392  }
393
394  // Sets the url base for the test server to be used to generate share urls
395  // on the files and directories.
396  void ConfigureShareUrlBase(const GURL& share_url_base) {
397    fake_drive_service_->set_share_url_base(share_url_base);
398  }
399
400  drive::DriveIntegrationService* CreateDriveIntegrationService(
401      Profile* profile) {
402    fake_drive_service_ = new drive::FakeDriveService;
403    fake_drive_service_->LoadResourceListForWapi(
404        "gdata/empty_feed.json");
405    fake_drive_service_->LoadAccountMetadataForWapi(
406        "gdata/account_metadata.json");
407    fake_drive_service_->LoadAppListForDriveApi("drive/applist.json");
408    integration_service_ = new drive::DriveIntegrationService(
409        profile, NULL, fake_drive_service_, test_cache_root_.path(), NULL);
410    return integration_service_;
411  }
412
413 private:
414  base::ScopedTempDir test_cache_root_;
415  drive::FakeDriveService* fake_drive_service_;
416  drive::DriveIntegrationService* integration_service_;
417};
418
419// Listener to obtain the test relative messages synchronously.
420class FileManagerTestListener : public content::NotificationObserver {
421 public:
422  struct Message {
423    int type;
424    std::string message;
425    scoped_refptr<extensions::TestSendMessageFunction> function;
426  };
427
428  FileManagerTestListener() {
429    registrar_.Add(this,
430                   chrome::NOTIFICATION_EXTENSION_TEST_PASSED,
431                   content::NotificationService::AllSources());
432    registrar_.Add(this,
433                   chrome::NOTIFICATION_EXTENSION_TEST_FAILED,
434                   content::NotificationService::AllSources());
435    registrar_.Add(this,
436                   chrome::NOTIFICATION_EXTENSION_TEST_MESSAGE,
437                   content::NotificationService::AllSources());
438  }
439
440  Message GetNextMessage() {
441    if (messages_.empty())
442      content::RunMessageLoop();
443    const Message entry = messages_.front();
444    messages_.pop_front();
445    return entry;
446  }
447
448  virtual void Observe(int type,
449                       const content::NotificationSource& source,
450                       const content::NotificationDetails& details) OVERRIDE {
451    Message entry;
452    entry.type = type;
453    entry.message = type != chrome::NOTIFICATION_EXTENSION_TEST_PASSED ?
454        *content::Details<std::string>(details).ptr() :
455        std::string();
456    entry.function = type == chrome::NOTIFICATION_EXTENSION_TEST_MESSAGE ?
457        content::Source<extensions::TestSendMessageFunction>(source).ptr() :
458        NULL;
459    messages_.push_back(entry);
460    base::MessageLoopForUI::current()->Quit();
461  }
462
463 private:
464  std::deque<Message> messages_;
465  content::NotificationRegistrar registrar_;
466};
467
468// Parameter of FileManagerBrowserTest.
469// The second value is the case name of JavaScript.
470typedef std::tr1::tuple<GuestMode, const char*> TestParameter;
471
472// The base test class.
473class FileManagerBrowserTest :
474      public ExtensionApiTest,
475      public ::testing::WithParamInterface<TestParameter> {
476 protected:
477  FileManagerBrowserTest() :
478      local_volume_(new LocalTestVolume),
479      drive_volume_(std::tr1::get<0>(GetParam()) != IN_GUEST_MODE ?
480                    new DriveTestVolume() : NULL) {}
481
482  virtual void SetUp() OVERRIDE {
483    // TODO(danakj): The GPU Video Decoder needs real GL bindings.
484    // crbug.com/269087
485    UseRealGLBindings();
486
487    ExtensionApiTest::SetUp();
488  }
489
490  virtual void SetUpInProcessBrowserTestFixture() OVERRIDE;
491
492  virtual void SetUpOnMainThread() OVERRIDE;
493
494  // Adds an incognito and guest-mode flags for tests in the guest mode.
495  virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
496
497  // Loads our testing extension and sends it a string identifying the current
498  // test.
499  void StartTest();
500
501  const scoped_ptr<LocalTestVolume> local_volume_;
502  const scoped_ptr<DriveTestVolume> drive_volume_;
503};
504
505void FileManagerBrowserTest::SetUpInProcessBrowserTestFixture() {
506  ExtensionApiTest::SetUpInProcessBrowserTestFixture();
507  extensions::ComponentLoader::EnableBackgroundExtensionsForTesting();
508  if (drive_volume_)
509    ASSERT_TRUE(drive_volume_->SetUp());
510}
511
512void FileManagerBrowserTest::SetUpOnMainThread() {
513  ExtensionApiTest::SetUpOnMainThread();
514  ASSERT_TRUE(local_volume_->Mount(browser()->profile()));
515
516  if (drive_volume_) {
517    // Install the web server to serve the mocked share dialog.
518    ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
519    const GURL share_url_base(embedded_test_server()->GetURL(
520        "/chromeos/file_manager/share_dialog_mock/index.html"));
521    drive_volume_->ConfigureShareUrlBase(share_url_base);
522    test_util::WaitUntilDriveMountPointIsAdded(browser()->profile());
523  }
524}
525
526void FileManagerBrowserTest::SetUpCommandLine(CommandLine* command_line) {
527  if (std::tr1::get<0>(GetParam()) == IN_GUEST_MODE) {
528    command_line->AppendSwitch(chromeos::switches::kGuestSession);
529    command_line->AppendSwitchNative(chromeos::switches::kLoginUser, "");
530    command_line->AppendSwitch(switches::kIncognito);
531  }
532  // TODO(yoshiki): Remove the flag when the feature is launched.
533  if (std::tr1::get<1>(GetParam()) == std::string("suggestAppDialog")) {
534    command_line->AppendSwitch(
535        chromeos::switches::kFileManagerEnableWebstoreIntegration);
536  }
537  ExtensionApiTest::SetUpCommandLine(command_line);
538}
539
540IN_PROC_BROWSER_TEST_P(FileManagerBrowserTest, Test) {
541  // Launch the extension.
542  base::FilePath path = test_data_dir_.AppendASCII("file_manager_browsertest");
543  const extensions::Extension* extension = LoadExtensionAsComponent(path);
544  ASSERT_TRUE(extension);
545
546  // Handle the messages from JavaScript.
547  // The while loop is break when the test is passed or failed.
548  FileManagerTestListener listener;
549  base::JSONValueConverter<AddEntriesMessage> add_entries_message_converter;
550  while (true) {
551    FileManagerTestListener::Message entry = listener.GetNextMessage();
552    if (entry.type == chrome::NOTIFICATION_EXTENSION_TEST_PASSED) {
553      // Test succeed.
554      break;
555    } else if (entry.type == chrome::NOTIFICATION_EXTENSION_TEST_FAILED) {
556      // Test failed.
557      ADD_FAILURE() << entry.message;
558      break;
559    }
560
561    // Parse the message value as JSON.
562    const scoped_ptr<const base::Value> value(
563        base::JSONReader::Read(entry.message));
564
565    // If the message is not the expected format, just ignore it.
566    const base::DictionaryValue* message_dictionary = NULL;
567    std::string name;
568    if (!value || !value->GetAsDictionary(&message_dictionary) ||
569        !message_dictionary->GetString("name", &name))
570      continue;
571
572    if (name == "getTestName") {
573      // Pass the test case name.
574      entry.function->Reply(std::tr1::get<1>(GetParam()));
575    } else if (name == "isInGuestMode") {
576      // Obtain whether the test is in guest mode or not.
577      entry.function->Reply(std::tr1::get<0>(GetParam()) ? "true" : "false");
578    } else if (name == "getCwsWidgetContainerMockUrl") {
579      // Obtain whether the test is in guest mode or not.
580      const GURL url = embedded_test_server()->GetURL(
581            "/chromeos/file_manager/cws_container_mock/index.html");
582      std::string origin = url.GetOrigin().spec();
583
584      // Removes trailing a slash.
585      if (*origin.rbegin() == '/')
586        origin.resize(origin.length() - 1);
587
588      const scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue());
589      res->SetString("url", url.spec());
590      res->SetString("origin", origin);
591      std::string jsonString;
592      base::JSONWriter::Write(res.get(), &jsonString);
593      entry.function->Reply(jsonString);
594    } else if (name == "addEntries") {
595      // Add entries to the specified volume.
596      AddEntriesMessage message;
597      if (!add_entries_message_converter.Convert(*value.get(), &message)) {
598        entry.function->Reply("onError");
599        continue;
600      }
601      for (size_t i = 0; i < message.entries.size(); ++i) {
602        switch (message.volume) {
603          case LOCAL_VOLUME:
604            local_volume_->CreateEntry(*message.entries[i]);
605            break;
606          case DRIVE_VOLUME:
607            if (drive_volume_)
608              drive_volume_->CreateEntry(*message.entries[i]);
609            break;
610          default:
611            NOTREACHED();
612            break;
613        }
614      }
615      entry.function->Reply("onEntryAdded");
616    }
617  }
618}
619
620INSTANTIATE_TEST_CASE_P(
621    FileDisplay,
622    FileManagerBrowserTest,
623    ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "fileDisplayDownloads"),
624                      TestParameter(IN_GUEST_MODE, "fileDisplayDownloads"),
625                      TestParameter(NOT_IN_GUEST_MODE, "fileDisplayDrive")));
626
627INSTANTIATE_TEST_CASE_P(
628    OpenSpecialTypes,
629    FileManagerBrowserTest,
630    ::testing::Values(TestParameter(IN_GUEST_MODE, "videoOpenDownloads"),
631                      TestParameter(NOT_IN_GUEST_MODE, "videoOpenDownloads"),
632                      TestParameter(NOT_IN_GUEST_MODE, "videoOpenDrive"),
633                      TestParameter(IN_GUEST_MODE, "audioOpenDownloads"),
634                      TestParameter(NOT_IN_GUEST_MODE, "audioOpenDownloads"),
635                      TestParameter(NOT_IN_GUEST_MODE, "audioOpenDrive"),
636                      TestParameter(IN_GUEST_MODE, "galleryOpenDownloads"),
637                      TestParameter(NOT_IN_GUEST_MODE,
638                                    "galleryOpenDownloads"),
639                      TestParameter(NOT_IN_GUEST_MODE, "galleryOpenDrive")));
640
641/* http://crbug.com/316918 Tests are flaky.
642INSTANTIATE_TEST_CASE_P(
643    KeyboardOperations,
644    FileManagerBrowserTest,
645    ::testing::Values(TestParameter(IN_GUEST_MODE, "keyboardDeleteDownloads"),
646                      TestParameter(NOT_IN_GUEST_MODE,
647                                    "keyboardDeleteDownloads"),
648                      TestParameter(NOT_IN_GUEST_MODE, "keyboardDeleteDrive"),
649                      TestParameter(IN_GUEST_MODE, "keyboardCopyDownloads"),
650                      TestParameter(NOT_IN_GUEST_MODE, "keyboardCopyDownloads"),
651                      TestParameter(NOT_IN_GUEST_MODE, "keyboardCopyDrive")));
652*/
653
654INSTANTIATE_TEST_CASE_P(
655    DriveSpecific,
656    FileManagerBrowserTest,
657    ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "openSidebarRecent"),
658                      TestParameter(NOT_IN_GUEST_MODE, "openSidebarOffline"),
659                      TestParameter(NOT_IN_GUEST_MODE,
660                                    "openSidebarSharedWithMe"),
661                      TestParameter(NOT_IN_GUEST_MODE, "autocomplete")));
662
663INSTANTIATE_TEST_CASE_P(
664    Transfer,
665    FileManagerBrowserTest,
666    ::testing::Values(TestParameter(NOT_IN_GUEST_MODE,
667                                    "transferFromDriveToDownloads"),
668                      TestParameter(NOT_IN_GUEST_MODE,
669                                    "transferFromDownloadsToDrive"),
670                      TestParameter(NOT_IN_GUEST_MODE,
671                                    "transferFromSharedToDownloads"),
672                      TestParameter(NOT_IN_GUEST_MODE,
673                                    "transferFromSharedToDrive"),
674                      TestParameter(NOT_IN_GUEST_MODE,
675                                    "transferFromRecentToDownloads"),
676                      TestParameter(NOT_IN_GUEST_MODE,
677                                    "transferFromRecentToDrive"),
678                      TestParameter(NOT_IN_GUEST_MODE,
679                                    "transferFromOfflineToDownloads"),
680                      TestParameter(NOT_IN_GUEST_MODE,
681                                    "transferFromOfflineToDrive")));
682
683INSTANTIATE_TEST_CASE_P(
684     HideSearchBox,
685     FileManagerBrowserTest,
686     ::testing::Values(TestParameter(IN_GUEST_MODE, "hideSearchBox"),
687                       TestParameter(NOT_IN_GUEST_MODE, "hideSearchBox")));
688
689INSTANTIATE_TEST_CASE_P(
690    RestorePrefs,
691    FileManagerBrowserTest,
692    ::testing::Values(TestParameter(IN_GUEST_MODE, "restoreSortColumn"),
693                      TestParameter(NOT_IN_GUEST_MODE, "restoreSortColumn"),
694                      TestParameter(IN_GUEST_MODE, "restoreCurrentView"),
695                      TestParameter(NOT_IN_GUEST_MODE, "restoreCurrentView")));
696
697INSTANTIATE_TEST_CASE_P(
698    ShareDialog,
699    FileManagerBrowserTest,
700    ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "shareFile"),
701                      TestParameter(NOT_IN_GUEST_MODE, "shareDirectory")));
702
703INSTANTIATE_TEST_CASE_P(
704    RestoreGeometry,
705    FileManagerBrowserTest,
706    ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "restoreGeometry"),
707                      TestParameter(IN_GUEST_MODE, "restoreGeometry")));
708
709INSTANTIATE_TEST_CASE_P(
710    Traverse,
711    FileManagerBrowserTest,
712    ::testing::Values(TestParameter(IN_GUEST_MODE, "traverseDownloads"),
713                      TestParameter(NOT_IN_GUEST_MODE, "traverseDownloads"),
714                      TestParameter(NOT_IN_GUEST_MODE, "traverseDrive")));
715
716INSTANTIATE_TEST_CASE_P(
717    SuggestAppDialog,
718    FileManagerBrowserTest,
719    ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "suggestAppDialog")));
720
721INSTANTIATE_TEST_CASE_P(
722    ExecuteDefaultTaskOnDownloads,
723    FileManagerBrowserTest,
724    ::testing::Values(
725        TestParameter(NOT_IN_GUEST_MODE, "executeDefaultTaskOnDownloads"),
726        TestParameter(IN_GUEST_MODE, "executeDefaultTaskOnDownloads")));
727
728INSTANTIATE_TEST_CASE_P(
729    ExecuteDefaultTaskOnDrive,
730    FileManagerBrowserTest,
731    ::testing::Values(
732        TestParameter(NOT_IN_GUEST_MODE, "executeDefaultTaskOnDrive")));
733
734INSTANTIATE_TEST_CASE_P(
735    NavigationList,
736    FileManagerBrowserTest,
737    ::testing::Values(TestParameter(NOT_IN_GUEST_MODE,
738                                    "traverseNavigationList")));
739
740INSTANTIATE_TEST_CASE_P(
741    TabIndex,
742    FileManagerBrowserTest,
743    ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "searchBoxFocus")));
744
745INSTANTIATE_TEST_CASE_P(
746    Thumbnails,
747    FileManagerBrowserTest,
748    ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "thumbnailsDownloads"),
749                      TestParameter(IN_GUEST_MODE, "thumbnailsDownloads")));
750
751}  // namespace
752}  // namespace file_manager
753