| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/drive/file_system_util.h" | 5 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/md5.h" | 10 #include "base/md5.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/browser/google_apis/test_util.h" | 13 #include "chrome/browser/google_apis/test_util.h" |
| 14 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "webkit/browser/fileapi/external_mount_points.h" | 16 #include "webkit/browser/fileapi/external_mount_points.h" |
| 17 #include "webkit/browser/fileapi/file_system_backend.h" | 17 #include "webkit/browser/fileapi/file_system_backend.h" |
| 18 #include "webkit/browser/fileapi/file_system_context.h" | 18 #include "webkit/browser/fileapi/file_system_context.h" |
| 19 #include "webkit/browser/fileapi/file_system_task_runners.h" | |
| 20 #include "webkit/browser/fileapi/file_system_url.h" | 19 #include "webkit/browser/fileapi/file_system_url.h" |
| 21 #include "webkit/browser/fileapi/isolated_context.h" | 20 #include "webkit/browser/fileapi/isolated_context.h" |
| 22 #include "webkit/browser/fileapi/mock_file_system_options.h" | 21 #include "webkit/browser/fileapi/mock_file_system_options.h" |
| 23 | 22 |
| 24 namespace drive { | 23 namespace drive { |
| 25 namespace util { | 24 namespace util { |
| 26 | 25 |
| 27 TEST(FileSystemUtilTest, FilePathToDriveURL) { | 26 TEST(FileSystemUtilTest, FilePathToDriveURL) { |
| 28 base::FilePath path; | 27 base::FilePath path; |
| 29 | 28 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 TEST(FileSystemUtilTest, ExtractDrivePathFromFileSystemUrl) { | 91 TEST(FileSystemUtilTest, ExtractDrivePathFromFileSystemUrl) { |
| 93 // Set up file system context for testing. | 92 // Set up file system context for testing. |
| 94 base::ScopedTempDir temp_dir_; | 93 base::ScopedTempDir temp_dir_; |
| 95 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 94 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 96 | 95 |
| 97 base::MessageLoop message_loop; | 96 base::MessageLoop message_loop; |
| 98 scoped_refptr<fileapi::ExternalMountPoints> mount_points = | 97 scoped_refptr<fileapi::ExternalMountPoints> mount_points = |
| 99 fileapi::ExternalMountPoints::CreateRefCounted(); | 98 fileapi::ExternalMountPoints::CreateRefCounted(); |
| 100 scoped_refptr<fileapi::FileSystemContext> context( | 99 scoped_refptr<fileapi::FileSystemContext> context( |
| 101 new fileapi::FileSystemContext( | 100 new fileapi::FileSystemContext( |
| 102 fileapi::FileSystemTaskRunners::CreateMockTaskRunners(), | 101 base::MessageLoopProxy::current().get(), |
| 102 base::MessageLoopProxy::current().get(), |
| 103 mount_points.get(), | 103 mount_points.get(), |
| 104 NULL, // special_storage_policy | 104 NULL, // special_storage_policy |
| 105 NULL, // quota_manager_proxy, | 105 NULL, // quota_manager_proxy, |
| 106 ScopedVector<fileapi::FileSystemBackend>(), | 106 ScopedVector<fileapi::FileSystemBackend>(), |
| 107 temp_dir_.path(), // partition_path | 107 temp_dir_.path(), // partition_path |
| 108 fileapi::CreateAllowFileAccessOptions())); | 108 fileapi::CreateAllowFileAccessOptions())); |
| 109 | 109 |
| 110 // Type:"external" + virtual_path:"drive/foo/bar" resolves to "drive/foo/bar". | 110 // Type:"external" + virtual_path:"drive/foo/bar" resolves to "drive/foo/bar". |
| 111 const std::string& drive_mount_name = | 111 const std::string& drive_mount_name = |
| 112 GetDriveMountPointPath().BaseName().AsUTF8Unsafe(); | 112 GetDriveMountPointPath().BaseName().AsUTF8Unsafe(); |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 | 329 |
| 330 base::FilePath path = temp_dir.path().AppendASCII("test.txt"); | 330 base::FilePath path = temp_dir.path().AppendASCII("test.txt"); |
| 331 const char kTestData[] = "abcdefghijklmnopqrstuvwxyz0123456789"; | 331 const char kTestData[] = "abcdefghijklmnopqrstuvwxyz0123456789"; |
| 332 ASSERT_TRUE(google_apis::test_util::WriteStringToFile(path, kTestData)); | 332 ASSERT_TRUE(google_apis::test_util::WriteStringToFile(path, kTestData)); |
| 333 | 333 |
| 334 EXPECT_EQ(base::MD5String(kTestData), GetMd5Digest(path)); | 334 EXPECT_EQ(base::MD5String(kTestData), GetMd5Digest(path)); |
| 335 } | 335 } |
| 336 | 336 |
| 337 } // namespace util | 337 } // namespace util |
| 338 } // namespace drive | 338 } // namespace drive |
| OLD | NEW |