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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/operations/create_directory_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/create_directo ry.h" 5 #include "chrome/browser/chromeos/file_system_provider/operations/create_directo ry.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 kDirectoryPath[] = 31 const base::FilePath::CharType kDirectoryPath[] =
31 FILE_PATH_LITERAL("/kitty/and/puppy/happy"); 32 FILE_PATH_LITERAL("/kitty/and/puppy/happy");
32 33
33 } // namespace 34 } // namespace
34 35
35 class FileSystemProviderOperationsCreateDirectoryTest : public testing::Test { 36 class FileSystemProviderOperationsCreateDirectoryTest : public testing::Test {
36 protected: 37 protected:
37 FileSystemProviderOperationsCreateDirectoryTest() {} 38 FileSystemProviderOperationsCreateDirectoryTest() {}
38 ~FileSystemProviderOperationsCreateDirectoryTest() override {} 39 ~FileSystemProviderOperationsCreateDirectoryTest() override {}
39 40
40 void SetUp() override { 41 void SetUp() override {
41 MountOptions mount_options(kFileSystemId, "" /* display_name */); 42 MountOptions mount_options(kFileSystemId, "" /* display_name */);
42 mount_options.writable = true; 43 mount_options.writable = true;
43 file_system_info_ = 44 file_system_info_ = ProvidedFileSystemInfo(
44 ProvidedFileSystemInfo(kExtensionId, mount_options, base::FilePath()); 45 kExtensionId, mount_options, base::FilePath(), false /* configurable */,
46 extensions::SOURCE_FILE);
45 } 47 }
46 48
47 ProvidedFileSystemInfo file_system_info_; 49 ProvidedFileSystemInfo file_system_info_;
48 }; 50 };
49 51
50 TEST_F(FileSystemProviderOperationsCreateDirectoryTest, Execute) { 52 TEST_F(FileSystemProviderOperationsCreateDirectoryTest, Execute) {
51 using extensions::api::file_system_provider::CreateDirectoryRequestedOptions; 53 using extensions::api::file_system_provider::CreateDirectoryRequestedOptions;
52 54
53 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); 55 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
54 util::StatusCallbackLog callback_log; 56 util::StatusCallbackLog callback_log;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 base::Unretained(&dispatcher))); 98 base::Unretained(&dispatcher)));
97 99
98 EXPECT_FALSE(create_directory.Execute(kRequestId)); 100 EXPECT_FALSE(create_directory.Execute(kRequestId));
99 } 101 }
100 102
101 TEST_F(FileSystemProviderOperationsCreateDirectoryTest, Execute_ReadOnly) { 103 TEST_F(FileSystemProviderOperationsCreateDirectoryTest, Execute_ReadOnly) {
102 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); 104 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
103 util::StatusCallbackLog callback_log; 105 util::StatusCallbackLog callback_log;
104 106
105 const ProvidedFileSystemInfo read_only_file_system_info( 107 const ProvidedFileSystemInfo read_only_file_system_info(
106 kExtensionId, 108 kExtensionId, MountOptions(kFileSystemId, "" /* display_name */),
107 MountOptions(kFileSystemId, "" /* display_name */), 109 base::FilePath() /* mount_path */, false /* configurable */,
108 base::FilePath() /* mount_path */); 110 extensions::SOURCE_FILE);
109 111
110 CreateDirectory create_directory( 112 CreateDirectory create_directory(
111 NULL, read_only_file_system_info, base::FilePath(kDirectoryPath), 113 NULL, read_only_file_system_info, base::FilePath(kDirectoryPath),
112 true /* recursive */, 114 true /* recursive */,
113 base::Bind(&util::LogStatusCallback, &callback_log)); 115 base::Bind(&util::LogStatusCallback, &callback_log));
114 create_directory.SetDispatchEventImplForTesting( 116 create_directory.SetDispatchEventImplForTesting(
115 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, 117 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl,
116 base::Unretained(&dispatcher))); 118 base::Unretained(&dispatcher)));
117 119
118 EXPECT_FALSE(create_directory.Execute(kRequestId)); 120 EXPECT_FALSE(create_directory.Execute(kRequestId));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 create_directory.OnError(kRequestId, 158 create_directory.OnError(kRequestId,
157 scoped_ptr<RequestValue>(new RequestValue()), 159 scoped_ptr<RequestValue>(new RequestValue()),
158 base::File::FILE_ERROR_TOO_MANY_OPENED); 160 base::File::FILE_ERROR_TOO_MANY_OPENED);
159 ASSERT_EQ(1u, callback_log.size()); 161 ASSERT_EQ(1u, callback_log.size());
160 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); 162 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]);
161 } 163 }
162 164
163 } // namespace operations 165 } // namespace operations
164 } // namespace file_system_provider 166 } // namespace file_system_provider
165 } // namespace chromeos 167 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698