Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Unified Diff: chrome/browser/chromeos/file_system_provider/operations/observe_directory_unittest.cc

Issue 625463002: [fsp] Add support for observing entries and notifying about changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/file_system_provider/operations/observe_directory_unittest.cc
diff --git a/chrome/browser/chromeos/file_system_provider/operations/create_directory_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/observe_directory_unittest.cc
similarity index 61%
copy from chrome/browser/chromeos/file_system_provider/operations/create_directory_unittest.cc
copy to chrome/browser/chromeos/file_system_provider/operations/observe_directory_unittest.cc
index aa067069823194837274b7f575033fa504be8b09..c2b946db26f80c8f864c187cb0498d8f3591b815 100644
--- a/chrome/browser/chromeos/file_system_provider/operations/create_directory_unittest.cc
+++ b/chrome/browser/chromeos/file_system_provider/operations/observe_directory_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/create_directory.h"
+#include "chrome/browser/chromeos/file_system_provider/operations/observe_directory.h"
#include <string>
#include <vector>
@@ -31,44 +31,45 @@ const base::FilePath::CharType kDirectoryPath[] = "/kitty/and/puppy/happy";
} // namespace
-class FileSystemProviderOperationsCreateDirectoryTest : public testing::Test {
+class FileSystemProviderOperationsObserveDirectoryTest : public testing::Test {
protected:
- FileSystemProviderOperationsCreateDirectoryTest() {}
- virtual ~FileSystemProviderOperationsCreateDirectoryTest() {}
+ FileSystemProviderOperationsObserveDirectoryTest() {}
+ virtual ~FileSystemProviderOperationsObserveDirectoryTest() {}
virtual void SetUp() override {
file_system_info_ =
ProvidedFileSystemInfo(kExtensionId,
kFileSystemId,
"" /* file_system_name */,
- true /* writable */,
+ false /* writable */,
+ false /* supports_notify_tag */,
base::FilePath() /* mount_path */);
}
ProvidedFileSystemInfo file_system_info_;
};
-TEST_F(FileSystemProviderOperationsCreateDirectoryTest, Execute) {
- using extensions::api::file_system_provider::CreateDirectoryRequestedOptions;
+TEST_F(FileSystemProviderOperationsObserveDirectoryTest, Execute) {
+ using extensions::api::file_system_provider::ObserveDirectoryRequestedOptions;
util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
util::StatusCallbackLog callback_log;
- CreateDirectory create_directory(
+ ObserveDirectory observe_directory(
NULL,
file_system_info_,
base::FilePath::FromUTF8Unsafe(kDirectoryPath),
true /* recursive */,
base::Bind(&util::LogStatusCallback, &callback_log));
- create_directory.SetDispatchEventImplForTesting(
+ observe_directory.SetDispatchEventImplForTesting(
base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl,
base::Unretained(&dispatcher)));
- EXPECT_TRUE(create_directory.Execute(kRequestId));
+ EXPECT_TRUE(observe_directory.Execute(kRequestId));
ASSERT_EQ(1u, dispatcher.events().size());
extensions::Event* event = dispatcher.events()[0];
- EXPECT_EQ(extensions::api::file_system_provider::OnCreateDirectoryRequested::
+ EXPECT_EQ(extensions::api::file_system_provider::OnObserveDirectoryRequested::
kEventName,
event->event_name);
base::ListValue* event_args = event->event_args.get();
@@ -77,98 +78,74 @@ TEST_F(FileSystemProviderOperationsCreateDirectoryTest, Execute) {
const base::DictionaryValue* options_as_value = NULL;
ASSERT_TRUE(event_args->GetDictionary(0, &options_as_value));
- CreateDirectoryRequestedOptions options;
+ ObserveDirectoryRequestedOptions options;
ASSERT_TRUE(
- CreateDirectoryRequestedOptions::Populate(*options_as_value, &options));
+ ObserveDirectoryRequestedOptions::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_TRUE(options.recursive);
}
-TEST_F(FileSystemProviderOperationsCreateDirectoryTest, Execute_NoListener) {
+TEST_F(FileSystemProviderOperationsObserveDirectoryTest, Execute_NoListener) {
util::LoggingDispatchEventImpl dispatcher(false /* dispatch_reply */);
util::StatusCallbackLog callback_log;
- CreateDirectory create_directory(
+ ObserveDirectory observe_directory(
NULL,
file_system_info_,
base::FilePath::FromUTF8Unsafe(kDirectoryPath),
true /* recursive */,
base::Bind(&util::LogStatusCallback, &callback_log));
- create_directory.SetDispatchEventImplForTesting(
+ observe_directory.SetDispatchEventImplForTesting(
base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl,
base::Unretained(&dispatcher)));
- EXPECT_FALSE(create_directory.Execute(kRequestId));
+ EXPECT_FALSE(observe_directory.Execute(kRequestId));
}
-TEST_F(FileSystemProviderOperationsCreateDirectoryTest, Execute_ReadOnly) {
+TEST_F(FileSystemProviderOperationsObserveDirectoryTest, OnSuccess) {
util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
util::StatusCallbackLog callback_log;
- const ProvidedFileSystemInfo read_only_file_system_info(
- kExtensionId,
- kFileSystemId,
- "" /* file_system_name */,
- false /* writable */,
- base::FilePath() /* mount_path */);
-
- CreateDirectory create_directory(
- NULL,
- read_only_file_system_info,
- base::FilePath::FromUTF8Unsafe(kDirectoryPath),
- true /* recursive */,
- base::Bind(&util::LogStatusCallback, &callback_log));
- create_directory.SetDispatchEventImplForTesting(
- base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl,
- base::Unretained(&dispatcher)));
-
- EXPECT_FALSE(create_directory.Execute(kRequestId));
-}
-
-TEST_F(FileSystemProviderOperationsCreateDirectoryTest, OnSuccess) {
- util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
- util::StatusCallbackLog callback_log;
-
- CreateDirectory create_directory(
+ ObserveDirectory observe_directory(
NULL,
file_system_info_,
base::FilePath::FromUTF8Unsafe(kDirectoryPath),
true /* recursive */,
base::Bind(&util::LogStatusCallback, &callback_log));
- create_directory.SetDispatchEventImplForTesting(
+ observe_directory.SetDispatchEventImplForTesting(
base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl,
base::Unretained(&dispatcher)));
- EXPECT_TRUE(create_directory.Execute(kRequestId));
+ EXPECT_TRUE(observe_directory.Execute(kRequestId));
- create_directory.OnSuccess(kRequestId,
- scoped_ptr<RequestValue>(new RequestValue()),
- false /* has_more */);
+ observe_directory.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(FileSystemProviderOperationsCreateDirectoryTest, OnError) {
+TEST_F(FileSystemProviderOperationsObserveDirectoryTest, OnError) {
util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
util::StatusCallbackLog callback_log;
- CreateDirectory create_directory(
+ ObserveDirectory observe_directory(
NULL,
file_system_info_,
base::FilePath::FromUTF8Unsafe(kDirectoryPath),
true /* recursive */,
base::Bind(&util::LogStatusCallback, &callback_log));
- create_directory.SetDispatchEventImplForTesting(
+ observe_directory.SetDispatchEventImplForTesting(
base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl,
base::Unretained(&dispatcher)));
- EXPECT_TRUE(create_directory.Execute(kRequestId));
+ EXPECT_TRUE(observe_directory.Execute(kRequestId));
- create_directory.OnError(kRequestId,
- scoped_ptr<RequestValue>(new RequestValue()),
- base::File::FILE_ERROR_TOO_MANY_OPENED);
+ observe_directory.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]);
}

Powered by Google App Engine
This is Rietveld 408576698