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

Side by Side Diff: chrome/browser/chromeos/extensions/external_filesystem_apitest.cc

Issue 10805034: Fix flakiness in RemoteFileSystemExtensionApiTests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/json/json_file_value_serializer.h" 8 #include "base/json/json_file_value_serializer.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 private: 186 private:
187 FilePath test_mount_point_; 187 FilePath test_mount_point_;
188 }; 188 };
189 189
190 class RemoteFileSystemExtensionApiTest : public ExtensionApiTest { 190 class RemoteFileSystemExtensionApiTest : public ExtensionApiTest {
191 public: 191 public:
192 RemoteFileSystemExtensionApiTest() {} 192 RemoteFileSystemExtensionApiTest() {}
193 193
194 virtual ~RemoteFileSystemExtensionApiTest() {} 194 virtual ~RemoteFileSystemExtensionApiTest() {}
195 195
196 // Sets up GDataFileSystem that will be used in the test. 196 virtual void SetUp() OVERRIDE {
197 // NOTE: Remote mount point should get added to mount point provider when 197 // Set up cache root and documents service to be used when creating gdata
198 // getLocalFileSystem is called from filebrowser_component extension. 198 // system service. This has to be done early on (before the browser is
199 virtual void SetupGDataFileSystemForTest() { 199 // created) because the system service instance is initialized very early
200 // |mock_documents_service_| is owned by |system_service|. 200 // by FileBrowserEventRouter.
201 FilePath tmp_dir_path;
202 PathService::Get(base::DIR_TEMP, &tmp_dir_path);
203 ASSERT_TRUE(test_cache_root_.CreateUniqueTempDirUnderPath(tmp_dir_path));
204 gdata::GDataSystemServiceFactory::set_cache_root_for_test(
205 test_cache_root_.path().value().c_str());
206
201 mock_documents_service_ = new gdata::MockDocumentsService(); 207 mock_documents_service_ = new gdata::MockDocumentsService();
208
202 operation_registry_.reset(new gdata::GDataOperationRegistry()); 209 operation_registry_.reset(new gdata::GDataOperationRegistry());
203 gdata::GDataSystemService* system_service = 210 // FileBrowserEventRouter will add and remove itself from operation registry
204 gdata::GDataSystemServiceFactory::GetInstance()-> 211 // observer list.
205 GetWithCustomDocumentsServiceForTesting( 212 EXPECT_CALL(*mock_documents_service_, operation_registry()).
206 browser()->profile(), mock_documents_service_); 213 WillRepeatedly(Return(operation_registry_.get()));
207 EXPECT_TRUE(system_service); 214
215 // |mock_documents_service_| will eventually get owned by a system service.
216 gdata::GDataSystemServiceFactory::set_documents_service_for_test(
217 mock_documents_service_);
218
219 ExtensionApiTest::SetUp();
220 }
221
222 virtual void TearDown() OVERRIDE {
223 // Let's make sure we don't leak documents service.
224 gdata::GDataSystemServiceFactory::set_documents_service_for_test(NULL);
225 ExtensionApiTest::TearDown();
208 } 226 }
209 227
210 protected: 228 protected:
229 ScopedTempDir test_cache_root_;
211 gdata::MockDocumentsService* mock_documents_service_; 230 gdata::MockDocumentsService* mock_documents_service_;
212 scoped_ptr<gdata::GDataOperationRegistry> operation_registry_; 231 scoped_ptr<gdata::GDataOperationRegistry> operation_registry_;
213 }; 232 };
214 233
215 IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, LocalFileSystem) { 234 IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, LocalFileSystem) {
216 AddTmpMountPoint(); 235 AddTmpMountPoint();
217 ASSERT_TRUE(RunComponentExtensionTest("local_filesystem")) << message_; 236 ASSERT_TRUE(RunComponentExtensionTest("local_filesystem")) << message_;
218 } 237 }
219 238
220 IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, FileBrowserTest) { 239 IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, FileBrowserTest) {
(...skipping 30 matching lines...) Expand all
251 FileBrowserTestWriteComponent) { 270 FileBrowserTestWriteComponent) {
252 AddTmpMountPoint(); 271 AddTmpMountPoint();
253 ASSERT_TRUE(RunComponentExtensionTest("filesystem_handler_write")) 272 ASSERT_TRUE(RunComponentExtensionTest("filesystem_handler_write"))
254 << message_; 273 << message_;
255 ASSERT_TRUE(RunExtensionSubtest( 274 ASSERT_TRUE(RunExtensionSubtest(
256 "filebrowser_component", "write.html", kComponentFlags)) << message_; 275 "filebrowser_component", "write.html", kComponentFlags)) << message_;
257 } 276 }
258 277
259 IN_PROC_BROWSER_TEST_F(RemoteFileSystemExtensionApiTest, 278 IN_PROC_BROWSER_TEST_F(RemoteFileSystemExtensionApiTest,
260 RemoteMountPoint) { 279 RemoteMountPoint) {
261 SetupGDataFileSystemForTest();
262
263 EXPECT_CALL(*mock_documents_service_, GetAccountMetadata(_)).Times(1); 280 EXPECT_CALL(*mock_documents_service_, GetAccountMetadata(_)).Times(1);
264 281
265 // First, file browser will try to create new directory. 282 // First, file browser will try to create new directory.
266 scoped_ptr<base::Value> dir_value(LoadJSONFile(kTestDirectory)); 283 scoped_ptr<base::Value> dir_value(LoadJSONFile(kTestDirectory));
267 EXPECT_CALL(*mock_documents_service_, 284 EXPECT_CALL(*mock_documents_service_,
268 CreateDirectory(_, _, _)) 285 CreateDirectory(_, _, _))
269 .WillOnce(MockCreateDirectoryCallback(gdata::HTTP_SUCCESS, &dir_value)); 286 .WillOnce(MockCreateDirectoryCallback(gdata::HTTP_SUCCESS, &dir_value));
270 287
271 // Then the test will try to read an existing file file. 288 // Then the test will try to read an existing file file.
272 // Remote filesystem should first request root feed from gdata server. 289 // Remote filesystem should first request root feed from gdata server.
(...skipping 19 matching lines...) Expand all
292 309
293 // We expect to download url defined in document entry returned by 310 // We expect to download url defined in document entry returned by
294 // GetDocumentEntry mock implementation. 311 // GetDocumentEntry mock implementation.
295 EXPECT_CALL(*mock_documents_service_, 312 EXPECT_CALL(*mock_documents_service_,
296 DownloadFile(_, _, GURL("https://file_content_url_changed"), 313 DownloadFile(_, _, GURL("https://file_content_url_changed"),
297 _, _)) 314 _, _))
298 .WillOnce(MockDownloadFileCallback(gdata::HTTP_SUCCESS)); 315 .WillOnce(MockDownloadFileCallback(gdata::HTTP_SUCCESS));
299 316
300 // On exit, all operations in progress should be cancelled. 317 // On exit, all operations in progress should be cancelled.
301 EXPECT_CALL(*mock_documents_service_, CancelAll()); 318 EXPECT_CALL(*mock_documents_service_, CancelAll());
302 // This one is called on exit, but we don't care much about it, as long as it
303 // retunrs something valid (i.e. not NULL).
304 EXPECT_CALL(*mock_documents_service_, operation_registry()).
305 WillRepeatedly(Return(operation_registry_.get()));
306 319
307 // All is set... RUN THE TEST. 320 // All is set... RUN THE TEST.
308 EXPECT_TRUE(RunExtensionTest("filesystem_handler")) << message_; 321 EXPECT_TRUE(RunExtensionTest("filesystem_handler")) << message_;
309 EXPECT_TRUE(RunExtensionSubtest("filebrowser_component", "remote.html", 322 EXPECT_TRUE(RunExtensionSubtest("filebrowser_component", "remote.html",
310 kComponentFlags)) << message_; 323 kComponentFlags)) << message_;
311 } 324 }
312 325
313 // This test fails under AddressSanitizer, see http://crbug.com/136169. 326 // This test fails under AddressSanitizer, see http://crbug.com/136169.
314 #if defined(ADDRESS_SANITIZER) 327 #if defined(ADDRESS_SANITIZER)
315 #define MAYBE_ContentSearch DISABLED_ContentSearch 328 #define MAYBE_ContentSearch DISABLED_ContentSearch
316 #else 329 #else
317 #define MAYBE_ContentSearch ContentSearch 330 #define MAYBE_ContentSearch ContentSearch
318 #endif 331 #endif
319 IN_PROC_BROWSER_TEST_F(RemoteFileSystemExtensionApiTest, 332 IN_PROC_BROWSER_TEST_F(RemoteFileSystemExtensionApiTest,
320 MAYBE_ContentSearch) { 333 MAYBE_ContentSearch) {
321 SetupGDataFileSystemForTest();
322
323 EXPECT_CALL(*mock_documents_service_, GetAccountMetadata(_)).Times(1); 334 EXPECT_CALL(*mock_documents_service_, GetAccountMetadata(_)).Times(1);
324 335
325 // First, test will get drive root directory, to init file system. 336 // First, test will get drive root directory, to init file system.
326 scoped_ptr<base::Value> documents_value(LoadJSONFile(kTestRootFeed)); 337 scoped_ptr<base::Value> documents_value(LoadJSONFile(kTestRootFeed));
327 EXPECT_CALL(*mock_documents_service_, 338 EXPECT_CALL(*mock_documents_service_,
328 GetDocuments(_, _, "", _, _)) 339 GetDocuments(_, _, "", _, _))
329 .WillOnce(MockGetDocumentsCallback(gdata::HTTP_SUCCESS, 340 .WillOnce(MockGetDocumentsCallback(gdata::HTTP_SUCCESS,
330 &documents_value)); 341 &documents_value));
331 342
332 // We return the whole test file system in serch results. 343 // We return the whole test file system in serch results.
(...skipping 13 matching lines...) Expand all
346 357
347 // We expect to download url defined in document entry returned by 358 // We expect to download url defined in document entry returned by
348 // GetDocumentEntry mock implementation. 359 // GetDocumentEntry mock implementation.
349 EXPECT_CALL(*mock_documents_service_, 360 EXPECT_CALL(*mock_documents_service_,
350 DownloadFile(_, _, GURL("https://file_content_url_changed"), 361 DownloadFile(_, _, GURL("https://file_content_url_changed"),
351 _, _)) 362 _, _))
352 .WillOnce(MockDownloadFileCallback(gdata::HTTP_SUCCESS)); 363 .WillOnce(MockDownloadFileCallback(gdata::HTTP_SUCCESS));
353 364
354 // On exit, all operations in progress should be cancelled. 365 // On exit, all operations in progress should be cancelled.
355 EXPECT_CALL(*mock_documents_service_, CancelAll()); 366 EXPECT_CALL(*mock_documents_service_, CancelAll());
356 // This one is called on exit, but we don't care much about it, as long as it
357 // retunrs something valid (i.e. not NULL).
358 EXPECT_CALL(*mock_documents_service_, operation_registry()).
359 WillRepeatedly(Return(operation_registry_.get()));
360 367
361 // All is set... RUN THE TEST. 368 // All is set... RUN THE TEST.
362 EXPECT_TRUE(RunExtensionSubtest("filebrowser_component", "remote_search.html", 369 EXPECT_TRUE(RunExtensionSubtest("filebrowser_component", "remote_search.html",
363 kComponentFlags)) << message_; 370 kComponentFlags)) << message_;
364 } 371 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698