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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/operations/open_file_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/open_file.h" 5 #include "chrome/browser/chromeos/file_system_provider/operations/open_file.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
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 67
67 } // namespace 68 } // namespace
68 69
69 class FileSystemProviderOperationsOpenFileTest : public testing::Test { 70 class FileSystemProviderOperationsOpenFileTest : public testing::Test {
70 protected: 71 protected:
71 FileSystemProviderOperationsOpenFileTest() {} 72 FileSystemProviderOperationsOpenFileTest() {}
72 ~FileSystemProviderOperationsOpenFileTest() override {} 73 ~FileSystemProviderOperationsOpenFileTest() override {}
73 74
74 void SetUp() override { 75 void SetUp() override {
75 file_system_info_ = ProvidedFileSystemInfo( 76 file_system_info_ = ProvidedFileSystemInfo(
76 kExtensionId, 77 kExtensionId, MountOptions(kFileSystemId, "" /* display_name */),
77 MountOptions(kFileSystemId, "" /* display_name */), 78 base::FilePath(), false /* configurable */, extensions::SOURCE_FILE);
78 base::FilePath());
79 } 79 }
80 80
81 ProvidedFileSystemInfo file_system_info_; 81 ProvidedFileSystemInfo file_system_info_;
82 }; 82 };
83 83
84 TEST_F(FileSystemProviderOperationsOpenFileTest, Execute) { 84 TEST_F(FileSystemProviderOperationsOpenFileTest, Execute) {
85 using extensions::api::file_system_provider::OpenFileRequestedOptions; 85 using extensions::api::file_system_provider::OpenFileRequestedOptions;
86 86
87 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); 87 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
88 CallbackLogger callback_logger; 88 CallbackLogger callback_logger;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 base::Unretained(&dispatcher))); 130 base::Unretained(&dispatcher)));
131 131
132 EXPECT_FALSE(open_file.Execute(kRequestId)); 132 EXPECT_FALSE(open_file.Execute(kRequestId));
133 } 133 }
134 134
135 TEST_F(FileSystemProviderOperationsOpenFileTest, Execute_ReadOnly) { 135 TEST_F(FileSystemProviderOperationsOpenFileTest, Execute_ReadOnly) {
136 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); 136 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
137 CallbackLogger callback_logger; 137 CallbackLogger callback_logger;
138 138
139 const ProvidedFileSystemInfo read_only_file_system_info( 139 const ProvidedFileSystemInfo read_only_file_system_info(
140 kExtensionId, 140 kExtensionId, MountOptions(kFileSystemId, "" /* display_name */),
141 MountOptions(kFileSystemId, "" /* display_name */), 141 base::FilePath() /* mount_path */, false /* configurable */,
142 base::FilePath() /* mount_path */); 142 extensions::SOURCE_FILE);
143 143
144 // Opening for read on a read-only file system is allowed. 144 // Opening for read on a read-only file system is allowed.
145 { 145 {
146 OpenFile open_file(NULL, read_only_file_system_info, 146 OpenFile open_file(NULL, read_only_file_system_info,
147 base::FilePath(kFilePath), OPEN_FILE_MODE_READ, 147 base::FilePath(kFilePath), OPEN_FILE_MODE_READ,
148 base::Bind(&CallbackLogger::OnOpenFile, 148 base::Bind(&CallbackLogger::OnOpenFile,
149 base::Unretained(&callback_logger))); 149 base::Unretained(&callback_logger)));
150 open_file.SetDispatchEventImplForTesting( 150 open_file.SetDispatchEventImplForTesting(
151 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, 151 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl,
152 base::Unretained(&dispatcher))); 152 base::Unretained(&dispatcher)));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 base::File::FILE_ERROR_TOO_MANY_OPENED); 210 base::File::FILE_ERROR_TOO_MANY_OPENED);
211 ASSERT_EQ(1u, callback_logger.events().size()); 211 ASSERT_EQ(1u, callback_logger.events().size());
212 CallbackLogger::Event* event = callback_logger.events()[0]; 212 CallbackLogger::Event* event = callback_logger.events()[0];
213 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, event->result()); 213 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, event->result());
214 ASSERT_EQ(0, event->file_handle()); 214 ASSERT_EQ(0, event->file_handle());
215 } 215 }
216 216
217 } // namespace operations 217 } // namespace operations
218 } // namespace file_system_provider 218 } // namespace file_system_provider
219 } // namespace chromeos 219 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698