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

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

Issue 1221093002: Add support for refreshing contents of providers which don't support watchers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed tests. Created 5 years, 5 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"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } // namespace 68 } // namespace
69 69
70 class FileSystemProviderOperationsOpenFileTest : public testing::Test { 70 class FileSystemProviderOperationsOpenFileTest : public testing::Test {
71 protected: 71 protected:
72 FileSystemProviderOperationsOpenFileTest() {} 72 FileSystemProviderOperationsOpenFileTest() {}
73 ~FileSystemProviderOperationsOpenFileTest() override {} 73 ~FileSystemProviderOperationsOpenFileTest() override {}
74 74
75 void SetUp() override { 75 void SetUp() override {
76 file_system_info_ = ProvidedFileSystemInfo( 76 file_system_info_ = ProvidedFileSystemInfo(
77 kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), 77 kExtensionId, MountOptions(kFileSystemId, "" /* display_name */),
78 base::FilePath(), false /* configurable */, extensions::SOURCE_FILE); 78 base::FilePath(), false /* configurable */, true /* watchable */,
79 extensions::SOURCE_FILE);
79 } 80 }
80 81
81 ProvidedFileSystemInfo file_system_info_; 82 ProvidedFileSystemInfo file_system_info_;
82 }; 83 };
83 84
84 TEST_F(FileSystemProviderOperationsOpenFileTest, Execute) { 85 TEST_F(FileSystemProviderOperationsOpenFileTest, Execute) {
85 using extensions::api::file_system_provider::OpenFileRequestedOptions; 86 using extensions::api::file_system_provider::OpenFileRequestedOptions;
86 87
87 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); 88 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
88 CallbackLogger callback_logger; 89 CallbackLogger callback_logger;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 EXPECT_FALSE(open_file.Execute(kRequestId)); 133 EXPECT_FALSE(open_file.Execute(kRequestId));
133 } 134 }
134 135
135 TEST_F(FileSystemProviderOperationsOpenFileTest, Execute_ReadOnly) { 136 TEST_F(FileSystemProviderOperationsOpenFileTest, Execute_ReadOnly) {
136 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); 137 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
137 CallbackLogger callback_logger; 138 CallbackLogger callback_logger;
138 139
139 const ProvidedFileSystemInfo read_only_file_system_info( 140 const ProvidedFileSystemInfo read_only_file_system_info(
140 kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), 141 kExtensionId, MountOptions(kFileSystemId, "" /* display_name */),
141 base::FilePath() /* mount_path */, false /* configurable */, 142 base::FilePath() /* mount_path */, false /* configurable */,
142 extensions::SOURCE_FILE); 143 true /* watchable */, extensions::SOURCE_FILE);
143 144
144 // Opening for read on a read-only file system is allowed. 145 // Opening for read on a read-only file system is allowed.
145 { 146 {
146 OpenFile open_file(NULL, read_only_file_system_info, 147 OpenFile open_file(NULL, read_only_file_system_info,
147 base::FilePath(kFilePath), OPEN_FILE_MODE_READ, 148 base::FilePath(kFilePath), OPEN_FILE_MODE_READ,
148 base::Bind(&CallbackLogger::OnOpenFile, 149 base::Bind(&CallbackLogger::OnOpenFile,
149 base::Unretained(&callback_logger))); 150 base::Unretained(&callback_logger)));
150 open_file.SetDispatchEventImplForTesting( 151 open_file.SetDispatchEventImplForTesting(
151 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, 152 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl,
152 base::Unretained(&dispatcher))); 153 base::Unretained(&dispatcher)));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 base::File::FILE_ERROR_TOO_MANY_OPENED); 211 base::File::FILE_ERROR_TOO_MANY_OPENED);
211 ASSERT_EQ(1u, callback_logger.events().size()); 212 ASSERT_EQ(1u, callback_logger.events().size());
212 CallbackLogger::Event* event = callback_logger.events()[0]; 213 CallbackLogger::Event* event = callback_logger.events()[0];
213 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, event->result()); 214 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, event->result());
214 ASSERT_EQ(0, event->file_handle()); 215 ASSERT_EQ(0, event->file_handle());
215 } 216 }
216 217
217 } // namespace operations 218 } // namespace operations
218 } // namespace file_system_provider 219 } // namespace file_system_provider
219 } // namespace chromeos 220 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698