| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/file_system_provider/mount_path_util.h" | 5 #include "chrome/browser/chromeos/file_system_provider/mount_path_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "chrome/browser/chromeos/file_system_provider/fake_provided_file_system
.h" | 11 #include "chrome/browser/chromeos/file_system_provider/fake_provided_file_system
.h" |
| 12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte
rface.h" | 12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte
rface.h" |
| 13 #include "chrome/browser/chromeos/file_system_provider/service.h" | 13 #include "chrome/browser/chromeos/file_system_provider/service.h" |
| 14 #include "chrome/browser/chromeos/file_system_provider/service_factory.h" | 14 #include "chrome/browser/chromeos/file_system_provider/service_factory.h" |
| 15 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 15 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
| 16 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 16 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/common/extensions/api/file_system_provider_capabilities/file_sy
stem_provider_capabilities_handler.h" |
| 18 #include "chrome/test/base/testing_browser_process.h" | 19 #include "chrome/test/base/testing_browser_process.h" |
| 19 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
| 20 #include "chrome/test/base/testing_profile_manager.h" | 21 #include "chrome/test/base/testing_profile_manager.h" |
| 21 #include "components/keyed_service/core/keyed_service.h" | 22 #include "components/keyed_service/core/keyed_service.h" |
| 22 #include "content/public/browser/browser_context.h" | 23 #include "content/public/browser/browser_context.h" |
| 23 #include "content/public/test/test_browser_thread_bundle.h" | 24 #include "content/public/test/test_browser_thread_bundle.h" |
| 24 #include "extensions/browser/extension_registry.h" | 25 #include "extensions/browser/extension_registry.h" |
| 25 #include "storage/browser/fileapi/external_mount_points.h" | 26 #include "storage/browser/fileapi/external_mount_points.h" |
| 26 #include "storage/browser/fileapi/isolated_context.h" | 27 #include "storage/browser/fileapi/isolated_context.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 EXPECT_TRUE(parser.Parse()); | 171 EXPECT_TRUE(parser.Parse()); |
| 171 | 172 |
| 172 ProvidedFileSystemInterface* file_system = parser.file_system(); | 173 ProvidedFileSystemInterface* file_system = parser.file_system(); |
| 173 ASSERT_TRUE(file_system); | 174 ASSERT_TRUE(file_system); |
| 174 EXPECT_EQ(kFileSystemId, file_system->GetFileSystemInfo().file_system_id()); | 175 EXPECT_EQ(kFileSystemId, file_system->GetFileSystemInfo().file_system_id()); |
| 175 EXPECT_EQ(kFilePath.AsUTF8Unsafe(), parser.file_path().AsUTF8Unsafe()); | 176 EXPECT_EQ(kFilePath.AsUTF8Unsafe(), parser.file_path().AsUTF8Unsafe()); |
| 176 } | 177 } |
| 177 | 178 |
| 178 TEST_F(FileSystemProviderMountPathUtilTest, Parser_WrongUrl) { | 179 TEST_F(FileSystemProviderMountPathUtilTest, Parser_WrongUrl) { |
| 179 const ProvidedFileSystemInfo file_system_info( | 180 const ProvidedFileSystemInfo file_system_info( |
| 180 kExtensionId, | 181 kExtensionId, MountOptions(kFileSystemId, kDisplayName), |
| 181 MountOptions(kFileSystemId, kDisplayName), | 182 GetMountPath(profile_, kExtensionId, kFileSystemId), |
| 182 GetMountPath(profile_, kExtensionId, kFileSystemId)); | 183 false /* configurable */, extensions::SOURCE_FILE); |
| 183 | 184 |
| 184 const base::FilePath kFilePath = base::FilePath(FILE_PATH_LITERAL("/hello")); | 185 const base::FilePath kFilePath = base::FilePath(FILE_PATH_LITERAL("/hello")); |
| 185 const storage::FileSystemURL url = | 186 const storage::FileSystemURL url = |
| 186 CreateFileSystemURL(profile_, file_system_info, kFilePath); | 187 CreateFileSystemURL(profile_, file_system_info, kFilePath); |
| 187 // It is impossible to create a cracked URL for a mount point which doesn't | 188 // It is impossible to create a cracked URL for a mount point which doesn't |
| 188 // exist, therefore is will always be invalid, and empty. | 189 // exist, therefore is will always be invalid, and empty. |
| 189 EXPECT_FALSE(url.is_valid()); | 190 EXPECT_FALSE(url.is_valid()); |
| 190 | 191 |
| 191 FileSystemURLParser parser(url); | 192 FileSystemURLParser parser(url); |
| 192 EXPECT_FALSE(parser.Parse()); | 193 EXPECT_FALSE(parser.Parse()); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 const base::FilePath kFilePath = | 306 const base::FilePath kFilePath = |
| 306 base::FilePath(FILE_PATH_LITERAL("provided/hello/world")); | 307 base::FilePath(FILE_PATH_LITERAL("provided/hello/world")); |
| 307 LocalPathParser parser(profile_, kFilePath); | 308 LocalPathParser parser(profile_, kFilePath); |
| 308 EXPECT_FALSE(parser.Parse()); | 309 EXPECT_FALSE(parser.Parse()); |
| 309 } | 310 } |
| 310 } | 311 } |
| 311 | 312 |
| 312 } // namespace util | 313 } // namespace util |
| 313 } // namespace file_system_provider | 314 } // namespace file_system_provider |
| 314 } // namespace chromeos | 315 } // namespace chromeos |
| OLD | NEW |