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

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/file_manager_private_apitest.cc

Issue 2966713002: file_manager: Migrate FILE thread to TaskScheduler (Closed)
Patch Set: fix unit test Created 3 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 (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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h" 11 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h"
12 #include "chrome/browser/chromeos/file_manager/file_watcher.h" 12 #include "chrome/browser/chromeos/file_manager/file_watcher.h"
13 #include "chrome/browser/chromeos/file_manager/mount_test_util.h" 13 #include "chrome/browser/chromeos/file_manager/mount_test_util.h"
14 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info .h" 14 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info .h"
15 #include "chrome/browser/extensions/extension_apitest.h" 15 #include "chrome/browser/extensions/extension_apitest.h"
16 #include "chrome/common/extensions/api/file_system_provider_capabilities/file_sy stem_provider_capabilities_handler.h" 16 #include "chrome/common/extensions/api/file_system_provider_capabilities/file_sy stem_provider_capabilities_handler.h"
17 #include "chrome/test/base/testing_profile.h" 17 #include "chrome/test/base/testing_profile.h"
18 #include "chrome/test/base/ui_test_utils.h"
19 #include "chromeos/dbus/cros_disks_client.h" 18 #include "chromeos/dbus/cros_disks_client.h"
20 #include "chromeos/disks/mock_disk_mount_manager.h" 19 #include "chromeos/disks/mock_disk_mount_manager.h"
21 #include "components/drive/file_change.h" 20 #include "components/drive/file_change.h"
22 #include "extensions/common/extension.h" 21 #include "extensions/common/extension.h"
23 #include "extensions/common/install_warning.h" 22 #include "extensions/common/install_warning.h"
24 #include "google_apis/drive/test_util.h" 23 #include "google_apis/drive/test_util.h"
25 #include "storage/browser/fileapi/external_mount_points.h" 24 #include "storage/browser/fileapi/external_mount_points.h"
26 25
27 using ::testing::_; 26 using ::testing::_;
28 using ::testing::ReturnRef; 27 using ::testing::ReturnRef;
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 event_router_->AddFileWatch( 371 event_router_->AddFileWatch(
373 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/d/e")), 372 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/d/e")),
374 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs-hash/root/a/d/e")), 373 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs-hash/root/a/d/e")),
375 "extension_2", base::Bind(&AddFileWatchCallback)); 374 "extension_2", base::Bind(&AddFileWatchCallback));
376 375
377 event_router_->AddFileWatch( 376 event_router_->AddFileWatch(
378 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/aaa")), 377 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/aaa")),
379 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs-hash/root/aaa")), 378 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs-hash/root/aaa")),
380 "extension_3", base::Bind(&AddFileWatchCallback)); 379 "extension_3", base::Bind(&AddFileWatchCallback));
381 380
382 // event_router->addFileWatch create some tasks which are performed on message 381 // event_router->addFileWatch create some tasks which are performed on
383 // loop of BrowserThread::FILE. Wait until they are done. 382 // TaskScheduler. Wait until they are done.
384 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); 383 base::TaskScheduler::GetInstance()->FlushForTesting();
385 // We also wait the UI thread here, since some tasks which are performed above 384 // We also wait the UI thread here, since some tasks which are performed
386 // message loop back results to the UI thread. 385 // above message loop back results to the UI thread.
387 base::RunLoop().RunUntilIdle(); 386 base::RunLoop().RunUntilIdle();
388 387
389 // When /a is deleted (1 and 2 is notified). 388 // When /a is deleted (1 and 2 is notified).
390 FileChange first_change; 389 FileChange first_change;
391 first_change.Update( 390 first_change.Update(
392 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a")), 391 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a")),
393 FileType::FILE_TYPE_DIRECTORY, ChangeType::CHANGE_TYPE_DELETE); 392 FileType::FILE_TYPE_DIRECTORY, ChangeType::CHANGE_TYPE_DELETE);
394 event_router_->OnFileChanged(first_change); 393 event_router_->OnFileChanged(first_change);
395 EXPECT_EQ(2, counter); 394 EXPECT_EQ(2, counter);
396 395
(...skipping 17 matching lines...) Expand all
414 event_router_->RemoveFileWatch( 413 event_router_->RemoveFileWatch(
415 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/b/c")), 414 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/b/c")),
416 "extension_1"); 415 "extension_1");
417 event_router_->RemoveFileWatch( 416 event_router_->RemoveFileWatch(
418 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/d/e")), 417 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/d/e")),
419 "extension_2"); 418 "extension_2");
420 event_router_->RemoveFileWatch( 419 event_router_->RemoveFileWatch(
421 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/aaa")), 420 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/aaa")),
422 "extension_3"); 421 "extension_3");
423 422
424 // event_router->removeFileWatch create some tasks which are performed on 423 // event_router->addFileWatch create some tasks which are performed on
425 // message loop of BrowserThread::FILE. Wait until they are done. 424 // TaskScheduler. Wait until they are done.
426 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); 425 base::TaskScheduler::GetInstance()->FlushForTesting();
427 } 426 }
428 427
429 IN_PROC_BROWSER_TEST_F(FileManagerPrivateApiTest, ContentChecksum) { 428 IN_PROC_BROWSER_TEST_F(FileManagerPrivateApiTest, ContentChecksum) {
430 base::ScopedTempDir temp_dir; 429 base::ScopedTempDir temp_dir;
431 base::FilePath mount_point_dir; 430 base::FilePath mount_point_dir;
432 const char kLocalMountPointName[] = "local"; 431 const char kLocalMountPointName[] = "local";
433 432
434 ASSERT_TRUE(InitializeLocalFileSystem(kLocalMountPointName, &temp_dir, 433 ASSERT_TRUE(InitializeLocalFileSystem(kLocalMountPointName, &temp_dir,
435 &mount_point_dir)) 434 &mount_point_dir))
436 << "Failed to initialize test file system"; 435 << "Failed to initialize test file system";
437 436
438 EXPECT_TRUE(content::BrowserContext::GetMountPoints(browser()->profile()) 437 EXPECT_TRUE(content::BrowserContext::GetMountPoints(browser()->profile())
439 ->RegisterFileSystem( 438 ->RegisterFileSystem(
440 kLocalMountPointName, storage::kFileSystemTypeNativeLocal, 439 kLocalMountPointName, storage::kFileSystemTypeNativeLocal,
441 storage::FileSystemMountOption(), mount_point_dir)); 440 storage::FileSystemMountOption(), mount_point_dir));
442 file_manager::VolumeManager::Get(browser()->profile()) 441 file_manager::VolumeManager::Get(browser()->profile())
443 ->AddVolumeForTesting(mount_point_dir, file_manager::VOLUME_TYPE_TESTING, 442 ->AddVolumeForTesting(mount_point_dir, file_manager::VOLUME_TYPE_TESTING,
444 chromeos::DEVICE_TYPE_UNKNOWN, 443 chromeos::DEVICE_TYPE_UNKNOWN,
445 false /* read_only */); 444 false /* read_only */);
446 445
447 ASSERT_TRUE(RunComponentExtensionTest("file_browser/content_checksum_test")); 446 ASSERT_TRUE(RunComponentExtensionTest("file_browser/content_checksum_test"));
448 } 447 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698