| Index: chrome/browser/chromeos/file_system_provider/operations/unmount_unittest.cc
|
| diff --git a/chrome/browser/chromeos/file_system_provider/operations/close_file_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/unmount_unittest.cc
|
| similarity index 64%
|
| copy from chrome/browser/chromeos/file_system_provider/operations/close_file_unittest.cc
|
| copy to chrome/browser/chromeos/file_system_provider/operations/unmount_unittest.cc
|
| index c11101b97b267405bbfc5d5e3ee960327c5408af..5dcc2858de5061615533e7c2a643954a01ae5f6d 100644
|
| --- a/chrome/browser/chromeos/file_system_provider/operations/close_file_unittest.cc
|
| +++ b/chrome/browser/chromeos/file_system_provider/operations/unmount_unittest.cc
|
| @@ -9,13 +9,12 @@
|
| #include "base/files/file_path.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/memory/scoped_vector.h"
|
| -#include "chrome/browser/chromeos/file_system_provider/operations/close_file.h"
|
| +#include "chrome/browser/chromeos/file_system_provider/operations/unmount.h"
|
| #include "chrome/browser/chromeos/file_system_provider/provided_file_system_interface.h"
|
| #include "chrome/common/extensions/api/file_system_provider.h"
|
| #include "chrome/common/extensions/api/file_system_provider_internal.h"
|
| #include "extensions/browser/event_router.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| -#include "webkit/browser/fileapi/async_file_util.h"
|
|
|
| namespace chromeos {
|
| namespace file_system_provider {
|
| @@ -25,7 +24,6 @@ namespace {
|
| const char kExtensionId[] = "mbflcebpggnecokmikipoihdbecnjfoj";
|
| const char kFileSystemId[] = "testing-file-system";
|
| const int kRequestId = 2;
|
| -const int kOpenRequestId = 3;
|
|
|
| // Fake event dispatcher implementation with extra logging capability. Acts as
|
| // a providing extension end-point.
|
| @@ -55,7 +53,7 @@ class CallbackLogger {
|
| CallbackLogger() : weak_ptr_factory_(this) {}
|
| virtual ~CallbackLogger() {}
|
|
|
| - void OnCloseFile(base::File::Error result) { events_.push_back(result); }
|
| + void OnUnmount(base::File::Error result) { events_.push_back(result); }
|
|
|
| std::vector<base::File::Error>& events() { return events_; }
|
|
|
| @@ -65,6 +63,7 @@ class CallbackLogger {
|
|
|
| private:
|
| std::vector<base::File::Error> events_;
|
| + bool dispatch_reply_;
|
| base::WeakPtrFactory<CallbackLogger> weak_ptr_factory_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(CallbackLogger);
|
| @@ -72,10 +71,10 @@ class CallbackLogger {
|
|
|
| } // namespace
|
|
|
| -class FileSystemProviderOperationsCloseFileTest : public testing::Test {
|
| +class FileSystemProviderOperationsUnmountTest : public testing::Test {
|
| protected:
|
| - FileSystemProviderOperationsCloseFileTest() {}
|
| - virtual ~FileSystemProviderOperationsCloseFileTest() {}
|
| + FileSystemProviderOperationsUnmountTest() {}
|
| + virtual ~FileSystemProviderOperationsUnmountTest() {}
|
|
|
| virtual void SetUp() OVERRIDE {
|
| file_system_info_ =
|
| @@ -88,28 +87,27 @@ class FileSystemProviderOperationsCloseFileTest : public testing::Test {
|
| ProvidedFileSystemInfo file_system_info_;
|
| };
|
|
|
| -TEST_F(FileSystemProviderOperationsCloseFileTest, Execute) {
|
| +TEST_F(FileSystemProviderOperationsUnmountTest, Execute) {
|
| LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
|
| CallbackLogger callback_logger;
|
|
|
| - CloseFile close_file(
|
| + Unmount unmount(
|
| NULL,
|
| file_system_info_,
|
| - kOpenRequestId,
|
| - base::Bind(&CallbackLogger::OnCloseFile, callback_logger.GetWeakPtr()));
|
| - close_file.SetDispatchEventImplForTesting(
|
| + base::Bind(&CallbackLogger::OnUnmount, callback_logger.GetWeakPtr()));
|
| + unmount.SetDispatchEventImplForTesting(
|
| base::Bind(&LoggingDispatchEventImpl::OnDispatchEventImpl,
|
| base::Unretained(&dispatcher)));
|
|
|
| - EXPECT_TRUE(close_file.Execute(kRequestId));
|
| + EXPECT_TRUE(unmount.Execute(kRequestId));
|
|
|
| ASSERT_EQ(1u, dispatcher.events().size());
|
| extensions::Event* event = dispatcher.events()[0];
|
| EXPECT_EQ(
|
| - extensions::api::file_system_provider::OnCloseFileRequested::kEventName,
|
| + extensions::api::file_system_provider::OnUnmountRequested::kEventName,
|
| event->event_name);
|
| base::ListValue* event_args = event->event_args.get();
|
| - ASSERT_EQ(3u, event_args->GetSize());
|
| + ASSERT_EQ(2u, event_args->GetSize());
|
|
|
| std::string event_file_system_id;
|
| EXPECT_TRUE(event_args->GetString(0, &event_file_system_id));
|
| @@ -118,75 +116,69 @@ TEST_F(FileSystemProviderOperationsCloseFileTest, Execute) {
|
| int event_request_id = -1;
|
| EXPECT_TRUE(event_args->GetInteger(1, &event_request_id));
|
| EXPECT_EQ(kRequestId, event_request_id);
|
| -
|
| - int event_open_request_id = -1;
|
| - EXPECT_TRUE(event_args->GetInteger(2, &event_open_request_id));
|
| - EXPECT_EQ(kOpenRequestId, event_open_request_id);
|
| }
|
|
|
| -TEST_F(FileSystemProviderOperationsCloseFileTest, Execute_NoListener) {
|
| +TEST_F(FileSystemProviderOperationsUnmountTest, Execute_NoListener) {
|
| LoggingDispatchEventImpl dispatcher(false /* dispatch_reply */);
|
| CallbackLogger callback_logger;
|
|
|
| - CloseFile close_file(
|
| + Unmount unmount(
|
| NULL,
|
| file_system_info_,
|
| - kOpenRequestId,
|
| - base::Bind(&CallbackLogger::OnCloseFile, callback_logger.GetWeakPtr()));
|
| - close_file.SetDispatchEventImplForTesting(
|
| + base::Bind(&CallbackLogger::OnUnmount, callback_logger.GetWeakPtr()));
|
| + unmount.SetDispatchEventImplForTesting(
|
| base::Bind(&LoggingDispatchEventImpl::OnDispatchEventImpl,
|
| base::Unretained(&dispatcher)));
|
|
|
| - EXPECT_FALSE(close_file.Execute(kRequestId));
|
| + EXPECT_FALSE(unmount.Execute(kRequestId));
|
| }
|
|
|
| -TEST_F(FileSystemProviderOperationsCloseFileTest, OnSuccess) {
|
| +TEST_F(FileSystemProviderOperationsUnmountTest, OnSuccess) {
|
| using extensions::api::file_system_provider_internal::
|
| - CloseFileRequestedSuccess::Params;
|
| + UnmountRequestedSuccess::Params;
|
|
|
| LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
|
| CallbackLogger callback_logger;
|
|
|
| - CloseFile close_file(
|
| + Unmount unmount(
|
| NULL,
|
| file_system_info_,
|
| - kOpenRequestId,
|
| - base::Bind(&CallbackLogger::OnCloseFile, callback_logger.GetWeakPtr()));
|
| - close_file.SetDispatchEventImplForTesting(
|
| + base::Bind(&CallbackLogger::OnUnmount, callback_logger.GetWeakPtr()));
|
| + unmount.SetDispatchEventImplForTesting(
|
| base::Bind(&LoggingDispatchEventImpl::OnDispatchEventImpl,
|
| base::Unretained(&dispatcher)));
|
|
|
| - EXPECT_TRUE(close_file.Execute(kRequestId));
|
| + EXPECT_TRUE(unmount.Execute(kRequestId));
|
|
|
| - close_file.OnSuccess(kRequestId,
|
| - scoped_ptr<RequestValue>(new RequestValue()),
|
| - false /* has_next */);
|
| + unmount.OnSuccess(kRequestId,
|
| + scoped_ptr<RequestValue>(new RequestValue()),
|
| + false /* has_more */);
|
| ASSERT_EQ(1u, callback_logger.events().size());
|
| - EXPECT_EQ(base::File::FILE_OK, callback_logger.events()[0]);
|
| + base::File::Error event_result = callback_logger.events()[0];
|
| + EXPECT_EQ(base::File::FILE_OK, event_result);
|
| }
|
|
|
| -TEST_F(FileSystemProviderOperationsCloseFileTest, OnError) {
|
| - using extensions::api::file_system_provider_internal::
|
| - CloseFileRequestedError::Params;
|
| +TEST_F(FileSystemProviderOperationsUnmountTest, OnError) {
|
| + using extensions::api::file_system_provider_internal::UnmountRequestedError::
|
| + Params;
|
|
|
| LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
|
| CallbackLogger callback_logger;
|
|
|
| - CloseFile close_file(
|
| + Unmount unmount(
|
| NULL,
|
| file_system_info_,
|
| - kOpenRequestId,
|
| - base::Bind(&CallbackLogger::OnCloseFile, callback_logger.GetWeakPtr()));
|
| - close_file.SetDispatchEventImplForTesting(
|
| + base::Bind(&CallbackLogger::OnUnmount, callback_logger.GetWeakPtr()));
|
| + unmount.SetDispatchEventImplForTesting(
|
| base::Bind(&LoggingDispatchEventImpl::OnDispatchEventImpl,
|
| base::Unretained(&dispatcher)));
|
|
|
| - EXPECT_TRUE(close_file.Execute(kRequestId));
|
| + EXPECT_TRUE(unmount.Execute(kRequestId));
|
|
|
| - close_file.OnError(kRequestId, base::File::FILE_ERROR_TOO_MANY_OPENED);
|
| + unmount.OnError(kRequestId, base::File::FILE_ERROR_NOT_FOUND);
|
| ASSERT_EQ(1u, callback_logger.events().size());
|
| - EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED,
|
| - callback_logger.events()[0]);
|
| + base::File::Error event_result = callback_logger.events()[0];
|
| + EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, event_result);
|
| }
|
|
|
| } // namespace operations
|
|
|