| 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/extensions/api/file_system/entry_watcher_service.h" | 5 #include "chrome/browser/extensions/api/file_system/entry_watcher_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 log->push_back(status); | 29 log->push_back(status); |
| 30 } | 30 } |
| 31 | 31 |
| 32 } // namespace | 32 } // namespace |
| 33 | 33 |
| 34 class EntryWatcherServiceTest : public testing::Test { | 34 class EntryWatcherServiceTest : public testing::Test { |
| 35 protected: | 35 protected: |
| 36 EntryWatcherServiceTest() {} | 36 EntryWatcherServiceTest() {} |
| 37 virtual ~EntryWatcherServiceTest() {} | 37 virtual ~EntryWatcherServiceTest() {} |
| 38 | 38 |
| 39 virtual void SetUp() OVERRIDE { | 39 virtual void SetUp() override { |
| 40 profile_.reset(new TestingProfile); | 40 profile_.reset(new TestingProfile); |
| 41 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); | 41 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); |
| 42 file_system_context_ = | 42 file_system_context_ = |
| 43 content::CreateFileSystemContextForTesting(NULL, data_dir_.path()); | 43 content::CreateFileSystemContextForTesting(NULL, data_dir_.path()); |
| 44 service_.reset(new EntryWatcherService(profile_.get())); | 44 service_.reset(new EntryWatcherService(profile_.get())); |
| 45 service_->SetDispatchEventImplForTesting(base::Bind( | 45 service_->SetDispatchEventImplForTesting(base::Bind( |
| 46 &EntryWatcherServiceTest::DispatchEventImpl, base::Unretained(this))); | 46 &EntryWatcherServiceTest::DispatchEventImpl, base::Unretained(this))); |
| 47 service_->SetGetFileSystemContextImplForTesting( | 47 service_->SetGetFileSystemContextImplForTesting( |
| 48 base::Bind(&EntryWatcherServiceTest::GetFileSystemContextImpl, | 48 base::Bind(&EntryWatcherServiceTest::GetFileSystemContextImpl, |
| 49 base::Unretained(this))); | 49 base::Unretained(this))); |
| 50 testing_url_ = file_system_context_->CreateCrackedFileSystemURL( | 50 testing_url_ = file_system_context_->CreateCrackedFileSystemURL( |
| 51 GURL(std::string("chrome-extension://") + kExtensionId), | 51 GURL(std::string("chrome-extension://") + kExtensionId), |
| 52 storage::kFileSystemTypeTest, | 52 storage::kFileSystemTypeTest, |
| 53 base::FilePath::FromUTF8Unsafe("/x/y/z")); | 53 base::FilePath::FromUTF8Unsafe("/x/y/z")); |
| 54 } | 54 } |
| 55 | 55 |
| 56 virtual void TearDown() OVERRIDE { | 56 virtual void TearDown() override { |
| 57 dispatch_event_log_targets_.clear(); | 57 dispatch_event_log_targets_.clear(); |
| 58 dispatch_event_log_events_.clear(); | 58 dispatch_event_log_events_.clear(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void DispatchEventImpl(const std::string& extension_id, | 61 void DispatchEventImpl(const std::string& extension_id, |
| 62 scoped_ptr<Event> event) { | 62 scoped_ptr<Event> event) { |
| 63 dispatch_event_log_targets_.push_back(extension_id); | 63 dispatch_event_log_targets_.push_back(extension_id); |
| 64 dispatch_event_log_events_.push_back(event.release()); | 64 dispatch_event_log_events_.push_back(event.release()); |
| 65 } | 65 } |
| 66 | 66 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 std::vector<base::File::Error> log; | 245 std::vector<base::File::Error> log; |
| 246 service_->UnwatchEntry( | 246 service_->UnwatchEntry( |
| 247 kExtensionId, testing_url_, base::Bind(&LogStatus, &log)); | 247 kExtensionId, testing_url_, base::Bind(&LogStatus, &log)); |
| 248 base::RunLoop().RunUntilIdle(); | 248 base::RunLoop().RunUntilIdle(); |
| 249 | 249 |
| 250 ASSERT_EQ(1u, log.size()); | 250 ASSERT_EQ(1u, log.size()); |
| 251 EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, log[0]); | 251 EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, log[0]); |
| 252 } | 252 } |
| 253 | 253 |
| 254 } // namespace extensions | 254 } // namespace extensions |
| OLD | NEW |