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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/operations/move_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/move_entry.h" 5 #include "chrome/browser/chromeos/file_system_provider/operations/move_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"
18 #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" 19 #include "chrome/common/extensions/api/file_system_provider_internal.h"
18 #include "extensions/browser/event_router.h" 20 #include "extensions/browser/event_router.h"
19 #include "storage/browser/fileapi/async_file_util.h" 21 #include "storage/browser/fileapi/async_file_util.h"
20 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
21 23
22 namespace chromeos { 24 namespace chromeos {
23 namespace file_system_provider { 25 namespace file_system_provider {
24 namespace operations { 26 namespace operations {
25 namespace { 27 namespace {
26 28
27 const char kExtensionId[] = "mbflcebpggnecokmikipoihdbecnjfoj"; 29 const char kExtensionId[] = "mbflcebpggnecokmikipoihdbecnjfoj";
28 const char kFileSystemId[] = "testing-file-system"; 30 const char kFileSystemId[] = "testing-file-system";
29 const int kRequestId = 2; 31 const int kRequestId = 2;
30 const base::FilePath::CharType kSourcePath[] = 32 const base::FilePath::CharType kSourcePath[] =
31 FILE_PATH_LITERAL("/bunny/and/bear/happy"); 33 FILE_PATH_LITERAL("/bunny/and/bear/happy");
32 const base::FilePath::CharType kTargetPath[] = 34 const base::FilePath::CharType kTargetPath[] =
33 FILE_PATH_LITERAL("/kitty/and/puppy/happy"); 35 FILE_PATH_LITERAL("/kitty/and/puppy/happy");
34 36
35 } // namespace 37 } // namespace
36 38
37 class FileSystemProviderOperationsMoveEntryTest : public testing::Test { 39 class FileSystemProviderOperationsMoveEntryTest : public testing::Test {
38 protected: 40 protected:
39 FileSystemProviderOperationsMoveEntryTest() {} 41 FileSystemProviderOperationsMoveEntryTest() {}
40 ~FileSystemProviderOperationsMoveEntryTest() override {} 42 ~FileSystemProviderOperationsMoveEntryTest() override {}
41 43
42 void SetUp() override { 44 void SetUp() override {
43 MountOptions mount_options(kFileSystemId, "" /* display_name */); 45 MountOptions mount_options(kFileSystemId, "" /* display_name */);
44 mount_options.writable = true; 46 mount_options.writable = true;
45 file_system_info_ = 47 file_system_info_ = ProvidedFileSystemInfo(
46 ProvidedFileSystemInfo(kExtensionId, mount_options, base::FilePath()); 48 kExtensionId, mount_options, base::FilePath(), false /* configurable */,
49 extensions::SOURCE_FILE);
47 } 50 }
48 51
49 ProvidedFileSystemInfo file_system_info_; 52 ProvidedFileSystemInfo file_system_info_;
50 }; 53 };
51 54
52 TEST_F(FileSystemProviderOperationsMoveEntryTest, Execute) { 55 TEST_F(FileSystemProviderOperationsMoveEntryTest, Execute) {
53 using extensions::api::file_system_provider::MoveEntryRequestedOptions; 56 using extensions::api::file_system_provider::MoveEntryRequestedOptions;
54 57
55 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); 58 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
56 util::StatusCallbackLog callback_log; 59 util::StatusCallbackLog callback_log;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 base::Unretained(&dispatcher))); 98 base::Unretained(&dispatcher)));
96 99
97 EXPECT_FALSE(move_entry.Execute(kRequestId)); 100 EXPECT_FALSE(move_entry.Execute(kRequestId));
98 } 101 }
99 102
100 TEST_F(FileSystemProviderOperationsMoveEntryTest, Execute_ReadOnly) { 103 TEST_F(FileSystemProviderOperationsMoveEntryTest, Execute_ReadOnly) {
101 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); 104 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
102 util::StatusCallbackLog callback_log; 105 util::StatusCallbackLog callback_log;
103 106
104 const ProvidedFileSystemInfo read_only_file_system_info( 107 const ProvidedFileSystemInfo read_only_file_system_info(
105 kExtensionId, 108 kExtensionId, MountOptions(kFileSystemId, "" /* display_name */),
106 MountOptions(kFileSystemId, "" /* display_name */), 109 base::FilePath() /* mount_path */, false /* configurable */,
107 base::FilePath() /* mount_path */); 110 extensions::SOURCE_FILE);
108 111
109 MoveEntry move_entry(NULL, read_only_file_system_info, 112 MoveEntry move_entry(NULL, read_only_file_system_info,
110 base::FilePath(kSourcePath), base::FilePath(kTargetPath), 113 base::FilePath(kSourcePath), base::FilePath(kTargetPath),
111 base::Bind(&util::LogStatusCallback, &callback_log)); 114 base::Bind(&util::LogStatusCallback, &callback_log));
112 move_entry.SetDispatchEventImplForTesting( 115 move_entry.SetDispatchEventImplForTesting(
113 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, 116 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl,
114 base::Unretained(&dispatcher))); 117 base::Unretained(&dispatcher)));
115 118
116 EXPECT_FALSE(move_entry.Execute(kRequestId)); 119 EXPECT_FALSE(move_entry.Execute(kRequestId));
117 } 120 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 move_entry.OnError(kRequestId, 155 move_entry.OnError(kRequestId,
153 scoped_ptr<RequestValue>(new RequestValue()), 156 scoped_ptr<RequestValue>(new RequestValue()),
154 base::File::FILE_ERROR_TOO_MANY_OPENED); 157 base::File::FILE_ERROR_TOO_MANY_OPENED);
155 ASSERT_EQ(1u, callback_log.size()); 158 ASSERT_EQ(1u, callback_log.size());
156 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); 159 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]);
157 } 160 }
158 161
159 } // namespace operations 162 } // namespace operations
160 } // namespace file_system_provider 163 } // namespace file_system_provider
161 } // namespace chromeos 164 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698