diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/files/file_path_watcher_browsertest.cc | 3 | ||||
-rw-r--r-- | base/files/important_file_writer_unittest.cc | 3 | ||||
-rw-r--r-- | base/message_loop_unittest.cc | 4 | ||||
-rw-r--r-- | base/message_pump_glib_unittest.cc | 6 | ||||
-rw-r--r-- | base/metrics/field_trial_unittest.cc | 16 | ||||
-rw-r--r-- | base/observer_list_unittest.cc | 28 | ||||
-rw-r--r-- | base/prefs/json_pref_store_unittest.cc | 4 | ||||
-rw-r--r-- | base/system_monitor/system_monitor_unittest.cc | 27 | ||||
-rw-r--r-- | base/task_runner_util_unittest.cc | 51 |
9 files changed, 73 insertions, 69 deletions
diff --git a/base/files/file_path_watcher_browsertest.cc b/base/files/file_path_watcher_browsertest.cc index e7d1680..4f0cb27 100644 --- a/base/files/file_path_watcher_browsertest.cc +++ b/base/files/file_path_watcher_browsertest.cc @@ -22,6 +22,7 @@ #include "base/files/scoped_temp_dir.h" #include "base/message_loop.h" #include "base/message_loop_proxy.h" +#include "base/run_loop.h" #include "base/stl_util.h" #include "base/stringprintf.h" #include "base/synchronization/waitable_event.h" @@ -167,7 +168,7 @@ class FilePathWatcherTest : public testing::Test { } virtual void TearDown() OVERRIDE { - loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); } void DeleteDelegateOnFileThread(TestDelegate* delegate) { diff --git a/base/files/important_file_writer_unittest.cc b/base/files/important_file_writer_unittest.cc index 970e9f6..65da814 100644 --- a/base/files/important_file_writer_unittest.cc +++ b/base/files/important_file_writer_unittest.cc @@ -10,6 +10,7 @@ #include "base/files/scoped_temp_dir.h" #include "base/logging.h" #include "base/message_loop.h" +#include "base/run_loop.h" #include "base/threading/thread.h" #include "base/time.h" #include "testing/gtest/include/gtest/gtest.h" @@ -63,7 +64,7 @@ TEST_F(ImportantFileWriterTest, Basic) { MessageLoopProxy::current()); EXPECT_FALSE(file_util::PathExists(writer.path())); writer.WriteNow("foo"); - loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); ASSERT_TRUE(file_util::PathExists(writer.path())); EXPECT_EQ("foo", GetFileContent(writer.path())); diff --git a/base/message_loop_unittest.cc b/base/message_loop_unittest.cc index c839fac..984a025 100644 --- a/base/message_loop_unittest.cc +++ b/base/message_loop_unittest.cc @@ -327,7 +327,7 @@ void RunTest_PostDelayedTask_SharedTimer( // and then run all pending to force them both to have run. This is just // encouraging flakiness if there is any. PlatformThread::Sleep(TimeDelta::FromMilliseconds(100)); - loop.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_TRUE(run_time1.is_null()); EXPECT_FALSE(run_time2.is_null()); @@ -383,7 +383,7 @@ void RunTest_PostDelayedTask_SharedTimer_SubPump() { // and then run all pending to force them both to have run. This is just // encouraging flakiness if there is any. PlatformThread::Sleep(TimeDelta::FromMilliseconds(100)); - loop.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_TRUE(run_time.is_null()); } diff --git a/base/message_pump_glib_unittest.cc b/base/message_pump_glib_unittest.cc index 9ef3822..be11c2f 100644 --- a/base/message_pump_glib_unittest.cc +++ b/base/message_pump_glib_unittest.cc @@ -15,6 +15,7 @@ #include "base/callback.h" #include "base/memory/ref_counted.h" #include "base/message_loop.h" +#include "base/run_loop.h" #include "base/threading/thread.h" #include "testing/gtest/include/gtest/gtest.h" @@ -22,6 +23,7 @@ #include <gtk/gtk.h> #endif +namespace base { namespace { // This class injects dummy "events" into the GLib loop. When "handled" these @@ -189,7 +191,7 @@ TEST_F(MessagePumpGLibTest, TestQuit) { // Checks that Quit works and that the basic infrastructure is working. // Quit from a task - loop()->RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_EQ(0, injector()->processed_events()); injector()->Reset(); @@ -574,3 +576,5 @@ TEST_F(MessagePumpGLibTest, TestGtkLoop) { base::Bind(&TestGtkLoopInternal, base::Unretained(injector()))); loop()->Run(); } + +} // namespace base diff --git a/base/metrics/field_trial_unittest.cc b/base/metrics/field_trial_unittest.cc index 09a3809..0e872ff 100644 --- a/base/metrics/field_trial_unittest.cc +++ b/base/metrics/field_trial_unittest.cc @@ -2,9 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/message_loop.h" #include "base/metrics/field_trial.h" + +#include "base/message_loop.h" #include "base/rand_util.h" +#include "base/run_loop.h" #include "base/stringprintf.h" #include "base/string_number_conversions.h" #include "testing/gtest/include/gtest/gtest.h" @@ -450,7 +452,7 @@ TEST_F(FieldTrialTest, CreateTrialsFromStringObserver) { TestFieldTrialObserver observer; ASSERT_TRUE(FieldTrialList::CreateTrialsFromString("Abc/def/")); - message_loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_EQ("Abc", observer.trial_name()); EXPECT_EQ("def", observer.group_name()); } @@ -637,7 +639,7 @@ TEST_F(FieldTrialTest, Observe) { const int chosen_group = trial->group(); EXPECT_TRUE(chosen_group == default_group || chosen_group == secondary_group); - message_loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_EQ(kTrialName, observer.trial_name()); if (chosen_group == default_group) EXPECT_EQ(kDefaultGroupName, observer.group_name()); @@ -659,13 +661,13 @@ TEST_F(FieldTrialTest, ObserveDisabled) { trial->Disable(); // Observer shouldn't be notified of a disabled trial. - message_loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_TRUE(observer.trial_name().empty()); EXPECT_TRUE(observer.group_name().empty()); // Observer shouldn't be notified even after a |group()| call. EXPECT_EQ(default_group, trial->group()); - message_loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_TRUE(observer.trial_name().empty()); EXPECT_TRUE(observer.group_name().empty()); } @@ -685,13 +687,13 @@ TEST_F(FieldTrialTest, ObserveForcedDisabled) { trial->Disable(); // Observer shouldn't be notified of a disabled trial, even when forced. - message_loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_TRUE(observer.trial_name().empty()); EXPECT_TRUE(observer.group_name().empty()); // Observer shouldn't be notified even after a |group()| call. EXPECT_EQ(default_group, trial->group()); - message_loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_TRUE(observer.trial_name().empty()); EXPECT_TRUE(observer.group_name().empty()); } diff --git a/base/observer_list_unittest.cc b/base/observer_list_unittest.cc index 0a2a49d..591d230 100644 --- a/base/observer_list_unittest.cc +++ b/base/observer_list_unittest.cc @@ -10,12 +10,11 @@ #include "base/compiler_specific.h" #include "base/memory/weak_ptr.h" #include "base/message_loop.h" +#include "base/run_loop.h" #include "base/threading/platform_thread.h" #include "testing/gtest/include/gtest/gtest.h" -using base::PlatformThread; -using base::Time; - +namespace base { namespace { class Foo { @@ -223,14 +222,14 @@ TEST(ObserverListThreadSafeTest, BasicTest) { observer_list->AddObserver(&b); observer_list->Notify(&Foo::Observe, 10); - loop.RunUntilIdle(); + RunLoop().RunUntilIdle(); observer_list->AddObserver(&evil); observer_list->AddObserver(&c); observer_list->AddObserver(&d); observer_list->Notify(&Foo::Observe, 10); - loop.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_EQ(20, a.total); EXPECT_EQ(-20, b.total); @@ -253,7 +252,7 @@ TEST(ObserverListThreadSafeTest, RemoveObserver) { observer_list->RemoveObserver(&b); observer_list->Notify(&Foo::Observe, 10); - loop.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_EQ(0, a.total); EXPECT_EQ(0, b.total); @@ -264,7 +263,7 @@ TEST(ObserverListThreadSafeTest, RemoveObserver) { observer_list->RemoveObserver(&b); observer_list->Notify(&Foo::Observe, 10); - loop.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_EQ(10, a.total); EXPECT_EQ(0, b.total); @@ -286,7 +285,7 @@ TEST(ObserverListThreadSafeTest, WithoutMessageLoop) { observer_list->AddObserver(&c); observer_list->Notify(&Foo::Observe, 10); - loop.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_EQ(0, a.total); EXPECT_EQ(0, b.total); @@ -300,7 +299,7 @@ TEST(ObserverListThreadSafeTest, WithoutMessageLoop) { // Notify again. observer_list->Notify(&Foo::Observe, 20); - loop.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_EQ(20, a.total); EXPECT_EQ(0, b.total); @@ -314,7 +313,7 @@ TEST(ObserverListThreadSafeTest, WithoutMessageLoop) { MessageLoop loop; observer_list->AddObserver(&b); observer_list->Notify(&Foo::Observe, 30); - loop.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_EQ(20, a.total); EXPECT_EQ(30, b.total); @@ -359,7 +358,7 @@ TEST(ObserverListThreadSafeTest, RemoveMultipleObservers) { a.AddFooToRemove(&b); observer_list->Notify(&Foo::Observe, 1); - loop.RunUntilIdle(); + RunLoop().RunUntilIdle(); } // A test driver for a multi-threaded notification loop. Runs a number @@ -399,7 +398,7 @@ static void ThreadSafeObserverHarness(int num_threads, observer_list->Notify(&Foo::Observe, 10); - loop.RunUntilIdle(); + RunLoop().RunUntilIdle(); } for (int index = 0; index < num_threads; index++) { @@ -464,7 +463,7 @@ TEST(ObserverListThreadSafeTest, Existing) { observer_list->AddObserver(&b); observer_list->Notify(&Foo::Observe, 1); - loop.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_TRUE(b.added); // B's adder should not have been notified because it was added during @@ -473,7 +472,7 @@ TEST(ObserverListThreadSafeTest, Existing) { // Notify again to make sure b's adder is notified. observer_list->Notify(&Foo::Observe, 1); - loop.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_EQ(1, b.adder.total); } @@ -547,3 +546,4 @@ TEST(ObserverListTest, IteratorOutlivesList) { } } // namespace +} // namespace base diff --git a/base/prefs/json_pref_store_unittest.cc b/base/prefs/json_pref_store_unittest.cc index b44d9e5..f932988 100644 --- a/base/prefs/json_pref_store_unittest.cc +++ b/base/prefs/json_pref_store_unittest.cc @@ -207,7 +207,7 @@ TEST_F(JsonPrefStoreTest, BasicAsync) { EXPECT_CALL(mock_observer, OnInitializationCompleted(true)).Times(1); EXPECT_CALL(*mock_error_delegate, OnError(PersistentPrefStore::PREF_READ_ERROR_NONE)).Times(0); - message_loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); pref_store->RemoveObserver(&mock_observer); ASSERT_FALSE(pref_store->ReadOnly()); @@ -244,7 +244,7 @@ TEST_F(JsonPrefStoreTest, AsyncNonExistingFile) { EXPECT_CALL(mock_observer, OnInitializationCompleted(true)).Times(1); EXPECT_CALL(*mock_error_delegate, OnError(PersistentPrefStore::PREF_READ_ERROR_NO_FILE)).Times(1); - message_loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); pref_store->RemoveObserver(&mock_observer); EXPECT_FALSE(pref_store->ReadOnly()); diff --git a/base/system_monitor/system_monitor_unittest.cc b/base/system_monitor/system_monitor_unittest.cc index 10bd7e7..56f48ef 100644 --- a/base/system_monitor/system_monitor_unittest.cc +++ b/base/system_monitor/system_monitor_unittest.cc @@ -6,6 +6,7 @@ #include "base/file_path.h" #include "base/message_loop.h" +#include "base/run_loop.h" #include "base/test/mock_devices_changed_observer.h" #include "base/utf_string_conversions.h" #include "testing/gmock/include/gmock/gmock.h" @@ -80,27 +81,27 @@ TEST_F(SystemMonitorTest, PowerNotifications) { // Sending resume when not suspended should have no effect. system_monitor_->ProcessPowerMessage(SystemMonitor::RESUME_EVENT); - message_loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_EQ(test[0].resumes(), 0); // Pretend we suspended. system_monitor_->ProcessPowerMessage(SystemMonitor::SUSPEND_EVENT); - message_loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_EQ(test[0].suspends(), 1); // Send a second suspend notification. This should be suppressed. system_monitor_->ProcessPowerMessage(SystemMonitor::SUSPEND_EVENT); - message_loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_EQ(test[0].suspends(), 1); // Pretend we were awakened. system_monitor_->ProcessPowerMessage(SystemMonitor::RESUME_EVENT); - message_loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_EQ(test[0].resumes(), 1); // Send a duplicate resume notification. This should be suppressed. system_monitor_->ProcessPowerMessage(SystemMonitor::RESUME_EVENT); - message_loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_EQ(test[0].resumes(), 1); } @@ -130,20 +131,20 @@ TEST_F(SystemMonitorTest, DeviceChangeNotifications) { } system_monitor_->ProcessDevicesChanged(SystemMonitor::DEVTYPE_UNKNOWN); - message_loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); system_monitor_->ProcessDevicesChanged(SystemMonitor::DEVTYPE_UNKNOWN); system_monitor_->ProcessDevicesChanged(SystemMonitor::DEVTYPE_UNKNOWN); - message_loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); system_monitor_->ProcessRemovableStorageAttached(kDeviceId1, kDeviceName, FILE_PATH_LITERAL("path")); - message_loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); system_monitor_->ProcessRemovableStorageDetached(kDeviceId1); system_monitor_->ProcessRemovableStorageDetached(kDeviceId2); - message_loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); } TEST_F(SystemMonitorTest, GetAttachedRemovableStorageEmpty) { @@ -159,7 +160,7 @@ TEST_F(SystemMonitorTest, GetAttachedRemovableStorageAttachDetach) { system_monitor_->ProcessRemovableStorageAttached(kDeviceId1, kDeviceName1, kDevicePath1.value()); - message_loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); std::vector<SystemMonitor::RemovableStorageInfo> devices = system_monitor_->GetAttachedRemovableStorage(); ASSERT_EQ(1U, devices.size()); @@ -173,7 +174,7 @@ TEST_F(SystemMonitorTest, GetAttachedRemovableStorageAttachDetach) { system_monitor_->ProcessRemovableStorageAttached(kDeviceId2, kDeviceName2, kDevicePath2.value()); - message_loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); devices = system_monitor_->GetAttachedRemovableStorage(); ASSERT_EQ(2U, devices.size()); EXPECT_EQ(kDeviceId1, devices[0].device_id); @@ -184,7 +185,7 @@ TEST_F(SystemMonitorTest, GetAttachedRemovableStorageAttachDetach) { EXPECT_EQ(kDevicePath2.value(), devices[1].location); system_monitor_->ProcessRemovableStorageDetached(kDeviceId1); - message_loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); devices = system_monitor_->GetAttachedRemovableStorage(); ASSERT_EQ(1U, devices.size()); EXPECT_EQ(kDeviceId2, devices[0].device_id); @@ -192,7 +193,7 @@ TEST_F(SystemMonitorTest, GetAttachedRemovableStorageAttachDetach) { EXPECT_EQ(kDevicePath2.value(), devices[0].location); system_monitor_->ProcessRemovableStorageDetached(kDeviceId2); - message_loop_.RunUntilIdle(); + RunLoop().RunUntilIdle(); devices = system_monitor_->GetAttachedRemovableStorage(); EXPECT_EQ(0U, devices.size()); } diff --git a/base/task_runner_util_unittest.cc b/base/task_runner_util_unittest.cc index d4d3769..f02a388 100644 --- a/base/task_runner_util_unittest.cc +++ b/base/task_runner_util_unittest.cc @@ -6,6 +6,7 @@ #include "base/bind.h" #include "base/message_loop.h" +#include "base/run_loop.h" #include "testing/gtest/include/gtest/gtest.h" namespace base { @@ -65,31 +66,29 @@ void ExpectScopedFoo(scoped_ptr_malloc<Foo, FreeFooFunctor> foo) { } // namespace TEST(TaskRunnerHelpersTest, PostTaskAndReplyWithResult) { - MessageLoop message_loop; int result = 0; - PostTaskAndReplyWithResult( - message_loop.message_loop_proxy(), - FROM_HERE, - Bind(&ReturnFourtyTwo), - Bind(&StoreValue, &result)); + MessageLoop message_loop; + PostTaskAndReplyWithResult(message_loop.message_loop_proxy(), + FROM_HERE, + Bind(&ReturnFourtyTwo), + Bind(&StoreValue, &result)); - message_loop.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_EQ(42, result); } TEST(TaskRunnerHelpersTest, PostTaskAndReplyWithResultImplicitConvert) { - MessageLoop message_loop; double result = 0; - PostTaskAndReplyWithResult( - message_loop.message_loop_proxy(), - FROM_HERE, - Bind(&ReturnFourtyTwo), - Bind(&StoreDoubleValue, &result)); + MessageLoop message_loop; + PostTaskAndReplyWithResult(message_loop.message_loop_proxy(), + FROM_HERE, + Bind(&ReturnFourtyTwo), + Bind(&StoreDoubleValue, &result)); - message_loop.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_DOUBLE_EQ(42.0, result); } @@ -99,14 +98,12 @@ TEST(TaskRunnerHelpersTest, PostTaskAndReplyWithResultPassed) { g_foo_free_count = 0; MessageLoop message_loop; + PostTaskAndReplyWithResult(message_loop.message_loop_proxy(), + FROM_HERE, + Bind(&CreateFoo), + Bind(&ExpectFoo)); - PostTaskAndReplyWithResult( - message_loop.message_loop_proxy(), - FROM_HERE, - Bind(&CreateFoo), - Bind(&ExpectFoo)); - - message_loop.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_EQ(1, g_foo_destruct_count); EXPECT_EQ(0, g_foo_free_count); @@ -117,14 +114,12 @@ TEST(TaskRunnerHelpersTest, PostTaskAndReplyWithResultPassedFreeProc) { g_foo_free_count = 0; MessageLoop message_loop; + PostTaskAndReplyWithResult(message_loop.message_loop_proxy(), + FROM_HERE, + Bind(&CreateScopedFoo), + Bind(&ExpectScopedFoo)); - PostTaskAndReplyWithResult( - message_loop.message_loop_proxy(), - FROM_HERE, - Bind(&CreateScopedFoo), - Bind(&ExpectScopedFoo)); - - message_loop.RunUntilIdle(); + RunLoop().RunUntilIdle(); EXPECT_EQ(1, g_foo_destruct_count); EXPECT_EQ(1, g_foo_free_count); |