| 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 28 #include "webkit/browser/fileapi/async_file_util.h" | 28 #include "webkit/browser/fileapi/async_file_util.h" |
| 29 #include "webkit/browser/fileapi/external_mount_points.h" | 29 #include "webkit/browser/fileapi/external_mount_points.h" |
| 30 #include "webkit/browser/fileapi/file_system_url.h" | 30 #include "webkit/browser/fileapi/file_system_url.h" |
| 31 | 31 |
| 32 namespace chromeos { | 32 namespace chromeos { |
| 33 namespace file_system_provider { | 33 namespace file_system_provider { |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 const char kExtensionId[] = "mbflcebpggnecokmikipoihdbecnjfoj"; | 36 const char kExtensionId[] = "mbflcebpggnecokmikipoihdbecnjfoj"; |
| 37 const char kFileSystemId[] = "testing-file-system"; |
| 37 | 38 |
| 38 // Logs callbacks invocations on the file stream reader. | 39 // Logs callbacks invocations on the file stream reader. |
| 39 class EventLogger { | 40 class EventLogger { |
| 40 public: | 41 public: |
| 41 EventLogger() : weak_ptr_factory_(this) {} | 42 EventLogger() : weak_ptr_factory_(this) {} |
| 42 virtual ~EventLogger() {} | 43 virtual ~EventLogger() {} |
| 43 | 44 |
| 44 void OnRead(int result) { results_.push_back(result); } | 45 void OnRead(int result) { results_.push_back(result); } |
| 45 void OnGetLength(int64 result) { results_.push_back(result); } | 46 void OnGetLength(int64 result) { results_.push_back(result); } |
| 46 | 47 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 profile_manager_.reset( | 89 profile_manager_.reset( |
| 89 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); | 90 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); |
| 90 ASSERT_TRUE(profile_manager_->SetUp()); | 91 ASSERT_TRUE(profile_manager_->SetUp()); |
| 91 profile_ = profile_manager_->CreateTestingProfile("testing-profile"); | 92 profile_ = profile_manager_->CreateTestingProfile("testing-profile"); |
| 92 | 93 |
| 93 ServiceFactory::GetInstance()->SetTestingFactory(profile_, &CreateService); | 94 ServiceFactory::GetInstance()->SetTestingFactory(profile_, &CreateService); |
| 94 Service* service = Service::Get(profile_); // Owned by its factory. | 95 Service* service = Service::Get(profile_); // Owned by its factory. |
| 95 service->SetFileSystemFactoryForTests( | 96 service->SetFileSystemFactoryForTests( |
| 96 base::Bind(&FakeProvidedFileSystem::Create)); | 97 base::Bind(&FakeProvidedFileSystem::Create)); |
| 97 | 98 |
| 98 const int file_system_id = | 99 const bool result = service->MountFileSystem( |
| 99 service->MountFileSystem(kExtensionId, "testing-file-system"); | 100 kExtensionId, kFileSystemId, "Testing File System"); |
| 100 ASSERT_LT(0, file_system_id); | 101 ASSERT_TRUE(result); |
| 101 const ProvidedFileSystemInfo& file_system_info = | 102 const ProvidedFileSystemInfo& file_system_info = |
| 102 service->GetProvidedFileSystem(kExtensionId, file_system_id) | 103 service->GetProvidedFileSystem(kExtensionId, kFileSystemId) |
| 103 ->GetFileSystemInfo(); | 104 ->GetFileSystemInfo(); |
| 104 const std::string mount_point_name = | 105 const std::string mount_point_name = |
| 105 file_system_info.mount_path().BaseName().AsUTF8Unsafe(); | 106 file_system_info.mount_path().BaseName().AsUTF8Unsafe(); |
| 106 | 107 |
| 107 file_url_ = CreateFileSystemURL( | 108 file_url_ = CreateFileSystemURL( |
| 108 mount_point_name, base::FilePath::FromUTF8Unsafe(kFakeFilePath + 1)); | 109 mount_point_name, base::FilePath::FromUTF8Unsafe(kFakeFilePath + 1)); |
| 109 ASSERT_TRUE(file_url_.is_valid()); | 110 ASSERT_TRUE(file_url_.is_valid()); |
| 110 wrong_file_url_ = CreateFileSystemURL( | 111 wrong_file_url_ = CreateFileSystemURL( |
| 111 mount_point_name, base::FilePath::FromUTF8Unsafe("im-not-here.txt")); | 112 mount_point_name, base::FilePath::FromUTF8Unsafe("im-not-here.txt")); |
| 112 ASSERT_TRUE(wrong_file_url_.is_valid()); | 113 ASSERT_TRUE(wrong_file_url_.is_valid()); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 base::Bind(&EventLogger::OnGetLength, logger.GetWeakPtr())); | 286 base::Bind(&EventLogger::OnGetLength, logger.GetWeakPtr())); |
| 286 EXPECT_EQ(net::ERR_IO_PENDING, result); | 287 EXPECT_EQ(net::ERR_IO_PENDING, result); |
| 287 base::RunLoop().RunUntilIdle(); | 288 base::RunLoop().RunUntilIdle(); |
| 288 | 289 |
| 289 ASSERT_EQ(1u, logger.results().size()); | 290 ASSERT_EQ(1u, logger.results().size()); |
| 290 EXPECT_EQ(net::ERR_FAILED, logger.results()[0]); | 291 EXPECT_EQ(net::ERR_FAILED, logger.results()[0]); |
| 291 } | 292 } |
| 292 | 293 |
| 293 } // namespace file_system_provider | 294 } // namespace file_system_provider |
| 294 } // namespace chromeos | 295 } // namespace chromeos |
| OLD | NEW |