diff options
author | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-18 06:36:25 +0000 |
---|---|---|
committer | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-18 06:36:25 +0000 |
commit | 90c38b1ce047c65c1bdc7a5483ef48e8d05126dc (patch) | |
tree | 79b601a5deb801b51c58c26bf1471818368924bc | |
parent | 8a078498d8e6934a6aabe358902d2cf569067cde (diff) | |
download | chromium_src-90c38b1ce047c65c1bdc7a5483ef48e8d05126dc.zip chromium_src-90c38b1ce047c65c1bdc7a5483ef48e8d05126dc.tar.gz chromium_src-90c38b1ce047c65c1bdc7a5483ef48e8d05126dc.tar.bz2 |
Use TestBrowserThreadBundle instead of TestBrowserThread (c/b/cros/drive).
and some easy part of c/b/google_apis
BUG=247551
Review URL: https://chromiumcodereview.appspot.com/17024004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206905 0039d316-1c4b-4281-b951-d872f2087c98
16 files changed, 156 insertions, 229 deletions
diff --git a/chrome/browser/chromeos/drive/change_list_processor_unittest.cc b/chrome/browser/chromeos/drive/change_list_processor_unittest.cc index c42a165..d28fb0b 100644 --- a/chrome/browser/chromeos/drive/change_list_processor_unittest.cc +++ b/chrome/browser/chromeos/drive/change_list_processor_unittest.cc @@ -5,8 +5,9 @@ #include "chrome/browser/chromeos/drive/change_list_processor.h" #include "base/files/scoped_temp_dir.h" -#include "base/message_loop.h" -#include "base/threading/sequenced_worker_pool.h" +#include "base/location.h" +#include "base/message_loop/message_loop_proxy.h" +#include "base/task_runner_util.h" #include "base/values.h" #include "chrome/browser/chromeos/drive/drive.pb.h" #include "chrome/browser/chromeos/drive/file_system_util.h" @@ -15,7 +16,7 @@ #include "chrome/browser/google_apis/drive_api_parser.h" #include "chrome/browser/google_apis/gdata_wapi_parser.h" #include "chrome/browser/google_apis/test_util.h" -#include "content/public/test/test_browser_thread.h" +#include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" namespace drive { @@ -40,15 +41,8 @@ struct EntryExpectation { class ChangeListProcessorTest : public testing::Test { protected: - ChangeListProcessorTest() - : ui_thread_(content::BrowserThread::UI, &message_loop_) { - } - virtual void SetUp() OVERRIDE { - scoped_refptr<base::SequencedWorkerPool> pool = - content::BrowserThread::GetBlockingPool(); - blocking_task_runner_ = - pool->GetSequencedTaskRunner(pool->GetSequenceToken()); + blocking_task_runner_ = base::MessageLoopProxy::current(); ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); metadata_.reset(new internal::ResourceMetadata(temp_dir_.path(), blocking_task_runner_)); @@ -66,7 +60,6 @@ class ChangeListProcessorTest : public testing::Test { virtual void TearDown() OVERRIDE { metadata_.reset(); - blocking_task_runner_ = NULL; } // Parses a json file at |test_data_path| relative to Chrome test directory @@ -150,8 +143,7 @@ class ChangeListProcessorTest : public testing::Test { } private: - base::MessageLoopForUI message_loop_; - content::TestBrowserThread ui_thread_; + content::TestBrowserThreadBundle thread_bundle_; scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; base::ScopedTempDir temp_dir_; scoped_ptr<internal::ResourceMetadata, test_util::DestroyHelperForTests> diff --git a/chrome/browser/chromeos/drive/download_handler_unittest.cc b/chrome/browser/chromeos/drive/download_handler_unittest.cc index 9b22810..94a7e05 100644 --- a/chrome/browser/chromeos/drive/download_handler_unittest.cc +++ b/chrome/browser/chromeos/drive/download_handler_unittest.cc @@ -5,14 +5,13 @@ #include "chrome/browser/chromeos/drive/download_handler.h" #include "base/files/scoped_temp_dir.h" -#include "base/message_loop.h" #include "chrome/browser/chromeos/drive/dummy_file_system.h" #include "chrome/browser/chromeos/drive/file_system_util.h" #include "chrome/browser/chromeos/drive/file_write_helper.h" #include "chrome/browser/google_apis/test_util.h" #include "content/public/test/mock_download_item.h" #include "content/public/test/mock_download_manager.h" -#include "content/public/test/test_browser_thread.h" +#include "content/public/test/test_browser_thread_bundle.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -70,8 +69,7 @@ class DownloadHandlerTestFileSystem : public DummyFileSystem { class DownloadHandlerTest : public testing::Test { public: DownloadHandlerTest() - : ui_thread_(content::BrowserThread::UI, &message_loop_), - download_manager_(new content::MockDownloadManager) {} + : download_manager_(new content::MockDownloadManager) {} virtual void SetUp() OVERRIDE { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); @@ -88,8 +86,7 @@ class DownloadHandlerTest : public testing::Test { protected: base::ScopedTempDir temp_dir_; - base::MessageLoopForUI message_loop_; - content::TestBrowserThread ui_thread_; + content::TestBrowserThreadBundle thread_bundle_; scoped_ptr<content::MockDownloadManager> download_manager_; DownloadHandlerTestFileSystem test_file_system_; scoped_ptr<FileWriteHelper> file_write_helper_; diff --git a/chrome/browser/chromeos/drive/drive_integration_service_unittest.cc b/chrome/browser/chromeos/drive/drive_integration_service_unittest.cc index 5d5339b..f22adf5 100644 --- a/chrome/browser/chromeos/drive/drive_integration_service_unittest.cc +++ b/chrome/browser/chromeos/drive/drive_integration_service_unittest.cc @@ -4,21 +4,17 @@ #include "chrome/browser/chromeos/drive/drive_integration_service.h" -#include "base/message_loop.h" #include "chrome/browser/chromeos/drive/dummy_file_system.h" #include "chrome/browser/chromeos/drive/test_util.h" #include "chrome/browser/google_apis/dummy_drive_service.h" #include "chrome/test/base/testing_profile.h" -#include "content/public/test/test_browser_thread.h" +#include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" namespace drive { class DriveIntegrationServiceTest : public testing::Test { public: - DriveIntegrationServiceTest() - : ui_thread_(content::BrowserThread::UI, &message_loop_) {} - virtual void SetUp() OVERRIDE { profile_.reset(new TestingProfile); integration_service_.reset(new DriveIntegrationService( @@ -35,8 +31,7 @@ class DriveIntegrationServiceTest : public testing::Test { } protected: - base::MessageLoopForUI message_loop_; - content::TestBrowserThread ui_thread_; + content::TestBrowserThreadBundle thread_bundle_; scoped_ptr<TestingProfile> profile_; scoped_ptr<DriveIntegrationService> integration_service_; }; diff --git a/chrome/browser/chromeos/drive/fake_file_system_unittest.cc b/chrome/browser/chromeos/drive/fake_file_system_unittest.cc index 61f425a..b34e31d 100644 --- a/chrome/browser/chromeos/drive/fake_file_system_unittest.cc +++ b/chrome/browser/chromeos/drive/fake_file_system_unittest.cc @@ -5,12 +5,10 @@ #include "chrome/browser/chromeos/drive/fake_file_system.h" #include "base/file_util.h" -#include "base/message_loop.h" #include "chrome/browser/chromeos/drive/file_system_util.h" #include "chrome/browser/google_apis/fake_drive_service.h" #include "chrome/browser/google_apis/test_util.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/test/test_browser_thread.h" +#include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" namespace drive { @@ -18,10 +16,6 @@ namespace test_util { class FakeFileSystemTest : public ::testing::Test { protected: - FakeFileSystemTest() - : ui_thread_(content::BrowserThread::UI, &message_loop_) { - } - virtual void SetUp() OVERRIDE { // Initialize FakeDriveService. fake_drive_service_.reset(new google_apis::FakeDriveService); @@ -36,9 +30,7 @@ class FakeFileSystemTest : public ::testing::Test { ASSERT_TRUE(fake_file_system_->InitializeForTesting()); } - base::MessageLoopForUI message_loop_; - content::TestBrowserThread ui_thread_; - + content::TestBrowserThreadBundle thread_bundle_; scoped_ptr<google_apis::FakeDriveService> fake_drive_service_; scoped_ptr<FakeFileSystem> fake_file_system_; }; diff --git a/chrome/browser/chromeos/drive/file_system/operation_test_base.cc b/chrome/browser/chromeos/drive/file_system/operation_test_base.cc index 55e68cb..b31d433 100644 --- a/chrome/browser/chromeos/drive/file_system/operation_test_base.cc +++ b/chrome/browser/chromeos/drive/file_system/operation_test_base.cc @@ -15,6 +15,7 @@ #include "chrome/browser/google_apis/fake_drive_service.h" #include "chrome/browser/google_apis/test_util.h" #include "chrome/test/base/testing_profile.h" +#include "content/public/browser/browser_thread.h" namespace drive { namespace file_system { @@ -35,8 +36,7 @@ void OperationTestBase::LoggingObserver::OnCacheFileUploadNeededByOperation( upload_needed_resource_ids_.insert(resource_id); } -OperationTestBase::OperationTestBase() - : ui_thread_(content::BrowserThread::UI, &message_loop_) { +OperationTestBase::OperationTestBase() { } OperationTestBase::~OperationTestBase() { diff --git a/chrome/browser/chromeos/drive/file_system/operation_test_base.h b/chrome/browser/chromeos/drive/file_system/operation_test_base.h index f02ddd4..026fae1 100644 --- a/chrome/browser/chromeos/drive/file_system/operation_test_base.h +++ b/chrome/browser/chromeos/drive/file_system/operation_test_base.h @@ -8,11 +8,10 @@ #include <set> #include "base/files/scoped_temp_dir.h" -#include "base/message_loop.h" #include "chrome/browser/chromeos/drive/drive.pb.h" #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" #include "chrome/browser/chromeos/drive/test_util.h" -#include "content/public/test/test_browser_thread.h" +#include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" class TestingProfile; @@ -100,8 +99,7 @@ class OperationTestBase : public testing::Test { internal::FileCache* cache() { return cache_.get(); } private: - base::MessageLoopForUI message_loop_; - content::TestBrowserThread ui_thread_; + content::TestBrowserThreadBundle thread_bundle_; scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; scoped_ptr<TestingProfile> profile_; base::ScopedTempDir temp_dir_; diff --git a/chrome/browser/chromeos/drive/file_system_unittest.cc b/chrome/browser/chromeos/drive/file_system_unittest.cc index 3f651e2..bf8007c9 100644 --- a/chrome/browser/chromeos/drive/file_system_unittest.cc +++ b/chrome/browser/chromeos/drive/file_system_unittest.cc @@ -11,9 +11,11 @@ #include "base/file_util.h" #include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" +#include "base/location.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop.h" -#include "base/threading/sequenced_worker_pool.h" +#include "base/message_loop/message_loop_proxy.h" +#include "base/run_loop.h" +#include "base/task_runner_util.h" #include "chrome/browser/chromeos/drive/change_list_loader.h" #include "chrome/browser/chromeos/drive/drive.pb.h" #include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h" @@ -26,8 +28,7 @@ #include "chrome/browser/google_apis/fake_drive_service.h" #include "chrome/browser/google_apis/test_util.h" #include "chrome/test/base/testing_profile.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/test/test_browser_thread.h" +#include "content/public/test/test_browser_thread_bundle.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -42,32 +43,29 @@ namespace { const int64 kLotsOfSpace = internal::kMinFreeSpace * 10; // Counts the number of invocation, and if it increased up to |expected_counter| -// quits the current message loop. +// quits the current message loop by calling |quit|. void AsyncInitializationCallback( - int* counter, int expected_counter, base::MessageLoop* message_loop, + int* counter, int expected_counter, const base::Closure& quit, FileError error, scoped_ptr<ResourceEntry> entry) { if (error != FILE_ERROR_OK || !entry) { // If we hit an error case, quit the message loop immediately. // Then the expectation in the test case can find it because the actual // value of |counter| is different from the expected one. - message_loop->Quit(); + quit.Run(); return; } (*counter)++; if (*counter >= expected_counter) - message_loop->Quit(); + quit.Run(); } } // namespace class FileSystemTest : public testing::Test { protected: - FileSystemTest() - : ui_thread_(content::BrowserThread::UI, &message_loop_) { - } - virtual void SetUp() OVERRIDE { + blocking_task_runner_ = base::MessageLoopProxy::current(); profile_.reset(new TestingProfile); // The fake object will be manually deleted in TearDown(). @@ -82,11 +80,6 @@ class FileSystemTest : public testing::Test { scheduler_.reset(new JobScheduler(profile_.get(), fake_drive_service_.get())); - scoped_refptr<base::SequencedWorkerPool> pool = - content::BrowserThread::GetBlockingPool(); - blocking_task_runner_ = - pool->GetSequencedTaskRunner(pool->GetSequenceToken()); - cache_.reset(new internal::FileCache(util::GetCacheRootPath(profile_.get()), blocking_task_runner_.get(), fake_free_disk_space_getter_.get())); @@ -337,8 +330,7 @@ class FileSystemTest : public testing::Test { return true; } - base::MessageLoopForUI message_loop_; - content::TestBrowserThread ui_thread_; + content::TestBrowserThreadBundle thread_bundle_; scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; scoped_ptr<TestingProfile> profile_; @@ -357,15 +349,17 @@ TEST_F(FileSystemTest, DuplicatedAsyncInitialization) { EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); + base::RunLoop loop; + int counter = 0; const GetResourceEntryCallback& callback = base::Bind( - &AsyncInitializationCallback, &counter, 2, &message_loop_); + &AsyncInitializationCallback, &counter, 2, loop.QuitClosure()); file_system_->GetResourceEntryByPath( base::FilePath(FILE_PATH_LITERAL("drive/root")), callback); file_system_->GetResourceEntryByPath( base::FilePath(FILE_PATH_LITERAL("drive/root")), callback); - message_loop_.Run(); // Wait to get our result + loop.Run(); // Wait to get our result EXPECT_EQ(2, counter); // Although GetResourceEntryByPath() was called twice, the resource list diff --git a/chrome/browser/chromeos/drive/file_write_helper_unittest.cc b/chrome/browser/chromeos/drive/file_write_helper_unittest.cc index 4a80cec..936748d 100644 --- a/chrome/browser/chromeos/drive/file_write_helper_unittest.cc +++ b/chrome/browser/chromeos/drive/file_write_helper_unittest.cc @@ -5,12 +5,9 @@ #include "chrome/browser/chromeos/drive/file_write_helper.h" #include "base/bind.h" -#include "base/message_loop.h" -#include "base/threading/thread_restrictions.h" #include "chrome/browser/chromeos/drive/dummy_file_system.h" #include "chrome/browser/chromeos/drive/test_util.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/test/test_browser_thread.h" +#include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" namespace drive { @@ -72,13 +69,11 @@ class TestFileSystem : public DummyFileSystem { class FileWriteHelperTest : public testing::Test { public: FileWriteHelperTest() - : ui_thread_(content::BrowserThread::UI, &message_loop_), - test_file_system_(new TestFileSystem) { + : test_file_system_(new TestFileSystem) { } protected: - base::MessageLoopForUI message_loop_; - content::TestBrowserThread ui_thread_; + content::TestBrowserThreadBundle thread_bundle_; scoped_ptr<TestFileSystem> test_file_system_; }; diff --git a/chrome/browser/chromeos/drive/job_scheduler_unittest.cc b/chrome/browser/chromeos/drive/job_scheduler_unittest.cc index d0518bb..b1e9816 100644 --- a/chrome/browser/chromeos/drive/job_scheduler_unittest.cc +++ b/chrome/browser/chromeos/drive/job_scheduler_unittest.cc @@ -17,7 +17,7 @@ #include "chrome/browser/google_apis/gdata_wapi_parser.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/testing_profile.h" -#include "content/public/test/test_browser_thread.h" +#include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" namespace drive { @@ -101,8 +101,7 @@ class JobListLogger : public JobListObserver { class JobSchedulerTest : public testing::Test { public: JobSchedulerTest() - : ui_thread_(content::BrowserThread::UI, &message_loop_), - profile_(new TestingProfile) { + : profile_(new TestingProfile) { } virtual void SetUp() OVERRIDE { @@ -161,8 +160,7 @@ class JobSchedulerTest : public testing::Test { ChangeConnectionType(net::NetworkChangeNotifier::CONNECTION_NONE); } - base::MessageLoopForUI message_loop_; - content::TestBrowserThread ui_thread_; + content::TestBrowserThreadBundle thread_bundle_; scoped_ptr<TestingProfile> profile_; scoped_ptr<JobScheduler> scheduler_; scoped_ptr<FakeNetworkChangeNotifier> fake_network_change_notifier_; diff --git a/chrome/browser/chromeos/drive/resource_metadata_unittest.cc b/chrome/browser/chromeos/drive/resource_metadata_unittest.cc index 70b4903..82801e8 100644 --- a/chrome/browser/chromeos/drive/resource_metadata_unittest.cc +++ b/chrome/browser/chromeos/drive/resource_metadata_unittest.cc @@ -9,7 +9,6 @@ #include <vector> #include "base/files/scoped_temp_dir.h" -#include "base/message_loop.h" #include "base/sequenced_task_runner.h" #include "base/threading/sequenced_worker_pool.h" #include "base/threading/thread_restrictions.h" @@ -17,7 +16,8 @@ #include "chrome/browser/chromeos/drive/file_system_util.h" #include "chrome/browser/chromeos/drive/test_util.h" #include "chrome/browser/google_apis/test_util.h" -#include "content/public/test/test_browser_thread.h" +#include "content/public/browser/browser_thread.h" +#include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" namespace drive { @@ -115,10 +115,6 @@ void SetUpEntries(ResourceMetadata* resource_metadata) { // Tests for methods invoked from the UI thread. class ResourceMetadataTestOnUIThread : public testing::Test { protected: - ResourceMetadataTestOnUIThread() - : ui_thread_(content::BrowserThread::UI, &message_loop_) { - } - virtual void SetUp() OVERRIDE { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); @@ -185,8 +181,7 @@ class ResourceMetadataTestOnUIThread : public testing::Test { resource_metadata_; private: - base::MessageLoopForUI message_loop_; - content::TestBrowserThread ui_thread_; + content::TestBrowserThreadBundle thread_bundle_; }; TEST_F(ResourceMetadataTestOnUIThread, LargestChangestamp) { @@ -871,15 +866,12 @@ TEST_F(ResourceMetadataTestOnUIThread, Reset) { // Tests for methods running on the blocking task runner. class ResourceMetadataTest : public testing::Test { protected: - ResourceMetadataTest() - : ui_thread_(content::BrowserThread::UI, &message_loop_) {} - virtual void SetUp() OVERRIDE { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); // Use the main thread as the blocking task runner. resource_metadata_.reset(new ResourceMetadata( - temp_dir_.path(), message_loop_.message_loop_proxy())); + temp_dir_.path(), base::MessageLoopProxy::current())); ASSERT_EQ(FILE_ERROR_OK, resource_metadata_->Initialize()); @@ -890,8 +882,7 @@ class ResourceMetadataTest : public testing::Test { } base::ScopedTempDir temp_dir_; - base::MessageLoopForUI message_loop_; - content::TestBrowserThread ui_thread_; + content::TestBrowserThreadBundle thread_bundle_; scoped_ptr<ResourceMetadata, test_util::DestroyHelperForTests> resource_metadata_; }; diff --git a/chrome/browser/chromeos/drive/search_metadata_unittest.cc b/chrome/browser/chromeos/drive/search_metadata_unittest.cc index 243e668..182caaf 100644 --- a/chrome/browser/chromeos/drive/search_metadata_unittest.cc +++ b/chrome/browser/chromeos/drive/search_metadata_unittest.cc @@ -5,14 +5,15 @@ #include "chrome/browser/chromeos/drive/search_metadata.h" #include "base/files/scoped_temp_dir.h" -#include "base/message_loop.h" +#include "base/location.h" +#include "base/message_loop/message_loop_proxy.h" #include "base/strings/stringprintf.h" -#include "base/threading/sequenced_worker_pool.h" +#include "base/task_runner_util.h" #include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h" #include "chrome/browser/chromeos/drive/file_cache.h" #include "chrome/browser/chromeos/drive/file_system_util.h" #include "chrome/browser/chromeos/drive/test_util.h" -#include "content/public/test/test_browser_thread.h" +#include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" namespace drive { @@ -63,18 +64,11 @@ class MetadataInfoGenerator { class SearchMetadataTest : public testing::Test { protected: - SearchMetadataTest() - : ui_thread_(content::BrowserThread::UI, &message_loop_) { - } - virtual void SetUp() OVERRIDE { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); + blocking_task_runner_ = base::MessageLoopProxy::current(); fake_free_disk_space_getter_.reset(new FakeFreeDiskSpaceGetter); - scoped_refptr<base::SequencedWorkerPool> pool = - content::BrowserThread::GetBlockingPool(); - blocking_task_runner_ = - pool->GetSequencedTaskRunner(pool->GetSequenceToken()); cache_.reset(new internal::FileCache(temp_dir_.path(), blocking_task_runner_.get(), fake_free_disk_space_getter_.get())); @@ -223,8 +217,7 @@ class SearchMetadataTest : public testing::Test { EXPECT_EQ(FILE_ERROR_OK, error); } - base::MessageLoopForUI message_loop_; - content::TestBrowserThread ui_thread_; + content::TestBrowserThreadBundle thread_bundle_; base::ScopedTempDir temp_dir_; scoped_ptr<FakeFreeDiskSpaceGetter> fake_free_disk_space_getter_; scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; diff --git a/chrome/browser/google_apis/DEPS b/chrome/browser/google_apis/DEPS index 7934512..ea1ba4b 100644 --- a/chrome/browser/google_apis/DEPS +++ b/chrome/browser/google_apis/DEPS @@ -23,6 +23,7 @@ specific_include_rules = { "!chrome/test/base/testing_browser_process.h", "!chrome/test/base/testing_profile.h", "!content/public/test/test_browser_thread.h", + "!content/public/test/test_browser_thread_bundle.h", "!content/public/test/test_utils.h", ], "drive_uploader.cc": [ diff --git a/chrome/browser/google_apis/base_requests_unittest.cc b/chrome/browser/google_apis/base_requests_unittest.cc index 182f7c5..aaca989 100644 --- a/chrome/browser/google_apis/base_requests_unittest.cc +++ b/chrome/browser/google_apis/base_requests_unittest.cc @@ -6,12 +6,11 @@ #include "base/bind.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop.h" #include "base/values.h" #include "chrome/browser/google_apis/request_sender.h" #include "chrome/browser/google_apis/test_util.h" #include "chrome/test/base/testing_profile.h" -#include "content/public/test/test_browser_thread.h" +#include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" namespace google_apis { @@ -47,8 +46,7 @@ class FakeGetDataRequest : public GetDataRequest { class BaseRequestsTest : public testing::Test { public: BaseRequestsTest() - : ui_thread_(content::BrowserThread::UI, &message_loop_), - parse_json_callback_called_(false), + : parse_json_callback_called_(false), get_data_callback_called_(false) { } @@ -73,8 +71,7 @@ class BaseRequestsTest : public testing::Test { LOG(ERROR) << "Initialized."; } - base::MessageLoopForUI message_loop_; - content::TestBrowserThread ui_thread_; + content::TestBrowserThreadBundle thread_bundle_; scoped_ptr<TestingProfile> profile_; scoped_ptr<RequestSender> runner_; diff --git a/chrome/browser/google_apis/drive_uploader_unittest.cc b/chrome/browser/google_apis/drive_uploader_unittest.cc index 5dfce4b..5d709d7 100644 --- a/chrome/browser/google_apis/drive_uploader_unittest.cc +++ b/chrome/browser/google_apis/drive_uploader_unittest.cc @@ -17,7 +17,7 @@ #include "base/values.h" #include "chrome/browser/google_apis/dummy_drive_service.h" #include "chrome/browser/google_apis/test_util.h" -#include "content/public/test/test_browser_thread.h" +#include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" namespace google_apis { @@ -284,10 +284,6 @@ class MockDriveServiceNoConnectionAtResume : public DummyDriveService { class DriveUploaderTest : public testing::Test { public: - DriveUploaderTest() - : ui_thread_(content::BrowserThread::UI, &message_loop_) { - } - virtual void SetUp() OVERRIDE { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); } @@ -297,8 +293,7 @@ class DriveUploaderTest : public testing::Test { } protected: - base::MessageLoopForUI message_loop_; - content::TestBrowserThread ui_thread_; + content::TestBrowserThreadBundle thread_bundle_; base::ScopedTempDir temp_dir_; }; diff --git a/chrome/browser/google_apis/fake_drive_service_unittest.cc b/chrome/browser/google_apis/fake_drive_service_unittest.cc index 8e1ecb6..6b4bddb 100644 --- a/chrome/browser/google_apis/fake_drive_service_unittest.cc +++ b/chrome/browser/google_apis/fake_drive_service_unittest.cc @@ -9,7 +9,7 @@ #include "base/file_util.h" #include "base/files/scoped_temp_dir.h" -#include "base/message_loop.h" +#include "base/run_loop.h" #include "base/stl_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" @@ -17,8 +17,7 @@ #include "chrome/browser/google_apis/gdata_wapi_parser.h" #include "chrome/browser/google_apis/gdata_wapi_requests.h" #include "chrome/browser/google_apis/test_util.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/test/test_browser_thread.h" +#include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" namespace google_apis { @@ -27,10 +26,6 @@ namespace { class FakeDriveServiceTest : public testing::Test { protected: - FakeDriveServiceTest() - : ui_thread_(content::BrowserThread::UI, &message_loop_) { - } - // Returns the resource entry that matches |resource_id|. scoped_ptr<ResourceEntry> FindEntry(const std::string& resource_id) { GDataErrorCode error = GDATA_OTHER_ERROR; @@ -38,7 +33,7 @@ class FakeDriveServiceTest : public testing::Test { fake_service_.GetResourceEntry( resource_id, test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); return resource_entry.Pass(); } @@ -58,7 +53,7 @@ class FakeDriveServiceTest : public testing::Test { parent_resource_id, directory_name, test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); return error == HTTP_CREATED; } @@ -82,12 +77,11 @@ class FakeDriveServiceTest : public testing::Test { scoped_ptr<AboutResource> about_resource; fake_service_.GetAboutResource( test_util::CreateCopyResultCallback(&error, &about_resource)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); return about_resource->largest_change_id(); } - base::MessageLoopForUI message_loop_; - content::TestBrowserThread ui_thread_; + content::TestBrowserThreadBundle thread_bundle_; FakeDriveService fake_service_; }; @@ -103,7 +97,7 @@ TEST_F(FakeDriveServiceTest, GetAllResourceList) { scoped_ptr<ResourceList> resource_list; fake_service_.GetAllResourceList( test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -121,7 +115,7 @@ TEST_F(FakeDriveServiceTest, GetAllResourceList_Offline) { scoped_ptr<ResourceList> resource_list; fake_service_.GetAllResourceList( test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, error); EXPECT_FALSE(resource_list); @@ -136,7 +130,7 @@ TEST_F(FakeDriveServiceTest, GetResourceListInDirectory_InRootDirectory) { fake_service_.GetResourceListInDirectory( fake_service_.GetRootResourceId(), test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -154,7 +148,7 @@ TEST_F(FakeDriveServiceTest, GetResourceListInDirectory_InNonRootDirectory) { fake_service_.GetResourceListInDirectory( "folder:1_folder_resource_id", test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -174,7 +168,7 @@ TEST_F(FakeDriveServiceTest, GetResourceListInDirectory_Offline) { fake_service_.GetResourceListInDirectory( fake_service_.GetRootResourceId(), test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, error); EXPECT_FALSE(resource_list); @@ -189,7 +183,7 @@ TEST_F(FakeDriveServiceTest, Search) { fake_service_.Search( "File", // search_query test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -207,7 +201,7 @@ TEST_F(FakeDriveServiceTest, Search_WithAttribute) { fake_service_.Search( "title:1.txt", // search_query test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -225,7 +219,7 @@ TEST_F(FakeDriveServiceTest, Search_MultipleQueries) { fake_service_.Search( "Directory 1", // search_query test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -235,7 +229,7 @@ TEST_F(FakeDriveServiceTest, Search_MultipleQueries) { fake_service_.Search( "\"Directory 1\"", // search_query test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -253,7 +247,7 @@ TEST_F(FakeDriveServiceTest, Search_Offline) { fake_service_.Search( "Directory 1", // search_query test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, error); EXPECT_FALSE(resource_list); @@ -269,7 +263,7 @@ TEST_F(FakeDriveServiceTest, SearchByTitle) { "1.txt", // title fake_service_.GetRootResourceId(), // directory_resource_id test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -288,7 +282,7 @@ TEST_F(FakeDriveServiceTest, SearchByTitle_EmptyDirectoryResourceId) { "1.txt", // title "", // directory resource id test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -308,7 +302,7 @@ TEST_F(FakeDriveServiceTest, SearchByTitle_Offline) { "Directory 1", // title fake_service_.GetRootResourceId(), // directory_resource_id test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, error); EXPECT_FALSE(resource_list); @@ -327,7 +321,7 @@ TEST_F(FakeDriveServiceTest, GetChangeList_NoNewEntries) { fake_service_.GetChangeList( 654321 + 1, // start_changestamp test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -356,7 +350,7 @@ TEST_F(FakeDriveServiceTest, GetChangeList_WithNewEntry) { fake_service_.GetChangeList( 654321 + 1, // start_changestamp test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -376,7 +370,7 @@ TEST_F(FakeDriveServiceTest, GetChangeList_Offline) { fake_service_.GetChangeList( 654321, // start_changestamp test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, error); EXPECT_FALSE(resource_list); @@ -391,7 +385,7 @@ TEST_F(FakeDriveServiceTest, ContinueGetResourceList_GetAllResourceList) { scoped_ptr<ResourceList> resource_list; fake_service_.GetAllResourceList( test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -413,7 +407,7 @@ TEST_F(FakeDriveServiceTest, ContinueGetResourceList_GetAllResourceList) { fake_service_.ContinueGetResourceList( next_url, test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -431,7 +425,7 @@ TEST_F(FakeDriveServiceTest, ContinueGetResourceList_GetAllResourceList) { fake_service_.ContinueGetResourceList( next_url, test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -451,7 +445,7 @@ TEST_F(FakeDriveServiceTest, fake_service_.GetResourceListInDirectory( fake_service_.GetRootResourceId(), test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -473,7 +467,7 @@ TEST_F(FakeDriveServiceTest, fake_service_.ContinueGetResourceList( next_url, test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -491,7 +485,7 @@ TEST_F(FakeDriveServiceTest, fake_service_.ContinueGetResourceList( next_url, test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -510,7 +504,7 @@ TEST_F(FakeDriveServiceTest, ContinueGetResourceList_Search) { fake_service_.Search( "File", // search_query test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -531,7 +525,7 @@ TEST_F(FakeDriveServiceTest, ContinueGetResourceList_Search) { fake_service_.ContinueGetResourceList( next_url, test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -561,7 +555,7 @@ TEST_F(FakeDriveServiceTest, ContinueGetResourceList_GetChangeList) { fake_service_.GetChangeList( 654321 + 1, // start_changestamp test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -583,7 +577,7 @@ TEST_F(FakeDriveServiceTest, ContinueGetResourceList_GetChangeList) { fake_service_.ContinueGetResourceList( next_url, test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -601,7 +595,7 @@ TEST_F(FakeDriveServiceTest, ContinueGetResourceList_GetChangeList) { fake_service_.ContinueGetResourceList( next_url, test_util::CreateCopyResultCallback(&error, &resource_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_list); @@ -618,7 +612,7 @@ TEST_F(FakeDriveServiceTest, GetAboutResource) { scoped_ptr<AboutResource> about_resource; fake_service_.GetAboutResource( test_util::CreateCopyResultCallback(&error, &about_resource)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); @@ -638,7 +632,7 @@ TEST_F(FakeDriveServiceTest, GetAboutResource_Offline) { scoped_ptr<AboutResource> about_resource; fake_service_.GetAboutResource( test_util::CreateCopyResultCallback(&error, &about_resource)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, error); EXPECT_FALSE(about_resource); @@ -652,7 +646,7 @@ TEST_F(FakeDriveServiceTest, GetAppList) { scoped_ptr<AppList> app_list; fake_service_.GetAppList( test_util::CreateCopyResultCallback(&error, &app_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); @@ -668,7 +662,7 @@ TEST_F(FakeDriveServiceTest, GetAppList_Offline) { scoped_ptr<AppList> app_list; fake_service_.GetAppList( test_util::CreateCopyResultCallback(&error, &app_list)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, error); EXPECT_FALSE(app_list); @@ -684,7 +678,7 @@ TEST_F(FakeDriveServiceTest, GetResourceEntry_ExistingFile) { fake_service_.GetResourceEntry( kResourceId, test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_entry); @@ -702,7 +696,7 @@ TEST_F(FakeDriveServiceTest, GetResourceEntry_NonexistingFile) { fake_service_.GetResourceEntry( kResourceId, test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_NOT_FOUND, error); ASSERT_FALSE(resource_entry); @@ -719,7 +713,7 @@ TEST_F(FakeDriveServiceTest, GetResourceEntry_Offline) { fake_service_.GetResourceEntry( kResourceId, test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, error); EXPECT_FALSE(resource_entry); @@ -736,7 +730,7 @@ TEST_F(FakeDriveServiceTest, DeleteResource_ExistingFile) { fake_service_.DeleteResource("file:2_file_resource_id", std::string(), // etag test_util::CreateCopyResultCallback(&error)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); // Resource "file:2_file_resource_id" should be gone now. @@ -751,7 +745,7 @@ TEST_F(FakeDriveServiceTest, DeleteResource_NonexistingFile) { fake_service_.DeleteResource("file:nonexisting_resource_id", std::string(), // etag test_util::CreateCopyResultCallback(&error)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_NOT_FOUND, error); } @@ -765,7 +759,7 @@ TEST_F(FakeDriveServiceTest, DeleteResource_Offline) { fake_service_.DeleteResource("file:2_file_resource_id", std::string(), // etag test_util::CreateCopyResultCallback(&error)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, error); } @@ -793,7 +787,7 @@ TEST_F(FakeDriveServiceTest, DownloadFile_ExistingFile) { get_content_callback.callback(), base::Bind(&test_util::AppendProgressCallbackResult, &download_progress_values)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); EXPECT_EQ(output_file_path, kOutputFilePath); @@ -827,7 +821,7 @@ TEST_F(FakeDriveServiceTest, DownloadFile_NonexistingFile) { test_util::CreateCopyResultCallback(&error, &output_file_path), GetContentCallback(), ProgressCallback()); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_NOT_FOUND, error); } @@ -852,7 +846,7 @@ TEST_F(FakeDriveServiceTest, DownloadFile_Offline) { test_util::CreateCopyResultCallback(&error, &output_file_path), GetContentCallback(), ProgressCallback()); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, error); } @@ -874,7 +868,7 @@ TEST_F(FakeDriveServiceTest, CopyResource) { kParentResourceId, "new name", test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_entry); @@ -899,7 +893,7 @@ TEST_F(FakeDriveServiceTest, CopyResource_NonExisting) { "folder:1_folder_resource_id", "new name", test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_NOT_FOUND, error); } @@ -920,7 +914,7 @@ TEST_F(FakeDriveServiceTest, CopyResource_EmptyParentResourceId) { std::string(), "new name", test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_entry); @@ -946,7 +940,7 @@ TEST_F(FakeDriveServiceTest, CopyResource_Offline) { "folder:1_folder_resource_id", "new name", test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, error); EXPECT_FALSE(resource_entry); @@ -967,7 +961,7 @@ TEST_F(FakeDriveServiceTest, CopyHostedDocument_Existing) { kResourceId, "new name", test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_entry); @@ -990,7 +984,7 @@ TEST_F(FakeDriveServiceTest, CopyHostedDocument_NonExisting) { kResourceId, "new name", test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_NOT_FOUND, error); } @@ -1007,7 +1001,7 @@ TEST_F(FakeDriveServiceTest, CopyHostedDocument_Offline) { kResourceId, "new name", test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, error); EXPECT_FALSE(resource_entry); @@ -1027,7 +1021,7 @@ TEST_F(FakeDriveServiceTest, RenameResource_ExistingFile) { fake_service_.RenameResource(kResourceId, "new name", test_util::CreateCopyResultCallback(&error)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); @@ -1049,7 +1043,7 @@ TEST_F(FakeDriveServiceTest, RenameResource_NonexistingFile) { fake_service_.RenameResource(kResourceId, "new name", test_util::CreateCopyResultCallback(&error)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_NOT_FOUND, error); } @@ -1065,7 +1059,7 @@ TEST_F(FakeDriveServiceTest, RenameResource_Offline) { fake_service_.RenameResource(kResourceId, "new name", test_util::CreateCopyResultCallback(&error)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, error); } @@ -1090,7 +1084,7 @@ TEST_F(FakeDriveServiceTest, TouchResource_ExistingFile) { base::Time::FromUTCExploded(kModifiedDate), base::Time::FromUTCExploded(kLastViewedByMeDate), test_util::CreateCopyResultCallback(&error, &entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); @@ -1121,7 +1115,7 @@ TEST_F(FakeDriveServiceTest, TouchResource_NonexistingFile) { base::Time::FromUTCExploded(kModifiedDate), base::Time::FromUTCExploded(kLastViewedByMeDate), test_util::CreateCopyResultCallback(&error, &entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_NOT_FOUND, error); } @@ -1143,7 +1137,7 @@ TEST_F(FakeDriveServiceTest, TouchResource_Offline) { base::Time::FromUTCExploded(kModifiedDate), base::Time::FromUTCExploded(kLastViewedByMeDate), test_util::CreateCopyResultCallback(&error, &entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, error); } @@ -1169,7 +1163,7 @@ TEST_F(FakeDriveServiceTest, AddResourceToDirectory_FileInRootDirectory) { kNewParentResourceId, kResourceId, test_util::CreateCopyResultCallback(&error)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); @@ -1202,7 +1196,7 @@ TEST_F(FakeDriveServiceTest, AddResourceToDirectory_FileInNonRootDirectory) { kNewParentResourceId, kResourceId, test_util::CreateCopyResultCallback(&error)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); @@ -1226,7 +1220,7 @@ TEST_F(FakeDriveServiceTest, AddResourceToDirectory_NonexistingFile) { kNewParentResourceId, kResourceId, test_util::CreateCopyResultCallback(&error)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_NOT_FOUND, error); } @@ -1251,7 +1245,7 @@ TEST_F(FakeDriveServiceTest, AddResourceToDirectory_OrphanFile) { kNewParentResourceId, kResourceId, test_util::CreateCopyResultCallback(&error)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); @@ -1276,7 +1270,7 @@ TEST_F(FakeDriveServiceTest, AddResourceToDirectory_Offline) { kNewParentResourceId, kResourceId, test_util::CreateCopyResultCallback(&error)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, error); } @@ -1304,7 +1298,7 @@ TEST_F(FakeDriveServiceTest, RemoveResourceFromDirectory_ExistingFile) { kParentResourceId, kResourceId, test_util::CreateCopyResultCallback(&error)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); @@ -1330,7 +1324,7 @@ TEST_F(FakeDriveServiceTest, RemoveResourceFromDirectory_NonexistingFile) { kParentResourceId, kResourceId, test_util::CreateCopyResultCallback(&error)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_NOT_FOUND, error); } @@ -1347,7 +1341,7 @@ TEST_F(FakeDriveServiceTest, RemoveResourceFromDirectory_OrphanFile) { kParentResourceId, kResourceId, test_util::CreateCopyResultCallback(&error)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_NOT_FOUND, error); } @@ -1365,7 +1359,7 @@ TEST_F(FakeDriveServiceTest, RemoveResourceFromDirectory_Offline) { kParentResourceId, kResourceId, test_util::CreateCopyResultCallback(&error)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, error); } @@ -1384,7 +1378,7 @@ TEST_F(FakeDriveServiceTest, AddNewDirectory_ToRootDirectory) { fake_service_.GetRootResourceId(), "new directory", test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_CREATED, error); ASSERT_TRUE(resource_entry); @@ -1412,7 +1406,7 @@ TEST_F(FakeDriveServiceTest, AddNewDirectory_ToRootDirectoryOnEmptyFileSystem) { fake_service_.GetRootResourceId(), "new directory", test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_CREATED, error); ASSERT_TRUE(resource_entry); @@ -1442,7 +1436,7 @@ TEST_F(FakeDriveServiceTest, AddNewDirectory_ToNonRootDirectory) { kParentResourceId, "new directory", test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_CREATED, error); ASSERT_TRUE(resource_entry); @@ -1467,7 +1461,7 @@ TEST_F(FakeDriveServiceTest, AddNewDirectory_ToNonexistingDirectory) { kParentResourceId, "new directory", test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_NOT_FOUND, error); EXPECT_FALSE(resource_entry); @@ -1484,7 +1478,7 @@ TEST_F(FakeDriveServiceTest, AddNewDirectory_Offline) { fake_service_.GetRootResourceId(), "new directory", test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, error); EXPECT_FALSE(resource_entry); @@ -1504,7 +1498,7 @@ TEST_F(FakeDriveServiceTest, InitiateUploadNewFile_Offline) { "folder:1_folder_resource_id", "new file.foo", test_util::CreateCopyResultCallback(&error, &upload_location)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, error); EXPECT_TRUE(upload_location.is_empty()); @@ -1523,7 +1517,7 @@ TEST_F(FakeDriveServiceTest, InitiateUploadNewFile_NotFound) { "non_existent", "new file.foo", test_util::CreateCopyResultCallback(&error, &upload_location)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_NOT_FOUND, error); EXPECT_TRUE(upload_location.is_empty()); @@ -1542,7 +1536,7 @@ TEST_F(FakeDriveServiceTest, InitiateUploadNewFile) { "folder:1_folder_resource_id", "new file.foo", test_util::CreateCopyResultCallback(&error, &upload_location)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); EXPECT_FALSE(upload_location.is_empty()); @@ -1564,7 +1558,7 @@ TEST_F(FakeDriveServiceTest, InitiateUploadExistingFile_Offline) { "file:2_file_resource_id", std::string(), // etag test_util::CreateCopyResultCallback(&error, &upload_location)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, error); EXPECT_TRUE(upload_location.is_empty()); @@ -1583,7 +1577,7 @@ TEST_F(FakeDriveServiceTest, InitiateUploadExistingFile_NotFound) { "non_existent", std::string(), // etag test_util::CreateCopyResultCallback(&error, &upload_location)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_NOT_FOUND, error); EXPECT_TRUE(upload_location.is_empty()); @@ -1602,7 +1596,7 @@ TEST_F(FakeDriveServiceTest, InitiateUploadExistingFile_WrongETag) { "file:2_file_resource_id", "invalid_etag", test_util::CreateCopyResultCallback(&error, &upload_location)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_PRECONDITION, error); EXPECT_TRUE(upload_location.is_empty()); @@ -1621,7 +1615,7 @@ TEST_F(FakeDriveServiceTest, InitiateUpload_ExistingFile) { "file:2_file_resource_id", "\"HhMOFgxXHit7ImBr\"", test_util::CreateCopyResultCallback(&error, &upload_location)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); EXPECT_EQ(GURL("https://2_file_link_resumable_create_media?mode=existing"), @@ -1641,7 +1635,7 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_Offline) { "folder:1_folder_resource_id", "new file.foo", test_util::CreateCopyResultCallback(&error, &upload_location)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); EXPECT_FALSE(upload_location.is_empty()); @@ -1659,7 +1653,7 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_Offline) { base::FilePath(), test_util::CreateCopyResultCallback(&response, &entry), ProgressCallback()); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, response.code); EXPECT_FALSE(entry.get()); @@ -1678,7 +1672,7 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_NotFound) { "folder:1_folder_resource_id", "new file.foo", test_util::CreateCopyResultCallback(&error, &upload_location)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); ASSERT_EQ(HTTP_SUCCESS, error); @@ -1691,7 +1685,7 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_NotFound) { base::FilePath(), test_util::CreateCopyResultCallback(&response, &entry), ProgressCallback()); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_NOT_FOUND, response.code); EXPECT_FALSE(entry.get()); @@ -1710,7 +1704,7 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_ExistingFile) { "file:2_file_resource_id", "\"HhMOFgxXHit7ImBr\"", test_util::CreateCopyResultCallback(&error, &upload_location)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); ASSERT_EQ(HTTP_SUCCESS, error); @@ -1725,7 +1719,7 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_ExistingFile) { test_util::CreateCopyResultCallback(&response, &entry), base::Bind(&test_util::AppendProgressCallbackResult, &upload_progress_values)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_RESUME_INCOMPLETE, response.code); EXPECT_FALSE(entry.get()); @@ -1743,7 +1737,7 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_ExistingFile) { test_util::CreateCopyResultCallback(&response, &entry), base::Bind(&test_util::AppendProgressCallbackResult, &upload_progress_values)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, response.code); EXPECT_TRUE(entry.get()); @@ -1768,7 +1762,7 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_NewFile) { "folder:1_folder_resource_id", "new file.foo", test_util::CreateCopyResultCallback(&error, &upload_location)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); EXPECT_FALSE(upload_location.is_empty()); @@ -1786,7 +1780,7 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_NewFile) { test_util::CreateCopyResultCallback(&response, &entry), base::Bind(&test_util::AppendProgressCallbackResult, &upload_progress_values)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_RESUME_INCOMPLETE, response.code); EXPECT_FALSE(entry.get()); @@ -1804,7 +1798,7 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_NewFile) { test_util::CreateCopyResultCallback(&response, &entry), base::Bind(&test_util::AppendProgressCallbackResult, &upload_progress_values)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_CREATED, response.code); EXPECT_TRUE(entry.get()); @@ -1837,7 +1831,7 @@ TEST_F(FakeDriveServiceTest, AddNewFile_ToRootDirectory) { kTitle, false, // shared_with_me test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_CREATED, error); ASSERT_TRUE(resource_entry); @@ -1875,7 +1869,7 @@ TEST_F(FakeDriveServiceTest, AddNewFile_ToRootDirectoryOnEmptyFileSystem) { kTitle, false, // shared_with_me test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_CREATED, error); ASSERT_TRUE(resource_entry); @@ -1914,7 +1908,7 @@ TEST_F(FakeDriveServiceTest, AddNewFile_ToNonRootDirectory) { kTitle, false, // shared_with_me test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_CREATED, error); ASSERT_TRUE(resource_entry); @@ -1948,7 +1942,7 @@ TEST_F(FakeDriveServiceTest, AddNewFile_ToNonexistingDirectory) { kTitle, false, // shared_with_me test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_NOT_FOUND, error); EXPECT_FALSE(resource_entry); @@ -1972,7 +1966,7 @@ TEST_F(FakeDriveServiceTest, AddNewFile_Offline) { kTitle, false, // shared_with_me test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, error); EXPECT_FALSE(resource_entry); @@ -1999,7 +1993,7 @@ TEST_F(FakeDriveServiceTest, AddNewFile_SharedWithMeLabel) { kTitle, true, // shared_with_me test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_CREATED, error); ASSERT_TRUE(resource_entry); @@ -2032,7 +2026,7 @@ TEST_F(FakeDriveServiceTest, SetLastModifiedTime_ExistingFile) { kResourceId, time, test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_SUCCESS, error); ASSERT_TRUE(resource_entry); @@ -2053,7 +2047,7 @@ TEST_F(FakeDriveServiceTest, SetLastModifiedTime_NonexistingFile) { kResourceId, time, test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(HTTP_NOT_FOUND, error); EXPECT_FALSE(resource_entry); @@ -2074,7 +2068,7 @@ TEST_F(FakeDriveServiceTest, SetLastModifiedTime_Offline) { kResourceId, time, test_util::CreateCopyResultCallback(&error, &resource_entry)); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(GDATA_NO_CONNECTION, error); EXPECT_FALSE(resource_entry); diff --git a/chrome/browser/google_apis/request_registry_unittest.cc b/chrome/browser/google_apis/request_registry_unittest.cc index 3d891dc..d2f7b34 100644 --- a/chrome/browser/google_apis/request_registry_unittest.cc +++ b/chrome/browser/google_apis/request_registry_unittest.cc @@ -6,9 +6,8 @@ #include "base/compiler_specific.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop.h" #include "chrome/browser/google_apis/request_registry.h" -#include "content/public/test/test_browser_thread.h" +#include "content/public/test/test_browser_thread_bundle.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -38,11 +37,7 @@ class MockRequest : public RequestRegistry::Request, class RequestRegistryTest : public testing::Test { protected: - RequestRegistryTest() - : ui_thread_(content::BrowserThread::UI, &message_loop_) { - } - base::MessageLoopForUI message_loop_; - content::TestBrowserThread ui_thread_; + content::TestBrowserThreadBundle thread_bundle_; }; TEST_F(RequestRegistryTest, OneSuccess) { |