OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/platform_util.h" | 5 #include "chrome/browser/platform_util.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // without having to install the extension. | 43 // without having to install the extension. |
44 class PlatformUtilTestContentBrowserClient | 44 class PlatformUtilTestContentBrowserClient |
45 : public chrome::ChromeContentBrowserClient { | 45 : public chrome::ChromeContentBrowserClient { |
46 public: | 46 public: |
47 void GetAdditionalFileSystemBackends( | 47 void GetAdditionalFileSystemBackends( |
48 content::BrowserContext* browser_context, | 48 content::BrowserContext* browser_context, |
49 const base::FilePath& storage_partition_path, | 49 const base::FilePath& storage_partition_path, |
50 ScopedVector<storage::FileSystemBackend>* additional_backends) override { | 50 ScopedVector<storage::FileSystemBackend>* additional_backends) override { |
51 storage::ExternalMountPoints* external_mount_points = | 51 storage::ExternalMountPoints* external_mount_points = |
52 content::BrowserContext::GetMountPoints(browser_context); | 52 content::BrowserContext::GetMountPoints(browser_context); |
53 scoped_refptr<content::MockSpecialStoragePolicy> special_storage_policy = | |
54 new content::MockSpecialStoragePolicy(); | |
55 | 53 |
56 // New FileSystemBackend that uses our MockSpecialStoragePolicy. | 54 // New FileSystemBackend that uses our MockSpecialStoragePolicy. |
57 chromeos::FileSystemBackend* backend = new chromeos::FileSystemBackend( | 55 chromeos::FileSystemBackend* backend = new chromeos::FileSystemBackend( |
58 nullptr, nullptr, nullptr, special_storage_policy, | 56 nullptr, nullptr, nullptr, external_mount_points, |
59 external_mount_points, | |
60 storage::ExternalMountPoints::GetSystemInstance()); | 57 storage::ExternalMountPoints::GetSystemInstance()); |
61 additional_backends->push_back(backend); | 58 additional_backends->push_back(backend); |
62 | |
63 // The only change we need to make is to add kFileManagerAppId as a file | |
64 // handler. | |
65 special_storage_policy->AddFileHandler(file_manager::kFileManagerAppId); | |
66 } | 59 } |
67 }; | 60 }; |
68 | 61 |
69 // Base test fixture class to be used on Chrome OS. | 62 // Base test fixture class to be used on Chrome OS. |
70 class PlatformUtilTestBase : public BrowserWithTestWindowTest { | 63 class PlatformUtilTestBase : public BrowserWithTestWindowTest { |
71 protected: | 64 protected: |
72 void SetUpPlatformFixture(const base::FilePath& test_directory) { | 65 void SetUpPlatformFixture(const base::FilePath& test_directory) { |
73 content_browser_client_.reset(new PlatformUtilTestContentBrowserClient()); | 66 content_browser_client_.reset(new PlatformUtilTestContentBrowserClient()); |
74 old_content_browser_client_ = | 67 old_content_browser_client_ = |
75 content::SetBrowserClientForTesting(content_browser_client_.get()); | 68 content::SetBrowserClientForTesting(content_browser_client_.get()); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 TEST_F(PlatformUtilPosixTest, OpenFolderWithPosixSymlinks) { | 284 TEST_F(PlatformUtilPosixTest, OpenFolderWithPosixSymlinks) { |
292 EXPECT_EQ(OPEN_SUCCEEDED, CallOpenItem(symlink_to_folder_, OPEN_FOLDER)); | 285 EXPECT_EQ(OPEN_SUCCEEDED, CallOpenItem(symlink_to_folder_, OPEN_FOLDER)); |
293 EXPECT_EQ(OPEN_FAILED_INVALID_TYPE, | 286 EXPECT_EQ(OPEN_FAILED_INVALID_TYPE, |
294 CallOpenItem(symlink_to_file_, OPEN_FOLDER)); | 287 CallOpenItem(symlink_to_file_, OPEN_FOLDER)); |
295 EXPECT_EQ(OPEN_FAILED_PATH_NOT_FOUND, | 288 EXPECT_EQ(OPEN_FAILED_PATH_NOT_FOUND, |
296 CallOpenItem(symlink_to_nowhere_, OPEN_FOLDER)); | 289 CallOpenItem(symlink_to_nowhere_, OPEN_FOLDER)); |
297 } | 290 } |
298 #endif // OS_POSIX && !OS_CHROMEOS | 291 #endif // OS_POSIX && !OS_CHROMEOS |
299 | 292 |
300 } // namespace platform_util | 293 } // namespace platform_util |
OLD | NEW |