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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/operations/copy_entry_unittest.cc

Issue 1137383002: Show the eject button only for removabled and file handlers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed tests. Created 5 years, 7 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 unified diff | Download patch
OLDNEW
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/chromeos/file_system_provider/operations/copy_entry.h" 5 #include "chrome/browser/chromeos/file_system_provider/operations/copy_entry.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"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
14 #include "chrome/browser/chromeos/file_system_provider/operations/test_util.h" 14 #include "chrome/browser/chromeos/file_system_provider/operations/test_util.h"
15 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte rface.h" 15 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte rface.h"
16 #include "chrome/common/extensions/api/file_system_provider.h" 16 #include "chrome/common/extensions/api/file_system_provider.h"
17 #include "chrome/common/extensions/api/file_system_provider_capabilities/file_sy stem_provider_capabilities_handler.h"
17 #include "chrome/common/extensions/api/file_system_provider_internal.h" 18 #include "chrome/common/extensions/api/file_system_provider_internal.h"
18 #include "extensions/browser/event_router.h" 19 #include "extensions/browser/event_router.h"
19 #include "storage/browser/fileapi/async_file_util.h" 20 #include "storage/browser/fileapi/async_file_util.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 22
22 namespace chromeos { 23 namespace chromeos {
23 namespace file_system_provider { 24 namespace file_system_provider {
24 namespace operations { 25 namespace operations {
25 namespace { 26 namespace {
26 27
27 const char kExtensionId[] = "mbflcebpggnecokmikipoihdbecnjfoj"; 28 const char kExtensionId[] = "mbflcebpggnecokmikipoihdbecnjfoj";
28 const char kFileSystemId[] = "testing-file-system"; 29 const char kFileSystemId[] = "testing-file-system";
29 const int kRequestId = 2; 30 const int kRequestId = 2;
30 const base::FilePath::CharType kSourcePath[] = 31 const base::FilePath::CharType kSourcePath[] =
31 FILE_PATH_LITERAL("/bunny/and/bear/happy"); 32 FILE_PATH_LITERAL("/bunny/and/bear/happy");
32 const base::FilePath::CharType kTargetPath[] = 33 const base::FilePath::CharType kTargetPath[] =
33 FILE_PATH_LITERAL("/kitty/and/puppy/happy"); 34 FILE_PATH_LITERAL("/kitty/and/puppy/happy");
34 35
35 } // namespace 36 } // namespace
36 37
37 class FileSystemProviderOperationsCopyEntryTest : public testing::Test { 38 class FileSystemProviderOperationsCopyEntryTest : public testing::Test {
38 protected: 39 protected:
39 FileSystemProviderOperationsCopyEntryTest() {} 40 FileSystemProviderOperationsCopyEntryTest() {}
40 ~FileSystemProviderOperationsCopyEntryTest() override {} 41 ~FileSystemProviderOperationsCopyEntryTest() override {}
41 42
42 void SetUp() override { 43 void SetUp() override {
43 MountOptions mount_options(kFileSystemId, "" /* display_name */); 44 MountOptions mount_options(kFileSystemId, "" /* display_name */);
44 mount_options.writable = true; 45 mount_options.writable = true;
45 file_system_info_ = 46 file_system_info_ = ProvidedFileSystemInfo(
46 ProvidedFileSystemInfo(kExtensionId, mount_options, base::FilePath()); 47 kExtensionId, mount_options, base::FilePath(), false /* configurable */,
48 extensions::SOURCE_FILE);
47 } 49 }
48 50
49 ProvidedFileSystemInfo file_system_info_; 51 ProvidedFileSystemInfo file_system_info_;
50 }; 52 };
51 53
52 TEST_F(FileSystemProviderOperationsCopyEntryTest, Execute) { 54 TEST_F(FileSystemProviderOperationsCopyEntryTest, Execute) {
53 using extensions::api::file_system_provider::CopyEntryRequestedOptions; 55 using extensions::api::file_system_provider::CopyEntryRequestedOptions;
54 56
55 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); 57 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
56 util::StatusCallbackLog callback_log; 58 util::StatusCallbackLog callback_log;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 base::Unretained(&dispatcher))); 97 base::Unretained(&dispatcher)));
96 98
97 EXPECT_FALSE(copy_entry.Execute(kRequestId)); 99 EXPECT_FALSE(copy_entry.Execute(kRequestId));
98 } 100 }
99 101
100 TEST_F(FileSystemProviderOperationsCopyEntryTest, Execute_ReadOnly) { 102 TEST_F(FileSystemProviderOperationsCopyEntryTest, Execute_ReadOnly) {
101 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); 103 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
102 util::StatusCallbackLog callback_log; 104 util::StatusCallbackLog callback_log;
103 105
104 const ProvidedFileSystemInfo read_only_file_system_info( 106 const ProvidedFileSystemInfo read_only_file_system_info(
105 kExtensionId, 107 kExtensionId, MountOptions(kFileSystemId, "" /* display_name */),
106 MountOptions(kFileSystemId, "" /* display_name */), 108 base::FilePath() /* mount_path */, false /* configurable */,
107 base::FilePath() /* mount_path */); 109 extensions::SOURCE_FILE);
108 110
109 CopyEntry copy_entry(NULL, read_only_file_system_info, 111 CopyEntry copy_entry(NULL, read_only_file_system_info,
110 base::FilePath(kSourcePath), base::FilePath(kTargetPath), 112 base::FilePath(kSourcePath), base::FilePath(kTargetPath),
111 base::Bind(&util::LogStatusCallback, &callback_log)); 113 base::Bind(&util::LogStatusCallback, &callback_log));
112 copy_entry.SetDispatchEventImplForTesting( 114 copy_entry.SetDispatchEventImplForTesting(
113 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, 115 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl,
114 base::Unretained(&dispatcher))); 116 base::Unretained(&dispatcher)));
115 117
116 EXPECT_FALSE(copy_entry.Execute(kRequestId)); 118 EXPECT_FALSE(copy_entry.Execute(kRequestId));
117 } 119 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 copy_entry.OnError(kRequestId, 154 copy_entry.OnError(kRequestId,
153 scoped_ptr<RequestValue>(new RequestValue()), 155 scoped_ptr<RequestValue>(new RequestValue()),
154 base::File::FILE_ERROR_TOO_MANY_OPENED); 156 base::File::FILE_ERROR_TOO_MANY_OPENED);
155 ASSERT_EQ(1u, callback_log.size()); 157 ASSERT_EQ(1u, callback_log.size());
156 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); 158 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]);
157 } 159 }
158 160
159 } // namespace operations 161 } // namespace operations
160 } // namespace file_system_provider 162 } // namespace file_system_provider
161 } // namespace chromeos 163 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698