Index: chrome/browser/chromeos/file_system_provider/operations/add_watcher_unittest.cc |
diff --git a/chrome/browser/chromeos/file_system_provider/operations/observe_directory_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/add_watcher_unittest.cc |
similarity index 53% |
rename from chrome/browser/chromeos/file_system_provider/operations/observe_directory_unittest.cc |
rename to chrome/browser/chromeos/file_system_provider/operations/add_watcher_unittest.cc |
index c682e6113f0c2300068728ba99b51a02ee2aefd1..2b46f5e7fca71c7c6faf4cb0f2f050d1fc1468b1 100644 |
--- a/chrome/browser/chromeos/file_system_provider/operations/observe_directory_unittest.cc |
+++ b/chrome/browser/chromeos/file_system_provider/operations/add_watcher_unittest.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/chromeos/file_system_provider/operations/observe_directory.h" |
+#include "chrome/browser/chromeos/file_system_provider/operations/add_watcher.h" |
#include <string> |
#include <vector> |
@@ -27,14 +27,14 @@ namespace { |
const char kExtensionId[] = "mbflcebpggnecokmikipoihdbecnjfoj"; |
const char kFileSystemId[] = "testing-file-system"; |
const int kRequestId = 2; |
-const base::FilePath::CharType kDirectoryPath[] = "/kitty/and/puppy/happy"; |
+const base::FilePath::CharType kEntryPath[] = "/kitty/and/puppy/happy"; |
} // namespace |
-class FileSystemProviderOperationsObserveDirectoryTest : public testing::Test { |
+class FileSystemProviderOperationsAddWatcherTest : public testing::Test { |
protected: |
- FileSystemProviderOperationsObserveDirectoryTest() {} |
- virtual ~FileSystemProviderOperationsObserveDirectoryTest() {} |
+ FileSystemProviderOperationsAddWatcherTest() {} |
+ virtual ~FileSystemProviderOperationsAddWatcherTest() {} |
virtual void SetUp() override { |
file_system_info_ = ProvidedFileSystemInfo( |
@@ -46,103 +46,99 @@ class FileSystemProviderOperationsObserveDirectoryTest : public testing::Test { |
ProvidedFileSystemInfo file_system_info_; |
}; |
-TEST_F(FileSystemProviderOperationsObserveDirectoryTest, Execute) { |
- using extensions::api::file_system_provider::ObserveDirectoryRequestedOptions; |
+TEST_F(FileSystemProviderOperationsAddWatcherTest, Execute) { |
+ using extensions::api::file_system_provider::AddWatcherRequestedOptions; |
util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
util::StatusCallbackLog callback_log; |
- ObserveDirectory observe_directory( |
- NULL, |
- file_system_info_, |
- base::FilePath::FromUTF8Unsafe(kDirectoryPath), |
- true /* recursive */, |
- base::Bind(&util::LogStatusCallback, &callback_log)); |
- observe_directory.SetDispatchEventImplForTesting( |
+ AddWatcher add_watcher(NULL, |
+ file_system_info_, |
+ base::FilePath::FromUTF8Unsafe(kEntryPath), |
+ true /* recursive */, |
+ base::Bind(&util::LogStatusCallback, &callback_log)); |
+ add_watcher.SetDispatchEventImplForTesting( |
base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
base::Unretained(&dispatcher))); |
- EXPECT_TRUE(observe_directory.Execute(kRequestId)); |
+ EXPECT_TRUE(add_watcher.Execute(kRequestId)); |
ASSERT_EQ(1u, dispatcher.events().size()); |
extensions::Event* event = dispatcher.events()[0]; |
- EXPECT_EQ(extensions::api::file_system_provider::OnObserveDirectoryRequested:: |
- kEventName, |
- event->event_name); |
+ EXPECT_EQ( |
+ extensions::api::file_system_provider::OnAddWatcherRequested::kEventName, |
+ event->event_name); |
base::ListValue* event_args = event->event_args.get(); |
ASSERT_EQ(1u, event_args->GetSize()); |
const base::DictionaryValue* options_as_value = NULL; |
ASSERT_TRUE(event_args->GetDictionary(0, &options_as_value)); |
- ObserveDirectoryRequestedOptions options; |
+ AddWatcherRequestedOptions options; |
ASSERT_TRUE( |
- ObserveDirectoryRequestedOptions::Populate(*options_as_value, &options)); |
+ AddWatcherRequestedOptions::Populate(*options_as_value, &options)); |
EXPECT_EQ(kFileSystemId, options.file_system_id); |
EXPECT_EQ(kRequestId, options.request_id); |
- EXPECT_EQ(kDirectoryPath, options.directory_path); |
+ EXPECT_EQ(kEntryPath, options.entry_path); |
EXPECT_TRUE(options.recursive); |
} |
-TEST_F(FileSystemProviderOperationsObserveDirectoryTest, Execute_NoListener) { |
+TEST_F(FileSystemProviderOperationsAddWatcherTest, Execute_NoListener) { |
util::LoggingDispatchEventImpl dispatcher(false /* dispatch_reply */); |
util::StatusCallbackLog callback_log; |
- ObserveDirectory observe_directory( |
- NULL, |
- file_system_info_, |
- base::FilePath::FromUTF8Unsafe(kDirectoryPath), |
- true /* recursive */, |
- base::Bind(&util::LogStatusCallback, &callback_log)); |
- observe_directory.SetDispatchEventImplForTesting( |
+ AddWatcher add_watcher(NULL, |
+ file_system_info_, |
+ base::FilePath::FromUTF8Unsafe(kEntryPath), |
+ true /* recursive */, |
+ base::Bind(&util::LogStatusCallback, &callback_log)); |
+ add_watcher.SetDispatchEventImplForTesting( |
base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
base::Unretained(&dispatcher))); |
- EXPECT_FALSE(observe_directory.Execute(kRequestId)); |
+ EXPECT_FALSE(add_watcher.Execute(kRequestId)); |
} |
-TEST_F(FileSystemProviderOperationsObserveDirectoryTest, OnSuccess) { |
+TEST_F(FileSystemProviderOperationsAddWatcherTest, OnSuccess) { |
util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
util::StatusCallbackLog callback_log; |
- ObserveDirectory observe_directory( |
- NULL, |
- file_system_info_, |
- base::FilePath::FromUTF8Unsafe(kDirectoryPath), |
- true /* recursive */, |
- base::Bind(&util::LogStatusCallback, &callback_log)); |
- observe_directory.SetDispatchEventImplForTesting( |
+ AddWatcher add_watcher(NULL, |
+ file_system_info_, |
+ base::FilePath::FromUTF8Unsafe(kEntryPath), |
+ true /* recursive */, |
+ base::Bind(&util::LogStatusCallback, &callback_log)); |
+ add_watcher.SetDispatchEventImplForTesting( |
base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
base::Unretained(&dispatcher))); |
- EXPECT_TRUE(observe_directory.Execute(kRequestId)); |
+ EXPECT_TRUE(add_watcher.Execute(kRequestId)); |
- observe_directory.OnSuccess(kRequestId, |
- scoped_ptr<RequestValue>(new RequestValue()), |
- false /* has_more */); |
+ add_watcher.OnSuccess(kRequestId, |
+ scoped_ptr<RequestValue>(new RequestValue()), |
+ false /* has_more */); |
ASSERT_EQ(1u, callback_log.size()); |
EXPECT_EQ(base::File::FILE_OK, callback_log[0]); |
} |
-TEST_F(FileSystemProviderOperationsObserveDirectoryTest, OnError) { |
+TEST_F(FileSystemProviderOperationsAddWatcherTest, OnError) { |
util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
util::StatusCallbackLog callback_log; |
- ObserveDirectory observe_directory( |
- NULL, |
- file_system_info_, |
- base::FilePath::FromUTF8Unsafe(kDirectoryPath), |
- true /* recursive */, |
- base::Bind(&util::LogStatusCallback, &callback_log)); |
- observe_directory.SetDispatchEventImplForTesting( |
+ AddWatcher add_watcher(NULL, |
+ file_system_info_, |
+ base::FilePath::FromUTF8Unsafe(kEntryPath), |
+ true /* recursive */, |
+ base::Bind(&util::LogStatusCallback, &callback_log)); |
+ add_watcher.SetDispatchEventImplForTesting( |
base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
base::Unretained(&dispatcher))); |
- EXPECT_TRUE(observe_directory.Execute(kRequestId)); |
+ EXPECT_TRUE(add_watcher.Execute(kRequestId)); |
- observe_directory.OnError(kRequestId, |
- scoped_ptr<RequestValue>(new RequestValue()), |
- base::File::FILE_ERROR_TOO_MANY_OPENED); |
+ add_watcher.OnError(kRequestId, |
+ scoped_ptr<RequestValue>(new RequestValue()), |
+ base::File::FILE_ERROR_TOO_MANY_OPENED); |
ASSERT_EQ(1u, callback_log.size()); |
EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); |
} |