| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/browser/platform_util_internal.h" | 16 #include "chrome/browser/platform_util_internal.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 18 |
| 19 #if defined(OS_CHROMEOS) | 19 #if defined(OS_CHROMEOS) |
| 20 #include "base/json/json_string_value_serializer.h" | 20 #include "base/json/json_string_value_serializer.h" |
| 21 #include "base/memory/ptr_util.h" |
| 21 #include "base/values.h" | 22 #include "base/values.h" |
| 22 #include "chrome/browser/chrome_content_browser_client.h" | 23 #include "chrome/browser/chrome_content_browser_client.h" |
| 23 #include "chrome/browser/chromeos/file_manager/app_id.h" | 24 #include "chrome/browser/chromeos/file_manager/app_id.h" |
| 24 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" | 25 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" |
| 25 #include "chrome/browser/chromeos/fileapi/file_system_backend_delegate.h" | 26 #include "chrome/browser/chromeos/fileapi/file_system_backend_delegate.h" |
| 26 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 27 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 27 #include "chrome/test/base/browser_with_test_window_test.h" | 28 #include "chrome/test/base/browser_with_test_window_test.h" |
| 28 #include "content/public/browser/browser_context.h" | 29 #include "content/public/browser/browser_context.h" |
| 29 #include "content/public/common/content_client.h" | 30 #include "content/public/common/content_client.h" |
| 30 #include "content/public/test/mock_special_storage_policy.h" | 31 #include "content/public/test/mock_special_storage_policy.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 43 #if defined(OS_CHROMEOS) | 44 #if defined(OS_CHROMEOS) |
| 44 | 45 |
| 45 // ChromeContentBrowserClient subclass that sets up a custom file system backend | 46 // ChromeContentBrowserClient subclass that sets up a custom file system backend |
| 46 // that allows the test to grant file access to the file manager extension ID | 47 // that allows the test to grant file access to the file manager extension ID |
| 47 // without having to install the extension. | 48 // without having to install the extension. |
| 48 class PlatformUtilTestContentBrowserClient : public ChromeContentBrowserClient { | 49 class PlatformUtilTestContentBrowserClient : public ChromeContentBrowserClient { |
| 49 public: | 50 public: |
| 50 void GetAdditionalFileSystemBackends( | 51 void GetAdditionalFileSystemBackends( |
| 51 content::BrowserContext* browser_context, | 52 content::BrowserContext* browser_context, |
| 52 const base::FilePath& storage_partition_path, | 53 const base::FilePath& storage_partition_path, |
| 53 ScopedVector<storage::FileSystemBackend>* additional_backends) override { | 54 std::vector<std::unique_ptr<storage::FileSystemBackend>>* |
| 55 additional_backends) override { |
| 54 storage::ExternalMountPoints* external_mount_points = | 56 storage::ExternalMountPoints* external_mount_points = |
| 55 content::BrowserContext::GetMountPoints(browser_context); | 57 content::BrowserContext::GetMountPoints(browser_context); |
| 56 | 58 |
| 57 // New FileSystemBackend that uses our MockSpecialStoragePolicy. | 59 // New FileSystemBackend that uses our MockSpecialStoragePolicy. |
| 58 chromeos::FileSystemBackend* backend = new chromeos::FileSystemBackend( | 60 additional_backends->push_back( |
| 59 nullptr, nullptr, nullptr, nullptr, nullptr, external_mount_points, | 61 base::MakeUnique<chromeos::FileSystemBackend>( |
| 60 storage::ExternalMountPoints::GetSystemInstance()); | 62 nullptr, nullptr, nullptr, nullptr, nullptr, external_mount_points, |
| 61 additional_backends->push_back(backend); | 63 storage::ExternalMountPoints::GetSystemInstance())); |
| 62 } | 64 } |
| 63 }; | 65 }; |
| 64 | 66 |
| 65 // Base test fixture class to be used on Chrome OS. | 67 // Base test fixture class to be used on Chrome OS. |
| 66 class PlatformUtilTestBase : public BrowserWithTestWindowTest { | 68 class PlatformUtilTestBase : public BrowserWithTestWindowTest { |
| 67 protected: | 69 protected: |
| 68 void SetUpPlatformFixture(const base::FilePath& test_directory) { | 70 void SetUpPlatformFixture(const base::FilePath& test_directory) { |
| 69 content_browser_client_.reset(new PlatformUtilTestContentBrowserClient()); | 71 content_browser_client_.reset(new PlatformUtilTestContentBrowserClient()); |
| 70 old_content_browser_client_ = | 72 old_content_browser_client_ = |
| 71 content::SetBrowserClientForTesting(content_browser_client_.get()); | 73 content::SetBrowserClientForTesting(content_browser_client_.get()); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 TEST_F(PlatformUtilPosixTest, OpenFolderWithPosixSymlinks) { | 289 TEST_F(PlatformUtilPosixTest, OpenFolderWithPosixSymlinks) { |
| 288 EXPECT_EQ(OPEN_SUCCEEDED, CallOpenItem(symlink_to_folder_, OPEN_FOLDER)); | 290 EXPECT_EQ(OPEN_SUCCEEDED, CallOpenItem(symlink_to_folder_, OPEN_FOLDER)); |
| 289 EXPECT_EQ(OPEN_FAILED_INVALID_TYPE, | 291 EXPECT_EQ(OPEN_FAILED_INVALID_TYPE, |
| 290 CallOpenItem(symlink_to_file_, OPEN_FOLDER)); | 292 CallOpenItem(symlink_to_file_, OPEN_FOLDER)); |
| 291 EXPECT_EQ(OPEN_FAILED_PATH_NOT_FOUND, | 293 EXPECT_EQ(OPEN_FAILED_PATH_NOT_FOUND, |
| 292 CallOpenItem(symlink_to_nowhere_, OPEN_FOLDER)); | 294 CallOpenItem(symlink_to_nowhere_, OPEN_FOLDER)); |
| 293 } | 295 } |
| 294 #endif // OS_POSIX && !OS_CHROMEOS | 296 #endif // OS_POSIX && !OS_CHROMEOS |
| 295 | 297 |
| 296 } // namespace platform_util | 298 } // namespace platform_util |
| OLD | NEW |