Index: chrome/browser/chromeos/file_system_provider/operations/copy_entry_unittest.cc |
diff --git a/chrome/browser/chromeos/file_system_provider/operations/close_file_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/copy_entry_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/copy_entry_unittest.cc |
index c4af6106088a6c9412605881343c303d5d25d7d2..1144a74d8034071b3db7b5f7ef946b49e347c344 100644 |
--- a/chrome/browser/chromeos/file_system_provider/operations/close_file_unittest.cc |
+++ b/chrome/browser/chromeos/file_system_provider/operations/copy_entry_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/close_file.h" |
+#include "chrome/browser/chromeos/file_system_provider/operations/copy_entry.h" |
#include <string> |
#include <vector> |
@@ -10,6 +10,7 @@ |
#include "base/files/file.h" |
#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/test_util.h" |
#include "chrome/browser/chromeos/file_system_provider/provided_file_system_interface.h" |
#include "chrome/common/extensions/api/file_system_provider.h" |
@@ -26,45 +27,47 @@ namespace { |
const char kExtensionId[] = "mbflcebpggnecokmikipoihdbecnjfoj"; |
const char kFileSystemId[] = "testing-file-system"; |
const int kRequestId = 2; |
-const int kOpenRequestId = 3; |
+const base::FilePath::CharType kSourcePath[] = "/bunny/and/bear/happy"; |
+const base::FilePath::CharType kTargetPath[] = "/kitty/and/puppy/happy"; |
} // namespace |
-class FileSystemProviderOperationsCloseFileTest : public testing::Test { |
+class FileSystemProviderOperationsCopyEntryTest : public testing::Test { |
protected: |
- FileSystemProviderOperationsCloseFileTest() {} |
- virtual ~FileSystemProviderOperationsCloseFileTest() {} |
+ FileSystemProviderOperationsCopyEntryTest() {} |
+ virtual ~FileSystemProviderOperationsCopyEntryTest() {} |
virtual void SetUp() OVERRIDE { |
file_system_info_ = |
ProvidedFileSystemInfo(kExtensionId, |
kFileSystemId, |
- "" /* display_name */, |
- false /* writable */, |
+ "" /* file_system_name */, |
+ true /* writable */, |
base::FilePath() /* mount_path */); |
} |
ProvidedFileSystemInfo file_system_info_; |
}; |
-TEST_F(FileSystemProviderOperationsCloseFileTest, Execute) { |
+TEST_F(FileSystemProviderOperationsCopyEntryTest, Execute) { |
util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
util::StatusCallbackLog callback_log; |
- CloseFile close_file(NULL, |
+ CopyEntry copy_entry(NULL, |
file_system_info_, |
- kOpenRequestId, |
+ base::FilePath::FromUTF8Unsafe(kSourcePath), |
+ base::FilePath::FromUTF8Unsafe(kTargetPath), |
base::Bind(&util::LogStatusCallback, &callback_log)); |
- close_file.SetDispatchEventImplForTesting( |
+ copy_entry.SetDispatchEventImplForTesting( |
base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
base::Unretained(&dispatcher))); |
- EXPECT_TRUE(close_file.Execute(kRequestId)); |
+ EXPECT_TRUE(copy_entry.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::OnCopyEntryRequested::kEventName, |
event->event_name); |
base::ListValue* event_args = event->event_args.get(); |
ASSERT_EQ(1u, event_args->GetSize()); |
@@ -80,62 +83,69 @@ TEST_F(FileSystemProviderOperationsCloseFileTest, Execute) { |
EXPECT_TRUE(options->GetInteger("requestId", &event_request_id)); |
EXPECT_EQ(kRequestId, event_request_id); |
- int event_open_request_id = -1; |
- EXPECT_TRUE(options->GetInteger("openRequestId", &event_open_request_id)); |
- EXPECT_EQ(kOpenRequestId, event_open_request_id); |
+ std::string event_source_path; |
+ EXPECT_TRUE(options->GetString("sourcePath", &event_source_path)); |
+ EXPECT_EQ(kSourcePath, event_source_path); |
+ |
+ std::string event_target_path; |
+ EXPECT_TRUE(options->GetString("targetPath", &event_target_path)); |
+ EXPECT_EQ(kTargetPath, event_target_path); |
} |
-TEST_F(FileSystemProviderOperationsCloseFileTest, Execute_NoListener) { |
+TEST_F(FileSystemProviderOperationsCopyEntryTest, Execute_NoListener) { |
util::LoggingDispatchEventImpl dispatcher(false /* dispatch_reply */); |
util::StatusCallbackLog callback_log; |
- CloseFile close_file(NULL, |
+ CopyEntry copy_entry(NULL, |
file_system_info_, |
- kOpenRequestId, |
+ base::FilePath::FromUTF8Unsafe(kSourcePath), |
+ base::FilePath::FromUTF8Unsafe(kTargetPath), |
base::Bind(&util::LogStatusCallback, &callback_log)); |
- close_file.SetDispatchEventImplForTesting( |
+ copy_entry.SetDispatchEventImplForTesting( |
base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
base::Unretained(&dispatcher))); |
- EXPECT_FALSE(close_file.Execute(kRequestId)); |
+ EXPECT_FALSE(copy_entry.Execute(kRequestId)); |
} |
-TEST_F(FileSystemProviderOperationsCloseFileTest, OnSuccess) { |
+TEST_F(FileSystemProviderOperationsCopyEntryTest, OnSuccess) { |
util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
util::StatusCallbackLog callback_log; |
- CloseFile close_file(NULL, |
+ CopyEntry copy_entry(NULL, |
file_system_info_, |
- kOpenRequestId, |
+ base::FilePath::FromUTF8Unsafe(kSourcePath), |
+ base::FilePath::FromUTF8Unsafe(kTargetPath), |
base::Bind(&util::LogStatusCallback, &callback_log)); |
- close_file.SetDispatchEventImplForTesting( |
+ copy_entry.SetDispatchEventImplForTesting( |
base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
base::Unretained(&dispatcher))); |
- EXPECT_TRUE(close_file.Execute(kRequestId)); |
+ EXPECT_TRUE(copy_entry.Execute(kRequestId)); |
- close_file.OnSuccess(kRequestId, |
+ copy_entry.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(FileSystemProviderOperationsCloseFileTest, OnError) { |
+TEST_F(FileSystemProviderOperationsCopyEntryTest, OnError) { |
util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
util::StatusCallbackLog callback_log; |
- CloseFile close_file(NULL, |
+ CopyEntry copy_entry(NULL, |
file_system_info_, |
- kOpenRequestId, |
+ base::FilePath::FromUTF8Unsafe(kSourcePath), |
+ base::FilePath::FromUTF8Unsafe(kTargetPath), |
base::Bind(&util::LogStatusCallback, &callback_log)); |
- close_file.SetDispatchEventImplForTesting( |
+ copy_entry.SetDispatchEventImplForTesting( |
base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
base::Unretained(&dispatcher))); |
- EXPECT_TRUE(close_file.Execute(kRequestId)); |
+ EXPECT_TRUE(copy_entry.Execute(kRequestId)); |
- close_file.OnError(kRequestId, |
+ copy_entry.OnError(kRequestId, |
scoped_ptr<RequestValue>(new RequestValue()), |
base::File::FILE_ERROR_TOO_MANY_OPENED); |
ASSERT_EQ(1u, callback_log.size()); |