| 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/values.h" | 21 #include "base/values.h" |
| 22 #include "chrome/browser/chrome_content_browser_client.h" | 22 #include "chrome/browser/chrome_content_browser_client.h" |
| 23 #include "chrome/browser/chromeos/file_manager/app_id.h" | 23 #include "chrome/browser/chromeos/file_manager/app_id.h" |
| 24 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" | 24 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" |
| 25 #include "chrome/browser/chromeos/fileapi/file_system_backend_delegate.h" |
| 25 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 26 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 26 #include "chrome/test/base/browser_with_test_window_test.h" | 27 #include "chrome/test/base/browser_with_test_window_test.h" |
| 27 #include "content/public/browser/browser_context.h" | 28 #include "content/public/browser/browser_context.h" |
| 28 #include "content/public/common/content_client.h" | 29 #include "content/public/common/content_client.h" |
| 29 #include "content/public/test/mock_special_storage_policy.h" | 30 #include "content/public/test/mock_special_storage_policy.h" |
| 30 #include "extensions/browser/extension_registry.h" | 31 #include "extensions/browser/extension_registry.h" |
| 31 #include "extensions/common/extension.h" | 32 #include "extensions/common/extension.h" |
| 32 #include "storage/browser/fileapi/external_mount_points.h" | 33 #include "storage/browser/fileapi/external_mount_points.h" |
| 33 #include "storage/common/fileapi/file_system_types.h" | 34 #include "storage/common/fileapi/file_system_types.h" |
| 34 #else | 35 #else |
| (...skipping 13 matching lines...) Expand all Loading... |
| 48 public: | 49 public: |
| 49 void GetAdditionalFileSystemBackends( | 50 void GetAdditionalFileSystemBackends( |
| 50 content::BrowserContext* browser_context, | 51 content::BrowserContext* browser_context, |
| 51 const base::FilePath& storage_partition_path, | 52 const base::FilePath& storage_partition_path, |
| 52 ScopedVector<storage::FileSystemBackend>* additional_backends) override { | 53 ScopedVector<storage::FileSystemBackend>* additional_backends) override { |
| 53 storage::ExternalMountPoints* external_mount_points = | 54 storage::ExternalMountPoints* external_mount_points = |
| 54 content::BrowserContext::GetMountPoints(browser_context); | 55 content::BrowserContext::GetMountPoints(browser_context); |
| 55 | 56 |
| 56 // New FileSystemBackend that uses our MockSpecialStoragePolicy. | 57 // New FileSystemBackend that uses our MockSpecialStoragePolicy. |
| 57 chromeos::FileSystemBackend* backend = new chromeos::FileSystemBackend( | 58 chromeos::FileSystemBackend* backend = new chromeos::FileSystemBackend( |
| 58 nullptr, nullptr, nullptr, external_mount_points, | 59 nullptr, nullptr, nullptr, nullptr, external_mount_points, |
| 59 storage::ExternalMountPoints::GetSystemInstance()); | 60 storage::ExternalMountPoints::GetSystemInstance()); |
| 60 additional_backends->push_back(backend); | 61 additional_backends->push_back(backend); |
| 61 } | 62 } |
| 62 }; | 63 }; |
| 63 | 64 |
| 64 // Base test fixture class to be used on Chrome OS. | 65 // Base test fixture class to be used on Chrome OS. |
| 65 class PlatformUtilTestBase : public BrowserWithTestWindowTest { | 66 class PlatformUtilTestBase : public BrowserWithTestWindowTest { |
| 66 protected: | 67 protected: |
| 67 void SetUpPlatformFixture(const base::FilePath& test_directory) { | 68 void SetUpPlatformFixture(const base::FilePath& test_directory) { |
| 68 content_browser_client_.reset(new PlatformUtilTestContentBrowserClient()); | 69 content_browser_client_.reset(new PlatformUtilTestContentBrowserClient()); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 TEST_F(PlatformUtilPosixTest, OpenFolderWithPosixSymlinks) { | 287 TEST_F(PlatformUtilPosixTest, OpenFolderWithPosixSymlinks) { |
| 287 EXPECT_EQ(OPEN_SUCCEEDED, CallOpenItem(symlink_to_folder_, OPEN_FOLDER)); | 288 EXPECT_EQ(OPEN_SUCCEEDED, CallOpenItem(symlink_to_folder_, OPEN_FOLDER)); |
| 288 EXPECT_EQ(OPEN_FAILED_INVALID_TYPE, | 289 EXPECT_EQ(OPEN_FAILED_INVALID_TYPE, |
| 289 CallOpenItem(symlink_to_file_, OPEN_FOLDER)); | 290 CallOpenItem(symlink_to_file_, OPEN_FOLDER)); |
| 290 EXPECT_EQ(OPEN_FAILED_PATH_NOT_FOUND, | 291 EXPECT_EQ(OPEN_FAILED_PATH_NOT_FOUND, |
| 291 CallOpenItem(symlink_to_nowhere_, OPEN_FOLDER)); | 292 CallOpenItem(symlink_to_nowhere_, OPEN_FOLDER)); |
| 292 } | 293 } |
| 293 #endif // OS_POSIX && !OS_CHROMEOS | 294 #endif // OS_POSIX && !OS_CHROMEOS |
| 294 | 295 |
| 295 } // namespace platform_util | 296 } // namespace platform_util |
| OLD | NEW |