Remove calls to deprecated MessageLoop methods on Windows and Linux.
This Cl removes most calls to these methods on Windows and Linux: - MessageLoop::PostTask - MessageLoop::PostDelayedTask - MessageLoop::ReleaseSoon - MessageLoop::DeleteSoon - MessageLoop::Run - MessageLoop::RunUntilIdle Also note that calls to thread->message_loop()->task_runner() have been replaced with thread->task_runner() (|thread| is a base::Thread). This CL was generated by running the clang-tidy checks available here https://crbug.com/616447#c153 on Windows and Mac and by applying a few manual fixes (e.g. to remove a call made from a macro in audio_low_latency_input_win_unittest.cc). BUG=616447 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation Review-Url: https://codereview.chromium.org/2211473003 Cr-Commit-Position: refs/heads/master@{#414442}
This commit is contained in:
ash
shelf
shell
content
test
base
memory
message_loop
message_loop_task_runner_unittest.ccmessage_loop_unittest.ccmessage_pump_glib_unittest.ccmessage_pump_perftest.cc
task_scheduler
win
blimp/client/core/contents
chrome
browser
download
first_run
importer
local_discovery
metrics
password_manager
native_backend_gnome_x_unittest.ccnative_backend_kwallet_x_unittest.ccnative_backend_libsecret_unittest.ccpassword_store_win_unittest.cc
prerender
printing
cloud_print
profiles
safe_browsing
ui
common
test
chromedriver
server
components
arc
autofill
content
browser
cronet
data_usage
data_use_measurement
dom_distiller
nacl
policy
core
sync
driver
tools
testserver
sync_sessions
content
browser
appcache
download
frame_host
indexed_db
renderer_host
tracing
web_contents
gpu
public
renderer
media
shell
browser
dbus
end_to_end_async_unittest.ccmock_unittest.ccobject_manager_unittest.ccsignal_sender_verification_unittest.cctest_service.cc
device
battery
bluetooth
extensions
ipc
attachment_broker_privileged_win_unittest.ccipc_channel_mojo_unittest.ccipc_channel_unittest.ccipc_channel_win.cc
jingle/notifier/listener
media
audio
capture
video
cast
test
device_monitors
gpu
rendering_helper.ccv4l2_image_processor.ccv4l2_slice_video_decode_accelerator.ccv4l2_video_decode_accelerator.ccvaapi_video_encode_accelerator.cc
midi
net
base
dns
http
test
spawned_test_server
tools
ppapi/nacl_irt
remoting
services/navigation/content_client
ui
app_list
aura
base
events
gl
keyboard
message_center
shell_dialogs
views
controls
widget
@ -32,6 +32,7 @@
|
||||
#include "ash/wm/window_state_aura.h"
|
||||
#include "ash/wm/window_util.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "ui/aura/client/aura_constants.h"
|
||||
#include "ui/aura/client/window_tree_client.h"
|
||||
#include "ui/aura/window.h"
|
||||
@ -89,7 +90,7 @@ class ShelfAnimationWaiter : views::WidgetObserver {
|
||||
if (IsDoneAnimating())
|
||||
done_waiting_ = true;
|
||||
else
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
|
||||
// Returns true if the animation has completed and it was valid.
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "base/command_line.h"
|
||||
#include "base/i18n/icu_util.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/threading/thread.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
@ -171,7 +172,7 @@ void ShellBrowserMainParts::PostMainMessageLoopRun() {
|
||||
}
|
||||
|
||||
bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) {
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "ash/common/shelf/shelf_model.h"
|
||||
#include "ash/common/shelf/shelf_view.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "ui/views/animation/bounds_animator.h"
|
||||
#include "ui/views/controls/menu/menu_runner.h"
|
||||
#include "ui/views/view_model.h"
|
||||
@ -93,7 +94,7 @@ void ShelfViewTestAPI::RunMessageLoopUntilAnimationsDone() {
|
||||
|
||||
// This nested loop will quit when TestAPIAnimationObserver's
|
||||
// OnBoundsAnimatorDone is called.
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
shelf_view_->bounds_animator_->RemoveObserver(observer.get());
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/memory_pressure_listener.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
@ -209,7 +210,7 @@ TEST_F(WinMemoryPressureMonitorTest, CheckMemoryPressure) {
|
||||
// events.
|
||||
monitor.SetNone();
|
||||
monitor.CheckMemoryPressure();
|
||||
message_loop_.RunUntilIdle();
|
||||
RunLoop().RunUntilIdle();
|
||||
EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE,
|
||||
monitor.GetCurrentPressureLevel());
|
||||
|
||||
@ -219,7 +220,7 @@ TEST_F(WinMemoryPressureMonitorTest, CheckMemoryPressure) {
|
||||
MEMORY_PRESSURE_LEVEL_MODERATE));
|
||||
monitor.SetModerate();
|
||||
monitor.CheckMemoryPressure();
|
||||
message_loop_.RunUntilIdle();
|
||||
RunLoop().RunUntilIdle();
|
||||
EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE,
|
||||
monitor.GetCurrentPressureLevel());
|
||||
testing::Mock::VerifyAndClearExpectations(&monitor);
|
||||
@ -232,7 +233,7 @@ TEST_F(WinMemoryPressureMonitorTest, CheckMemoryPressure) {
|
||||
MEMORY_PRESSURE_LEVEL_MODERATE));
|
||||
}
|
||||
monitor.CheckMemoryPressure();
|
||||
message_loop_.RunUntilIdle();
|
||||
RunLoop().RunUntilIdle();
|
||||
EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE,
|
||||
monitor.GetCurrentPressureLevel());
|
||||
testing::Mock::VerifyAndClearExpectations(&monitor);
|
||||
@ -244,7 +245,7 @@ TEST_F(WinMemoryPressureMonitorTest, CheckMemoryPressure) {
|
||||
MEMORY_PRESSURE_LEVEL_CRITICAL));
|
||||
monitor.SetCritical();
|
||||
monitor.CheckMemoryPressure();
|
||||
message_loop_.RunUntilIdle();
|
||||
RunLoop().RunUntilIdle();
|
||||
EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL,
|
||||
monitor.GetCurrentPressureLevel());
|
||||
testing::Mock::VerifyAndClearExpectations(&monitor);
|
||||
@ -254,7 +255,7 @@ TEST_F(WinMemoryPressureMonitorTest, CheckMemoryPressure) {
|
||||
OnMemoryPressure(MemoryPressureListener::
|
||||
MEMORY_PRESSURE_LEVEL_CRITICAL));
|
||||
monitor.CheckMemoryPressure();
|
||||
message_loop_.RunUntilIdle();
|
||||
RunLoop().RunUntilIdle();
|
||||
EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL,
|
||||
monitor.GetCurrentPressureLevel());
|
||||
testing::Mock::VerifyAndClearExpectations(&monitor);
|
||||
@ -266,7 +267,7 @@ TEST_F(WinMemoryPressureMonitorTest, CheckMemoryPressure) {
|
||||
MEMORY_PRESSURE_LEVEL_MODERATE));
|
||||
monitor.SetModerate();
|
||||
monitor.CheckMemoryPressure();
|
||||
message_loop_.RunUntilIdle();
|
||||
RunLoop().RunUntilIdle();
|
||||
EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE,
|
||||
monitor.GetCurrentPressureLevel());
|
||||
testing::Mock::VerifyAndClearExpectations(&monitor);
|
||||
@ -279,7 +280,7 @@ TEST_F(WinMemoryPressureMonitorTest, CheckMemoryPressure) {
|
||||
MEMORY_PRESSURE_LEVEL_MODERATE));
|
||||
}
|
||||
monitor.CheckMemoryPressure();
|
||||
message_loop_.RunUntilIdle();
|
||||
RunLoop().RunUntilIdle();
|
||||
EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE,
|
||||
monitor.GetCurrentPressureLevel());
|
||||
testing::Mock::VerifyAndClearExpectations(&monitor);
|
||||
@ -288,7 +289,7 @@ TEST_F(WinMemoryPressureMonitorTest, CheckMemoryPressure) {
|
||||
// Going down to no pressure should not produce an notification.
|
||||
monitor.SetNone();
|
||||
monitor.CheckMemoryPressure();
|
||||
message_loop_.RunUntilIdle();
|
||||
RunLoop().RunUntilIdle();
|
||||
EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE,
|
||||
monitor.GetCurrentPressureLevel());
|
||||
testing::Mock::VerifyAndClearExpectations(&monitor);
|
||||
|
@ -37,7 +37,7 @@ class MessageLoopTaskRunnerTest : public testing::Test {
|
||||
task_thread_.Start();
|
||||
|
||||
// Allow us to pause the |task_thread_|'s MessageLoop.
|
||||
task_thread_.message_loop()->task_runner()->PostTask(
|
||||
task_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, Bind(&MessageLoopTaskRunnerTest::BlockTaskThreadHelper,
|
||||
Unretained(this)));
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "base/pending_task.h"
|
||||
#include "base/posix/eintr_wrapper.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/synchronization/waitable_event.h"
|
||||
#include "base/test/test_simple_task_runner.h"
|
||||
#include "base/threading/platform_thread.h"
|
||||
@ -157,7 +158,7 @@ void SubPumpFunc() {
|
||||
}
|
||||
|
||||
void RunTest_PostDelayedTask_SharedTimer_SubPump() {
|
||||
MessageLoop loop(MessageLoop::TYPE_UI);
|
||||
MessageLoop message_loop(MessageLoop::TYPE_UI);
|
||||
|
||||
// Test that the interval of the timer, used to run the next delayed task, is
|
||||
// set to a value corresponding to when the next delayed task should run.
|
||||
@ -167,23 +168,20 @@ void RunTest_PostDelayedTask_SharedTimer_SubPump() {
|
||||
int num_tasks = 1;
|
||||
Time run_time;
|
||||
|
||||
loop.PostTask(FROM_HERE, Bind(&SubPumpFunc));
|
||||
message_loop.task_runner()->PostTask(FROM_HERE, Bind(&SubPumpFunc));
|
||||
|
||||
// This very delayed task should never run.
|
||||
loop.PostDelayedTask(
|
||||
FROM_HERE,
|
||||
Bind(&RecordRunTimeFunc, &run_time, &num_tasks),
|
||||
message_loop.task_runner()->PostDelayedTask(
|
||||
FROM_HERE, Bind(&RecordRunTimeFunc, &run_time, &num_tasks),
|
||||
TimeDelta::FromSeconds(1000));
|
||||
|
||||
// This slightly delayed task should run from within SubPumpFunc.
|
||||
loop.PostDelayedTask(
|
||||
FROM_HERE,
|
||||
Bind(&PostQuitMessage, 0),
|
||||
TimeDelta::FromMilliseconds(10));
|
||||
message_loop.task_runner()->PostDelayedTask(
|
||||
FROM_HERE, Bind(&PostQuitMessage, 0), TimeDelta::FromMilliseconds(10));
|
||||
|
||||
Time start_time = Time::Now();
|
||||
|
||||
loop.Run();
|
||||
RunLoop().Run();
|
||||
EXPECT_EQ(1, num_tasks);
|
||||
|
||||
// Ensure that we ran in far less time than the slower timer.
|
||||
@ -323,27 +321,25 @@ void QuitFunc(TaskList* order, int cookie) {
|
||||
order->RecordEnd(QUITMESSAGELOOP, cookie);
|
||||
}
|
||||
|
||||
void RecursiveFuncWin(MessageLoop* target,
|
||||
void RecursiveFuncWin(scoped_refptr<SingleThreadTaskRunner> task_runner,
|
||||
HANDLE event,
|
||||
bool expect_window,
|
||||
TaskList* order,
|
||||
bool is_reentrant) {
|
||||
target->PostTask(FROM_HERE,
|
||||
Bind(&RecursiveFunc, order, 1, 2, is_reentrant));
|
||||
target->PostTask(FROM_HERE,
|
||||
Bind(&MessageBoxFunc, order, 2, is_reentrant));
|
||||
target->PostTask(FROM_HERE,
|
||||
Bind(&RecursiveFunc, order, 3, 2, is_reentrant));
|
||||
task_runner->PostTask(FROM_HERE,
|
||||
Bind(&RecursiveFunc, order, 1, 2, is_reentrant));
|
||||
task_runner->PostTask(FROM_HERE,
|
||||
Bind(&MessageBoxFunc, order, 2, is_reentrant));
|
||||
task_runner->PostTask(FROM_HERE,
|
||||
Bind(&RecursiveFunc, order, 3, 2, is_reentrant));
|
||||
// The trick here is that for recursive task processing, this task will be
|
||||
// ran _inside_ the MessageBox message loop, dismissing the MessageBox
|
||||
// without a chance.
|
||||
// For non-recursive task processing, this will be executed _after_ the
|
||||
// MessageBox will have been dismissed by the code below, where
|
||||
// expect_window_ is true.
|
||||
target->PostTask(FROM_HERE,
|
||||
Bind(&EndDialogFunc, order, 4));
|
||||
target->PostTask(FROM_HERE,
|
||||
Bind(&QuitFunc, order, 5));
|
||||
task_runner->PostTask(FROM_HERE, Bind(&EndDialogFunc, order, 4));
|
||||
task_runner->PostTask(FROM_HERE, Bind(&QuitFunc, order, 5));
|
||||
|
||||
// Enforce that every tasks are sent before starting to run the main thread
|
||||
// message loop.
|
||||
@ -381,16 +377,12 @@ void RunTest_RecursiveDenial2(MessageLoop::Type message_loop_type) {
|
||||
ASSERT_EQ(true, worker.StartWithOptions(options));
|
||||
TaskList order;
|
||||
win::ScopedHandle event(CreateEvent(NULL, FALSE, FALSE, NULL));
|
||||
worker.message_loop()->PostTask(FROM_HERE,
|
||||
Bind(&RecursiveFuncWin,
|
||||
MessageLoop::current(),
|
||||
event.Get(),
|
||||
true,
|
||||
&order,
|
||||
false));
|
||||
worker.task_runner()->PostTask(
|
||||
FROM_HERE, Bind(&RecursiveFuncWin, ThreadTaskRunnerHandle::Get(),
|
||||
event.Get(), true, &order, false));
|
||||
// Let the other thread execute.
|
||||
WaitForSingleObject(event.Get(), INFINITE);
|
||||
MessageLoop::current()->Run();
|
||||
RunLoop().Run();
|
||||
|
||||
ASSERT_EQ(17u, order.Size());
|
||||
EXPECT_EQ(order.Get(0), TaskItem(RECURSIVE, 1, true));
|
||||
@ -425,16 +417,12 @@ void RunTest_RecursiveSupport2(MessageLoop::Type message_loop_type) {
|
||||
ASSERT_EQ(true, worker.StartWithOptions(options));
|
||||
TaskList order;
|
||||
win::ScopedHandle event(CreateEvent(NULL, FALSE, FALSE, NULL));
|
||||
worker.message_loop()->PostTask(FROM_HERE,
|
||||
Bind(&RecursiveFuncWin,
|
||||
MessageLoop::current(),
|
||||
event.Get(),
|
||||
false,
|
||||
&order,
|
||||
true));
|
||||
worker.task_runner()->PostTask(
|
||||
FROM_HERE, Bind(&RecursiveFuncWin, ThreadTaskRunnerHandle::Get(),
|
||||
event.Get(), false, &order, true));
|
||||
// Let the other thread execute.
|
||||
WaitForSingleObject(event.Get(), INFINITE);
|
||||
MessageLoop::current()->Run();
|
||||
RunLoop().Run();
|
||||
|
||||
ASSERT_EQ(18u, order.Size());
|
||||
EXPECT_EQ(order.Get(0), TaskItem(RECURSIVE, 1, true));
|
||||
@ -541,12 +529,9 @@ void RunTest_IOHandler() {
|
||||
options.message_loop_type = MessageLoop::TYPE_IO;
|
||||
ASSERT_TRUE(thread.StartWithOptions(options));
|
||||
|
||||
MessageLoop* thread_loop = thread.message_loop();
|
||||
ASSERT_TRUE(NULL != thread_loop);
|
||||
|
||||
TestIOHandler handler(kPipeName, callback_called.Get(), false);
|
||||
thread_loop->PostTask(FROM_HERE, Bind(&TestIOHandler::Init,
|
||||
Unretained(&handler)));
|
||||
thread.task_runner()->PostTask(
|
||||
FROM_HERE, Bind(&TestIOHandler::Init, Unretained(&handler)));
|
||||
// Make sure the thread runs and sleeps for lack of work.
|
||||
PlatformThread::Sleep(TimeDelta::FromMilliseconds(100));
|
||||
|
||||
@ -582,19 +567,16 @@ void RunTest_WaitForIO() {
|
||||
options.message_loop_type = MessageLoop::TYPE_IO;
|
||||
ASSERT_TRUE(thread.StartWithOptions(options));
|
||||
|
||||
MessageLoop* thread_loop = thread.message_loop();
|
||||
ASSERT_TRUE(NULL != thread_loop);
|
||||
|
||||
TestIOHandler handler1(kPipeName1, callback1_called.Get(), false);
|
||||
TestIOHandler handler2(kPipeName2, callback2_called.Get(), true);
|
||||
thread_loop->PostTask(FROM_HERE, Bind(&TestIOHandler::Init,
|
||||
Unretained(&handler1)));
|
||||
thread.task_runner()->PostTask(
|
||||
FROM_HERE, Bind(&TestIOHandler::Init, Unretained(&handler1)));
|
||||
// TODO(ajwong): Do we really need such long Sleeps in this function?
|
||||
// Make sure the thread runs and sleeps for lack of work.
|
||||
TimeDelta delay = TimeDelta::FromMilliseconds(100);
|
||||
PlatformThread::Sleep(delay);
|
||||
thread_loop->PostTask(FROM_HERE, Bind(&TestIOHandler::Init,
|
||||
Unretained(&handler2)));
|
||||
thread.task_runner()->PostTask(
|
||||
FROM_HERE, Bind(&TestIOHandler::Init, Unretained(&handler2)));
|
||||
PlatformThread::Sleep(delay);
|
||||
|
||||
// At this time handler1 is waiting to be called, and the thread is waiting
|
||||
@ -707,26 +689,26 @@ TEST(MessageLoopTest, WaitForIO) {
|
||||
}
|
||||
|
||||
TEST(MessageLoopTest, HighResolutionTimer) {
|
||||
MessageLoop loop;
|
||||
MessageLoop message_loop;
|
||||
Time::EnableHighResolutionTimer(true);
|
||||
|
||||
const TimeDelta kFastTimer = TimeDelta::FromMilliseconds(5);
|
||||
const TimeDelta kSlowTimer = TimeDelta::FromMilliseconds(100);
|
||||
|
||||
EXPECT_FALSE(loop.HasHighResolutionTasks());
|
||||
EXPECT_FALSE(message_loop.HasHighResolutionTasks());
|
||||
// Post a fast task to enable the high resolution timers.
|
||||
loop.PostDelayedTask(FROM_HERE, Bind(&PostNTasksThenQuit, 1),
|
||||
kFastTimer);
|
||||
EXPECT_TRUE(loop.HasHighResolutionTasks());
|
||||
loop.Run();
|
||||
EXPECT_FALSE(loop.HasHighResolutionTasks());
|
||||
message_loop.task_runner()->PostDelayedTask(
|
||||
FROM_HERE, Bind(&PostNTasksThenQuit, 1), kFastTimer);
|
||||
EXPECT_TRUE(message_loop.HasHighResolutionTasks());
|
||||
RunLoop().Run();
|
||||
EXPECT_FALSE(message_loop.HasHighResolutionTasks());
|
||||
EXPECT_FALSE(Time::IsHighResolutionTimerInUse());
|
||||
// Check that a slow task does not trigger the high resolution logic.
|
||||
loop.PostDelayedTask(FROM_HERE, Bind(&PostNTasksThenQuit, 1),
|
||||
kSlowTimer);
|
||||
EXPECT_FALSE(loop.HasHighResolutionTasks());
|
||||
loop.Run();
|
||||
EXPECT_FALSE(loop.HasHighResolutionTasks());
|
||||
message_loop.task_runner()->PostDelayedTask(
|
||||
FROM_HERE, Bind(&PostNTasksThenQuit, 1), kSlowTimer);
|
||||
EXPECT_FALSE(message_loop.HasHighResolutionTasks());
|
||||
RunLoop().Run();
|
||||
EXPECT_FALSE(message_loop.HasHighResolutionTasks());
|
||||
Time::EnableHighResolutionTimer(false);
|
||||
}
|
||||
|
||||
@ -992,7 +974,7 @@ TEST(MessageLoopTest, AlwaysHaveUserMessageWhenNesting) {
|
||||
|
||||
ASSERT_TRUE(PostMessage(message_hwnd, kSignalMsg, 0, 1));
|
||||
|
||||
loop.Run();
|
||||
RunLoop().Run();
|
||||
|
||||
ASSERT_TRUE(UnregisterClass(MAKEINTATOM(atom), instance));
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/threading/thread.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
@ -195,7 +196,7 @@ TEST_F(MessagePumpGLibTest, TestQuit) {
|
||||
injector()->Reset();
|
||||
// Quit from an event
|
||||
injector()->AddEvent(0, MessageLoop::QuitWhenIdleClosure());
|
||||
loop()->Run();
|
||||
RunLoop().Run();
|
||||
EXPECT_EQ(1, injector()->processed_events());
|
||||
}
|
||||
|
||||
@ -215,7 +216,7 @@ TEST_F(MessagePumpGLibTest, TestEventTaskInterleave) {
|
||||
injector()->AddEventAsTask(0, posted_task);
|
||||
injector()->AddEventAsTask(0, Bind(&DoNothing));
|
||||
injector()->AddEvent(0, MessageLoop::QuitWhenIdleClosure());
|
||||
loop()->Run();
|
||||
RunLoop().Run();
|
||||
EXPECT_EQ(4, injector()->processed_events());
|
||||
|
||||
injector()->Reset();
|
||||
@ -226,7 +227,7 @@ TEST_F(MessagePumpGLibTest, TestEventTaskInterleave) {
|
||||
injector()->AddEventAsTask(0, posted_task);
|
||||
injector()->AddEventAsTask(10, Bind(&DoNothing));
|
||||
injector()->AddEvent(0, MessageLoop::QuitWhenIdleClosure());
|
||||
loop()->Run();
|
||||
RunLoop().Run();
|
||||
EXPECT_EQ(4, injector()->processed_events());
|
||||
}
|
||||
|
||||
@ -235,15 +236,15 @@ TEST_F(MessagePumpGLibTest, TestWorkWhileWaitingForEvents) {
|
||||
// Tests that we process tasks while waiting for new events.
|
||||
// The event queue is empty at first.
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
loop()->PostTask(FROM_HERE, Bind(&IncrementInt, &task_count));
|
||||
loop()->task_runner()->PostTask(FROM_HERE,
|
||||
Bind(&IncrementInt, &task_count));
|
||||
}
|
||||
// After all the previous tasks have executed, enqueue an event that will
|
||||
// quit.
|
||||
loop()->PostTask(
|
||||
FROM_HERE,
|
||||
Bind(&EventInjector::AddEvent, Unretained(injector()), 0,
|
||||
MessageLoop::QuitWhenIdleClosure()));
|
||||
loop()->Run();
|
||||
loop()->task_runner()->PostTask(
|
||||
FROM_HERE, Bind(&EventInjector::AddEvent, Unretained(injector()), 0,
|
||||
MessageLoop::QuitWhenIdleClosure()));
|
||||
RunLoop().Run();
|
||||
ASSERT_EQ(10, task_count);
|
||||
EXPECT_EQ(1, injector()->processed_events());
|
||||
|
||||
@ -251,21 +252,19 @@ TEST_F(MessagePumpGLibTest, TestWorkWhileWaitingForEvents) {
|
||||
injector()->Reset();
|
||||
task_count = 0;
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
loop()->PostDelayedTask(
|
||||
FROM_HERE,
|
||||
Bind(&IncrementInt, &task_count),
|
||||
TimeDelta::FromMilliseconds(10*i));
|
||||
loop()->task_runner()->PostDelayedTask(FROM_HERE,
|
||||
Bind(&IncrementInt, &task_count),
|
||||
TimeDelta::FromMilliseconds(10 * i));
|
||||
}
|
||||
// After all the previous tasks have executed, enqueue an event that will
|
||||
// quit.
|
||||
// This relies on the fact that delayed tasks are executed in delay order.
|
||||
// That is verified in message_loop_unittest.cc.
|
||||
loop()->PostDelayedTask(
|
||||
FROM_HERE,
|
||||
Bind(&EventInjector::AddEvent, Unretained(injector()), 10,
|
||||
MessageLoop::QuitWhenIdleClosure()),
|
||||
loop()->task_runner()->PostDelayedTask(
|
||||
FROM_HERE, Bind(&EventInjector::AddEvent, Unretained(injector()), 10,
|
||||
MessageLoop::QuitWhenIdleClosure()),
|
||||
TimeDelta::FromMilliseconds(150));
|
||||
loop()->Run();
|
||||
RunLoop().Run();
|
||||
ASSERT_EQ(10, task_count);
|
||||
EXPECT_EQ(1, injector()->processed_events());
|
||||
}
|
||||
@ -287,7 +286,7 @@ TEST_F(MessagePumpGLibTest, TestEventsWhileWaitingForWork) {
|
||||
|
||||
// And then quit (relies on the condition tested by TestEventTaskInterleave).
|
||||
injector()->AddEvent(10, MessageLoop::QuitWhenIdleClosure());
|
||||
loop()->Run();
|
||||
RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(12, injector()->processed_events());
|
||||
}
|
||||
@ -363,12 +362,12 @@ TEST_F(MessagePumpGLibTest, TestConcurrentEventPostedTask) {
|
||||
0, Bind(&ConcurrentHelper::FromEvent, helper.get()));
|
||||
|
||||
// Similarly post 2 tasks.
|
||||
loop()->PostTask(
|
||||
loop()->task_runner()->PostTask(
|
||||
FROM_HERE, Bind(&ConcurrentHelper::FromTask, helper.get()));
|
||||
loop()->PostTask(
|
||||
loop()->task_runner()->PostTask(
|
||||
FROM_HERE, Bind(&ConcurrentHelper::FromTask, helper.get()));
|
||||
|
||||
loop()->Run();
|
||||
RunLoop().Run();
|
||||
EXPECT_EQ(0, helper->event_count());
|
||||
EXPECT_EQ(0, helper->task_count());
|
||||
}
|
||||
@ -396,10 +395,9 @@ void AddEventsAndDrainGLib(EventInjector* injector) {
|
||||
|
||||
TEST_F(MessagePumpGLibTest, TestDrainingGLib) {
|
||||
// Tests that draining events using GLib works.
|
||||
loop()->PostTask(
|
||||
FROM_HERE,
|
||||
Bind(&AddEventsAndDrainGLib, Unretained(injector())));
|
||||
loop()->Run();
|
||||
loop()->task_runner()->PostTask(
|
||||
FROM_HERE, Bind(&AddEventsAndDrainGLib, Unretained(injector())));
|
||||
RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(3, injector()->processed_events());
|
||||
}
|
||||
@ -512,10 +510,9 @@ TEST_F(MessagePumpGLibTest, TestGLibLoop) {
|
||||
// loop is not run by MessageLoop::Run() but by a straight GLib loop.
|
||||
// Note that in this case we don't make strong guarantees about niceness
|
||||
// between events and posted tasks.
|
||||
loop()->PostTask(
|
||||
FROM_HERE,
|
||||
Bind(&TestGLibLoopInternal, Unretained(injector())));
|
||||
loop()->Run();
|
||||
loop()->task_runner()->PostTask(
|
||||
FROM_HERE, Bind(&TestGLibLoopInternal, Unretained(injector())));
|
||||
RunLoop().Run();
|
||||
}
|
||||
|
||||
TEST_F(MessagePumpGLibTest, TestGtkLoop) {
|
||||
@ -523,10 +520,9 @@ TEST_F(MessagePumpGLibTest, TestGtkLoop) {
|
||||
// loop is not run by MessageLoop::Run() but by a straight Gtk loop.
|
||||
// Note that in this case we don't make strong guarantees about niceness
|
||||
// between events and posted tasks.
|
||||
loop()->PostTask(
|
||||
FROM_HERE,
|
||||
Bind(&TestGtkLoopInternal, Unretained(injector())));
|
||||
loop()->Run();
|
||||
loop()->task_runner()->PostTask(
|
||||
FROM_HERE, Bind(&TestGtkLoopInternal, Unretained(injector())));
|
||||
RunLoop().Run();
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
@ -101,7 +101,7 @@ class ScheduleWorkTest : public testing::Test {
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_scheduling_threads; ++i) {
|
||||
scheduling_threads[i]->message_loop()->task_runner()->PostTask(
|
||||
scheduling_threads[i]->task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&ScheduleWorkTest::Schedule, base::Unretained(this), i));
|
||||
}
|
||||
|
552
base/task_scheduler/scheduler_worker_unittest.cc~RF3e0a7fad.TMP
Normal file
552
base/task_scheduler/scheduler_worker_unittest.cc~RF3e0a7fad.TMP
Normal file
@ -0,0 +1,552 @@
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/task_scheduler/scheduler_worker.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/bind_helpers.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/synchronization/condition_variable.h"
|
||||
#include "base/synchronization/waitable_event.h"
|
||||
#include "base/task_scheduler/scheduler_lock.h"
|
||||
#include "base/task_scheduler/sequence.h"
|
||||
#include "base/task_scheduler/task.h"
|
||||
#include "base/task_scheduler/task_tracker.h"
|
||||
#include "base/threading/platform_thread.h"
|
||||
#include "base/time/time.h"
|
||||
#include "build/build_config.h"
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
using testing::_;
|
||||
using testing::Mock;
|
||||
using testing::Ne;
|
||||
using testing::StrictMock;
|
||||
|
||||
namespace base {
|
||||
namespace internal {
|
||||
namespace {
|
||||
|
||||
const size_t kNumSequencesPerTest = 150;
|
||||
|
||||
class SchedulerWorkerDefaultDelegate : public SchedulerWorker::Delegate {
|
||||
public:
|
||||
SchedulerWorkerDefaultDelegate() = default;
|
||||
|
||||
// SchedulerWorker::Delegate:
|
||||
void OnMainEntry(SchedulerWorker* worker, const TimeDelta& detach_duration) override {}
|
||||
scoped_refptr<Sequence> GetWork(SchedulerWorker* worker) override { return nullptr; }
|
||||
void ReEnqueueSequence(scoped_refptr<Sequence> sequence) override {
|
||||
ADD_FAILURE() << "Unexpected call to ReEnqueueSequence()";
|
||||
}
|
||||
TimeDelta GetSleepTimeout() override { return TimeDelta::Max(); }
|
||||
bool CanDetach(SchedulerWorker* worker) override { return false; }
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerDefaultDelegate);
|
||||
};
|
||||
|
||||
// The test parameter is the number of Tasks per Sequence returned by GetWork().
|
||||
class TaskSchedulerWorkerTest : public testing::TestWithParam<size_t> {
|
||||
protected:
|
||||
TaskSchedulerWorkerTest()
|
||||
: main_entry_called_(WaitableEvent::ResetPolicy::MANUAL,
|
||||
WaitableEvent::InitialState::NOT_SIGNALED),
|
||||
num_get_work_cv_(lock_.CreateConditionVariable()),
|
||||
worker_set_(WaitableEvent::ResetPolicy::MANUAL,
|
||||
WaitableEvent::InitialState::NOT_SIGNALED) {}
|
||||
|
||||
void SetUp() override {
|
||||
worker_ = SchedulerWorker::Create(
|
||||
ThreadPriority::NORMAL,
|
||||
WrapUnique(new TestSchedulerWorkerDelegate(this)),
|
||||
&task_tracker_,
|
||||
SchedulerWorker::InitialState::ALIVE);
|
||||
ASSERT_TRUE(worker_);
|
||||
worker_set_.Signal();
|
||||
main_entry_called_.Wait();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
worker_->JoinForTesting();
|
||||
}
|
||||
|
||||
size_t TasksPerSequence() const { return GetParam(); }
|
||||
|
||||
// Wait until GetWork() has been called |num_get_work| times.
|
||||
void WaitForNumGetWork(size_t num_get_work) {
|
||||
AutoSchedulerLock auto_lock(lock_);
|
||||
while (num_get_work_ < num_get_work)
|
||||
num_get_work_cv_->Wait();
|
||||
}
|
||||
|
||||
void SetMaxGetWork(size_t max_get_work) {
|
||||
AutoSchedulerLock auto_lock(lock_);
|
||||
max_get_work_ = max_get_work;
|
||||
}
|
||||
|
||||
void SetNumSequencesToCreate(size_t num_sequences_to_create) {
|
||||
AutoSchedulerLock auto_lock(lock_);
|
||||
EXPECT_EQ(0U, num_sequences_to_create_);
|
||||
num_sequences_to_create_ = num_sequences_to_create;
|
||||
}
|
||||
|
||||
size_t NumRunTasks() {
|
||||
AutoSchedulerLock auto_lock(lock_);
|
||||
return num_run_tasks_;
|
||||
}
|
||||
|
||||
std::vector<scoped_refptr<Sequence>> CreatedSequences() {
|
||||
AutoSchedulerLock auto_lock(lock_);
|
||||
return created_sequences_;
|
||||
}
|
||||
|
||||
std::vector<scoped_refptr<Sequence>> EnqueuedSequences() {
|
||||
AutoSchedulerLock auto_lock(lock_);
|
||||
return re_enqueued_sequences_;
|
||||
}
|
||||
|
||||
std::unique_ptr<SchedulerWorker> worker_;
|
||||
|
||||
private:
|
||||
class TestSchedulerWorkerDelegate : public SchedulerWorkerDefaultDelegate {
|
||||
public:
|
||||
TestSchedulerWorkerDelegate(TaskSchedulerWorkerTest* outer)
|
||||
: outer_(outer) {}
|
||||
|
||||
// SchedulerWorker::Delegate:
|
||||
void OnMainEntry(SchedulerWorker* worker,
|
||||
const TimeDelta& detach_duration) override {
|
||||
outer_->worker_set_.Wait();
|
||||
EXPECT_EQ(outer_->worker_.get(), worker);
|
||||
|
||||
// Without synchronization, OnMainEntry() could be called twice without
|
||||
// generating an error.
|
||||
AutoSchedulerLock auto_lock(outer_->lock_);
|
||||
EXPECT_FALSE(outer_->main_entry_called_.IsSignaled());
|
||||
outer_->main_entry_called_.Signal();
|
||||
}
|
||||
|
||||
scoped_refptr<Sequence> GetWork(SchedulerWorker* worker) override {
|
||||
EXPECT_EQ(outer_->worker_.get(), worker);
|
||||
|
||||
{
|
||||
AutoSchedulerLock auto_lock(outer_->lock_);
|
||||
|
||||
// Increment the number of times that this method has been called.
|
||||
++outer_->num_get_work_;
|
||||
outer_->num_get_work_cv_->Signal();
|
||||
|
||||
// Verify that this method isn't called more times than expected.
|
||||
EXPECT_LE(outer_->num_get_work_, outer_->max_get_work_);
|
||||
|
||||
// Check if a Sequence should be returned.
|
||||
if (outer_->num_sequences_to_create_ == 0)
|
||||
return nullptr;
|
||||
--outer_->num_sequences_to_create_;
|
||||
}
|
||||
|
||||
// Create a Sequence with TasksPerSequence() Tasks.
|
||||
scoped_refptr<Sequence> sequence(new Sequence);
|
||||
for (size_t i = 0; i < outer_->TasksPerSequence(); ++i) {
|
||||
std::unique_ptr<Task> task(new Task(
|
||||
FROM_HERE, Bind(&TaskSchedulerWorkerTest::RunTaskCallback,
|
||||
Unretained(outer_)),
|
||||
TaskTraits(), TimeDelta()));
|
||||
EXPECT_TRUE(outer_->task_tracker_.WillPostTask(task.get()));
|
||||
sequence->PushTask(std::move(task));
|
||||
}
|
||||
|
||||
{
|
||||
// Add the Sequence to the vector of created Sequences.
|
||||
AutoSchedulerLock auto_lock(outer_->lock_);
|
||||
outer_->created_sequences_.push_back(sequence);
|
||||
}
|
||||
|
||||
return sequence;
|
||||
}
|
||||
|
||||
// This override verifies that |sequence| contains the expected number of
|
||||
// Tasks and adds it to |enqueued_sequences_|. Unlike a normal
|
||||
// EnqueueSequence implementation, it doesn't reinsert |sequence| into a
|
||||
// queue for further execution.
|
||||
void ReEnqueueSequence(scoped_refptr<Sequence> sequence) override {
|
||||
EXPECT_GT(outer_->TasksPerSequence(), 1U);
|
||||
|
||||
// Verify that |sequence| contains TasksPerSequence() - 1 Tasks.
|
||||
for (size_t i = 0; i < outer_->TasksPerSequence() - 1; ++i) {
|
||||
EXPECT_TRUE(sequence->PeekTask());
|
||||
sequence->PopTask();
|
||||
}
|
||||
EXPECT_FALSE(sequence->PeekTask());
|
||||
|
||||
// Add |sequence| to |re_enqueued_sequences_|.
|
||||
AutoSchedulerLock auto_lock(outer_->lock_);
|
||||
outer_->re_enqueued_sequences_.push_back(std::move(sequence));
|
||||
EXPECT_LE(outer_->re_enqueued_sequences_.size(),
|
||||
outer_->created_sequences_.size());
|
||||
}
|
||||
|
||||
private:
|
||||
TaskSchedulerWorkerTest* outer_;
|
||||
};
|
||||
|
||||
void RunTaskCallback() {
|
||||
AutoSchedulerLock auto_lock(lock_);
|
||||
++num_run_tasks_;
|
||||
EXPECT_LE(num_run_tasks_, created_sequences_.size());
|
||||
}
|
||||
|
||||
TaskTracker task_tracker_;
|
||||
|
||||
// Synchronizes access to all members below.
|
||||
mutable SchedulerLock lock_;
|
||||
|
||||
// Signaled once OnMainEntry() has been called.
|
||||
WaitableEvent main_entry_called_;
|
||||
|
||||
// Number of Sequences that should be created by GetWork(). When this
|
||||
// is 0, GetWork() returns nullptr.
|
||||
size_t num_sequences_to_create_ = 0;
|
||||
|
||||
// Number of times that GetWork() has been called.
|
||||
size_t num_get_work_ = 0;
|
||||
|
||||
// Maximum number of times that GetWork() can be called.
|
||||
size_t max_get_work_ = 0;
|
||||
|
||||
// Condition variable signaled when |num_get_work_| is incremented.
|
||||
std::unique_ptr<ConditionVariable> num_get_work_cv_;
|
||||
|
||||
// Sequences created by GetWork().
|
||||
std::vector<scoped_refptr<Sequence>> created_sequences_;
|
||||
|
||||
// Sequences passed to EnqueueSequence().
|
||||
std::vector<scoped_refptr<Sequence>> re_enqueued_sequences_;
|
||||
|
||||
// Number of times that RunTaskCallback() has been called.
|
||||
size_t num_run_tasks_ = 0;
|
||||
|
||||
// Signaled after |worker_| is set.
|
||||
WaitableEvent worker_set_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(TaskSchedulerWorkerTest);
|
||||
};
|
||||
|
||||
// Verify that when GetWork() continuously returns Sequences, all Tasks in these
|
||||
// Sequences run successfully. The test wakes up the SchedulerWorker once.
|
||||
TEST_P(TaskSchedulerWorkerTest, ContinuousWork) {
|
||||
// Set GetWork() to return |kNumSequencesPerTest| Sequences before starting to
|
||||
// return nullptr.
|
||||
SetNumSequencesToCreate(kNumSequencesPerTest);
|
||||
|
||||
// Expect |kNumSequencesPerTest| calls to GetWork() in which it returns a
|
||||
// Sequence and one call in which its returns nullptr.
|
||||
const size_t kExpectedNumGetWork = kNumSequencesPerTest + 1;
|
||||
SetMaxGetWork(kExpectedNumGetWork);
|
||||
|
||||
// Wake up |worker_| and wait until GetWork() has been invoked the
|
||||
// expected amount of times.
|
||||
worker_->WakeUp();
|
||||
WaitForNumGetWork(kExpectedNumGetWork);
|
||||
|
||||
// All tasks should have run.
|
||||
EXPECT_EQ(kNumSequencesPerTest, NumRunTasks());
|
||||
|
||||
// If Sequences returned by GetWork() contain more than one Task, they aren't
|
||||
// empty after the worker pops Tasks from them and thus should be returned to
|
||||
// EnqueueSequence().
|
||||
if (TasksPerSequence() > 1)
|
||||
EXPECT_EQ(CreatedSequences(), EnqueuedSequences());
|
||||
else
|
||||
EXPECT_TRUE(EnqueuedSequences().empty());
|
||||
}
|
||||
|
||||
// Verify that when GetWork() alternates between returning a Sequence and
|
||||
// returning nullptr, all Tasks in the returned Sequences run successfully. The
|
||||
// test wakes up the SchedulerWorker once for each Sequence.
|
||||
TEST_P(TaskSchedulerWorkerTest, IntermittentWork) {
|
||||
for (size_t i = 0; i < kNumSequencesPerTest; ++i) {
|
||||
// Set GetWork() to return 1 Sequence before starting to return
|
||||
// nullptr.
|
||||
SetNumSequencesToCreate(1);
|
||||
|
||||
// Expect |i + 1| calls to GetWork() in which it returns a Sequence and
|
||||
// |i + 1| calls in which it returns nullptr.
|
||||
const size_t expected_num_get_work = 2 * (i + 1);
|
||||
SetMaxGetWork(expected_num_get_work);
|
||||
|
||||
// Wake up |worker_| and wait until GetWork() has been invoked
|
||||
// the expected amount of times.
|
||||
worker_->WakeUp();
|
||||
WaitForNumGetWork(expected_num_get_work);
|
||||
|
||||
// The Task should have run
|
||||
EXPECT_EQ(i + 1, NumRunTasks());
|
||||
|
||||
// If Sequences returned by GetWork() contain more than one Task, they
|
||||
// aren't empty after the worker pops Tasks from them and thus should be
|
||||
// returned to EnqueueSequence().
|
||||
if (TasksPerSequence() > 1)
|
||||
EXPECT_EQ(CreatedSequences(), EnqueuedSequences());
|
||||
else
|
||||
EXPECT_TRUE(EnqueuedSequences().empty());
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(OneTaskPerSequence,
|
||||
TaskSchedulerWorkerTest,
|
||||
::testing::Values(1));
|
||||
INSTANTIATE_TEST_CASE_P(TwoTasksPerSequence,
|
||||
TaskSchedulerWorkerTest,
|
||||
::testing::Values(2));
|
||||
|
||||
namespace {
|
||||
|
||||
class ControllableDetachDelegate : public SchedulerWorkerDefaultDelegate {
|
||||
public:
|
||||
ControllableDetachDelegate()
|
||||
: work_processed_(WaitableEvent::ResetPolicy::MANUAL,
|
||||
WaitableEvent::InitialState::NOT_SIGNALED),
|
||||
detach_requested_(WaitableEvent::ResetPolicy::MANUAL,
|
||||
WaitableEvent::InitialState::NOT_SIGNALED) {}
|
||||
|
||||
~ControllableDetachDelegate() override = default;
|
||||
|
||||
// SchedulerWorker::Delegate:
|
||||
MOCK_METHOD2(OnMainEntry,
|
||||
void(SchedulerWorker* worker, const TimeDelta& detach_duration));
|
||||
|
||||
scoped_refptr<Sequence> GetWork(SchedulerWorker* worker)
|
||||
override {
|
||||
// Sends one item of work to signal |work_processed_|. On subsequent calls,
|
||||
// sends nullptr to indicate there's no more work to be done.
|
||||
if (work_requested_)
|
||||
return nullptr;
|
||||
|
||||
work_requested_ = true;
|
||||
scoped_refptr<Sequence> sequence(new Sequence);
|
||||
std::unique_ptr<Task> task(new Task(
|
||||
FROM_HERE, Bind(&WaitableEvent::Signal, Unretained(&work_processed_)),
|
||||
TaskTraits(), TimeDelta()));
|
||||
sequence->PushTask(std::move(task));
|
||||
return sequence;
|
||||
}
|
||||
|
||||
bool CanDetach(SchedulerWorker* worker) override {
|
||||
detach_requested_.Signal();
|
||||
return can_detach_;
|
||||
}
|
||||
|
||||
void WaitForWorkToRun() {
|
||||
work_processed_.Wait();
|
||||
}
|
||||
|
||||
void WaitForDetachRequest() {
|
||||
detach_requested_.Wait();
|
||||
}
|
||||
|
||||
void ResetState() {
|
||||
work_requested_ = false;
|
||||
work_processed_.Reset();
|
||||
detach_requested_.Reset();
|
||||
}
|
||||
|
||||
void set_can_detach(bool can_detach) { can_detach_ = can_detach; }
|
||||
|
||||
private:
|
||||
bool work_requested_ = false;
|
||||
bool can_detach_ = false;
|
||||
WaitableEvent work_processed_;
|
||||
WaitableEvent detach_requested_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ControllableDetachDelegate);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(TaskSchedulerWorkerTest, WorkerDetaches) {
|
||||
TaskTracker task_tracker;
|
||||
// Will be owned by SchedulerWorker.
|
||||
ControllableDetachDelegate* delegate =
|
||||
new StrictMock<ControllableDetachDelegate>;
|
||||
delegate->set_can_detach(true);
|
||||
EXPECT_CALL(*delegate, OnMainEntry(_, TimeDelta::Max()));
|
||||
std::unique_ptr<SchedulerWorker> worker =
|
||||
SchedulerWorker::Create(
|
||||
ThreadPriority::NORMAL, WrapUnique(delegate), &task_tracker,
|
||||
SchedulerWorker::InitialState::ALIVE);
|
||||
worker->WakeUp();
|
||||
delegate->WaitForWorkToRun();
|
||||
Mock::VerifyAndClear(delegate);
|
||||
delegate->WaitForDetachRequest();
|
||||
// Sleep to give a chance for the detach to happen. A yield is too short.
|
||||
PlatformThread::Sleep(TimeDelta::FromMilliseconds(50));
|
||||
ASSERT_FALSE(worker->ThreadAliveForTesting());
|
||||
}
|
||||
|
||||
TEST(TaskSchedulerWorkerTest, WorkerDetachesAndWakes) {
|
||||
TaskTracker task_tracker;
|
||||
// Will be owned by SchedulerWorker.
|
||||
ControllableDetachDelegate* delegate =
|
||||
new StrictMock<ControllableDetachDelegate>;
|
||||
delegate->set_can_detach(true);
|
||||
EXPECT_CALL(*delegate, OnMainEntry(_, TimeDelta::Max()));
|
||||
std::unique_ptr<SchedulerWorker> worker =
|
||||
SchedulerWorker::Create(
|
||||
ThreadPriority::NORMAL, WrapUnique(delegate), &task_tracker,
|
||||
SchedulerWorker::InitialState::ALIVE);
|
||||
worker->WakeUp();
|
||||
delegate->WaitForWorkToRun();
|
||||
Mock::VerifyAndClear(delegate);
|
||||
delegate->WaitForDetachRequest();
|
||||
// Sleep to give a chance for the detach to happen. A yield is too short.
|
||||
PlatformThread::Sleep(TimeDelta::FromMilliseconds(50));
|
||||
ASSERT_FALSE(worker->ThreadAliveForTesting());
|
||||
|
||||
delegate->ResetState();
|
||||
delegate->set_can_detach(false);
|
||||
// When SchedulerWorker recreates its thread, expect OnMainEntry() to be
|
||||
// called with a detach duration which is not TimeDelta::Max().
|
||||
EXPECT_CALL(*delegate, OnMainEntry(worker.get(), Ne(TimeDelta::Max())));
|
||||
worker->WakeUp();
|
||||
delegate->WaitForWorkToRun();
|
||||
Mock::VerifyAndClear(delegate);
|
||||
delegate->WaitForDetachRequest();
|
||||
PlatformThread::Sleep(TimeDelta::FromMilliseconds(50));
|
||||
ASSERT_TRUE(worker->ThreadAliveForTesting());
|
||||
worker->JoinForTesting();
|
||||
}
|
||||
|
||||
TEST(TaskSchedulerWorkerTest, CreateDetached) {
|
||||
TaskTracker task_tracker;
|
||||
// Will be owned by SchedulerWorker.
|
||||
ControllableDetachDelegate* delegate =
|
||||
new StrictMock<ControllableDetachDelegate>;
|
||||
std::unique_ptr<SchedulerWorker> worker =
|
||||
SchedulerWorker::Create(
|
||||
ThreadPriority::NORMAL, WrapUnique(delegate), &task_tracker,
|
||||
SchedulerWorker::InitialState::DETACHED);
|
||||
ASSERT_FALSE(worker->ThreadAliveForTesting());
|
||||
EXPECT_CALL(*delegate, OnMainEntry(worker.get(), TimeDelta::Max()));
|
||||
worker->WakeUp();
|
||||
delegate->WaitForWorkToRun();
|
||||
Mock::VerifyAndClear(delegate);
|
||||
delegate->WaitForDetachRequest();
|
||||
ASSERT_TRUE(worker->ThreadAliveForTesting());
|
||||
worker->JoinForTesting();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class ExpectThreadPriorityDelegate : public SchedulerWorkerDefaultDelegate {
|
||||
public:
|
||||
ExpectThreadPriorityDelegate()
|
||||
: priority_verified_in_get_work_event_(
|
||||
WaitableEvent::ResetPolicy::AUTOMATIC,
|
||||
WaitableEvent::InitialState::NOT_SIGNALED),
|
||||
expected_thread_priority_(ThreadPriority::BACKGROUND) {}
|
||||
|
||||
void SetExpectedThreadPriority(ThreadPriority expected_thread_priority) {
|
||||
expected_thread_priority_ = expected_thread_priority;
|
||||
}
|
||||
|
||||
void WaitForPriorityVerifiedInGetWork() {
|
||||
priority_verified_in_get_work_event_.Wait();
|
||||
}
|
||||
|
||||
// SchedulerWorker::Delegate:
|
||||
void OnMainEntry(SchedulerWorker* worker,
|
||||
const TimeDelta& detach_duration) override {
|
||||
VerifyThreadPriority();
|
||||
}
|
||||
scoped_refptr<Sequence> GetWork(SchedulerWorker* worker) override {
|
||||
VerifyThreadPriority();
|
||||
priority_verified_in_get_work_event_.Signal();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
void VerifyThreadPriority() {
|
||||
AutoSchedulerLock auto_lock(expected_thread_priority_lock_);
|
||||
EXPECT_EQ(expected_thread_priority_,
|
||||
PlatformThread::GetCurrentThreadPriority());
|
||||
}
|
||||
|
||||
// Signaled after GetWork() has verified the priority of the worker thread.
|
||||
WaitableEvent priority_verified_in_get_work_event_;
|
||||
|
||||
// Synchronizes access to |expected_thread_priority_|.
|
||||
SchedulerLock expected_thread_priority_lock_;
|
||||
|
||||
// Expected thread priority for the next call to OnMainEntry() or GetWork().
|
||||
ThreadPriority expected_thread_priority_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ExpectThreadPriorityDelegate);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(TaskSchedulerWorkerTest, BumpPriorityOfAliveThreadDuringShutdown) {
|
||||
TaskTracker task_tracker;
|
||||
|
||||
std::unique_ptr<ExpectThreadPriorityDelegate> delegate(
|
||||
new ExpectThreadPriorityDelegate);
|
||||
ExpectThreadPriorityDelegate* delegate_raw = delegate.get();
|
||||
delegate_raw->SetExpectedThreadPriority(
|
||||
PlatformThread::CanIncreaseCurrentThreadPriority()
|
||||
? ThreadPriority::BACKGROUND
|
||||
: ThreadPriority::NORMAL);
|
||||
|
||||
std::unique_ptr<SchedulerWorker> worker = SchedulerWorker::Create(
|
||||
ThreadPriority::BACKGROUND, std::move(delegate), &task_tracker,
|
||||
SchedulerWorker::InitialState::ALIVE);
|
||||
|
||||
// Verify that the initial thread priority is BACKGROUND (or NORMAL if thread
|
||||
// priority can't be increased).
|
||||
worker->WakeUp();
|
||||
delegate_raw->WaitForPriorityVerifiedInGetWork();
|
||||
|
||||
// Verify that the thread priority is bumped to NORMAL during shutdown.
|
||||
delegate_raw->SetExpectedThreadPriority(ThreadPriority::NORMAL);
|
||||
task_tracker.SetHasShutdownStartedForTesting();
|
||||
worker->WakeUp();
|
||||
delegate_raw->WaitForPriorityVerifiedInGetWork();
|
||||
|
||||
worker->JoinForTesting();
|
||||
}
|
||||
|
||||
TEST(TaskSchedulerWorkerTest, BumpPriorityOfDetachedThreadDuringShutdown) {
|
||||
TaskTracker task_tracker;
|
||||
|
||||
std::unique_ptr<ExpectThreadPriorityDelegate> delegate(
|
||||
new ExpectThreadPriorityDelegate);
|
||||
ExpectThreadPriorityDelegate* delegate_raw = delegate.get();
|
||||
delegate_raw->SetExpectedThreadPriority(ThreadPriority::NORMAL);
|
||||
|
||||
// Create a DETACHED thread.
|
||||
std::unique_ptr<SchedulerWorker> worker = SchedulerWorker::Create(
|
||||
ThreadPriority::BACKGROUND, std::move(delegate), &task_tracker,
|
||||
SchedulerWorker::InitialState::DETACHED);
|
||||
|
||||
// Pretend that shutdown has started.
|
||||
task_tracker.SetHasShutdownStartedForTesting();
|
||||
|
||||
// Wake up the thread and verify that its priority is NORMAL when
|
||||
// OnMainEntry() and GetWork() are called.
|
||||
worker->WakeUp();
|
||||
delegate_raw->WaitForPriorityVerifiedInGetWork();
|
||||
|
||||
worker->JoinForTesting();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace internal
|
||||
} // namespace base
|
@ -49,7 +49,7 @@ void RunTest_BasicSignal(MessageLoop::Type message_loop_type) {
|
||||
|
||||
SetEvent(event);
|
||||
|
||||
MessageLoop::current()->Run();
|
||||
RunLoop().Run();
|
||||
|
||||
EXPECT_FALSE(watcher.IsWatching());
|
||||
CloseHandle(event);
|
||||
@ -113,7 +113,7 @@ void RunTest_SignalBeforeWatch(MessageLoop::Type message_loop_type) {
|
||||
bool ok = watcher.StartWatchingOnce(event, &delegate);
|
||||
EXPECT_TRUE(ok);
|
||||
|
||||
MessageLoop::current()->Run();
|
||||
RunLoop().Run();
|
||||
|
||||
EXPECT_FALSE(watcher.IsWatching());
|
||||
CloseHandle(event);
|
||||
@ -170,7 +170,7 @@ void RunTest_ExecuteMultipleTimes(MessageLoop::Type message_loop_type) {
|
||||
|
||||
SetEvent(event);
|
||||
|
||||
MessageLoop::current()->Run();
|
||||
RunLoop().Run();
|
||||
|
||||
EXPECT_TRUE(watcher.IsWatching());
|
||||
EXPECT_TRUE(watcher.StopWatching());
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "blimp/client/core/contents/blimp_contents_impl.h"
|
||||
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "blimp/client/core/contents/fake_navigation_feature.h"
|
||||
#include "blimp/client/core/contents/tab_control_feature.h"
|
||||
#include "blimp/client/public/contents/blimp_contents_observer.h"
|
||||
@ -58,7 +59,7 @@ TEST(BlimpContentsImplTest, LoadURLAndNotifyObservers) {
|
||||
EXPECT_CALL(observer2, OnNavigationStateChanged()).Times(2);
|
||||
|
||||
navigation_controller.LoadURL(GURL(kExampleURL));
|
||||
loop.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_EQ(kExampleURL, navigation_controller.GetURL().spec());
|
||||
|
||||
@ -66,7 +67,7 @@ TEST(BlimpContentsImplTest, LoadURLAndNotifyObservers) {
|
||||
blimp_contents.RemoveObserver(&observer1);
|
||||
|
||||
navigation_controller.LoadURL(GURL(kOtherExampleURL));
|
||||
loop.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_EQ(kOtherExampleURL, navigation_controller.GetURL().spec());
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "blimp/client/core/contents/blimp_navigation_controller_delegate.h"
|
||||
#include "blimp/client/core/contents/blimp_navigation_controller_impl.h"
|
||||
#include "blimp/client/core/contents/fake_navigation_feature.h"
|
||||
@ -51,7 +52,7 @@ TEST(BlimpNavigationControllerImplTest, BackForwardNavigation) {
|
||||
navigation_controller.GoForward();
|
||||
navigation_controller.Reload();
|
||||
|
||||
loop.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/test/test_file_util.h"
|
||||
#include "build/build_config.h"
|
||||
@ -86,7 +87,7 @@ void DownloadPathReservationTrackerTest::SetUp() {
|
||||
}
|
||||
|
||||
void DownloadPathReservationTrackerTest::TearDown() {
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
MockDownloadItem* DownloadPathReservationTrackerTest::CreateDownloadItem(
|
||||
@ -132,7 +133,7 @@ void DownloadPathReservationTrackerTest::CallGetReservedPath(
|
||||
base::Bind(&DownloadPathReservationTrackerTest::TestReservedPathCallback,
|
||||
weak_ptr_factory.GetWeakPtr(), return_path, return_verified,
|
||||
&did_run_callback));
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_TRUE(did_run_callback);
|
||||
}
|
||||
|
||||
@ -187,7 +188,7 @@ TEST_F(DownloadPathReservationTrackerTest, BasicReservation) {
|
||||
// Destroying the item should release the reservation.
|
||||
SetDownloadItemState(item.get(), DownloadItem::COMPLETE);
|
||||
item.reset();
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_FALSE(IsPathInUse(path));
|
||||
}
|
||||
|
||||
@ -216,7 +217,7 @@ TEST_F(DownloadPathReservationTrackerTest, InterruptedDownload) {
|
||||
|
||||
// Once the download is interrupted, the path should become available again.
|
||||
SetDownloadItemState(item.get(), DownloadItem::INTERRUPTED);
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_FALSE(IsPathInUse(path));
|
||||
}
|
||||
|
||||
@ -248,7 +249,7 @@ TEST_F(DownloadPathReservationTrackerTest, CompleteDownload) {
|
||||
// The path wouldn't be available since it is occupied on disk by the
|
||||
// completed download.
|
||||
SetDownloadItemState(item.get(), DownloadItem::COMPLETE);
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_FALSE(IsPathInUse(path));
|
||||
}
|
||||
|
||||
@ -290,7 +291,7 @@ TEST_F(DownloadPathReservationTrackerTest, ConflictingFiles) {
|
||||
|
||||
SetDownloadItemState(item.get(), DownloadItem::COMPLETE);
|
||||
item.reset();
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_TRUE(IsPathInUse(path));
|
||||
EXPECT_FALSE(IsPathInUse(reserved_path));
|
||||
}
|
||||
@ -339,7 +340,7 @@ TEST_F(DownloadPathReservationTrackerTest, ConflictingReservations) {
|
||||
EXPECT_EQ(uniquified_path.value(), reserved_path2.value());
|
||||
SetDownloadItemState(item2.get(), DownloadItem::COMPLETE);
|
||||
}
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_TRUE(IsPathInUse(path));
|
||||
EXPECT_FALSE(IsPathInUse(uniquified_path));
|
||||
|
||||
@ -360,7 +361,7 @@ TEST_F(DownloadPathReservationTrackerTest, ConflictingReservations) {
|
||||
EXPECT_EQ(uniquified_path.value(), reserved_path2.value());
|
||||
SetDownloadItemState(item2.get(), DownloadItem::COMPLETE);
|
||||
}
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// Now acquire an overwriting reservation. We should end up with the same
|
||||
// non-uniquified path for both reservations.
|
||||
@ -585,7 +586,7 @@ TEST_F(DownloadPathReservationTrackerTest, UpdatesToTargetPath) {
|
||||
// this state, we shouldn't lose the reservation.
|
||||
ASSERT_EQ(base::FilePath::StringType(), item->GetTargetFilePath().value());
|
||||
item->NotifyObserversDownloadUpdated();
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_TRUE(IsPathInUse(path));
|
||||
|
||||
// If the target path changes, we should update the reservation to match.
|
||||
@ -595,14 +596,14 @@ TEST_F(DownloadPathReservationTrackerTest, UpdatesToTargetPath) {
|
||||
EXPECT_CALL(*item, GetTargetFilePath())
|
||||
.WillRepeatedly(ReturnRef(new_target_path));
|
||||
item->NotifyObserversDownloadUpdated();
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_FALSE(IsPathInUse(path));
|
||||
EXPECT_TRUE(IsPathInUse(new_target_path));
|
||||
|
||||
// Destroying the item should release the reservation.
|
||||
SetDownloadItemState(item.get(), DownloadItem::COMPLETE);
|
||||
item.reset();
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_FALSE(IsPathInUse(new_target_path));
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/strings/string16.h"
|
||||
#include "chrome/browser/process_singleton.h"
|
||||
#include "chrome/grit/chromium_strings.h"
|
||||
@ -288,7 +289,7 @@ TryChromeDialogView::Result TryChromeDialogView::ShowModal(
|
||||
popup_->Show();
|
||||
if (!listener.is_null())
|
||||
listener.Run(popup_->GetNativeView());
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
if (!listener.is_null())
|
||||
listener.Run(NULL);
|
||||
return result_;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "base/macros.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/strings/string16.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
@ -225,7 +226,7 @@ IN_PROC_BROWSER_TEST_F(EdgeImporterBrowserTest, EdgeImporter) {
|
||||
|
||||
host->StartImportSettings(source_profile, browser()->profile(),
|
||||
importer::FAVORITES, observer.get());
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(EdgeImporterBrowserTest, EdgeImporterLegacyFallback) {
|
||||
@ -263,7 +264,7 @@ IN_PROC_BROWSER_TEST_F(EdgeImporterBrowserTest, EdgeImporterLegacyFallback) {
|
||||
|
||||
host->StartImportSettings(source_profile, browser()->profile(),
|
||||
importer::FAVORITES, observer.get());
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(EdgeImporterBrowserTest, EdgeImporterNoDatabase) {
|
||||
@ -294,5 +295,5 @@ IN_PROC_BROWSER_TEST_F(EdgeImporterBrowserTest, EdgeImporterNoDatabase) {
|
||||
|
||||
host->StartImportSettings(source_profile, browser()->profile(),
|
||||
importer::FAVORITES, observer.get());
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "base/files/scoped_temp_dir.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/string16.h"
|
||||
#include "base/strings/string_util.h"
|
||||
@ -521,7 +522,7 @@ IN_PROC_BROWSER_TEST_F(IEImporterBrowserTest, IEImporter) {
|
||||
browser()->profile(),
|
||||
importer::HISTORY | importer::PASSWORDS | importer::FAVORITES,
|
||||
observer);
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
// Cleans up.
|
||||
url_history_stg2->DeleteUrl(kIEIdentifyUrl, 0);
|
||||
@ -599,7 +600,7 @@ IN_PROC_BROWSER_TEST_F(IEImporterBrowserTest,
|
||||
browser()->profile(),
|
||||
importer::FAVORITES,
|
||||
observer);
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
}
|
||||
|
||||
@ -626,7 +627,7 @@ IN_PROC_BROWSER_TEST_F(IEImporterBrowserTest, IE7ImporterPasswordsTest) {
|
||||
browser()->profile(),
|
||||
importer::PASSWORDS,
|
||||
observer);
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(IEImporterBrowserTest, IEImporterHomePageTest) {
|
||||
@ -652,6 +653,6 @@ IN_PROC_BROWSER_TEST_F(IEImporterBrowserTest, IEImporterHomePageTest) {
|
||||
browser()->profile(),
|
||||
importer::HOME_PAGE,
|
||||
observer);
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "base/location.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "chrome/browser/local_discovery/service_discovery_client_impl.h"
|
||||
@ -84,13 +85,11 @@ class LocalDomainResolverTest : public testing::Test {
|
||||
}
|
||||
|
||||
void RunFor(base::TimeDelta time_period) {
|
||||
base::CancelableCallback<void()> callback(
|
||||
base::Bind(&base::MessageLoop::QuitWhenIdle,
|
||||
base::Unretained(base::MessageLoop::current())));
|
||||
base::RunLoop run_loop;
|
||||
base::CancelableCallback<void()> callback(run_loop.QuitWhenIdleClosure());
|
||||
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
||||
FROM_HERE, callback.callback(), time_period);
|
||||
|
||||
base::MessageLoop::current()->Run();
|
||||
run_loop.Run();
|
||||
callback.Cancel();
|
||||
}
|
||||
|
||||
|
@ -216,12 +216,11 @@ class ServiceDiscoveryTest : public ::testing::Test {
|
||||
|
||||
protected:
|
||||
void RunFor(base::TimeDelta time_period) {
|
||||
base::CancelableCallback<void()> callback(base::Bind(
|
||||
&ServiceDiscoveryTest::Stop, base::Unretained(this)));
|
||||
base::RunLoop run_loop;
|
||||
base::CancelableCallback<void()> callback(run_loop.QuitWhenIdleClosure());
|
||||
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
||||
FROM_HERE, callback.callback(), time_period);
|
||||
|
||||
base::MessageLoop::current()->Run();
|
||||
run_loop.Run();
|
||||
callback.Cancel();
|
||||
}
|
||||
|
||||
@ -288,7 +287,7 @@ TEST_F(ServiceDiscoveryTest, ReadCachedServices) {
|
||||
"hello._privet._tcp.local"))
|
||||
.Times(Exactly(1));
|
||||
|
||||
base::MessageLoop::current()->RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
|
||||
@ -310,7 +309,7 @@ TEST_F(ServiceDiscoveryTest, ReadCachedServicesMultiple) {
|
||||
"gdbye._privet._tcp.local"))
|
||||
.Times(Exactly(1));
|
||||
|
||||
base::MessageLoop::current()->RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
|
||||
@ -328,7 +327,7 @@ TEST_F(ServiceDiscoveryTest, OnServiceChanged) {
|
||||
|
||||
socket_factory_.SimulateReceive(kSamplePacketPTR, sizeof(kSamplePacketPTR));
|
||||
|
||||
base::MessageLoop::current()->RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_CALL(delegate, OnServiceUpdated(ServiceWatcher::UPDATE_CHANGED,
|
||||
"hello._privet._tcp.local"))
|
||||
@ -338,7 +337,7 @@ TEST_F(ServiceDiscoveryTest, OnServiceChanged) {
|
||||
|
||||
socket_factory_.SimulateReceive(kSamplePacketTXT, sizeof(kSamplePacketTXT));
|
||||
|
||||
base::MessageLoop::current()->RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
TEST_F(ServiceDiscoveryTest, SinglePacket) {
|
||||
@ -356,7 +355,7 @@ TEST_F(ServiceDiscoveryTest, SinglePacket) {
|
||||
socket_factory_.SimulateReceive(kSamplePacketPTR, sizeof(kSamplePacketPTR));
|
||||
|
||||
// Reset the "already updated" flag.
|
||||
base::MessageLoop::current()->RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_CALL(delegate, OnServiceUpdated(ServiceWatcher::UPDATE_CHANGED,
|
||||
"hello._privet._tcp.local"))
|
||||
@ -366,7 +365,7 @@ TEST_F(ServiceDiscoveryTest, SinglePacket) {
|
||||
|
||||
socket_factory_.SimulateReceive(kSamplePacketTXT, sizeof(kSamplePacketTXT));
|
||||
|
||||
base::MessageLoop::current()->RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
TEST_F(ServiceDiscoveryTest, ActivelyRefreshServices) {
|
||||
@ -390,7 +389,7 @@ TEST_F(ServiceDiscoveryTest, ActivelyRefreshServices) {
|
||||
|
||||
socket_factory_.SimulateReceive(kSamplePacketPTR, sizeof(kSamplePacketPTR));
|
||||
|
||||
base::MessageLoop::current()->RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
socket_factory_.SimulateReceive(kSamplePacketSRV, sizeof(kSamplePacketSRV));
|
||||
|
||||
@ -403,7 +402,7 @@ TEST_F(ServiceDiscoveryTest, ActivelyRefreshServices) {
|
||||
|
||||
RunFor(base::TimeDelta::FromSeconds(2));
|
||||
|
||||
base::MessageLoop::current()->RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
|
||||
@ -454,7 +453,7 @@ TEST_F(ServiceResolverTest, TxtAndSrvButNoA) {
|
||||
|
||||
socket_factory_.SimulateReceive(kSamplePacketSRV, sizeof(kSamplePacketSRV));
|
||||
|
||||
base::MessageLoop::current()->RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_CALL(
|
||||
*this, OnFinishedResolvingInternal(ServiceResolver::STATUS_SUCCESS,
|
||||
|
@ -707,7 +707,7 @@ TEST_F(ThreadWatcherListTest, Restart) {
|
||||
FROM_HERE, message_loop_for_ui.QuitWhenIdleClosure(),
|
||||
base::TimeDelta::FromSeconds(
|
||||
ThreadWatcherList::g_initialize_delay_seconds));
|
||||
message_loop_for_ui.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
CheckState(false /* has_thread_watcher_list */,
|
||||
true /* stopped */,
|
||||
@ -719,7 +719,7 @@ TEST_F(ThreadWatcherListTest, Restart) {
|
||||
FROM_HERE, message_loop_for_ui.QuitWhenIdleClosure(),
|
||||
base::TimeDelta::FromSeconds(
|
||||
ThreadWatcherList::g_initialize_delay_seconds + 1));
|
||||
message_loop_for_ui.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
CheckState(true /* has_thread_watcher_list */,
|
||||
false /* stopped */,
|
||||
@ -731,7 +731,7 @@ TEST_F(ThreadWatcherListTest, Restart) {
|
||||
FROM_HERE, message_loop_for_ui.QuitWhenIdleClosure(),
|
||||
base::TimeDelta::FromSeconds(
|
||||
ThreadWatcherList::g_initialize_delay_seconds));
|
||||
message_loop_for_ui.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
CheckState(false /* has_thread_watcher_list */,
|
||||
true /* stopped */,
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "base/location.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
@ -426,7 +427,7 @@ class NativeBackendGnomeTest : public testing::Test {
|
||||
void TearDown() override {
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
db_thread_.Stop();
|
||||
}
|
||||
|
||||
@ -438,7 +439,7 @@ class NativeBackendGnomeTest : public testing::Test {
|
||||
// quit so we can get on with the rest of the test.
|
||||
BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
|
||||
base::Bind(&PostQuitTask, &message_loop_));
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
|
||||
static void PostQuitTask(base::MessageLoop* loop) {
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "base/callback.h"
|
||||
#include "base/location.h"
|
||||
#include "base/pickle.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
@ -414,7 +415,7 @@ void NativeBackendKWalletTest::SetUp() {
|
||||
void NativeBackendKWalletTest::TearDown() {
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
db_thread_.Stop();
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "base/location.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
@ -338,12 +339,12 @@ class NativeBackendLibsecretTest : public testing::Test {
|
||||
void TearDown() override {
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
ASSERT_TRUE(global_mock_libsecret_items);
|
||||
global_mock_libsecret_items = nullptr;
|
||||
}
|
||||
|
||||
void RunUIThread() { base::MessageLoop::current()->Run(); }
|
||||
void RunUIThread() { base::RunLoop().Run(); }
|
||||
|
||||
void CheckUint32Attribute(const MockSecretItem* item,
|
||||
const std::string& attribute,
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "base/synchronization/waitable_event.h"
|
||||
@ -160,7 +161,7 @@ class PasswordStoreWinTest : public testing::Test {
|
||||
done.Wait();
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
db_thread_.Stop();
|
||||
}
|
||||
|
||||
@ -274,7 +275,7 @@ TEST_F(PasswordStoreWinTest, DISABLED_ConvertIE7Login) {
|
||||
UnorderedPasswordFormElementsAre(&expected_forms)));
|
||||
|
||||
store_->GetLogins(form, &consumer);
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
|
||||
TEST_F(PasswordStoreWinTest, OutstandingWDSQueries) {
|
||||
@ -308,7 +309,7 @@ TEST_F(PasswordStoreWinTest, OutstandingWDSQueries) {
|
||||
wdbs_->ShutdownDatabase();
|
||||
wdbs_ = nullptr;
|
||||
|
||||
base::MessageLoop::current()->RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
// Hangs flakily, see http://crbug.com/43836.
|
||||
@ -386,8 +387,8 @@ TEST_F(PasswordStoreWinTest, DISABLED_MultipleWDSQueriesOnDifferentThreads) {
|
||||
// Run the MessageLoop twice: once for the GetIE7Login that PasswordStoreWin
|
||||
// schedules on the DB thread and once for the one we just scheduled on the UI
|
||||
// thread.
|
||||
base::MessageLoop::current()->Run();
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
|
||||
TEST_F(PasswordStoreWinTest, EmptyLogins) {
|
||||
@ -419,7 +420,7 @@ TEST_F(PasswordStoreWinTest, EmptyLogins) {
|
||||
EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty()));
|
||||
|
||||
store_->GetLogins(form, &consumer);
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
|
||||
TEST_F(PasswordStoreWinTest, EmptyBlacklistLogins) {
|
||||
@ -435,7 +436,7 @@ TEST_F(PasswordStoreWinTest, EmptyBlacklistLogins) {
|
||||
EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty()));
|
||||
|
||||
store_->GetBlacklistLogins(&consumer);
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
|
||||
TEST_F(PasswordStoreWinTest, EmptyAutofillableLogins) {
|
||||
@ -451,5 +452,5 @@ TEST_F(PasswordStoreWinTest, EmptyAutofillableLogins) {
|
||||
EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty()));
|
||||
|
||||
store_->GetAutofillableLogins(&consumer);
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
|
@ -190,9 +190,7 @@ class PrerenderResourceThrottleTest : public testing::Test {
|
||||
}
|
||||
|
||||
// Runs any tasks queued on either thread.
|
||||
void RunEvents() {
|
||||
message_loop_.RunUntilIdle();
|
||||
}
|
||||
void RunEvents() { base::RunLoop().RunUntilIdle(); }
|
||||
|
||||
private:
|
||||
base::MessageLoopForIO message_loop_;
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "base/process/kill.h"
|
||||
#include "base/process/process.h"
|
||||
#include "base/rand_util.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/synchronization/waitable_event.h"
|
||||
#include "base/test/multiprocess_test.h"
|
||||
@ -283,7 +284,7 @@ int CloudPrintMockService_Main(SetExpectationsCallback set_expectations) {
|
||||
&listener,
|
||||
service_process.io_task_runner());
|
||||
|
||||
main_message_loop.Run();
|
||||
base::RunLoop().Run();
|
||||
if (!Mock::VerifyAndClearExpectations(&server))
|
||||
return kExpectationsNotMet;
|
||||
if (!g_good_shutdown)
|
||||
|
@ -76,7 +76,7 @@ class ProfileShortcutManagerTest : public testing::Test {
|
||||
const base::FilePath profile_path = entry->GetPath();
|
||||
base::string16 profile_name = entry->GetName();
|
||||
profile_attributes_storage_->RemoveProfile(profile_path);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
ASSERT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_name));
|
||||
// The icon file is not deleted until the profile directory is deleted.
|
||||
const base::FilePath icon_path =
|
||||
@ -93,12 +93,6 @@ class ProfileShortcutManagerTest : public testing::Test {
|
||||
return profile_path;
|
||||
}
|
||||
|
||||
void RunPendingTasks() {
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
|
||||
base::MessageLoop::current()->Run();
|
||||
}
|
||||
|
||||
void SetupDefaultProfileShortcut(const tracked_objects::Location& location) {
|
||||
ASSERT_EQ(0u, profile_attributes_storage_->GetNumberOfProfiles())
|
||||
<< location.ToString();
|
||||
@ -110,7 +104,7 @@ class ProfileShortcutManagerTest : public testing::Test {
|
||||
// Also create a non-badged shortcut for Chrome, which is conveniently done
|
||||
// by |CreateProfileShortcut()| since there is only one profile.
|
||||
profile_shortcut_manager_->CreateProfileShortcut(profile_1_path_);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
// Verify that there's now a shortcut with no profile information.
|
||||
ValidateNonProfileShortcut(location);
|
||||
}
|
||||
@ -197,7 +191,7 @@ class ProfileShortcutManagerTest : public testing::Test {
|
||||
std::string(), base::string16(), 0,
|
||||
std::string());
|
||||
profile_shortcut_manager_->CreateProfileShortcut(profile_path);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
ValidateProfileShortcut(location, profile_name, profile_path);
|
||||
}
|
||||
|
||||
@ -247,7 +241,7 @@ class ProfileShortcutManagerTest : public testing::Test {
|
||||
GetProfileAttributesWithPath(profile_path, &entry));
|
||||
ASSERT_NE(entry->GetName(), new_profile_name);
|
||||
entry->SetName(new_profile_name);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
BrowserDistribution* GetDistribution() {
|
||||
@ -368,7 +362,7 @@ TEST_F(ProfileShortcutManagerTest, CreateSecondProfileBadgesFirstShortcut) {
|
||||
profile_attributes_storage_->AddProfile(profile_2_path_, profile_2_name_,
|
||||
std::string(), base::string16(), 0,
|
||||
std::string());
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// Ensure that the second profile doesn't have a shortcut and that the first
|
||||
// profile's shortcut got renamed and badged.
|
||||
@ -382,7 +376,7 @@ TEST_F(ProfileShortcutManagerTest, DesktopShortcutsDeleteSecondToLast) {
|
||||
|
||||
// Delete one shortcut.
|
||||
profile_attributes_storage_->RemoveProfile(profile_2_path_);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_2_name_));
|
||||
|
||||
// Verify that the profile name has been removed from the remaining shortcut.
|
||||
@ -407,7 +401,7 @@ TEST_F(ProfileShortcutManagerTest, DeleteSecondToLastProfileWithoutShortcut) {
|
||||
|
||||
// Delete the profile that doesn't have a shortcut.
|
||||
profile_attributes_storage_->RemoveProfile(profile_1_path_);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// Verify that the remaining shortcut does not have a profile name.
|
||||
ValidateNonProfileShortcut(FROM_HERE);
|
||||
@ -431,7 +425,7 @@ TEST_F(ProfileShortcutManagerTest, DeleteSecondToLastProfileWithShortcut) {
|
||||
|
||||
// Delete the profile that has a shortcut.
|
||||
profile_attributes_storage_->RemoveProfile(profile_2_path_);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// Verify that the remaining shortcut does not have a profile name.
|
||||
ValidateNonProfileShortcut(FROM_HERE);
|
||||
@ -466,7 +460,7 @@ TEST_F(ProfileShortcutManagerTest, DeleteOnlyProfileWithShortcuts) {
|
||||
// Delete the third profile and check that its shortcut is gone and no
|
||||
// shortcuts have been re-created.
|
||||
profile_attributes_storage_->RemoveProfile(profile_3_path_);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
ASSERT_FALSE(base::PathExists(profile_1_shortcut_path));
|
||||
ASSERT_FALSE(base::PathExists(profile_2_shortcut_path));
|
||||
ASSERT_FALSE(base::PathExists(profile_3_shortcut_path));
|
||||
@ -478,7 +472,7 @@ TEST_F(ProfileShortcutManagerTest, DesktopShortcutsCreateSecond) {
|
||||
|
||||
// Delete one shortcut.
|
||||
profile_attributes_storage_->RemoveProfile(profile_2_path_);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// Verify that a default shortcut exists (no profile name/avatar).
|
||||
ValidateNonProfileShortcut(FROM_HERE);
|
||||
@ -507,7 +501,7 @@ TEST_F(ProfileShortcutManagerTest, RenamedDesktopShortcuts) {
|
||||
|
||||
// Ensure that a new shortcut does not get made if the old one was renamed.
|
||||
profile_shortcut_manager_->CreateProfileShortcut(profile_2_path_);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_2_name_));
|
||||
ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_2,
|
||||
profile_2_path_);
|
||||
@ -516,7 +510,7 @@ TEST_F(ProfileShortcutManagerTest, RenamedDesktopShortcuts) {
|
||||
ASSERT_TRUE(base::DeleteFile(profile_2_shortcut_path_2, false));
|
||||
EXPECT_FALSE(base::PathExists(profile_2_shortcut_path_2));
|
||||
profile_shortcut_manager_->CreateProfileShortcut(profile_2_path_);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_);
|
||||
}
|
||||
|
||||
@ -545,7 +539,7 @@ TEST_F(ProfileShortcutManagerTest, RenamedDesktopShortcutsGetDeleted) {
|
||||
|
||||
// Delete the profile and ensure both shortcuts were also deleted.
|
||||
profile_attributes_storage_->RemoveProfile(profile_2_path_);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_FALSE(base::PathExists(profile_2_shortcut_path_1));
|
||||
EXPECT_FALSE(base::PathExists(profile_2_shortcut_path_2));
|
||||
ValidateNonProfileShortcutAtPath(FROM_HERE,
|
||||
@ -643,7 +637,7 @@ TEST_F(ProfileShortcutManagerTest, RemoveProfileShortcuts) {
|
||||
// Delete shortcuts for profile 1 and ensure that they got deleted while the
|
||||
// shortcuts for profile 2 were kept.
|
||||
profile_shortcut_manager_->RemoveProfileShortcuts(profile_1_path_);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_FALSE(base::PathExists(profile_1_shortcut_path_1));
|
||||
EXPECT_FALSE(base::PathExists(profile_1_shortcut_path_2));
|
||||
ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_1,
|
||||
@ -666,7 +660,7 @@ TEST_F(ProfileShortcutManagerTest, HasProfileShortcuts) {
|
||||
|
||||
// Profile 2 should have a shortcut initially.
|
||||
profile_shortcut_manager_->HasProfileShortcuts(profile_2_path_, callback);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_TRUE(result.has_shortcuts);
|
||||
|
||||
// Delete the shortcut and check that the function returns false.
|
||||
@ -675,7 +669,7 @@ TEST_F(ProfileShortcutManagerTest, HasProfileShortcuts) {
|
||||
ASSERT_TRUE(base::DeleteFile(profile_2_shortcut_path, false));
|
||||
EXPECT_FALSE(base::PathExists(profile_2_shortcut_path));
|
||||
profile_shortcut_manager_->HasProfileShortcuts(profile_2_path_, callback);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_FALSE(result.has_shortcuts);
|
||||
}
|
||||
|
||||
@ -687,7 +681,7 @@ TEST_F(ProfileShortcutManagerTest, ProfileShortcutsWithSystemLevelShortcut) {
|
||||
profile_attributes_storage_->AddProfile(profile_1_path_, profile_1_name_,
|
||||
std::string(), base::string16(), 0,
|
||||
std::string());
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
ASSERT_EQ(1u, profile_attributes_storage_->GetNumberOfProfiles());
|
||||
|
||||
// Ensure system-level continues to exist and user-level was not created.
|
||||
@ -706,7 +700,7 @@ TEST_F(ProfileShortcutManagerTest, ProfileShortcutsWithSystemLevelShortcut) {
|
||||
profile_attributes_storage_->AddProfile(profile_3_path_, profile_3_name_,
|
||||
std::string(), base::string16(), 0,
|
||||
std::string());
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_3_name_));
|
||||
|
||||
// Ensure that changing the avatar icon and the name does not result in a
|
||||
@ -715,12 +709,12 @@ TEST_F(ProfileShortcutManagerTest, ProfileShortcutsWithSystemLevelShortcut) {
|
||||
ASSERT_TRUE(profile_attributes_storage_->
|
||||
GetProfileAttributesWithPath(profile_3_path_, &entry_3));
|
||||
entry_3->SetAvatarIconIndex(3u);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_3_name_));
|
||||
|
||||
const base::string16 new_profile_3_name = L"New Name 3";
|
||||
entry_3->SetName(new_profile_3_name);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_3_name_));
|
||||
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(new_profile_3_name));
|
||||
|
||||
@ -730,7 +724,7 @@ TEST_F(ProfileShortcutManagerTest, ProfileShortcutsWithSystemLevelShortcut) {
|
||||
ASSERT_TRUE(profile_attributes_storage_->
|
||||
GetProfileAttributesWithPath(profile_2_path_, &entry_2));
|
||||
entry_2->SetName(new_profile_2_name);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_2_name_));
|
||||
ValidateProfileShortcut(FROM_HERE, new_profile_2_name, profile_2_path_);
|
||||
}
|
||||
@ -745,7 +739,7 @@ TEST_F(ProfileShortcutManagerTest,
|
||||
// Delete a profile and verify that only the system-level shortcut still
|
||||
// exists.
|
||||
profile_attributes_storage_->RemoveProfile(profile_1_path_);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_TRUE(base::PathExists(system_level_shortcut_path));
|
||||
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(base::string16()));
|
||||
@ -774,7 +768,7 @@ TEST_F(ProfileShortcutManagerTest,
|
||||
// shortcut creation path in |DeleteDesktopShortcuts()|, which is
|
||||
// not covered by the |DeleteSecondToLastProfileWithSystemLevelShortcut| test.
|
||||
profile_attributes_storage_->RemoveProfile(profile_2_path_);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// Verify that only the system-level shortcut still exists.
|
||||
EXPECT_TRUE(base::PathExists(system_level_shortcut_path));
|
||||
@ -795,7 +789,7 @@ TEST_F(ProfileShortcutManagerTest, CreateProfileIcon) {
|
||||
EXPECT_FALSE(base::PathExists(icon_path));
|
||||
|
||||
profile_shortcut_manager_->CreateOrUpdateProfileIcon(profile_1_path_);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_TRUE(base::PathExists(icon_path));
|
||||
}
|
||||
|
||||
@ -826,7 +820,7 @@ TEST_F(ProfileShortcutManagerTest, UnbadgeProfileIconOnDeletion) {
|
||||
// Deleting the default profile will unbadge the new profile's icon and should
|
||||
// result in an icon that is identical to the unbadged default profile icon.
|
||||
profile_attributes_storage_->RemoveProfile(profile_1_path_);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
std::string unbadged_icon_2;
|
||||
EXPECT_TRUE(base::ReadFileToString(icon_path_2, &unbadged_icon_2));
|
||||
@ -853,7 +847,7 @@ TEST_F(ProfileShortcutManagerTest, ProfileIconOnAvatarChange) {
|
||||
ASSERT_TRUE(profile_attributes_storage_->
|
||||
GetProfileAttributesWithPath(profile_1_path_, &entry_1));
|
||||
entry_1->SetAvatarIconIndex(1u);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
std::string new_badged_icon_1;
|
||||
EXPECT_TRUE(base::ReadFileToString(icon_path_1, &new_badged_icon_1));
|
||||
@ -861,7 +855,7 @@ TEST_F(ProfileShortcutManagerTest, ProfileIconOnAvatarChange) {
|
||||
|
||||
// Ensure the new icon is not the unbadged icon.
|
||||
profile_attributes_storage_->RemoveProfile(profile_2_path_);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
std::string unbadged_icon_1;
|
||||
EXPECT_TRUE(base::ReadFileToString(icon_path_1, &unbadged_icon_1));
|
||||
@ -869,7 +863,7 @@ TEST_F(ProfileShortcutManagerTest, ProfileIconOnAvatarChange) {
|
||||
|
||||
// Ensure the icon doesn't change on avatar change without 2 profiles.
|
||||
entry_1->SetAvatarIconIndex(1u);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
std::string unbadged_icon_1_a;
|
||||
EXPECT_TRUE(base::ReadFileToString(icon_path_1, &unbadged_icon_1_a));
|
||||
@ -1015,7 +1009,7 @@ TEST_F(ProfileShortcutManagerTest, ShortcutsForProfilesWithIdenticalNames) {
|
||||
|
||||
// Delete profile1.
|
||||
profile_attributes_storage_->RemoveProfile(profile_1_path_);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(new_profile_1_name));
|
||||
// Check that nothing is changed for profile2 and profile3.
|
||||
ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_);
|
||||
@ -1028,7 +1022,7 @@ TEST_F(ProfileShortcutManagerTest, ShortcutsForProfilesWithIdenticalNames) {
|
||||
GetDefaultShortcutPathForProfile(profile_2_name_)));
|
||||
EXPECT_TRUE(base::PathExists(profile_3_shortcut_path));
|
||||
profile_attributes_storage_->RemoveProfile(profile_2_path_);
|
||||
RunPendingTasks();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_FALSE(base::PathExists(
|
||||
GetDefaultShortcutPathForProfile(profile_2_name_)));
|
||||
// Only profile3 exists. There should be non-profile shortcut only.
|
||||
|
@ -179,7 +179,8 @@ class BrowserFeatureExtractorTest : public ChromeRenderViewHostTestHarness {
|
||||
// Feature extraction takes ownership of the request object
|
||||
// and passes it along to the done callback in the end.
|
||||
StartExtractMalwareFeatures(request);
|
||||
base::MessageLoopForUI::current()->Run();
|
||||
ASSERT_TRUE(base::MessageLoopForUI::IsCurrent());
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(1U, success_.count(request));
|
||||
EXPECT_TRUE(success_[request]);
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/threading/thread.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "skia/ext/skia_utils_win.h"
|
||||
@ -37,7 +38,8 @@ ColorChooserDialog::ColorChooserDialog(views::ColorChooserListener* listener,
|
||||
HWND owning_hwnd = views::HWNDForNativeWindow(owning_window);
|
||||
ExecuteOpenParams execute_params(initial_color, BeginRun(owning_hwnd),
|
||||
owning_hwnd);
|
||||
execute_params.run_state.dialog_thread->message_loop()->PostTask(FROM_HERE,
|
||||
execute_params.run_state.dialog_thread->task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&ColorChooserDialog::ExecuteOpen, this, execute_params));
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "base/location.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "build/build_config.h"
|
||||
@ -305,7 +306,7 @@ class TestMessageLoopCondition {
|
||||
void Wait() {
|
||||
while (!signaled_) {
|
||||
waiting_ = true;
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
waiting_ = false;
|
||||
}
|
||||
signaled_ = false;
|
||||
@ -456,7 +457,7 @@ class LocalDiscoveryUITest : public WebUIBrowserTest {
|
||||
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
||||
FROM_HERE, callback.callback(), time_period);
|
||||
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
callback.Cancel();
|
||||
}
|
||||
|
||||
@ -502,7 +503,7 @@ IN_PROC_BROWSER_TEST_F(LocalDiscoveryUITest, AddRowTest) {
|
||||
test_service_discovery_client()->SimulateReceive(
|
||||
kAnnouncePacket, sizeof(kAnnouncePacket));
|
||||
|
||||
base::MessageLoop::current()->RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_TRUE(WebUIBrowserTest::RunJavascriptTest("checkOneDevice"));
|
||||
|
||||
@ -525,7 +526,7 @@ IN_PROC_BROWSER_TEST_F(LocalDiscoveryUITest, RegisterTest) {
|
||||
test_service_discovery_client()->SimulateReceive(
|
||||
kAnnouncePacket, sizeof(kAnnouncePacket));
|
||||
|
||||
base::MessageLoop::current()->RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_TRUE(WebUIBrowserTest::RunJavascriptTest("checkOneDevice"));
|
||||
|
||||
@ -578,7 +579,7 @@ IN_PROC_BROWSER_TEST_F(LocalDiscoveryUITest, RegisterTest) {
|
||||
test_service_discovery_client()->SimulateReceive(
|
||||
kAnnouncePacketRegistered, sizeof(kAnnouncePacketRegistered));
|
||||
|
||||
base::MessageLoop::current()->RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_TRUE(WebUIBrowserTest::RunJavascriptTest("expectRegisterDone"));
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "base/location.h"
|
||||
#include "base/process/kill.h"
|
||||
#include "base/process/launch.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/threading/platform_thread.h"
|
||||
@ -53,12 +54,11 @@ namespace {
|
||||
|
||||
bool g_good_shutdown = false;
|
||||
|
||||
void ShutdownTask(base::MessageLoop* loop) {
|
||||
void ShutdownTask(base::RunLoop* loop) {
|
||||
// Quit the main message loop.
|
||||
ASSERT_FALSE(g_good_shutdown);
|
||||
g_good_shutdown = true;
|
||||
loop->task_runner()->PostTask(FROM_HERE,
|
||||
base::MessageLoop::QuitWhenIdleClosure());
|
||||
loop->QuitWhenIdle();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@ -230,19 +230,19 @@ MULTIPROCESS_TEST_MAIN(ServiceProcessStateTestReadyFalse) {
|
||||
MULTIPROCESS_TEST_MAIN(ServiceProcessStateTestShutdown) {
|
||||
base::PlatformThread::SetName("ServiceProcessStateTestShutdownMainThread");
|
||||
base::MessageLoop message_loop;
|
||||
base::RunLoop run_loop;
|
||||
base::Thread io_thread_("ServiceProcessStateTestShutdownIOThread");
|
||||
base::Thread::Options options(base::MessageLoop::TYPE_IO, 0);
|
||||
EXPECT_TRUE(io_thread_.StartWithOptions(options));
|
||||
ServiceProcessState state;
|
||||
EXPECT_TRUE(state.Initialize());
|
||||
EXPECT_TRUE(state.SignalReady(
|
||||
io_thread_.task_runner().get(),
|
||||
base::Bind(&ShutdownTask, base::MessageLoop::current())));
|
||||
EXPECT_TRUE(state.SignalReady(io_thread_.task_runner().get(),
|
||||
base::Bind(&ShutdownTask, &run_loop)));
|
||||
message_loop.task_runner()->PostDelayedTask(
|
||||
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
|
||||
FROM_HERE, run_loop.QuitWhenIdleClosure(),
|
||||
TestTimeouts::action_max_timeout());
|
||||
EXPECT_FALSE(g_good_shutdown);
|
||||
message_loop.Run();
|
||||
run_loop.Run();
|
||||
EXPECT_TRUE(g_good_shutdown);
|
||||
return 0;
|
||||
}
|
||||
@ -283,9 +283,9 @@ class ServiceProcessStateFileManipulationTest : public ::testing::Test {
|
||||
ASSERT_TRUE(service_process_state_.Initialize());
|
||||
ASSERT_TRUE(service_process_state_.SignalReady(
|
||||
io_thread_.task_runner().get(), base::Closure()));
|
||||
loop_.task_runner()->PostDelayedTask(
|
||||
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
|
||||
TestTimeouts::action_max_timeout());
|
||||
loop_.task_runner()->PostDelayedTask(FROM_HERE,
|
||||
run_loop_.QuitWhenIdleClosure(),
|
||||
TestTimeouts::action_max_timeout());
|
||||
}
|
||||
|
||||
const MockLaunchd* mock_launchd() const { return mock_launchd_.get(); }
|
||||
@ -296,11 +296,12 @@ class ServiceProcessStateFileManipulationTest : public ::testing::Test {
|
||||
base::SingleThreadTaskRunner* GetIOTaskRunner() {
|
||||
return io_thread_.task_runner().get();
|
||||
}
|
||||
void Run() { loop_.Run(); }
|
||||
void Run() { run_loop_.Run(); }
|
||||
|
||||
private:
|
||||
base::ScopedTempDir temp_dir_;
|
||||
base::MessageLoopForUI loop_;
|
||||
base::RunLoop run_loop_;
|
||||
base::Thread io_thread_;
|
||||
base::FilePath executable_path_, bundle_path_;
|
||||
std::unique_ptr<MockLaunchd> mock_launchd_;
|
||||
|
@ -208,7 +208,7 @@ void RunServer(uint16_t port,
|
||||
HttpRequestHandlerFunc handle_request_func =
|
||||
base::Bind(&HandleRequestOnCmdThread, &handler, whitelisted_ips);
|
||||
|
||||
io_thread.message_loop()->task_runner()->PostTask(
|
||||
io_thread.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&StartServerOnIOThread, port, allow_remote,
|
||||
base::Bind(&HandleRequestOnIOThread, cmd_loop.task_runner(),
|
||||
@ -219,8 +219,8 @@ void RunServer(uint16_t port,
|
||||
// destroyed, which waits until all pending tasks have been completed.
|
||||
// This assumes the response is sent synchronously as part of the IO task.
|
||||
cmd_run_loop.Run();
|
||||
io_thread.message_loop()->task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&StopServerOnIOThread));
|
||||
io_thread.task_runner()->PostTask(FROM_HERE,
|
||||
base::Bind(&StopServerOnIOThread));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "chromeos/dbus/dbus_thread_manager.h"
|
||||
#include "components/arc/arc_bridge_service_impl.h"
|
||||
#include "components/arc/test/fake_arc_bridge_bootstrap.h"
|
||||
@ -37,7 +38,8 @@ class ArcBridgeTest : public testing::Test, public ArcBridgeService::Observer {
|
||||
void OnBridgeStopped(ArcBridgeService::StopReason stop_reason) override {
|
||||
state_ = ArcBridgeService::State::STOPPED;
|
||||
stop_reason_ = stop_reason;
|
||||
message_loop_.PostTask(FROM_HERE, message_loop_.QuitWhenIdleClosure());
|
||||
message_loop_.task_runner()->PostTask(FROM_HERE,
|
||||
message_loop_.QuitWhenIdleClosure());
|
||||
}
|
||||
|
||||
bool ready() const { return ready_; }
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
|
||||
namespace arc {
|
||||
|
||||
@ -28,7 +29,7 @@ void ArcStandaloneBridgeRunner::Stop(int exit_code) {
|
||||
DCHECK(thread_checker_.CalledOnValidThread());
|
||||
exit_code_ = exit_code;
|
||||
CHECK(run_loop_);
|
||||
message_loop_.PostTask(FROM_HERE, run_loop_->QuitClosure());
|
||||
message_loop_.task_runner()->PostTask(FROM_HERE, run_loop_->QuitClosure());
|
||||
}
|
||||
|
||||
} // namespace arc
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "base/macros.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/test/launcher/unit_test_launcher.h"
|
||||
#include "base/test/test_suite.h"
|
||||
#include "base/threading/platform_thread.h"
|
||||
@ -29,7 +30,7 @@ class ServiceHelperTest : public ::testing::Test {
|
||||
void Quit() {
|
||||
CHECK(base_loop_);
|
||||
CHECK(run_loop_);
|
||||
base_loop_->PostTask(FROM_HERE, run_loop_->QuitClosure());
|
||||
base_loop_->task_runner()->PostTask(FROM_HERE, run_loop_->QuitClosure());
|
||||
}
|
||||
|
||||
void Init() {
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "build/build_config.h"
|
||||
#include "components/autofill/content/browser/risk/proto/fingerprint.pb.h"
|
||||
#include "content/public/browser/gpu_data_manager.h"
|
||||
@ -211,7 +212,7 @@ IN_PROC_BROWSER_TEST_F(AutofillRiskFingerprintTest, GetFingerprint) {
|
||||
base::Unretained(this)));
|
||||
|
||||
// Wait for the callback to be called.
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
|
||||
} // namespace risk
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "base/macros.h"
|
||||
#include "base/metrics/statistics_recorder.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/synchronization/waitable_event.h"
|
||||
#include "base/threading/worker_pool.h"
|
||||
#include "components/cronet/ios/version.h"
|
||||
@ -74,7 +75,7 @@ void CronetEnvironment::PostToNetworkThread(
|
||||
void CronetEnvironment::PostToFileUserBlockingThread(
|
||||
const tracked_objects::Location& from_here,
|
||||
const base::Closure& task) {
|
||||
file_user_blocking_thread_->message_loop()->PostTask(from_here, task);
|
||||
file_user_blocking_thread_->task_runner()->PostTask(from_here, task);
|
||||
}
|
||||
|
||||
net::URLRequestContext* CronetEnvironment::GetURLRequestContext() const {
|
||||
|
@ -289,7 +289,7 @@ class DataUseAggregatorTest : public testing::Test {
|
||||
reporting_network_delegate_->set_data_use_context_map(data_use_context_map);
|
||||
|
||||
request->Start();
|
||||
loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
return request;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/test/histogram_tester.h"
|
||||
#include "build/build_config.h"
|
||||
#include "content/public/browser/resource_request_info.h"
|
||||
@ -63,7 +64,7 @@ class DataUseMeasurementTest : public testing::Test {
|
||||
}
|
||||
|
||||
request->Start();
|
||||
loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
data_use_measurement_.OnCompleted(*request, true);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/bind_helpers.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "components/dom_distiller/core/distiller_url_fetcher.h"
|
||||
#include "net/http/http_status_code.h"
|
||||
#include "net/url_request/test_url_fetcher_factory.h"
|
||||
@ -50,7 +51,7 @@ class DistillerURLFetcherTest : public testing::Test {
|
||||
url,
|
||||
base::Bind(&DistillerURLFetcherTest::FetcherCallback,
|
||||
base::Unretained(this)));
|
||||
loop.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
CHECK_EQ(expected_response, response_);
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "base/base_switches.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/process/launch.h"
|
||||
#include "base/process/process.h"
|
||||
@ -51,7 +50,7 @@ void NaClBrokerListener::Listen() {
|
||||
if (broker && !broker->IsPrivilegedBroker())
|
||||
broker->RegisterBrokerCommunicationChannel(channel_.get());
|
||||
CHECK(channel_->Connect());
|
||||
base::MessageLoop::current()->Run();
|
||||
run_loop_.Run();
|
||||
}
|
||||
|
||||
// NOTE: changes to this method need to be reviewed by the security team.
|
||||
@ -88,7 +87,7 @@ bool NaClBrokerListener::OnMessageReceived(const IPC::Message& msg) {
|
||||
|
||||
void NaClBrokerListener::OnChannelError() {
|
||||
// The browser died unexpectedly, quit to avoid a zombie process.
|
||||
base::MessageLoop::current()->QuitWhenIdle();
|
||||
run_loop_.QuitWhenIdle();
|
||||
}
|
||||
|
||||
void NaClBrokerListener::OnLaunchLoaderThroughBroker(
|
||||
@ -144,5 +143,5 @@ void NaClBrokerListener::OnLaunchDebugExceptionHandler(
|
||||
}
|
||||
|
||||
void NaClBrokerListener::OnStopBroker() {
|
||||
base::MessageLoop::current()->QuitWhenIdle();
|
||||
run_loop_.QuitWhenIdle();
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/process/process.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "components/nacl/common/nacl_types.h"
|
||||
#include "content/public/common/sandboxed_process_launcher_delegate.h"
|
||||
#include "ipc/ipc_listener.h"
|
||||
@ -44,6 +45,7 @@ class NaClBrokerListener : public content::SandboxedProcessLauncherDelegate,
|
||||
const std::string& startup_info);
|
||||
void OnStopBroker();
|
||||
|
||||
base::RunLoop run_loop_;
|
||||
base::Process browser_process_;
|
||||
std::unique_ptr<IPC::Channel> channel_;
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "base/file_descriptor_posix.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/rand_util.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "build/build_config.h"
|
||||
#include "components/nacl/common/nacl_messages.h"
|
||||
#include "components/nacl/common/nacl_types.h"
|
||||
@ -49,7 +50,7 @@ void NonSfiListener::Listen() {
|
||||
io_thread_.task_runner().get(),
|
||||
true, // Create pipe now.
|
||||
&shutdown_event_);
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
|
||||
bool NonSfiListener::OnMessageReceived(const IPC::Message& msg) {
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "base/callback.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "base/values.h"
|
||||
#include "components/policy/core/common/policy_pref_names.h"
|
||||
@ -91,13 +92,13 @@ class URLBlacklistManagerTest : public testing::Test {
|
||||
pref_service_.registry()->RegisterListPref(policy_prefs::kUrlBlacklist);
|
||||
pref_service_.registry()->RegisterListPref(policy_prefs::kUrlWhitelist);
|
||||
blacklist_manager_.reset(new TestingURLBlacklistManager(&pref_service_));
|
||||
loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (blacklist_manager_.get())
|
||||
blacklist_manager_->ShutdownOnUIThread();
|
||||
loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
// Delete |blacklist_manager_| while |io_thread_| is mapping IO to
|
||||
// |loop_|.
|
||||
blacklist_manager_.reset();
|
||||
@ -235,7 +236,7 @@ TEST_F(URLBlacklistManagerTest, SingleUpdateForTwoPrefChanges) {
|
||||
whitelist->AppendString("mail.google.com");
|
||||
pref_service_.SetManagedPref(policy_prefs::kUrlBlacklist, blacklist);
|
||||
pref_service_.SetManagedPref(policy_prefs::kUrlBlacklist, whitelist);
|
||||
loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_EQ(1, blacklist_manager_->update_called());
|
||||
}
|
||||
@ -247,7 +248,7 @@ TEST_F(URLBlacklistManagerTest, ShutdownWithPendingTask0) {
|
||||
blacklist_manager_->ShutdownOnUIThread();
|
||||
blacklist_manager_.reset();
|
||||
// Run the task after shutdown and deletion.
|
||||
loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
TEST_F(URLBlacklistManagerTest, ShutdownWithPendingTask1) {
|
||||
@ -256,11 +257,11 @@ TEST_F(URLBlacklistManagerTest, ShutdownWithPendingTask1) {
|
||||
// Shutdown comes before the task is executed.
|
||||
blacklist_manager_->ShutdownOnUIThread();
|
||||
// Run the task after shutdown, but before deletion.
|
||||
loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_EQ(0, blacklist_manager_->update_called());
|
||||
blacklist_manager_.reset();
|
||||
loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
TEST_F(URLBlacklistManagerTest, ShutdownWithPendingTask2) {
|
||||
@ -271,7 +272,7 @@ TEST_F(URLBlacklistManagerTest, ShutdownWithPendingTask2) {
|
||||
|
||||
EXPECT_FALSE(blacklist_manager_->set_blacklist_called());
|
||||
blacklist_manager_.reset();
|
||||
loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
@ -72,7 +73,7 @@ class CloudPolicyValidatorTest : public testing::Test {
|
||||
validator.release()->StartValidation(
|
||||
base::Bind(&CloudPolicyValidatorTest::ValidationCompletion,
|
||||
base::Unretained(this)));
|
||||
loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
Mock::VerifyAndClearExpectations(this);
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/callback.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/values.h"
|
||||
#include "components/policy/core/common/configuration_policy_provider.h"
|
||||
#include "components/policy/core/common/external_data_fetcher.h"
|
||||
@ -143,7 +144,7 @@ void PolicyTestBase::SetUp() {
|
||||
}
|
||||
|
||||
void PolicyTestBase::TearDown() {
|
||||
loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
bool PolicyTestBase::RegisterSchema(const PolicyNamespace& ns,
|
||||
@ -212,7 +213,7 @@ void ConfigurationPolicyProviderTest::SetUp() {
|
||||
provider_->Init(&schema_registry_);
|
||||
// Some providers do a reload on init. Make sure any notifications generated
|
||||
// are fired now.
|
||||
loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
const PolicyBundle kEmptyBundle;
|
||||
EXPECT_TRUE(provider_->policies().Equals(kEmptyBundle));
|
||||
@ -235,7 +236,7 @@ void ConfigurationPolicyProviderTest::CheckValue(
|
||||
// Install the value, reload policy and check the provider for the value.
|
||||
install_value.Run();
|
||||
provider_->RefreshPolicies();
|
||||
loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
PolicyBundle expected_bundle;
|
||||
expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))
|
||||
.Set(policy_name, harness_->policy_level(), harness_->policy_scope(),
|
||||
@ -252,7 +253,7 @@ void ConfigurationPolicyProviderTest::CheckValue(
|
||||
|
||||
TEST_P(ConfigurationPolicyProviderTest, Empty) {
|
||||
provider_->RefreshPolicies();
|
||||
loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
const PolicyBundle kEmptyBundle;
|
||||
EXPECT_TRUE(provider_->policies().Equals(kEmptyBundle));
|
||||
}
|
||||
@ -343,7 +344,7 @@ TEST_P(ConfigurationPolicyProviderTest, RefreshPolicies) {
|
||||
provider_->AddObserver(&observer);
|
||||
EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(1);
|
||||
provider_->RefreshPolicies();
|
||||
loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
Mock::VerifyAndClearExpectations(&observer);
|
||||
|
||||
EXPECT_TRUE(provider_->policies().Equals(bundle));
|
||||
@ -352,7 +353,7 @@ TEST_P(ConfigurationPolicyProviderTest, RefreshPolicies) {
|
||||
harness_->InstallStringPolicy(harness_->key_string(), "value");
|
||||
EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(1);
|
||||
provider_->RefreshPolicies();
|
||||
loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
Mock::VerifyAndClearExpectations(&observer);
|
||||
|
||||
bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))
|
||||
@ -402,7 +403,7 @@ TEST_P(Configuration3rdPartyPolicyProviderTest, Load3rdParty) {
|
||||
harness_->Install3rdPartyPolicy(&policy_3rdparty);
|
||||
|
||||
provider_->RefreshPolicies();
|
||||
loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
PolicyMap expected_policy;
|
||||
expected_policy.Set(harness_->key_dictionary(), harness_->policy_level(),
|
||||
|
@ -280,7 +280,7 @@ class NonUIModelTypeControllerTest : public testing::Test,
|
||||
}
|
||||
|
||||
// Runs any tasks posted on UI thread.
|
||||
void RunQueuedUIThreadTasks() { ui_loop_.RunUntilIdle(); }
|
||||
void RunQueuedUIThreadTasks() { base::RunLoop().RunUntilIdle(); }
|
||||
|
||||
// Runs any tasks posted on model thread.
|
||||
void RunQueuedModelThreadTasks() {
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/location.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "base/tracked_objects.h"
|
||||
@ -75,7 +76,7 @@ class SyncUIDataTypeControllerTest : public testing::Test,
|
||||
PumpLoop();
|
||||
}
|
||||
|
||||
void PumpLoop() { message_loop_.RunUntilIdle(); }
|
||||
void PumpLoop() { base::RunLoop().RunUntilIdle(); }
|
||||
|
||||
base::MessageLoopForUI message_loop_;
|
||||
const syncer::ModelType type_;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/process/launch.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/test/test_timeouts.h"
|
||||
#include "components/sync/test/local_sync_test_server.h"
|
||||
@ -116,6 +117,6 @@ int main(int argc, const char* argv[]) {
|
||||
printf("Python sync test server running at %s (type ctrl+c to exit)\n",
|
||||
test_server->host_port_pair().ToString().c_str());
|
||||
|
||||
message_loop.Run();
|
||||
base::RunLoop().Run();
|
||||
return 0;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
@ -456,7 +457,7 @@ void SyncFaviconCacheTest::TriggerSyncFaviconReceived(
|
||||
icon_url,
|
||||
icon_bytes,
|
||||
last_visit_time_ms);
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
// A freshly constructed cache should be empty.
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "base/files/scoped_temp_dir.h"
|
||||
#include "base/location.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "content/browser/appcache/appcache_database.h"
|
||||
#include "content/browser/appcache/appcache_storage_impl.h"
|
||||
@ -108,14 +109,14 @@ ChromeAppCacheServiceTest::CreateAppCacheServiceImpl(
|
||||
browser_context_.GetResourceContext(),
|
||||
base::RetainedRef(mock_request_context_getter), mock_policy));
|
||||
// Steps needed to initialize the storage of AppCache data.
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
if (init_storage) {
|
||||
AppCacheStorageImpl* storage =
|
||||
static_cast<AppCacheStorageImpl*>(
|
||||
appcache_service->storage());
|
||||
storage->database_->db_connection();
|
||||
storage->disk_cache();
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
return appcache_service;
|
||||
}
|
||||
@ -151,7 +152,7 @@ TEST_F(ChromeAppCacheServiceTest, KeepOnDestruction) {
|
||||
|
||||
// Test: delete the ChromeAppCacheService
|
||||
appcache_service = NULL;
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// Recreate the appcache (for reading the data back)
|
||||
appcache_service = CreateAppCacheServiceImpl(appcache_path, false);
|
||||
@ -171,7 +172,7 @@ TEST_F(ChromeAppCacheServiceTest, KeepOnDestruction) {
|
||||
|
||||
// Delete and let cleanup tasks run prior to returning.
|
||||
appcache_service = NULL;
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
TEST_F(ChromeAppCacheServiceTest, SaveSessionState) {
|
||||
@ -191,7 +192,7 @@ TEST_F(ChromeAppCacheServiceTest, SaveSessionState) {
|
||||
|
||||
// Test: delete the ChromeAppCacheService
|
||||
appcache_service = NULL;
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// Recreate the appcache (for reading the data back)
|
||||
appcache_service = CreateAppCacheServiceImpl(appcache_path, false);
|
||||
@ -211,7 +212,7 @@ TEST_F(ChromeAppCacheServiceTest, SaveSessionState) {
|
||||
|
||||
// Delete and let cleanup tasks run prior to returning.
|
||||
appcache_service = NULL;
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
} // namespace content
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/string16.h"
|
||||
#include "base/strings/string_util.h"
|
||||
@ -541,10 +542,8 @@ class DownloadManagerTest : public testing::Test {
|
||||
|
||||
download_manager_->Shutdown();
|
||||
download_manager_.reset();
|
||||
message_loop_.RunUntilIdle();
|
||||
ASSERT_EQ(NULL, mock_download_item_factory_.get());
|
||||
ASSERT_EQ(NULL, mock_download_file_factory_.get());
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
ASSERT_FALSE(mock_download_item_factory_);
|
||||
mock_download_manager_delegate_.reset();
|
||||
mock_browser_context_.reset();
|
||||
download_urls_.clear();
|
||||
|
@ -82,7 +82,7 @@ class RenderWidgetHostViewGuestTest : public testing::Test {
|
||||
|
||||
message_loop_.task_runner()->DeleteSoon(FROM_HERE,
|
||||
browser_context_.release());
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
#if !defined(OS_ANDROID)
|
||||
ImageTransportFactory::Terminate();
|
||||
#else
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/files/scoped_temp_dir.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/test/test_simple_task_runner.h"
|
||||
#include "base/threading/thread.h"
|
||||
#include "content/browser/browser_thread_impl.h"
|
||||
@ -86,12 +87,12 @@ TEST_F(IndexedDBTest, ClearSessionOnlyDatabases) {
|
||||
ASSERT_TRUE(base::CreateDirectory(normal_path));
|
||||
ASSERT_TRUE(base::CreateDirectory(session_only_path));
|
||||
FlushIndexedDBTaskRunner();
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
quota_manager_proxy_->SimulateQuotaManagerDestroyed();
|
||||
}
|
||||
|
||||
FlushIndexedDBTaskRunner();
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_TRUE(base::DirectoryExists(normal_path));
|
||||
EXPECT_FALSE(base::DirectoryExists(session_only_path));
|
||||
@ -121,11 +122,11 @@ TEST_F(IndexedDBTest, SetForceKeepSessionState) {
|
||||
session_only_path = idb_context->GetFilePathForTesting(kSessionOnlyOrigin);
|
||||
ASSERT_TRUE(base::CreateDirectory(normal_path));
|
||||
ASSERT_TRUE(base::CreateDirectory(session_only_path));
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
// Make sure we wait until the destructor has run.
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// No data was cleared because of SetForceKeepSessionState.
|
||||
EXPECT_TRUE(base::DirectoryExists(normal_path));
|
||||
@ -217,11 +218,11 @@ TEST_F(IndexedDBTest, ForceCloseOpenDatabasesOnDelete) {
|
||||
&IndexedDBContextImpl::DeleteForOrigin),
|
||||
idb_context, kTestOrigin));
|
||||
FlushIndexedDBTaskRunner();
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
// Make sure we wait until the destructor has run.
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_TRUE(open_db_callbacks->forced_close_called());
|
||||
EXPECT_FALSE(closed_db_callbacks->forced_close_called());
|
||||
|
@ -512,8 +512,9 @@ class RenderWidgetHostViewAuraTest : public testing::Test {
|
||||
browser_context_.reset();
|
||||
aura_test_helper_->TearDown();
|
||||
|
||||
message_loop_.DeleteSoon(FROM_HERE, browser_context_.release());
|
||||
message_loop_.RunUntilIdle();
|
||||
message_loop_.task_runner()->DeleteSoon(FROM_HERE,
|
||||
browser_context_.release());
|
||||
base::RunLoop().RunUntilIdle();
|
||||
ImageTransportFactory::Terminate();
|
||||
}
|
||||
|
||||
@ -2459,21 +2460,21 @@ TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFramesWithMemoryPressure) {
|
||||
|
||||
// If we hide one, it should not get evicted.
|
||||
views[0]->Hide();
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_TRUE(views[0]->HasFrameData());
|
||||
// Using a lesser memory pressure event however, should evict.
|
||||
SimulateMemoryPressure(
|
||||
base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE);
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_FALSE(views[0]->HasFrameData());
|
||||
|
||||
// Check the same for a higher pressure event.
|
||||
views[1]->Hide();
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_TRUE(views[1]->HasFrameData());
|
||||
SimulateMemoryPressure(
|
||||
base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL);
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_FALSE(views[1]->HasFrameData());
|
||||
|
||||
for (size_t i = 0; i < renderer_count; ++i) {
|
||||
@ -3320,7 +3321,7 @@ TEST_F(RenderWidgetHostViewAuraOverscrollTest,
|
||||
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
||||
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
|
||||
base::TimeDelta::FromMilliseconds(15));
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
|
||||
EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
|
||||
@ -3427,7 +3428,7 @@ TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollWithTouchEvents) {
|
||||
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
||||
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
|
||||
base::TimeDelta::FromMilliseconds(10));
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(1U, sink_->message_count());
|
||||
EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
|
||||
EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
|
||||
@ -3473,7 +3474,7 @@ TEST_F(RenderWidgetHostViewAuraOverscrollTest,
|
||||
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
||||
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
|
||||
base::TimeDelta::FromMilliseconds(10));
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
|
||||
EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
|
||||
EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode());
|
||||
@ -3508,7 +3509,7 @@ TEST_F(RenderWidgetHostViewAuraOverscrollTest,
|
||||
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
||||
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
|
||||
base::TimeDelta::FromMilliseconds(10));
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
|
||||
EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
|
||||
EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode());
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "base/json/json_string_value_serializer.h"
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/memory/singleton.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "base/time/time.h"
|
||||
@ -63,10 +64,9 @@ void EtwTracingAgent::StartAgentTracing(
|
||||
|
||||
// Start the consumer thread and start consuming events.
|
||||
thread_.Start();
|
||||
thread_.message_loop()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&EtwTracingAgent::TraceAndConsumeOnThread,
|
||||
base::Unretained(this)));
|
||||
thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&EtwTracingAgent::TraceAndConsumeOnThread,
|
||||
base::Unretained(this)));
|
||||
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE,
|
||||
@ -81,10 +81,9 @@ void EtwTracingAgent::StopAgentTracing(
|
||||
}
|
||||
|
||||
// Stop consuming and flush events.
|
||||
thread_.message_loop()->PostTask(FROM_HERE,
|
||||
base::Bind(&EtwTracingAgent::FlushOnThread,
|
||||
base::Unretained(this),
|
||||
callback));
|
||||
thread_.task_runner()->PostTask(FROM_HERE,
|
||||
base::Bind(&EtwTracingAgent::FlushOnThread,
|
||||
base::Unretained(this), callback));
|
||||
}
|
||||
|
||||
void EtwTracingAgent::OnStopSystemTracingDone(
|
||||
|
@ -173,7 +173,7 @@ class NavigationWatcher : public WebContentsObserver {
|
||||
if (navigated_)
|
||||
return;
|
||||
should_quit_loop_ = true;
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -241,11 +241,10 @@ void GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang() {
|
||||
base::ThreadTicks current_cpu_time = GetWatchedThreadTime();
|
||||
base::TimeDelta time_since_arm = current_cpu_time - arm_cpu_time_;
|
||||
if (use_thread_cpu_time_ && (time_since_arm < timeout_)) {
|
||||
message_loop()->PostDelayedTask(
|
||||
task_runner()->PostDelayedTask(
|
||||
FROM_HERE,
|
||||
base::Bind(
|
||||
&GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang,
|
||||
weak_factory_.GetWeakPtr()),
|
||||
base::Bind(&GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang,
|
||||
weak_factory_.GetWeakPtr()),
|
||||
timeout_ - time_since_arm);
|
||||
return;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "build/build_config.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
@ -124,7 +125,8 @@ void ContentBrowserTest::RunTestOnMainThreadLoop() {
|
||||
#endif
|
||||
|
||||
// Pump startup related events.
|
||||
base::MessageLoopForUI::current()->RunUntilIdle();
|
||||
DCHECK(base::MessageLoopForUI::IsCurrent());
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
pool.Recycle();
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "content/common/media/audio_messages.h"
|
||||
#include "content/renderer/media/audio_message_filter.h"
|
||||
#include "media/audio/audio_output_ipc.h"
|
||||
@ -193,7 +194,7 @@ TEST(AudioMessageFilterTest, Delegates) {
|
||||
EXPECT_TRUE(delegate2.state_changed_received());
|
||||
delegate2.Reset();
|
||||
|
||||
message_loop.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
ipc1->CloseStream();
|
||||
ipc2->CloseStream();
|
||||
|
@ -309,10 +309,10 @@ TEST_F(MediaStreamVideoCapturerSourceTest, Ended) {
|
||||
EXPECT_CALL(mock_delegate(), GetCurrentSupportedFormats(_, _, _, _));
|
||||
EXPECT_CALL(mock_delegate(), StartCapture(_, _, _));
|
||||
blink::WebMediaStreamTrack track = StartSource();
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
OnStarted(true);
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_EQ(blink::WebMediaStreamSource::ReadyStateLive,
|
||||
webkit_source_.getReadyState());
|
||||
|
||||
@ -320,7 +320,7 @@ TEST_F(MediaStreamVideoCapturerSourceTest, Ended) {
|
||||
|
||||
EXPECT_CALL(mock_delegate(), StopCapture());
|
||||
OnStarted(false);
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_EQ(blink::WebMediaStreamSource::ReadyStateEnded,
|
||||
webkit_source_.getReadyState());
|
||||
// Verify that MediaStreamSource::SourceStoppedCallback has been triggered.
|
||||
|
@ -149,12 +149,12 @@ TEST_F(MediaStreamVideoRendererSinkAsyncAddFrameReadyTest,
|
||||
const scoped_refptr<media::VideoFrame> video_frame =
|
||||
media::VideoFrame::CreateBlackFrame(gfx::Size(160, 80));
|
||||
OnVideoFrame(video_frame);
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
ASSERT_EQ(1u, frame_ready_cbs_.size());
|
||||
|
||||
EXPECT_CALL(*this, RepaintCallback(video_frame)).Times(1);
|
||||
frame_ready_cbs_[0].Run();
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
media_stream_video_renderer_sink_->Stop();
|
||||
}
|
||||
@ -190,7 +190,7 @@ TEST_F(MediaStreamVideoRendererSinkTransparencyTest,
|
||||
media::VideoFrame::CreateFrame(media::PIXEL_FORMAT_YV12A, kSize,
|
||||
gfx::Rect(kSize), kSize, kTimestamp);
|
||||
OnVideoFrame(video_frame);
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
media_stream_video_renderer_sink_->Stop();
|
||||
}
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "base/command_line.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/threading/thread.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "build/build_config.h"
|
||||
@ -37,6 +36,7 @@
|
||||
#include "url/gurl.h"
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "components/crash/content/browser/crash_dump_manager_android.h"
|
||||
#include "components/crash/content/browser/crash_dump_observer_android.h"
|
||||
#include "net/android/network_change_notifier_factory_android.h"
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "base/macros.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "base/test/test_timeouts.h"
|
||||
#include "base/threading/thread.h"
|
||||
@ -441,9 +442,8 @@ TEST_F(EndToEndAsyncTest, CancelPendingCalls) {
|
||||
|
||||
// We shouldn't receive any responses. Wait for a while just to make sure.
|
||||
run_loop_.reset(new base::RunLoop);
|
||||
message_loop_.PostDelayedTask(FROM_HERE,
|
||||
run_loop_->QuitClosure(),
|
||||
TestTimeouts::tiny_timeout());
|
||||
message_loop_.task_runner()->PostDelayedTask(
|
||||
FROM_HERE, run_loop_->QuitClosure(), TestTimeouts::tiny_timeout());
|
||||
run_loop_->Run();
|
||||
EXPECT_TRUE(response_strings_.empty());
|
||||
}
|
||||
@ -565,9 +565,8 @@ TEST_F(EndToEndAsyncTest, EmptyResponseCallback) {
|
||||
ObjectProxy::EmptyResponseCallback());
|
||||
// Post a delayed task to quit the message loop.
|
||||
run_loop_.reset(new base::RunLoop);
|
||||
message_loop_.PostDelayedTask(FROM_HERE,
|
||||
run_loop_->QuitClosure(),
|
||||
TestTimeouts::tiny_timeout());
|
||||
message_loop_.task_runner()->PostDelayedTask(
|
||||
FROM_HERE, run_loop_->QuitClosure(), TestTimeouts::tiny_timeout());
|
||||
run_loop_->Run();
|
||||
// We cannot tell if the empty callback is called, but at least we can
|
||||
// check if the test does not crash.
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "dbus/message.h"
|
||||
#include "dbus/mock_bus.h"
|
||||
#include "dbus/mock_exported_object.h"
|
||||
@ -121,11 +122,10 @@ class MockTest : public testing::Test {
|
||||
int timeout_ms,
|
||||
ObjectProxy::ResponseCallback response_callback) {
|
||||
Response* response = CreateMockProxyResponse(method_call, timeout_ms);
|
||||
message_loop_.PostTask(FROM_HERE,
|
||||
base::Bind(&MockTest::RunResponseCallback,
|
||||
base::Unretained(this),
|
||||
response_callback,
|
||||
response));
|
||||
message_loop_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&MockTest::RunResponseCallback, base::Unretained(this),
|
||||
response_callback, response));
|
||||
}
|
||||
|
||||
// Runs the given response callback with the given response.
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/threading/thread.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "dbus/bus.h"
|
||||
@ -404,10 +405,9 @@ TEST_F(ObjectManagerTest, PropertiesChangedAsObjectsReceived) {
|
||||
// after setting up the match rule for PropertiesChanged. We should process
|
||||
// the PropertiesChanged event right after that. If we don't receive it within
|
||||
// 2 seconds, then fail the test.
|
||||
message_loop_.PostDelayedTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&ObjectManagerTest::PropertiesChangedTestTimeout,
|
||||
base::Unretained(this)),
|
||||
message_loop_.task_runner()->PostDelayedTask(
|
||||
FROM_HERE, base::Bind(&ObjectManagerTest::PropertiesChangedTestTimeout,
|
||||
base::Unretained(this)),
|
||||
base::TimeDelta::FromSeconds(2));
|
||||
|
||||
while (last_name_value_ != "ChangedTestServiceName" && !timeout_expired_) {
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "base/metrics/histogram_samples.h"
|
||||
#include "base/metrics/statistics_recorder.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/test/test_timeouts.h"
|
||||
#include "base/threading/platform_thread.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
@ -117,7 +118,7 @@ class SignalSenderVerificationTest : public testing::Test {
|
||||
void OnOwnership(bool expected, bool success) {
|
||||
ASSERT_EQ(expected, success);
|
||||
// PostTask to quit the MessageLoop as this is called from D-Bus thread.
|
||||
message_loop_.PostTask(
|
||||
message_loop_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&SignalSenderVerificationTest::OnOwnershipInternal,
|
||||
base::Unretained(this)));
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/guid.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/test/test_timeouts.h"
|
||||
#include "base/threading/platform_thread.h"
|
||||
#include "dbus/bus.h"
|
||||
@ -75,10 +76,9 @@ bool TestService::WaitUntilServiceIsStarted() {
|
||||
}
|
||||
|
||||
void TestService::ShutdownAndBlock() {
|
||||
message_loop()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&TestService::ShutdownAndBlockInternal,
|
||||
base::Unretained(this)));
|
||||
message_loop()->task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&TestService::ShutdownAndBlockInternal,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
|
||||
bool TestService::HasDBusThread() {
|
||||
@ -93,19 +93,15 @@ void TestService::ShutdownAndBlockInternal() {
|
||||
}
|
||||
|
||||
void TestService::SendTestSignal(const std::string& message) {
|
||||
message_loop()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&TestService::SendTestSignalInternal,
|
||||
base::Unretained(this),
|
||||
message));
|
||||
message_loop()->task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&TestService::SendTestSignalInternal,
|
||||
base::Unretained(this), message));
|
||||
}
|
||||
|
||||
void TestService::SendTestSignalFromRoot(const std::string& message) {
|
||||
message_loop()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&TestService::SendTestSignalFromRootInternal,
|
||||
base::Unretained(this),
|
||||
message));
|
||||
message_loop()->task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&TestService::SendTestSignalFromRootInternal,
|
||||
base::Unretained(this), message));
|
||||
}
|
||||
|
||||
void TestService::SendTestSignalInternal(const std::string& message) {
|
||||
@ -132,11 +128,9 @@ void TestService::SendTestSignalFromRootInternal(const std::string& message) {
|
||||
}
|
||||
|
||||
void TestService::RequestOwnership(base::Callback<void(bool)> callback) {
|
||||
message_loop()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&TestService::RequestOwnershipInternal,
|
||||
base::Unretained(this),
|
||||
callback));
|
||||
message_loop()->task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&TestService::RequestOwnershipInternal,
|
||||
base::Unretained(this), callback));
|
||||
}
|
||||
|
||||
void TestService::RequestOwnershipInternal(
|
||||
@ -330,12 +324,10 @@ void TestService::SlowEcho(MethodCall* method_call,
|
||||
void TestService::AsyncEcho(MethodCall* method_call,
|
||||
ExportedObject::ResponseSender response_sender) {
|
||||
// Schedule a call to Echo() to send an asynchronous response after we return.
|
||||
message_loop()->PostDelayedTask(FROM_HERE,
|
||||
base::Bind(&TestService::Echo,
|
||||
base::Unretained(this),
|
||||
method_call,
|
||||
response_sender),
|
||||
TestTimeouts::tiny_timeout());
|
||||
message_loop()->task_runner()->PostDelayedTask(
|
||||
FROM_HERE, base::Bind(&TestService::Echo, base::Unretained(this),
|
||||
method_call, response_sender),
|
||||
TestTimeouts::tiny_timeout());
|
||||
}
|
||||
|
||||
void TestService::BrokenMethod(MethodCall* method_call,
|
||||
@ -648,11 +640,9 @@ void TestService::AddPropertiesToWriter(MessageWriter* writer) {
|
||||
}
|
||||
|
||||
void TestService::AddObject(const ObjectPath& object_path) {
|
||||
message_loop()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&TestService::AddObjectInternal,
|
||||
base::Unretained(this),
|
||||
object_path));
|
||||
message_loop()->task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&TestService::AddObjectInternal,
|
||||
base::Unretained(this), object_path));
|
||||
}
|
||||
|
||||
void TestService::AddObjectInternal(const ObjectPath& object_path) {
|
||||
@ -674,10 +664,9 @@ void TestService::AddObjectInternal(const ObjectPath& object_path) {
|
||||
}
|
||||
|
||||
void TestService::RemoveObject(const ObjectPath& object_path) {
|
||||
message_loop()->PostTask(FROM_HERE,
|
||||
base::Bind(&TestService::RemoveObjectInternal,
|
||||
base::Unretained(this),
|
||||
object_path));
|
||||
message_loop()->task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&TestService::RemoveObjectInternal,
|
||||
base::Unretained(this), object_path));
|
||||
}
|
||||
|
||||
void TestService::RemoveObjectInternal(const ObjectPath& object_path) {
|
||||
@ -694,11 +683,9 @@ void TestService::RemoveObjectInternal(const ObjectPath& object_path) {
|
||||
}
|
||||
|
||||
void TestService::SendPropertyChangedSignal(const std::string& name) {
|
||||
message_loop()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&TestService::SendPropertyChangedSignalInternal,
|
||||
base::Unretained(this),
|
||||
name));
|
||||
message_loop()->task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&TestService::SendPropertyChangedSignalInternal,
|
||||
base::Unretained(this), name));
|
||||
}
|
||||
|
||||
void TestService::SendPropertyChangedSignalInternal(const std::string& name) {
|
||||
@ -725,7 +712,7 @@ void TestService::SendPropertyChangedSignalInternal(const std::string& name) {
|
||||
}
|
||||
|
||||
void TestService::SendPropertyInvalidatedSignal() {
|
||||
message_loop()->PostTask(
|
||||
message_loop()->task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&TestService::SendPropertyInvalidatedSignalInternal,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/metrics/histogram.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/threading/thread.h"
|
||||
#include "base/values.h"
|
||||
#include "base/version.h"
|
||||
@ -315,7 +316,7 @@ class BatteryStatusManagerLinux::BatteryStatusNotificationThread
|
||||
~BatteryStatusNotificationThread() override {
|
||||
// Make sure to shutdown the dbus connection if it is still open in the very
|
||||
// end. It needs to happen on the BatteryStatusNotificationThread.
|
||||
message_loop()->PostTask(
|
||||
message_loop()->task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&BatteryStatusNotificationThread::ShutdownDBusConnection,
|
||||
base::Unretained(this)));
|
||||
@ -464,9 +465,8 @@ class BatteryStatusManagerLinux::BatteryStatusNotificationThread
|
||||
|
||||
// Shutdown DBus connection later because there may be pending tasks on
|
||||
// this thread.
|
||||
message_loop()->PostTask(FROM_HERE,
|
||||
base::Bind(&dbus::Bus::ShutdownAndBlock,
|
||||
system_bus_));
|
||||
message_loop()->task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&dbus::Bus::ShutdownAndBlock, system_bus_));
|
||||
system_bus_ = NULL;
|
||||
}
|
||||
|
||||
@ -569,7 +569,7 @@ bool BatteryStatusManagerLinux::StartListeningBatteryChange() {
|
||||
if (!StartNotifierThreadIfNecessary())
|
||||
return false;
|
||||
|
||||
notifier_thread_->message_loop()->PostTask(
|
||||
notifier_thread_->task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&BatteryStatusNotificationThread::StartListening,
|
||||
base::Unretained(notifier_thread_.get())));
|
||||
return true;
|
||||
@ -579,7 +579,7 @@ void BatteryStatusManagerLinux::StopListeningBatteryChange() {
|
||||
if (!notifier_thread_)
|
||||
return;
|
||||
|
||||
notifier_thread_->message_loop()->PostTask(
|
||||
notifier_thread_->task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&BatteryStatusNotificationThread::StopListening,
|
||||
base::Unretained(notifier_thread_.get())));
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "device/bluetooth/bluetooth_adapter.h"
|
||||
#include "device/bluetooth/bluetooth_adapter_factory.h"
|
||||
#include "device/bluetooth/bluetooth_uuid.h"
|
||||
@ -58,7 +59,7 @@ class BluetoothAdapterProfileBlueZTest : public testing::Test {
|
||||
device::BluetoothAdapterFactory::GetAdapter(
|
||||
base::Bind(&BluetoothAdapterProfileBlueZTest::AdapterCallback,
|
||||
base::Unretained(this)));
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
ASSERT_TRUE(adapter_.get() != nullptr);
|
||||
ASSERT_TRUE(adapter_->IsInitialized());
|
||||
ASSERT_TRUE(adapter_->IsPresent());
|
||||
@ -181,7 +182,7 @@ TEST_F(BluetoothAdapterProfileBlueZTest, DelegateCount) {
|
||||
base::Bind(&BluetoothAdapterProfileBlueZTest::DBusErrorCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_TRUE(profile_);
|
||||
EXPECT_EQ(1U, success_callback_count_);
|
||||
@ -218,7 +219,7 @@ TEST_F(BluetoothAdapterProfileBlueZTest, BlackHole) {
|
||||
base::Bind(&BluetoothAdapterProfileBlueZTest::DBusErrorCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_TRUE(profile_);
|
||||
EXPECT_EQ(1U, success_callback_count_);
|
||||
@ -232,7 +233,7 @@ TEST_F(BluetoothAdapterProfileBlueZTest, BlackHole) {
|
||||
base::Bind(&BluetoothAdapterProfileBlueZTest::DBusErrorCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_EQ(1U, success_callback_count_);
|
||||
EXPECT_EQ(1U, error_callback_count_);
|
||||
@ -253,7 +254,7 @@ TEST_F(BluetoothAdapterProfileBlueZTest, Routing) {
|
||||
base::Bind(&BluetoothAdapterProfileBlueZTest::DBusErrorCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
ASSERT_TRUE(profile_);
|
||||
ASSERT_EQ(1U, success_callback_count_);
|
||||
@ -274,7 +275,7 @@ TEST_F(BluetoothAdapterProfileBlueZTest, Routing) {
|
||||
base::Bind(&BluetoothAdapterProfileBlueZTest::DBusErrorCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_EQ(2U, success_callback_count_);
|
||||
EXPECT_EQ(0U, error_callback_count_);
|
||||
@ -289,7 +290,7 @@ TEST_F(BluetoothAdapterProfileBlueZTest, Routing) {
|
||||
base::Bind(&BluetoothAdapterProfileBlueZTest::DBusErrorCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_EQ(3U, success_callback_count_);
|
||||
EXPECT_EQ(0U, error_callback_count_);
|
||||
@ -305,7 +306,7 @@ TEST_F(BluetoothAdapterProfileBlueZTest, Routing) {
|
||||
base::Bind(&BluetoothAdapterProfileBlueZTest::DBusErrorCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_EQ(4U, success_callback_count_);
|
||||
EXPECT_EQ(0U, error_callback_count_);
|
||||
@ -339,7 +340,7 @@ TEST_F(BluetoothAdapterProfileBlueZTest, SimultaneousRegister) {
|
||||
base::Bind(&BluetoothAdapterProfileBlueZTest::BasicErrorCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_TRUE(profile_user_ptr_);
|
||||
EXPECT_EQ(2U, success_callback_count_);
|
||||
@ -350,7 +351,7 @@ TEST_F(BluetoothAdapterProfileBlueZTest, SimultaneousRegister) {
|
||||
adapter->ReleaseProfile(fake_delegate_autopair_.device_path_,
|
||||
profile_user_ptr_);
|
||||
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
TEST_F(BluetoothAdapterProfileBlueZTest, SimultaneousRegisterFail) {
|
||||
@ -380,7 +381,7 @@ TEST_F(BluetoothAdapterProfileBlueZTest, SimultaneousRegisterFail) {
|
||||
base::Bind(&BluetoothAdapterProfileBlueZTest::BasicErrorCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_FALSE(profile_user_ptr_);
|
||||
EXPECT_EQ(0U, success_callback_count_);
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "device/bluetooth/bluetooth_adapter.h"
|
||||
#include "device/bluetooth/bluetooth_adapter_factory.h"
|
||||
#include "device/bluetooth/bluetooth_advertisement.h"
|
||||
@ -82,7 +83,7 @@ class BluetoothAdvertisementBlueZTest : public testing::Test {
|
||||
BluetoothAdapterFactory::GetAdapter(
|
||||
base::Bind(&BluetoothAdvertisementBlueZTest::GetAdapterCallback,
|
||||
base::Unretained(this)));
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
|
||||
// Called whenever BluetoothAdapter is retrieved successfully.
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "dbus/object_path.h"
|
||||
#include "device/bluetooth/bluetooth_adapter.h"
|
||||
#include "device/bluetooth/bluetooth_adapter_factory.h"
|
||||
@ -134,7 +135,7 @@ class BluetoothAudioSinkBlueZTest : public testing::Test {
|
||||
BluetoothAdapterFactory::GetAdapter(
|
||||
base::Bind(&BluetoothAudioSinkBlueZTest::GetAdapterCallback,
|
||||
base::Unretained(this)));
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
|
||||
// Called whenever BluetoothAdapter is retrieved successfully.
|
||||
|
@ -222,7 +222,7 @@ class BluetoothBlueZTest : public testing::Test {
|
||||
continue;
|
||||
callback_count_ = 0;
|
||||
session->Stop(GetCallback(), GetErrorCallback());
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
ASSERT_EQ(1, callback_count_);
|
||||
}
|
||||
discovery_sessions_.clear();
|
||||
@ -306,7 +306,7 @@ class BluetoothBlueZTest : public testing::Test {
|
||||
void GetAdapter() {
|
||||
adapter_ = new BluetoothAdapterBlueZ(base::Bind(
|
||||
&BluetoothBlueZTest::AdapterCallback, base::Unretained(this)));
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
ASSERT_TRUE(adapter_.get() != nullptr);
|
||||
ASSERT_TRUE(adapter_->IsInitialized());
|
||||
}
|
||||
@ -328,7 +328,7 @@ class BluetoothBlueZTest : public testing::Test {
|
||||
base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback,
|
||||
base::Unretained(this)),
|
||||
GetErrorCallback());
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
ASSERT_EQ(2, callback_count_);
|
||||
ASSERT_EQ(0, error_callback_count_);
|
||||
ASSERT_EQ((size_t)1, discovery_sessions_.size());
|
||||
@ -340,10 +340,10 @@ class BluetoothBlueZTest : public testing::Test {
|
||||
|
||||
while (!observer.device_removed_count() &&
|
||||
observer.last_device_address() != address)
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
discovery_sessions_[0]->Stop(GetCallback(), GetErrorCallback());
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
ASSERT_EQ(1, callback_count_);
|
||||
ASSERT_EQ(0, error_callback_count_);
|
||||
callback_count_ = 0;
|
||||
@ -723,7 +723,7 @@ TEST_F(BluetoothBlueZTest, StopDiscovery) {
|
||||
base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback,
|
||||
base::Unretained(this)),
|
||||
GetErrorCallback());
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(2, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
callback_count_ = 0;
|
||||
@ -739,7 +739,7 @@ TEST_F(BluetoothBlueZTest, StopDiscovery) {
|
||||
TestBluetoothAdapterObserver observer(adapter_);
|
||||
|
||||
discovery_sessions_[0]->Stop(GetCallback(), GetErrorCallback());
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(1, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
|
||||
@ -757,7 +757,7 @@ TEST_F(BluetoothBlueZTest, StopDiscovery) {
|
||||
base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback,
|
||||
base::Unretained(this)),
|
||||
GetErrorCallback());
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(2, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
callback_count_ = 0;
|
||||
@ -769,7 +769,7 @@ TEST_F(BluetoothBlueZTest, StopDiscovery) {
|
||||
discovery_sessions_[0]->Stop(GetCallback(), GetErrorCallback());
|
||||
discovery_sessions_.clear();
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(1, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
}
|
||||
@ -786,7 +786,7 @@ TEST_F(BluetoothBlueZTest, Discovery) {
|
||||
base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback,
|
||||
base::Unretained(this)),
|
||||
GetErrorCallback());
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(2, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
callback_count_ = 0;
|
||||
@ -797,19 +797,19 @@ TEST_F(BluetoothBlueZTest, Discovery) {
|
||||
ASSERT_TRUE(discovery_sessions_[0]->IsActive());
|
||||
|
||||
// First two devices to appear.
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(2, observer.device_added_count());
|
||||
EXPECT_EQ(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress,
|
||||
observer.last_device_address());
|
||||
|
||||
// Next we should get another two devices...
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(4, observer.device_added_count());
|
||||
|
||||
// Okay, let's run forward until a device is actually removed...
|
||||
while (!observer.device_removed_count())
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1, observer.device_removed_count());
|
||||
EXPECT_EQ(bluez::FakeBluetoothDeviceClient::kVanishingDeviceAddress,
|
||||
@ -823,7 +823,7 @@ TEST_F(BluetoothBlueZTest, PoweredAndDiscovering) {
|
||||
base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback,
|
||||
base::Unretained(this)),
|
||||
GetErrorCallback());
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(2, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
callback_count_ = 0;
|
||||
@ -904,7 +904,7 @@ TEST_F(BluetoothBlueZTest, MultipleDiscoverySessions) {
|
||||
GetErrorCallback());
|
||||
}
|
||||
// Run only once, as there should have been one D-Bus call.
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
// The observer should have received the discovering changed event exactly
|
||||
// once, the success callback should have been called 3 times and the adapter
|
||||
@ -957,7 +957,7 @@ TEST_F(BluetoothBlueZTest, MultipleDiscoverySessions) {
|
||||
discovery_sessions_[i]->Stop(GetCallback(), GetErrorCallback());
|
||||
}
|
||||
// Run only once, as there should have been one D-Bus call.
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
// The observer should have received the discovering changed event exactly
|
||||
// once, the success callback should have been called 4 times and the adapter
|
||||
@ -1008,7 +1008,7 @@ TEST_F(BluetoothBlueZTest, UnexpectedChangesDuringMultipleDiscoverySessions) {
|
||||
GetErrorCallback());
|
||||
}
|
||||
// Run only once, as there should have been one D-Bus call.
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
// The observer should have received the discovering changed event exactly
|
||||
// once, the success callback should have been called 3 times and the adapter
|
||||
@ -1042,7 +1042,7 @@ TEST_F(BluetoothBlueZTest, UnexpectedChangesDuringMultipleDiscoverySessions) {
|
||||
dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath),
|
||||
GetCallback(), base::Bind(&BluetoothBlueZTest::DBusErrorCallback,
|
||||
base::Unretained(this)));
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(2, observer.discovering_changed_count());
|
||||
EXPECT_EQ(4, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -1062,7 +1062,7 @@ TEST_F(BluetoothBlueZTest, UnexpectedChangesDuringMultipleDiscoverySessions) {
|
||||
GetErrorCallback());
|
||||
}
|
||||
// Run only once, as there should have been one D-Bus call.
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(3, observer.discovering_changed_count());
|
||||
EXPECT_EQ(6, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -1108,7 +1108,8 @@ TEST_F(BluetoothBlueZTest, UnexpectedChangesDuringMultipleDiscoverySessions) {
|
||||
base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback,
|
||||
base::Unretained(this)),
|
||||
GetErrorCallback());
|
||||
message_loop_.Run(); // Run the loop, as there should have been a D-Bus call.
|
||||
// Run the loop, as there should have been a D-Bus call.
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(5, observer.discovering_changed_count());
|
||||
EXPECT_EQ(7, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -1118,7 +1119,8 @@ TEST_F(BluetoothBlueZTest, UnexpectedChangesDuringMultipleDiscoverySessions) {
|
||||
EXPECT_TRUE(discovery_sessions_[0]->IsActive());
|
||||
|
||||
discovery_sessions_[0]->Stop(GetCallback(), GetErrorCallback());
|
||||
message_loop_.Run(); // Run the loop, as there should have been a D-Bus call.
|
||||
// Run the loop, as there should have been a D-Bus call.
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(5, observer.discovering_changed_count());
|
||||
EXPECT_EQ(8, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -1132,7 +1134,8 @@ TEST_F(BluetoothBlueZTest, UnexpectedChangesDuringMultipleDiscoverySessions) {
|
||||
base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback,
|
||||
base::Unretained(this)),
|
||||
GetErrorCallback());
|
||||
message_loop_.Run(); // Run the loop, as there should have been a D-Bus call.
|
||||
// Run the loop, as there should have been a D-Bus call.
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(5, observer.discovering_changed_count());
|
||||
EXPECT_EQ(9, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -1148,7 +1151,7 @@ TEST_F(BluetoothBlueZTest, UnexpectedChangesDuringMultipleDiscoverySessions) {
|
||||
dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath),
|
||||
GetCallback(), base::Bind(&BluetoothBlueZTest::DBusErrorCallback,
|
||||
base::Unretained(this)));
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(5, observer.discovering_changed_count());
|
||||
EXPECT_EQ(10, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -1158,7 +1161,7 @@ TEST_F(BluetoothBlueZTest, UnexpectedChangesDuringMultipleDiscoverySessions) {
|
||||
// Now end the discovery session. This should change the adapter's discovery
|
||||
// state.
|
||||
discovery_sessions_[0]->Stop(GetCallback(), GetErrorCallback());
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(6, observer.discovering_changed_count());
|
||||
EXPECT_EQ(11, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -1189,7 +1192,7 @@ TEST_F(BluetoothBlueZTest, InvalidatedDiscoverySessions) {
|
||||
GetErrorCallback());
|
||||
}
|
||||
// Run only once, as there should have been one D-Bus call.
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
// The observer should have received the discovering changed event exactly
|
||||
// once, the success callback should have been called 3 times and the adapter
|
||||
@ -1226,7 +1229,7 @@ TEST_F(BluetoothBlueZTest, InvalidatedDiscoverySessions) {
|
||||
dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath),
|
||||
GetCallback(), base::Bind(&BluetoothBlueZTest::DBusErrorCallback,
|
||||
base::Unretained(this)));
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(2, observer.discovering_changed_count());
|
||||
EXPECT_EQ(4, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -1284,7 +1287,7 @@ TEST_F(BluetoothBlueZTest, QueuedDiscoveryRequests) {
|
||||
|
||||
// Process the pending call. The queued calls should execute and the discovery
|
||||
// session reference count should increase.
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(3, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
EXPECT_EQ(1, observer.discovering_changed_count());
|
||||
@ -1328,7 +1331,7 @@ TEST_F(BluetoothBlueZTest, QueuedDiscoveryRequests) {
|
||||
ASSERT_EQ((size_t)3, discovery_sessions_.size());
|
||||
|
||||
// Run the pending request.
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(6, callback_count_);
|
||||
EXPECT_EQ(1, error_callback_count_);
|
||||
EXPECT_EQ(3, observer.discovering_changed_count());
|
||||
@ -1339,7 +1342,7 @@ TEST_F(BluetoothBlueZTest, QueuedDiscoveryRequests) {
|
||||
|
||||
// The queued request to start discovery should have been issued but is still
|
||||
// pending. Run the loop and verify.
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(7, callback_count_);
|
||||
EXPECT_EQ(1, error_callback_count_);
|
||||
EXPECT_EQ(3, observer.discovering_changed_count());
|
||||
@ -1370,7 +1373,7 @@ TEST_F(BluetoothBlueZTest, StartDiscoverySession) {
|
||||
base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback,
|
||||
base::Unretained(this)),
|
||||
GetErrorCallback());
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(1, observer.discovering_changed_count());
|
||||
EXPECT_EQ(1, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -1386,7 +1389,7 @@ TEST_F(BluetoothBlueZTest, StartDiscoverySession) {
|
||||
base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback,
|
||||
base::Unretained(this)),
|
||||
GetErrorCallback());
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(1, observer.discovering_changed_count());
|
||||
EXPECT_EQ(2, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -1400,7 +1403,7 @@ TEST_F(BluetoothBlueZTest, StartDiscoverySession) {
|
||||
base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback,
|
||||
base::Unretained(this)),
|
||||
GetErrorCallback());
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(1, observer.discovering_changed_count());
|
||||
EXPECT_EQ(3, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -1413,7 +1416,7 @@ TEST_F(BluetoothBlueZTest, StartDiscoverySession) {
|
||||
// Stop the previous discovery session. The session should end but discovery
|
||||
// should continue.
|
||||
discovery_sessions_[0]->Stop(GetCallback(), GetErrorCallback());
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(1, observer.discovering_changed_count());
|
||||
EXPECT_EQ(4, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -1426,7 +1429,7 @@ TEST_F(BluetoothBlueZTest, StartDiscoverySession) {
|
||||
// Delete the current active session. Discovery should eventually stop.
|
||||
discovery_sessions_.clear();
|
||||
while (observer.last_discovering())
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_EQ(2, observer.discovering_changed_count());
|
||||
EXPECT_EQ(4, callback_count_);
|
||||
@ -1456,7 +1459,7 @@ TEST_F(BluetoothBlueZTest, SetDiscoveryFilterBeforeStartDiscovery) {
|
||||
base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback,
|
||||
base::Unretained(this)),
|
||||
base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this)));
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(2, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
callback_count_ = 0;
|
||||
@ -1479,7 +1482,7 @@ TEST_F(BluetoothBlueZTest, SetDiscoveryFilterBeforeStartDiscovery) {
|
||||
base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)),
|
||||
base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -1522,7 +1525,7 @@ TEST_F(BluetoothBlueZTest, SetDiscoveryFilterBeforeStartDiscoveryFail) {
|
||||
base::Unretained(this)),
|
||||
base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1, error_callback_count_);
|
||||
error_callback_count_ = 0;
|
||||
@ -1580,8 +1583,8 @@ TEST_F(BluetoothBlueZTest, QueuedSetDiscoveryFilterBeforeStartDiscovery) {
|
||||
|
||||
// Run requests, on DBus level there should be call SetDiscoveryFilter, then
|
||||
// StartDiscovery, then SetDiscoveryFilter again.
|
||||
message_loop_.Run();
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(2, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -1612,7 +1615,7 @@ TEST_F(BluetoothBlueZTest, QueuedSetDiscoveryFilterBeforeStartDiscovery) {
|
||||
base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)),
|
||||
base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(2, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -1675,7 +1678,7 @@ TEST_F(BluetoothBlueZTest, QueuedSetDiscoveryFilterBeforeStartDiscoveryFail) {
|
||||
base::Unretained(this)),
|
||||
base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
// First request to SetDiscoveryFilter should fail, resulting in no session
|
||||
// being created.
|
||||
@ -1687,7 +1690,7 @@ TEST_F(BluetoothBlueZTest, QueuedSetDiscoveryFilterBeforeStartDiscoveryFail) {
|
||||
ASSERT_FALSE(adapter_->IsDiscovering());
|
||||
ASSERT_EQ((size_t)0, discovery_sessions_.size());
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
// Second request should succeed
|
||||
EXPECT_EQ(1, callback_count_);
|
||||
@ -1711,7 +1714,7 @@ TEST_F(BluetoothBlueZTest, QueuedSetDiscoveryFilterBeforeStartDiscoveryFail) {
|
||||
base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)),
|
||||
base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -1740,7 +1743,7 @@ TEST_F(BluetoothBlueZTest, SetDiscoveryFilterAfterStartDiscovery) {
|
||||
base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback,
|
||||
base::Unretained(this)),
|
||||
base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this)));
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(2, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
callback_count_ = 0;
|
||||
@ -1770,7 +1773,7 @@ TEST_F(BluetoothBlueZTest, SetDiscoveryFilterAfterStartDiscovery) {
|
||||
base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)),
|
||||
base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(1, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
callback_count_ = 0;
|
||||
@ -1789,7 +1792,7 @@ TEST_F(BluetoothBlueZTest, SetDiscoveryFilterAfterStartDiscovery) {
|
||||
base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)),
|
||||
base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -1850,7 +1853,7 @@ TEST_F(BluetoothBlueZTest, SetDiscoveryFilterBeforeStartDiscoveryMultiple) {
|
||||
base::Unretained(this)),
|
||||
base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
if (i == 0) {
|
||||
EXPECT_EQ(1, observer.discovering_changed_count());
|
||||
@ -1897,7 +1900,7 @@ TEST_F(BluetoothBlueZTest, SetDiscoveryFilterBeforeStartDiscoveryMultiple) {
|
||||
discovery_sessions_[i]->Stop(
|
||||
base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)),
|
||||
base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this)));
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
if (i == 0) {
|
||||
auto* filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter();
|
||||
@ -1975,7 +1978,7 @@ TEST_F(BluetoothBlueZTest, SetDiscoveryFilterBeforeStartDiscoveryMultiple) {
|
||||
base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this)));
|
||||
|
||||
// each result in 1 requests.
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
if (i == 0) {
|
||||
auto* filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter();
|
||||
@ -2016,10 +2019,10 @@ TEST_F(BluetoothBlueZTest, SetDiscoveryFilterBeforeStartDiscoveryMultiple) {
|
||||
// filter no 2 is same as filter no 5, so removing it shouldn't cause any
|
||||
// filter update
|
||||
if (i != 2 && i != 5)
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
// Run only once, as there should have been one D-Bus call.
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
// The success callback should have been called 4 times and the adapter should
|
||||
// no longer be discovering.
|
||||
@ -2056,7 +2059,7 @@ TEST_F(BluetoothBlueZTest, SetDiscoveryFilterMergingTest) {
|
||||
base::Unretained(this)),
|
||||
base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
auto* filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter();
|
||||
EXPECT_EQ("le", *filter->transport);
|
||||
@ -2077,7 +2080,7 @@ TEST_F(BluetoothBlueZTest, SetDiscoveryFilterMergingTest) {
|
||||
base::Unretained(this)),
|
||||
base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter();
|
||||
EXPECT_EQ("le", *filter->transport);
|
||||
@ -2101,7 +2104,7 @@ TEST_F(BluetoothBlueZTest, SetDiscoveryFilterMergingTest) {
|
||||
base::Unretained(this)),
|
||||
base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter();
|
||||
EXPECT_EQ("auto", *filter->transport);
|
||||
@ -2119,7 +2122,7 @@ TEST_F(BluetoothBlueZTest, SetDiscoveryFilterMergingTest) {
|
||||
base::Unretained(this)),
|
||||
base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
filter = fake_bluetooth_adapter_client_->GetDiscoveryFilter();
|
||||
EXPECT_EQ("auto", *filter->transport);
|
||||
@ -2134,7 +2137,7 @@ TEST_F(BluetoothBlueZTest, SetDiscoveryFilterMergingTest) {
|
||||
base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this)));
|
||||
|
||||
// Every session stopping would trigger filter update
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2855,7 +2858,7 @@ TEST_F(BluetoothBlueZTest, PairTrustedDevice) {
|
||||
|
||||
// Confirm the passkey.
|
||||
device->ConfirmPairing();
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(1, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
|
||||
@ -2921,7 +2924,7 @@ TEST_F(BluetoothBlueZTest, PairLegacyAutopair) {
|
||||
EXPECT_EQ(0, pairing_delegate.call_count_);
|
||||
EXPECT_TRUE(device->IsConnecting());
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -2974,7 +2977,7 @@ TEST_F(BluetoothBlueZTest, PairDisplayPinCode) {
|
||||
EXPECT_EQ("123456", pairing_delegate.last_pincode_);
|
||||
EXPECT_TRUE(device->IsConnecting());
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -3034,14 +3037,14 @@ TEST_F(BluetoothBlueZTest, PairDisplayPasskey) {
|
||||
|
||||
// One call to KeysEntered() for each key, including [enter].
|
||||
for (int i = 1; i <= 7; ++i) {
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(2 + i, pairing_delegate.call_count_);
|
||||
EXPECT_EQ(1 + i, pairing_delegate.keys_entered_count_);
|
||||
EXPECT_EQ(static_cast<uint32_t>(i), pairing_delegate.last_entered_);
|
||||
}
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
// 8 KeysEntered notifications (0 to 7, inclusive) and one aditional call for
|
||||
// DisplayPasskey().
|
||||
@ -3103,7 +3106,7 @@ TEST_F(BluetoothBlueZTest, PairRequestPinCode) {
|
||||
|
||||
// Set the PIN.
|
||||
device->SetPinCode("1234");
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -3158,7 +3161,7 @@ TEST_F(BluetoothBlueZTest, PairConfirmPasskey) {
|
||||
|
||||
// Confirm the passkey.
|
||||
device->ConfirmPairing();
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -3209,7 +3212,7 @@ TEST_F(BluetoothBlueZTest, PairRequestPasskey) {
|
||||
|
||||
// Set the Passkey.
|
||||
device->SetPasskey(1234);
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -3256,7 +3259,7 @@ TEST_F(BluetoothBlueZTest, PairJustWorks) {
|
||||
|
||||
EXPECT_EQ(0, pairing_delegate.call_count_);
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -3303,7 +3306,7 @@ TEST_F(BluetoothBlueZTest, PairUnpairableDeviceFails) {
|
||||
EXPECT_TRUE(device->IsConnecting());
|
||||
|
||||
// Run the loop to get the error..
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(0, callback_count_);
|
||||
EXPECT_EQ(1, error_callback_count_);
|
||||
@ -3338,7 +3341,7 @@ TEST_F(BluetoothBlueZTest, PairingFails) {
|
||||
EXPECT_TRUE(device->IsConnecting());
|
||||
|
||||
// Run the loop to get the error..
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(0, callback_count_);
|
||||
EXPECT_EQ(1, error_callback_count_);
|
||||
@ -3373,7 +3376,7 @@ TEST_F(BluetoothBlueZTest, PairingFailsAtConnection) {
|
||||
EXPECT_EQ(0, pairing_delegate.call_count_);
|
||||
EXPECT_TRUE(device->IsConnecting());
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(0, callback_count_);
|
||||
EXPECT_EQ(1, error_callback_count_);
|
||||
@ -3422,7 +3425,7 @@ TEST_F(BluetoothBlueZTest, PairingRejectedAtPinCode) {
|
||||
|
||||
// Reject the pairing.
|
||||
device->RejectPairing();
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(0, callback_count_);
|
||||
EXPECT_EQ(1, error_callback_count_);
|
||||
@ -3460,7 +3463,7 @@ TEST_F(BluetoothBlueZTest, PairingCancelledAtPinCode) {
|
||||
|
||||
// Cancel the pairing.
|
||||
device->CancelPairing();
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(0, callback_count_);
|
||||
EXPECT_EQ(1, error_callback_count_);
|
||||
@ -3498,7 +3501,7 @@ TEST_F(BluetoothBlueZTest, PairingRejectedAtPasskey) {
|
||||
|
||||
// Reject the pairing.
|
||||
device->RejectPairing();
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(0, callback_count_);
|
||||
EXPECT_EQ(1, error_callback_count_);
|
||||
@ -3536,7 +3539,7 @@ TEST_F(BluetoothBlueZTest, PairingCancelledAtPasskey) {
|
||||
|
||||
// Cancel the pairing.
|
||||
device->CancelPairing();
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(0, callback_count_);
|
||||
EXPECT_EQ(1, error_callback_count_);
|
||||
@ -3574,7 +3577,7 @@ TEST_F(BluetoothBlueZTest, PairingRejectedAtConfirmation) {
|
||||
|
||||
// Reject the pairing.
|
||||
device->RejectPairing();
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(0, callback_count_);
|
||||
EXPECT_EQ(1, error_callback_count_);
|
||||
@ -3612,7 +3615,7 @@ TEST_F(BluetoothBlueZTest, PairingCancelledAtConfirmation) {
|
||||
|
||||
// Cancel the pairing.
|
||||
device->CancelPairing();
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(0, callback_count_);
|
||||
EXPECT_EQ(1, error_callback_count_);
|
||||
@ -3649,7 +3652,7 @@ TEST_F(BluetoothBlueZTest, PairingCancelledInFlight) {
|
||||
|
||||
// Cancel the pairing.
|
||||
device->CancelPairing();
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(0, callback_count_);
|
||||
EXPECT_EQ(1, error_callback_count_);
|
||||
@ -3692,7 +3695,7 @@ TEST_F(BluetoothBlueZTest, IncomingPairRequestPinCode) {
|
||||
|
||||
// Set the PIN.
|
||||
device->SetPinCode("1234");
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -3746,7 +3749,7 @@ TEST_F(BluetoothBlueZTest, IncomingPairConfirmPasskey) {
|
||||
|
||||
// Confirm the passkey.
|
||||
device->ConfirmPairing();
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -3799,7 +3802,7 @@ TEST_F(BluetoothBlueZTest, IncomingPairRequestPasskey) {
|
||||
|
||||
// Set the Passkey.
|
||||
device->SetPasskey(1234);
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -3853,7 +3856,7 @@ TEST_F(BluetoothBlueZTest, IncomingPairJustWorks) {
|
||||
|
||||
// Confirm the pairing.
|
||||
device->ConfirmPairing();
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -3898,7 +3901,7 @@ TEST_F(BluetoothBlueZTest, IncomingPairRequestPinCodeWithoutDelegate) {
|
||||
true, GetCallback(), base::Bind(&BluetoothBlueZTest::DBusErrorCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(0, callback_count_);
|
||||
EXPECT_EQ(1, error_callback_count_);
|
||||
@ -3937,7 +3940,7 @@ TEST_F(BluetoothBlueZTest, IncomingPairConfirmPasskeyWithoutDelegate) {
|
||||
true, GetCallback(), base::Bind(&BluetoothBlueZTest::DBusErrorCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(0, callback_count_);
|
||||
EXPECT_EQ(1, error_callback_count_);
|
||||
@ -3976,7 +3979,7 @@ TEST_F(BluetoothBlueZTest, IncomingPairRequestPasskeyWithoutDelegate) {
|
||||
true, GetCallback(), base::Bind(&BluetoothBlueZTest::DBusErrorCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(0, callback_count_);
|
||||
EXPECT_EQ(1, error_callback_count_);
|
||||
@ -4015,7 +4018,7 @@ TEST_F(BluetoothBlueZTest, IncomingPairJustWorksWithoutDelegate) {
|
||||
GetCallback(), base::Bind(&BluetoothBlueZTest::DBusErrorCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(0, callback_count_);
|
||||
EXPECT_EQ(1, error_callback_count_);
|
||||
@ -4198,7 +4201,7 @@ TEST_F(BluetoothBlueZTest, Shutdown) {
|
||||
base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback,
|
||||
base::Unretained(this)),
|
||||
GetErrorCallback());
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
ASSERT_EQ(3, callback_count_);
|
||||
ASSERT_EQ(0, error_callback_count_);
|
||||
callback_count_ = 0;
|
||||
|
@ -123,7 +123,7 @@ class BluetoothGattBlueZTest : public testing::Test {
|
||||
void GetAdapter() {
|
||||
device::BluetoothAdapterFactory::GetAdapter(base::Bind(
|
||||
&BluetoothGattBlueZTest::AdapterCallback, base::Unretained(this)));
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
ASSERT_TRUE(adapter_.get() != NULL);
|
||||
ASSERT_TRUE(adapter_->IsInitialized());
|
||||
ASSERT_TRUE(adapter_->IsPresent());
|
||||
@ -487,7 +487,7 @@ TEST_F(BluetoothGattBlueZTest, ServicesDiscoveredAfterAdapterIsCreated) {
|
||||
fake_bluetooth_gatt_service_client_->ExposeHeartRateService(
|
||||
dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
|
||||
// Run the message loop so that the characteristics/descriptors appear.
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
properties->services_resolved.ReplaceValue(true);
|
||||
|
||||
EXPECT_TRUE(device->IsGattServicesDiscoveryComplete());
|
||||
@ -522,7 +522,7 @@ TEST_F(BluetoothGattBlueZTest, ServicesDiscoveredAfterAdapterIsCreated) {
|
||||
fake_bluetooth_gatt_service_client_->ExposeHeartRateService(
|
||||
dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
|
||||
// Run the message loop so that the characteristics/descriptors appear.
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
properties->services_resolved.ReplaceValue(true);
|
||||
|
||||
EXPECT_TRUE(device->IsGattServicesDiscoveryComplete());
|
||||
@ -704,7 +704,7 @@ TEST_F(BluetoothGattBlueZTest, GattCharacteristicAddedAndRemoved) {
|
||||
EXPECT_TRUE(service->GetCharacteristics().empty());
|
||||
|
||||
// Run the message loop so that the characteristics appear.
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
// 3 characteristics should appear. Only 1 of the characteristics sends
|
||||
// value changed signals. Service changed should be fired once for
|
||||
@ -770,7 +770,7 @@ TEST_F(BluetoothGattBlueZTest, GattDescriptorAddedAndRemoved) {
|
||||
EXPECT_TRUE(service->GetCharacteristics().empty());
|
||||
|
||||
// Run the message loop so that the characteristics appear.
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(0, observer.gatt_service_changed_count());
|
||||
|
||||
// Only the Heart Rate Measurement characteristic has a descriptor.
|
||||
@ -857,7 +857,7 @@ TEST_F(BluetoothGattBlueZTest, GattCharacteristicValue) {
|
||||
EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count());
|
||||
|
||||
// Run the message loop so that the characteristics appear.
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
// Issue write request to non-writable characteristics.
|
||||
observer.Reset();
|
||||
@ -1073,7 +1073,7 @@ TEST_F(BluetoothGattBlueZTest, GattCharacteristicProperties) {
|
||||
EXPECT_TRUE(service->GetCharacteristics().empty());
|
||||
|
||||
// Run the message loop so that the characteristics appear.
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
BluetoothRemoteGattCharacteristic* characteristic =
|
||||
service->GetCharacteristic(fake_bluetooth_gatt_characteristic_client_
|
||||
@ -1119,7 +1119,7 @@ TEST_F(BluetoothGattBlueZTest, GattDescriptorValue) {
|
||||
EXPECT_TRUE(service->GetCharacteristics().empty());
|
||||
|
||||
// Run the message loop so that the characteristics appear.
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(0, observer.gatt_service_changed_count());
|
||||
|
||||
// Only the Heart Rate Measurement characteristic has a descriptor.
|
||||
@ -1197,7 +1197,7 @@ TEST_F(BluetoothGattBlueZTest, GattDescriptorValue) {
|
||||
base::Unretained(this)),
|
||||
base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback,
|
||||
base::Unretained(this)));
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(3, success_callback_count_);
|
||||
EXPECT_EQ(1, error_callback_count_);
|
||||
EXPECT_EQ(1U, update_sessions_.size());
|
||||
@ -1239,7 +1239,7 @@ TEST_F(BluetoothGattBlueZTest, NotifySessions) {
|
||||
EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count());
|
||||
|
||||
// Run the message loop so that the characteristics appear.
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
BluetoothRemoteGattCharacteristic* characteristic =
|
||||
service->GetCharacteristic(fake_bluetooth_gatt_characteristic_client_
|
||||
@ -1282,7 +1282,7 @@ TEST_F(BluetoothGattBlueZTest, NotifySessions) {
|
||||
|
||||
// Run the main loop. The initial call should complete. The queued call should
|
||||
// succeed immediately.
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(3, success_callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -1290,7 +1290,7 @@ TEST_F(BluetoothGattBlueZTest, NotifySessions) {
|
||||
EXPECT_EQ(3U, update_sessions_.size());
|
||||
|
||||
// Notifications should be getting sent regularly now.
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_GT(observer.gatt_characteristic_value_changed_count(), 1);
|
||||
|
||||
// Stop one of the sessions. The session should become inactive but the
|
||||
@ -1334,7 +1334,7 @@ TEST_F(BluetoothGattBlueZTest, NotifySessions) {
|
||||
EXPECT_TRUE(characteristic->IsNotifying());
|
||||
|
||||
// Run the message loop. Notifications should begin.
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1, success_callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -1344,7 +1344,7 @@ TEST_F(BluetoothGattBlueZTest, NotifySessions) {
|
||||
EXPECT_TRUE(characteristic->IsNotifying());
|
||||
|
||||
// Check that notifications are happening.
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_GT(observer.gatt_characteristic_value_changed_count(), 1);
|
||||
|
||||
// Request another session. This should return immediately.
|
||||
@ -1389,7 +1389,7 @@ TEST_F(BluetoothGattBlueZTest, NotifySessionsMadeInactive) {
|
||||
EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count());
|
||||
|
||||
// Run the message loop so that the characteristics appear.
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
BluetoothRemoteGattCharacteristic* characteristic =
|
||||
service->GetCharacteristic(fake_bluetooth_gatt_characteristic_client_
|
||||
@ -1431,7 +1431,7 @@ TEST_F(BluetoothGattBlueZTest, NotifySessionsMadeInactive) {
|
||||
|
||||
// Run the main loop. The initial call should complete. The queued calls
|
||||
// should succeed immediately.
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(4, success_callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -1475,7 +1475,7 @@ TEST_F(BluetoothGattBlueZTest, NotifySessionsMadeInactive) {
|
||||
EXPECT_TRUE(characteristic->IsNotifying());
|
||||
EXPECT_TRUE(update_sessions_.empty());
|
||||
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1, success_callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "device/bluetooth/bluetooth_adapter.h"
|
||||
#include "device/bluetooth/bluetooth_adapter_factory.h"
|
||||
#include "device/bluetooth/bluetooth_device.h"
|
||||
@ -82,7 +83,7 @@ class BluetoothSocketBlueZTest : public testing::Test {
|
||||
device::BluetoothAdapterFactory::GetAdapter(base::Bind(
|
||||
&BluetoothSocketBlueZTest::AdapterCallback, base::Unretained(this)));
|
||||
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
ASSERT_TRUE(adapter_.get() != nullptr);
|
||||
ASSERT_TRUE(adapter_->IsInitialized());
|
||||
@ -200,7 +201,7 @@ TEST_F(BluetoothSocketBlueZTest, Connect) {
|
||||
base::Unretained(this)),
|
||||
base::Bind(&BluetoothSocketBlueZTest::ErrorCallback,
|
||||
base::Unretained(this)));
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1U, success_callback_count_);
|
||||
EXPECT_EQ(0U, error_callback_count_);
|
||||
@ -221,7 +222,7 @@ TEST_F(BluetoothSocketBlueZTest, Connect) {
|
||||
base::Unretained(this)),
|
||||
base::Bind(&BluetoothSocketBlueZTest::ErrorCallback,
|
||||
base::Unretained(this)));
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1U, success_callback_count_);
|
||||
EXPECT_EQ(0U, error_callback_count_);
|
||||
@ -237,7 +238,7 @@ TEST_F(BluetoothSocketBlueZTest, Connect) {
|
||||
base::Unretained(this)),
|
||||
base::Bind(&BluetoothSocketBlueZTest::ReceiveErrorCallback,
|
||||
base::Unretained(this)));
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1U, success_callback_count_);
|
||||
EXPECT_EQ(0U, error_callback_count_);
|
||||
@ -262,7 +263,7 @@ TEST_F(BluetoothSocketBlueZTest, Connect) {
|
||||
base::Unretained(this)),
|
||||
base::Bind(&BluetoothSocketBlueZTest::ReceiveErrorCallback,
|
||||
base::Unretained(this)));
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(0U, success_callback_count_);
|
||||
EXPECT_EQ(1U, error_callback_count_);
|
||||
@ -281,7 +282,7 @@ TEST_F(BluetoothSocketBlueZTest, Connect) {
|
||||
base::Unretained(this)),
|
||||
base::Bind(&BluetoothSocketBlueZTest::ErrorCallback,
|
||||
base::Unretained(this)));
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(0U, success_callback_count_);
|
||||
EXPECT_EQ(1U, error_callback_count_);
|
||||
@ -294,7 +295,7 @@ TEST_F(BluetoothSocketBlueZTest, Connect) {
|
||||
socket->Disconnect(base::Bind(&BluetoothSocketBlueZTest::SuccessCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
EXPECT_EQ(1U, success_callback_count_);
|
||||
}
|
||||
|
||||
@ -307,7 +308,7 @@ TEST_F(BluetoothSocketBlueZTest, Listen) {
|
||||
base::Bind(&BluetoothSocketBlueZTest::ErrorCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1U, success_callback_count_);
|
||||
EXPECT_EQ(0U, error_callback_count_);
|
||||
@ -336,7 +337,7 @@ TEST_F(BluetoothSocketBlueZTest, Listen) {
|
||||
bluez::FakeBluetoothProfileManagerClient::kRfcommUuid,
|
||||
base::Bind(&base::DoNothing), base::Bind(&DoNothingDBusErrorCallback));
|
||||
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
server_socket->Accept(
|
||||
base::Bind(&BluetoothSocketBlueZTest::AcceptSuccessCallback,
|
||||
@ -344,7 +345,7 @@ TEST_F(BluetoothSocketBlueZTest, Listen) {
|
||||
base::Bind(&BluetoothSocketBlueZTest::ErrorCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1U, success_callback_count_);
|
||||
EXPECT_EQ(0U, error_callback_count_);
|
||||
@ -360,7 +361,7 @@ TEST_F(BluetoothSocketBlueZTest, Listen) {
|
||||
client_socket->Disconnect(base::Bind(
|
||||
&BluetoothSocketBlueZTest::SuccessCallback, base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1U, success_callback_count_);
|
||||
client_socket = nullptr;
|
||||
@ -375,14 +376,14 @@ TEST_F(BluetoothSocketBlueZTest, Listen) {
|
||||
base::Bind(&BluetoothSocketBlueZTest::ErrorCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
fake_bluetooth_device_client->ConnectProfile(
|
||||
static_cast<BluetoothDeviceBlueZ*>(device)->object_path(),
|
||||
bluez::FakeBluetoothProfileManagerClient::kRfcommUuid,
|
||||
base::Bind(&base::DoNothing), base::Bind(&DoNothingDBusErrorCallback));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1U, success_callback_count_);
|
||||
EXPECT_EQ(0U, error_callback_count_);
|
||||
@ -398,7 +399,7 @@ TEST_F(BluetoothSocketBlueZTest, Listen) {
|
||||
client_socket->Disconnect(base::Bind(
|
||||
&BluetoothSocketBlueZTest::SuccessCallback, base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1U, success_callback_count_);
|
||||
client_socket = nullptr;
|
||||
@ -410,7 +411,7 @@ TEST_F(BluetoothSocketBlueZTest, Listen) {
|
||||
base::Bind(&BluetoothSocketBlueZTest::ImmediateSuccessCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_EQ(1U, success_callback_count_);
|
||||
}
|
||||
@ -430,7 +431,7 @@ TEST_F(BluetoothSocketBlueZTest, ListenBeforeAdapterStart) {
|
||||
base::Unretained(this)),
|
||||
base::Bind(&BluetoothSocketBlueZTest::ErrorCallback,
|
||||
base::Unretained(this)));
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1U, success_callback_count_);
|
||||
EXPECT_EQ(0U, error_callback_count_);
|
||||
@ -456,7 +457,7 @@ TEST_F(BluetoothSocketBlueZTest, ListenBeforeAdapterStart) {
|
||||
// Make the adapter visible. This should register a profile.
|
||||
fake_bluetooth_adapter_client->SetVisible(true);
|
||||
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
profile_service_provider =
|
||||
fake_bluetooth_profile_manager_client->GetProfileServiceProvider(
|
||||
@ -468,7 +469,7 @@ TEST_F(BluetoothSocketBlueZTest, ListenBeforeAdapterStart) {
|
||||
base::Bind(&BluetoothSocketBlueZTest::ImmediateSuccessCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_EQ(1U, success_callback_count_);
|
||||
}
|
||||
@ -486,7 +487,7 @@ TEST_F(BluetoothSocketBlueZTest, ListenAcrossAdapterRestart) {
|
||||
base::Unretained(this)),
|
||||
base::Bind(&BluetoothSocketBlueZTest::ErrorCallback,
|
||||
base::Unretained(this)));
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1U, success_callback_count_);
|
||||
EXPECT_EQ(0U, error_callback_count_);
|
||||
@ -513,12 +514,12 @@ TEST_F(BluetoothSocketBlueZTest, ListenAcrossAdapterRestart) {
|
||||
// the profile since this doesn't happen automatically.
|
||||
fake_bluetooth_adapter_client->SetVisible(false);
|
||||
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// Then make the adapter visible again. This should re-register the profile.
|
||||
fake_bluetooth_adapter_client->SetVisible(true);
|
||||
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
profile_service_provider =
|
||||
fake_bluetooth_profile_manager_client->GetProfileServiceProvider(
|
||||
@ -530,7 +531,7 @@ TEST_F(BluetoothSocketBlueZTest, ListenAcrossAdapterRestart) {
|
||||
base::Bind(&BluetoothSocketBlueZTest::ImmediateSuccessCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_EQ(1U, success_callback_count_);
|
||||
}
|
||||
@ -546,7 +547,7 @@ TEST_F(BluetoothSocketBlueZTest, PairedConnectFails) {
|
||||
base::Unretained(this)),
|
||||
base::Bind(&BluetoothSocketBlueZTest::ErrorCallback,
|
||||
base::Unretained(this)));
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(0U, success_callback_count_);
|
||||
EXPECT_EQ(1U, error_callback_count_);
|
||||
@ -558,7 +559,7 @@ TEST_F(BluetoothSocketBlueZTest, PairedConnectFails) {
|
||||
base::Unretained(this)),
|
||||
base::Bind(&BluetoothSocketBlueZTest::ErrorCallback,
|
||||
base::Unretained(this)));
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(0U, success_callback_count_);
|
||||
EXPECT_EQ(2U, error_callback_count_);
|
||||
@ -574,7 +575,7 @@ TEST_F(BluetoothSocketBlueZTest, SocketListenTwice) {
|
||||
base::Bind(&BluetoothSocketBlueZTest::ErrorCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(1U, success_callback_count_);
|
||||
EXPECT_EQ(0U, error_callback_count_);
|
||||
@ -594,7 +595,7 @@ TEST_F(BluetoothSocketBlueZTest, SocketListenTwice) {
|
||||
|
||||
server_socket = nullptr;
|
||||
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_EQ(1U, success_callback_count_);
|
||||
EXPECT_EQ(1U, error_callback_count_);
|
||||
@ -607,7 +608,7 @@ TEST_F(BluetoothSocketBlueZTest, SocketListenTwice) {
|
||||
base::Bind(&BluetoothSocketBlueZTest::ErrorCallback,
|
||||
base::Unretained(this)));
|
||||
|
||||
message_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_EQ(2U, success_callback_count_);
|
||||
EXPECT_EQ(1U, error_callback_count_);
|
||||
@ -626,7 +627,7 @@ TEST_F(BluetoothSocketBlueZTest, SocketListenTwice) {
|
||||
|
||||
server_socket = nullptr;
|
||||
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EXPECT_EQ(2U, success_callback_count_);
|
||||
EXPECT_EQ(2U, error_callback_count_);
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <utility>
|
||||
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/values.h"
|
||||
#include "content/public/test/test_browser_thread.h"
|
||||
#include "extensions/browser/api/declarative/rules_registry_service.h"
|
||||
@ -143,7 +144,7 @@ TEST(RulesRegistryTest, FillOptionalIdentifiers) {
|
||||
|
||||
// Make sure that deletion traits of registry are executed.
|
||||
registry = NULL;
|
||||
message_loop.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
TEST(RulesRegistryTest, FillOptionalPriority) {
|
||||
@ -179,7 +180,7 @@ TEST(RulesRegistryTest, FillOptionalPriority) {
|
||||
|
||||
// Make sure that deletion traits of registry are executed.
|
||||
registry = NULL;
|
||||
message_loop.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
// Test verifies 2 rules defined in the manifest appear in the registry.
|
||||
|
@ -8,7 +8,9 @@
|
||||
#include "base/command_line.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "build/build_config.h"
|
||||
#include "components/version_info/version_info.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
@ -57,7 +59,8 @@ void AppShellTest::SetUpOnMainThread() {
|
||||
}
|
||||
|
||||
void AppShellTest::RunTestOnMainThreadLoop() {
|
||||
base::MessageLoopForUI::current()->RunUntilIdle();
|
||||
DCHECK(base::MessageLoopForUI::IsCurrent());
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
SetUpOnMainThread();
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "base/files/scoped_temp_dir.h"
|
||||
#include "base/memory/shared_memory.h"
|
||||
#include "base/memory/shared_memory_handle.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/win/scoped_handle.h"
|
||||
#include "ipc/attachment_broker_privileged_win.h"
|
||||
#include "ipc/attachment_broker_unprivileged_win.h"
|
||||
@ -355,7 +356,7 @@ TEST_F(IPCAttachmentBrokerPrivilegedWinTest, SendHandle) {
|
||||
|
||||
HANDLE h = CreateTempFile();
|
||||
SendMessageWithAttachment(h);
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
// Check the result.
|
||||
ASSERT_EQ(ProxyListener::MESSAGE_RECEIVED,
|
||||
@ -383,7 +384,7 @@ TEST_F(IPCAttachmentBrokerPrivilegedWinTest,
|
||||
IPC::HandleWin handle_win(h2, IPC::HandleWin::DUPLICATE);
|
||||
IPC::Message* message = new TestHandleWinMsg(100, handle_win, 200);
|
||||
sender()->Send(message);
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
// Check the result.
|
||||
ASSERT_EQ(ProxyListener::MESSAGE_RECEIVED,
|
||||
@ -410,7 +411,7 @@ TEST_F(IPCAttachmentBrokerPrivilegedWinTest, SendHandleToSelf) {
|
||||
|
||||
HANDLE h = CreateTempFile();
|
||||
SendMessageWithAttachment(h);
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
// Get the received attachment.
|
||||
IPC::BrokerableAttachment::AttachmentId* id = get_observer()->get_id();
|
||||
@ -447,7 +448,7 @@ TEST_F(IPCAttachmentBrokerPrivilegedWinTest, SendTwoHandles) {
|
||||
IPC::HandleWin handle_win2(h2, IPC::HandleWin::FILE_READ_WRITE);
|
||||
IPC::Message* message = new TestTwoHandleWinMsg(handle_win1, handle_win2);
|
||||
sender()->Send(message);
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
// Check the result.
|
||||
ASSERT_EQ(ProxyListener::MESSAGE_RECEIVED,
|
||||
@ -472,7 +473,7 @@ TEST_F(IPCAttachmentBrokerPrivilegedWinTest, SendHandleTwice) {
|
||||
ASSERT_TRUE(result);
|
||||
SendMessageWithAttachment(h);
|
||||
SendMessageWithAttachment(h2);
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
// Check the result.
|
||||
ASSERT_EQ(ProxyListener::MESSAGE_RECEIVED,
|
||||
@ -495,7 +496,7 @@ TEST_F(IPCAttachmentBrokerPrivilegedWinTest, SendSharedMemoryHandle) {
|
||||
shared_memory->CreateAndMapAnonymous(kSharedMemorySize);
|
||||
memcpy(shared_memory->memory(), kDataBuffer, strlen(kDataBuffer));
|
||||
sender()->Send(new TestSharedMemoryHandleMsg1(shared_memory->handle()));
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
// Check the result.
|
||||
ASSERT_EQ(ProxyListener::MESSAGE_RECEIVED,
|
||||
@ -523,7 +524,7 @@ int CommonPrivilegedProcessMain(OnMessageReceivedCallback callback,
|
||||
|
||||
while (true) {
|
||||
LOG(INFO) << "Privileged process spinning run loop.";
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
ProxyListener::Reason reason = listener.get_reason();
|
||||
if (reason == ProxyListener::CHANNEL_ERROR)
|
||||
break;
|
||||
|
@ -1300,7 +1300,7 @@ TEST_F(IPCChannelMojoTest, VerifyGlobalPid) {
|
||||
CreateChannel(&listener);
|
||||
ASSERT_TRUE(ConnectChannel());
|
||||
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
channel()->Close();
|
||||
|
||||
EXPECT_TRUE(WaitForClientShutdown());
|
||||
@ -1313,7 +1313,7 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(IPCChannelMojoTestVerifyGlobalPidClient,
|
||||
ListenerThatQuits listener;
|
||||
Connect(&listener);
|
||||
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
Close();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/run_loop.h"
|
||||
#include "build/build_config.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
@ -78,7 +79,7 @@ TEST_F(IPCChannelTest, ChannelTestExistingPipe) {
|
||||
IPC::TestChannelListener::SendOneMessage(sender(), "hello from parent");
|
||||
|
||||
// Run message loop.
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
// Close the channel so the client's OnChannelError() gets fired.
|
||||
channel()->Close();
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "base/pickle.h"
|
||||
#include "base/process/process_handle.h"
|
||||
#include "base/rand_util.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/threading/thread_checker.h"
|
||||
@ -412,13 +413,10 @@ bool ChannelWin::Connect() {
|
||||
// Complete setup asynchronously. By not setting input_state_.is_pending
|
||||
// to true, we indicate to OnIOCompleted that this is the special
|
||||
// initialization signal.
|
||||
base::MessageLoopForIO::current()->PostTask(
|
||||
base::MessageLoopForIO::current()->task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&ChannelWin::OnIOCompleted,
|
||||
weak_factory_.GetWeakPtr(),
|
||||
&input_state_.context,
|
||||
0,
|
||||
0));
|
||||
base::Bind(&ChannelWin::OnIOCompleted, weak_factory_.GetWeakPtr(),
|
||||
&input_state_.context, 0, 0));
|
||||
}
|
||||
|
||||
if (!waiting_connect_)
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "jingle/notifier/base/fake_base_task.h"
|
||||
#include "jingle/notifier/base/notifier_options.h"
|
||||
#include "jingle/notifier/listener/push_client_observer.h"
|
||||
@ -48,7 +49,7 @@ class XmppPushClientTest : public testing::Test {
|
||||
|
||||
void TearDown() override {
|
||||
// Clear out any messages posted by XmppPushClient.
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
xmpp_push_client_->RemoveObserver(&mock_observer_);
|
||||
xmpp_push_client_.reset();
|
||||
}
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/synchronization/lock.h"
|
||||
#include "base/test/test_timeouts.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
@ -429,10 +431,10 @@ TEST_F(AudioLowLatencyInputOutputTest, DISABLED_FullDuplexDelayMeasurement) {
|
||||
// Wait for approximately 10 seconds. The user shall hear his own voice
|
||||
// in loop back during this time. At the same time, delay recordings are
|
||||
// performed and stored in the output text file.
|
||||
message_loop()->PostDelayedTask(FROM_HERE,
|
||||
base::MessageLoop::QuitWhenIdleClosure(),
|
||||
TestTimeouts::action_timeout());
|
||||
message_loop()->Run();
|
||||
message_loop()->task_runner()->PostDelayedTask(
|
||||
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
|
||||
TestTimeouts::action_timeout());
|
||||
base::RunLoop().Run();
|
||||
|
||||
aos->Stop();
|
||||
ais->Stop();
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "base/memory/shared_memory.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/process/process_handle.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/sync_socket.h"
|
||||
#include "base/task_runner.h"
|
||||
@ -158,7 +159,7 @@ void AudioOutputDeviceTest::SetDevice(const std::string& device_id) {
|
||||
EXPECT_CALL(*audio_output_ipc_,
|
||||
RequestDeviceAuthorization(audio_device_.get(), 0, device_id, _));
|
||||
audio_device_->RequestDeviceAuthorization();
|
||||
io_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// Simulate response from browser
|
||||
OutputDeviceStatus device_status =
|
||||
@ -183,7 +184,7 @@ void AudioOutputDeviceTest::ReceiveAuthorization(OutputDeviceStatus status) {
|
||||
|
||||
audio_device_->OnDeviceAuthorized(device_status_, default_audio_parameters_,
|
||||
kDefaultDeviceId);
|
||||
io_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
void AudioOutputDeviceTest::StartAudioDevice() {
|
||||
@ -193,7 +194,7 @@ void AudioOutputDeviceTest::StartAudioDevice() {
|
||||
EXPECT_CALL(callback_, OnRenderError());
|
||||
|
||||
audio_device_->Start();
|
||||
io_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
void AudioOutputDeviceTest::CreateStream() {
|
||||
@ -218,7 +219,7 @@ void AudioOutputDeviceTest::CreateStream() {
|
||||
audio_device_->OnStreamCreated(
|
||||
duplicated_memory_handle,
|
||||
SyncSocket::UnwrapHandle(audio_device_socket_descriptor), kMemorySize);
|
||||
io_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
void AudioOutputDeviceTest::ExpectRenderCallback() {
|
||||
@ -249,7 +250,7 @@ void AudioOutputDeviceTest::WaitUntilRenderCallback() {
|
||||
io_loop_.task_runner()->PostDelayedTask(
|
||||
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
|
||||
TestTimeouts::action_timeout());
|
||||
io_loop_.Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
|
||||
void AudioOutputDeviceTest::StopAudioDevice() {
|
||||
@ -257,7 +258,7 @@ void AudioOutputDeviceTest::StopAudioDevice() {
|
||||
EXPECT_CALL(*audio_output_ipc_, CloseStream());
|
||||
|
||||
audio_device_->Stop();
|
||||
io_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
TEST_P(AudioOutputDeviceTest, Initialize) {
|
||||
@ -357,13 +358,13 @@ TEST_P(AudioOutputDeviceTest, AuthorizationTimedOut) {
|
||||
base::Unretained(this), OUTPUT_DEVICE_STATUS_ERROR_TIMED_OUT),
|
||||
event.GetClosure());
|
||||
|
||||
io_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// Runs the loop and waits for |thread| to call event's closure.
|
||||
event.RunAndWait();
|
||||
|
||||
audio_device_->Stop();
|
||||
io_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Render, AudioOutputDeviceTest, Values(false));
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "base/macros.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/test/test_timeouts.h"
|
||||
#include "base/win/scoped_com_initializer.h"
|
||||
#include "media/audio/audio_device_description.h"
|
||||
@ -35,10 +36,9 @@ using ::testing::NotNull;
|
||||
|
||||
namespace media {
|
||||
|
||||
ACTION_P3(CheckCountAndPostQuitTask, count, limit, loop) {
|
||||
if (++*count >= limit) {
|
||||
loop->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
|
||||
}
|
||||
ACTION_P3(CheckCountAndPostQuitTask, count, limit, run_loop) {
|
||||
if (++*count >= limit)
|
||||
run_loop->QuitWhenIdle();
|
||||
}
|
||||
|
||||
class MockAudioInputCallback : public AudioInputStream::AudioInputCallback {
|
||||
@ -260,11 +260,11 @@ class WinAudioInputTest : public ::testing::Test {
|
||||
WinAudioInputTest() {
|
||||
audio_manager_ =
|
||||
AudioManager::CreateForTesting(message_loop_.task_runner());
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
~WinAudioInputTest() override {
|
||||
audio_manager_.reset();
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -379,15 +379,18 @@ TEST_F(WinAudioInputTest, WASAPIAudioInputStreamTestPacketSizes) {
|
||||
uint32_t bytes_per_packet =
|
||||
aisw.channels() * aisw.frames_per_buffer() * (aisw.bits_per_sample() / 8);
|
||||
|
||||
// We use 10ms packets and will run the test until ten packets are received.
|
||||
// All should contain valid packets of the same size and a valid delay
|
||||
// estimate.
|
||||
EXPECT_CALL(sink, OnData(ais.get(), NotNull(), _, _))
|
||||
.Times(AtLeast(10))
|
||||
.WillRepeatedly(CheckCountAndPostQuitTask(&count, 10, &message_loop_));
|
||||
ais->Start(&sink);
|
||||
message_loop_.Run();
|
||||
ais->Stop();
|
||||
{
|
||||
// We use 10ms packets and will run the test until ten packets are received.
|
||||
// All should contain valid packets of the same size and a valid delay
|
||||
// estimate.
|
||||
base::RunLoop run_loop;
|
||||
EXPECT_CALL(sink, OnData(ais.get(), NotNull(), _, _))
|
||||
.Times(AtLeast(10))
|
||||
.WillRepeatedly(CheckCountAndPostQuitTask(&count, 10, &run_loop));
|
||||
ais->Start(&sink);
|
||||
run_loop.Run();
|
||||
ais->Stop();
|
||||
}
|
||||
|
||||
// Store current packet size (to be used in the subsequent tests).
|
||||
int frames_per_buffer_10ms = aisw.frames_per_buffer();
|
||||
@ -402,13 +405,16 @@ TEST_F(WinAudioInputTest, WASAPIAudioInputStreamTestPacketSizes) {
|
||||
bytes_per_packet = aisw.channels() * aisw.frames_per_buffer() *
|
||||
(aisw.bits_per_sample() / 8);
|
||||
|
||||
EXPECT_CALL(sink, OnData(ais.get(), NotNull(), _, _))
|
||||
.Times(AtLeast(10))
|
||||
.WillRepeatedly(CheckCountAndPostQuitTask(&count, 10, &message_loop_));
|
||||
ais->Start(&sink);
|
||||
message_loop_.Run();
|
||||
ais->Stop();
|
||||
ais.Close();
|
||||
{
|
||||
base::RunLoop run_loop;
|
||||
EXPECT_CALL(sink, OnData(ais.get(), NotNull(), _, _))
|
||||
.Times(AtLeast(10))
|
||||
.WillRepeatedly(CheckCountAndPostQuitTask(&count, 10, &run_loop));
|
||||
ais->Start(&sink);
|
||||
run_loop.Run();
|
||||
ais->Stop();
|
||||
ais.Close();
|
||||
}
|
||||
|
||||
// 5 ms packet size.
|
||||
|
||||
@ -418,13 +424,16 @@ TEST_F(WinAudioInputTest, WASAPIAudioInputStreamTestPacketSizes) {
|
||||
bytes_per_packet = aisw.channels() * aisw.frames_per_buffer() *
|
||||
(aisw.bits_per_sample() / 8);
|
||||
|
||||
EXPECT_CALL(sink, OnData(ais.get(), NotNull(), _, _))
|
||||
.Times(AtLeast(10))
|
||||
.WillRepeatedly(CheckCountAndPostQuitTask(&count, 10, &message_loop_));
|
||||
ais->Start(&sink);
|
||||
message_loop_.Run();
|
||||
ais->Stop();
|
||||
ais.Close();
|
||||
{
|
||||
base::RunLoop run_loop;
|
||||
EXPECT_CALL(sink, OnData(ais.get(), NotNull(), _, _))
|
||||
.Times(AtLeast(10))
|
||||
.WillRepeatedly(CheckCountAndPostQuitTask(&count, 10, &run_loop));
|
||||
ais->Start(&sink);
|
||||
run_loop.Run();
|
||||
ais->Stop();
|
||||
ais.Close();
|
||||
}
|
||||
}
|
||||
|
||||
// Test that we can capture a stream in loopback.
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/test/test_timeouts.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/win/scoped_com_initializer.h"
|
||||
@ -235,11 +237,11 @@ class WASAPIAudioOutputStreamTest : public ::testing::Test {
|
||||
WASAPIAudioOutputStreamTest() {
|
||||
audio_manager_ =
|
||||
AudioManager::CreateForTesting(message_loop_.task_runner());
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
~WASAPIAudioOutputStreamTest() override {
|
||||
audio_manager_.reset();
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -400,10 +402,10 @@ TEST_F(WASAPIAudioOutputStreamTest, ValidPacketSize) {
|
||||
.WillRepeatedly(Return(0));
|
||||
|
||||
aos->Start(&source);
|
||||
message_loop_.PostDelayedTask(FROM_HERE,
|
||||
base::MessageLoop::QuitWhenIdleClosure(),
|
||||
TestTimeouts::action_timeout());
|
||||
message_loop_.Run();
|
||||
message_loop_.task_runner()->PostDelayedTask(
|
||||
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
|
||||
TestTimeouts::action_timeout());
|
||||
base::RunLoop().Run();
|
||||
aos->Stop();
|
||||
aos->Close();
|
||||
}
|
||||
@ -590,10 +592,10 @@ TEST_F(WASAPIAudioOutputStreamTest,
|
||||
.WillRepeatedly(Return(aosw.samples_per_packet()));
|
||||
|
||||
aos->Start(&source);
|
||||
message_loop_.PostDelayedTask(FROM_HERE,
|
||||
base::MessageLoop::QuitWhenIdleClosure(),
|
||||
TestTimeouts::action_timeout());
|
||||
message_loop_.Run();
|
||||
message_loop_.task_runner()->PostDelayedTask(
|
||||
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
|
||||
TestTimeouts::action_timeout());
|
||||
base::RunLoop().Run();
|
||||
aos->Stop();
|
||||
aos->Close();
|
||||
}
|
||||
@ -623,10 +625,10 @@ TEST_F(WASAPIAudioOutputStreamTest,
|
||||
.WillRepeatedly(Return(aosw.samples_per_packet()));
|
||||
|
||||
aos->Start(&source);
|
||||
message_loop_.PostDelayedTask(FROM_HERE,
|
||||
base::MessageLoop::QuitWhenIdleClosure(),
|
||||
TestTimeouts::action_timeout());
|
||||
message_loop_.Run();
|
||||
message_loop_.task_runner()->PostDelayedTask(
|
||||
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
|
||||
TestTimeouts::action_timeout());
|
||||
base::RunLoop().Run();
|
||||
aos->Stop();
|
||||
aos->Close();
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "base/base_paths.h"
|
||||
#include "base/memory/aligned_memory.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/sync_socket.h"
|
||||
#include "base/win/scoped_com_initializer.h"
|
||||
#include "base/win/windows_version.h"
|
||||
@ -151,11 +152,11 @@ class WinAudioTest : public ::testing::Test {
|
||||
WinAudioTest() {
|
||||
audio_manager_ =
|
||||
AudioManager::CreateForTesting(message_loop_.task_runner());
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
~WinAudioTest() override {
|
||||
audio_manager_.reset();
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <list>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "build/build_config.h"
|
||||
#include "media/capture/video/linux/v4l2_capture_delegate.h"
|
||||
|
||||
@ -62,7 +63,7 @@ void VideoCaptureDeviceLinux::AllocateAndStart(
|
||||
client->OnError(FROM_HERE, "Failed to create VideoCaptureDelegate");
|
||||
return;
|
||||
}
|
||||
v4l2_thread_.message_loop()->PostTask(
|
||||
v4l2_thread_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&V4L2CaptureDelegate::AllocateAndStart, capture_impl_,
|
||||
params.requested_format.frame_size.width(),
|
||||
@ -73,7 +74,7 @@ void VideoCaptureDeviceLinux::AllocateAndStart(
|
||||
void VideoCaptureDeviceLinux::StopAndDeAllocate() {
|
||||
if (!v4l2_thread_.IsRunning())
|
||||
return; // Wrong state.
|
||||
v4l2_thread_.message_loop()->PostTask(
|
||||
v4l2_thread_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&V4L2CaptureDelegate::StopAndDeAllocate, capture_impl_));
|
||||
v4l2_thread_.Stop();
|
||||
@ -83,7 +84,7 @@ void VideoCaptureDeviceLinux::StopAndDeAllocate() {
|
||||
|
||||
void VideoCaptureDeviceLinux::SetRotation(int rotation) {
|
||||
if (v4l2_thread_.IsRunning()) {
|
||||
v4l2_thread_.message_loop()->PostTask(
|
||||
v4l2_thread_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&V4L2CaptureDelegate::SetRotation, capture_impl_, rotation));
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/threading/thread.h"
|
||||
@ -343,15 +344,15 @@ int main(int argc, char** argv) {
|
||||
base::Bind(&QuitLoopOnInitializationResult),
|
||||
media::cast::CreateDefaultVideoEncodeAcceleratorCallback(),
|
||||
media::cast::CreateDefaultVideoEncodeMemoryCallback()));
|
||||
io_message_loop.Run(); // Wait for video initialization.
|
||||
base::RunLoop().Run(); // Wait for video initialization.
|
||||
io_message_loop.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&media::cast::CastSender::InitializeAudio,
|
||||
base::Unretained(cast_sender.get()), audio_config,
|
||||
base::Bind(&QuitLoopOnInitializationResult)));
|
||||
io_message_loop.Run(); // Wait for audio initialization.
|
||||
base::RunLoop().Run(); // Wait for audio initialization.
|
||||
|
||||
fake_media_source->Start(cast_sender->audio_frame_input(),
|
||||
cast_sender->video_frame_input());
|
||||
io_message_loop.Run();
|
||||
base::RunLoop().Run();
|
||||
return 0;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/system_monitor/system_monitor.h"
|
||||
#include "base/test/mock_devices_changed_observer.h"
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
@ -35,12 +36,12 @@ class SystemMessageWindowWinTest : public testing::Test {
|
||||
TEST_F(SystemMessageWindowWinTest, DevicesChanged) {
|
||||
EXPECT_CALL(observer_, OnDevicesChanged(testing::_)).Times(1);
|
||||
window_.OnDeviceChange(DBT_DEVNODES_CHANGED, NULL);
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
TEST_F(SystemMessageWindowWinTest, RandomMessage) {
|
||||
window_.OnDeviceChange(DBT_DEVICEQUERYREMOVE, NULL);
|
||||
message_loop_.RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "base/macros.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/strings/stringize_macros.h"
|
||||
#include "base/synchronization/waitable_event.h"
|
||||
#include "base/time/time.h"
|
||||
@ -560,7 +561,7 @@ void RenderingHelper::CreateTexture(uint32_t texture_target,
|
||||
const gfx::Size& size,
|
||||
base::WaitableEvent* done) {
|
||||
if (base::MessageLoop::current() != message_loop_) {
|
||||
message_loop_->PostTask(
|
||||
message_loop_->task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&RenderingHelper::CreateTexture, base::Unretained(this),
|
||||
texture_target, texture_id, size, done));
|
||||
@ -635,7 +636,7 @@ void RenderingHelper::QueueVideoFrame(
|
||||
// Schedules the first RenderContent() if need.
|
||||
if (scheduled_render_time_.is_null()) {
|
||||
scheduled_render_time_ = base::TimeTicks::Now();
|
||||
message_loop_->PostTask(FROM_HERE, render_task_.callback());
|
||||
message_loop_->task_runner()->PostTask(FROM_HERE, render_task_.callback());
|
||||
}
|
||||
}
|
||||
|
||||
@ -885,7 +886,7 @@ void RenderingHelper::ScheduleNextRenderContent() {
|
||||
DropOneFrameForAllVideos();
|
||||
}
|
||||
|
||||
message_loop_->PostDelayedTask(FROM_HERE, render_task_.callback(),
|
||||
target - now);
|
||||
message_loop_->task_runner()->PostDelayedTask(
|
||||
FROM_HERE, render_task_.callback(), target - now);
|
||||
}
|
||||
} // namespace media
|
||||
|
@ -150,7 +150,7 @@ bool V4L2ImageProcessor::Initialize(VideoPixelFormat input_format,
|
||||
}
|
||||
|
||||
// StartDevicePoll will NotifyError on failure, so IgnoreResult is fine here.
|
||||
device_thread_.message_loop()->PostTask(
|
||||
device_thread_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(base::IgnoreResult(&V4L2ImageProcessor::StartDevicePoll),
|
||||
base::Unretained(this)));
|
||||
@ -228,7 +228,7 @@ void V4L2ImageProcessor::Process(const scoped_refptr<VideoFrame>& frame,
|
||||
job_record->output_buffer_index = output_buffer_index;
|
||||
job_record->ready_cb = cb;
|
||||
|
||||
device_thread_.message_loop()->PostTask(
|
||||
device_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&V4L2ImageProcessor::ProcessTask,
|
||||
base::Unretained(this), base::Passed(&job_record)));
|
||||
}
|
||||
@ -251,7 +251,7 @@ void V4L2ImageProcessor::Destroy() {
|
||||
|
||||
// If the device thread is running, destroy using posted task.
|
||||
if (device_thread_.IsRunning()) {
|
||||
device_thread_.message_loop()->PostTask(
|
||||
device_thread_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&V4L2ImageProcessor::DestroyTask, base::Unretained(this)));
|
||||
// Wait for tasks to finish/early-exit.
|
||||
@ -429,7 +429,7 @@ void V4L2ImageProcessor::DevicePollTask(bool poll_device) {
|
||||
|
||||
// All processing should happen on ServiceDeviceTask(), since we shouldn't
|
||||
// touch encoder state from this thread.
|
||||
device_thread_.message_loop()->PostTask(
|
||||
device_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&V4L2ImageProcessor::ServiceDeviceTask,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
@ -453,7 +453,7 @@ void V4L2ImageProcessor::ServiceDeviceTask() {
|
||||
bool poll_device =
|
||||
(input_buffer_queued_count_ > 0 || output_buffer_queued_count_ > 0);
|
||||
|
||||
device_poll_thread_.message_loop()->PostTask(
|
||||
device_poll_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&V4L2ImageProcessor::DevicePollTask,
|
||||
base::Unretained(this), poll_device));
|
||||
|
||||
@ -656,7 +656,7 @@ bool V4L2ImageProcessor::StartDevicePoll() {
|
||||
}
|
||||
// Enqueue a poll task with no devices to poll on - will wait only for the
|
||||
// poll interrupt
|
||||
device_poll_thread_.message_loop()->PostTask(
|
||||
device_poll_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&V4L2ImageProcessor::DevicePollTask,
|
||||
base::Unretained(this), false));
|
||||
|
||||
|
@ -863,7 +863,7 @@ void V4L2SliceVideoDecodeAccelerator::SchedulePollIfNeeded() {
|
||||
|
||||
DVLOGF(4) << "Scheduling device poll task";
|
||||
|
||||
device_poll_thread_.message_loop()->PostTask(
|
||||
device_poll_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&V4L2SliceVideoDecodeAccelerator::DevicePollTask,
|
||||
base::Unretained(this), true));
|
||||
|
||||
@ -1169,7 +1169,7 @@ bool V4L2SliceVideoDecodeAccelerator::StartDevicePoll() {
|
||||
output_streamon_ = true;
|
||||
}
|
||||
|
||||
device_poll_thread_.message_loop()->PostTask(
|
||||
device_poll_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&V4L2SliceVideoDecodeAccelerator::DevicePollTask,
|
||||
base::Unretained(this), true));
|
||||
|
||||
|
@ -290,7 +290,7 @@ bool V4L2VideoDecodeAccelerator::Initialize(const Config& config,
|
||||
decoder_state_ = kInitialized;
|
||||
|
||||
// StartDevicePoll will NOTIFY_ERROR on failure, so IgnoreResult is fine here.
|
||||
decoder_thread_.message_loop()->PostTask(
|
||||
decoder_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(base::IgnoreResult(
|
||||
&V4L2VideoDecodeAccelerator::StartDevicePoll),
|
||||
base::Unretained(this)));
|
||||
@ -313,7 +313,7 @@ void V4L2VideoDecodeAccelerator::Decode(
|
||||
}
|
||||
|
||||
// DecodeTask() will take care of running a DecodeBufferTask().
|
||||
decoder_thread_.message_loop()->PostTask(
|
||||
decoder_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&V4L2VideoDecodeAccelerator::DecodeTask,
|
||||
base::Unretained(this), bitstream_buffer));
|
||||
}
|
||||
@ -323,7 +323,7 @@ void V4L2VideoDecodeAccelerator::AssignPictureBuffers(
|
||||
DVLOGF(3) << "buffer_count=" << buffers.size();
|
||||
DCHECK(child_task_runner_->BelongsToCurrentThread());
|
||||
|
||||
decoder_thread_.message_loop()->PostTask(
|
||||
decoder_thread_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&V4L2VideoDecodeAccelerator::AssignPictureBuffersTask,
|
||||
base::Unretained(this), buffers));
|
||||
@ -442,7 +442,7 @@ void V4L2VideoDecodeAccelerator::CreateEGLImages(
|
||||
egl_images.push_back(egl_image);
|
||||
}
|
||||
|
||||
decoder_thread_.message_loop()->PostTask(
|
||||
decoder_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&V4L2VideoDecodeAccelerator::AssignEGLImages,
|
||||
base::Unretained(this), buffers, egl_images));
|
||||
}
|
||||
@ -521,7 +521,7 @@ void V4L2VideoDecodeAccelerator::ReusePictureBuffer(int32_t picture_buffer_id) {
|
||||
std::unique_ptr<EGLSyncKHRRef> egl_sync_ref(
|
||||
new EGLSyncKHRRef(egl_display_, egl_sync));
|
||||
|
||||
decoder_thread_.message_loop()->PostTask(
|
||||
decoder_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&V4L2VideoDecodeAccelerator::ReusePictureBufferTask,
|
||||
base::Unretained(this), picture_buffer_id,
|
||||
base::Passed(&egl_sync_ref)));
|
||||
@ -530,7 +530,7 @@ void V4L2VideoDecodeAccelerator::ReusePictureBuffer(int32_t picture_buffer_id) {
|
||||
void V4L2VideoDecodeAccelerator::Flush() {
|
||||
DVLOGF(3);
|
||||
DCHECK(child_task_runner_->BelongsToCurrentThread());
|
||||
decoder_thread_.message_loop()->PostTask(
|
||||
decoder_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&V4L2VideoDecodeAccelerator::FlushTask,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
@ -538,7 +538,7 @@ void V4L2VideoDecodeAccelerator::Flush() {
|
||||
void V4L2VideoDecodeAccelerator::Reset() {
|
||||
DVLOGF(3);
|
||||
DCHECK(child_task_runner_->BelongsToCurrentThread());
|
||||
decoder_thread_.message_loop()->PostTask(
|
||||
decoder_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&V4L2VideoDecodeAccelerator::ResetTask,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
@ -553,7 +553,7 @@ void V4L2VideoDecodeAccelerator::Destroy() {
|
||||
|
||||
// If the decoder thread is running, destroy using posted task.
|
||||
if (decoder_thread_.IsRunning()) {
|
||||
decoder_thread_.message_loop()->PostTask(
|
||||
decoder_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&V4L2VideoDecodeAccelerator::DestroyTask,
|
||||
base::Unretained(this)));
|
||||
// DestroyTask() will cause the decoder_thread_ to flush all tasks.
|
||||
@ -835,7 +835,7 @@ void V4L2VideoDecodeAccelerator::ScheduleDecodeBufferTaskIfNeeded() {
|
||||
buffers_to_decode++;
|
||||
if (decoder_decode_buffer_tasks_scheduled_ < buffers_to_decode) {
|
||||
decoder_decode_buffer_tasks_scheduled_++;
|
||||
decoder_thread_.message_loop()->PostTask(
|
||||
decoder_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&V4L2VideoDecodeAccelerator::DecodeBufferTask,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
@ -1049,7 +1049,7 @@ void V4L2VideoDecodeAccelerator::ServiceDeviceTask(bool event_pending) {
|
||||
// respectively, and we should have early-outed already.
|
||||
DCHECK(device_poll_thread_.message_loop());
|
||||
// Queue the DevicePollTask() now.
|
||||
device_poll_thread_.message_loop()->PostTask(
|
||||
device_poll_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&V4L2VideoDecodeAccelerator::DevicePollTask,
|
||||
base::Unretained(this), poll_device));
|
||||
|
||||
@ -1518,7 +1518,7 @@ void V4L2VideoDecodeAccelerator::FinishReset() {
|
||||
// jobs will early-out in the kResetting state.
|
||||
decoder_state_ = kResetting;
|
||||
SendPictureReady(); // Send all pending PictureReady.
|
||||
decoder_thread_.message_loop()->PostTask(
|
||||
decoder_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&V4L2VideoDecodeAccelerator::ResetDoneTask,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
@ -1590,7 +1590,7 @@ bool V4L2VideoDecodeAccelerator::StartDevicePoll() {
|
||||
NOTIFY_ERROR(PLATFORM_FAILURE);
|
||||
return false;
|
||||
}
|
||||
device_poll_thread_.message_loop()->PostTask(
|
||||
device_poll_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&V4L2VideoDecodeAccelerator::DevicePollTask,
|
||||
base::Unretained(this), 0));
|
||||
|
||||
@ -1742,7 +1742,7 @@ void V4L2VideoDecodeAccelerator::DevicePollTask(bool poll_device) {
|
||||
|
||||
// All processing should happen on ServiceDeviceTask(), since we shouldn't
|
||||
// touch decoder state from this thread.
|
||||
decoder_thread_.message_loop()->PostTask(
|
||||
decoder_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&V4L2VideoDecodeAccelerator::ServiceDeviceTask,
|
||||
base::Unretained(this), event_pending));
|
||||
}
|
||||
@ -2192,7 +2192,7 @@ void V4L2VideoDecodeAccelerator::ResolutionChangeDestroyBuffers() {
|
||||
}
|
||||
|
||||
// Finish resolution change on decoder thread.
|
||||
decoder_thread_.message_loop()->PostTask(
|
||||
decoder_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&V4L2VideoDecodeAccelerator::FinishResolutionChange,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "base/macros.h"
|
||||
#include "base/metrics/histogram.h"
|
||||
#include "base/numerics/safe_conversions.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "media/base/bind_to_current_loop.h"
|
||||
#include "media/gpu/h264_dpb.h"
|
||||
#include "media/gpu/shared_memory_region.h"
|
||||
@ -752,7 +753,7 @@ void VaapiVideoEncodeAccelerator::Destroy() {
|
||||
|
||||
// Early-exit encoder tasks if they are running and join the thread.
|
||||
if (encoder_thread_.IsRunning()) {
|
||||
encoder_thread_.message_loop()->PostTask(
|
||||
encoder_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&VaapiVideoEncodeAccelerator::DestroyTask,
|
||||
base::Unretained(this)));
|
||||
encoder_thread_.Stop();
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/posix/eintr_wrapper.h"
|
||||
#include "base/posix/safe_strerror.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/time/time.h"
|
||||
@ -286,7 +287,7 @@ void MidiManagerAlsa::StartInitialization() {
|
||||
// Start processing events. Don't do this before enumeration of both
|
||||
// ALSA and udev.
|
||||
event_thread_.Start();
|
||||
event_thread_.message_loop()->PostTask(
|
||||
event_thread_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&MidiManagerAlsa::ScheduleEventLoop, base::Unretained(this)));
|
||||
send_thread_.Start();
|
||||
@ -336,13 +337,13 @@ void MidiManagerAlsa::DispatchSendMidiData(MidiManagerClient* client,
|
||||
delay = std::max(time_to_send - base::TimeTicks::Now(), base::TimeDelta());
|
||||
}
|
||||
|
||||
send_thread_.message_loop()->PostDelayedTask(
|
||||
send_thread_.task_runner()->PostDelayedTask(
|
||||
FROM_HERE, base::Bind(&MidiManagerAlsa::SendMidiData,
|
||||
base::Unretained(this), port_index, data),
|
||||
delay);
|
||||
|
||||
// Acknowledge send.
|
||||
send_thread_.message_loop()->PostTask(
|
||||
send_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&MidiManagerAlsa::AccumulateMidiBytesSent,
|
||||
base::Unretained(this), client, data.size()));
|
||||
}
|
||||
@ -886,7 +887,7 @@ void MidiManagerAlsa::SendMidiData(uint32_t port_index,
|
||||
}
|
||||
|
||||
void MidiManagerAlsa::ScheduleEventLoop() {
|
||||
event_thread_.message_loop()->PostTask(
|
||||
event_thread_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&MidiManagerAlsa::EventLoop, base::Unretained(this)));
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "base/containers/hash_tables.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/strings/string16.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
@ -501,7 +502,7 @@ class MidiServiceWinImpl : public MidiServiceWin,
|
||||
|
||||
UpdateDeviceList();
|
||||
|
||||
task_thread_.message_loop()->PostTask(
|
||||
task_thread_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&MidiServiceWinImpl::CompleteInitializationOnTaskThread,
|
||||
base::Unretained(this), Result::OK));
|
||||
@ -529,13 +530,13 @@ class MidiServiceWinImpl : public MidiServiceWin,
|
||||
}
|
||||
const auto now = base::TimeTicks::Now();
|
||||
if (now < time) {
|
||||
sender_thread_.message_loop()->PostDelayedTask(
|
||||
sender_thread_.task_runner()->PostDelayedTask(
|
||||
FROM_HERE, base::Bind(&MidiServiceWinImpl::SendOnSenderThread,
|
||||
base::Unretained(this), port_number,
|
||||
state->port_age, data, time),
|
||||
time - now);
|
||||
} else {
|
||||
sender_thread_.message_loop()->PostTask(
|
||||
sender_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&MidiServiceWinImpl::SendOnSenderThread,
|
||||
base::Unretained(this), port_number,
|
||||
state->port_age, data, time));
|
||||
@ -585,7 +586,7 @@ class MidiServiceWinImpl : public MidiServiceWin,
|
||||
}
|
||||
|
||||
void UpdateDeviceList() {
|
||||
task_thread_.message_loop()->PostTask(
|
||||
task_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&MidiServiceWinImpl::UpdateDeviceListOnTaskThread,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
@ -665,7 +666,7 @@ class MidiServiceWinImpl : public MidiServiceWin,
|
||||
input_ports_[port_number]->port_age = input_ports_ages_[port_number];
|
||||
}
|
||||
// Several initial startup tasks cannot be done in MIM_OPEN handler.
|
||||
task_thread_.message_loop()->PostTask(
|
||||
task_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&MidiServiceWinImpl::StartInputDeviceOnTaskThread,
|
||||
base::Unretained(this), midi_in_handle));
|
||||
if (add_new_port) {
|
||||
@ -676,11 +677,11 @@ class MidiServiceWinImpl : public MidiServiceWin,
|
||||
base::WideToUTF8(state_device_info.product_name),
|
||||
MmversionToString(state_device_info.driver_version),
|
||||
MIDI_PORT_OPENED);
|
||||
task_thread_.message_loop()->PostTask(
|
||||
task_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&MidiServiceWinImpl::AddInputPortOnTaskThread,
|
||||
base::Unretained(this), port_info));
|
||||
} else {
|
||||
task_thread_.message_loop()->PostTask(
|
||||
task_thread_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&MidiServiceWinImpl::SetInputPortStateOnTaskThread,
|
||||
base::Unretained(this), port_number,
|
||||
@ -710,7 +711,7 @@ class MidiServiceWinImpl : public MidiServiceWin,
|
||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/dd757286.aspx
|
||||
const base::TimeTicks event_time =
|
||||
state->start_time + base::TimeDelta::FromMilliseconds(elapsed_ms);
|
||||
task_thread_.message_loop()->PostTask(
|
||||
task_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&MidiServiceWinImpl::ReceiveMidiDataOnTaskThread,
|
||||
base::Unretained(this), state->port_index, data,
|
||||
event_time));
|
||||
@ -747,7 +748,7 @@ class MidiServiceWinImpl : public MidiServiceWin,
|
||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/dd757286.aspx
|
||||
const base::TimeTicks event_time =
|
||||
state->start_time + base::TimeDelta::FromMilliseconds(elapsed_ms);
|
||||
task_thread_.message_loop()->PostTask(
|
||||
task_thread_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&MidiServiceWinImpl::ReceiveMidiDataOnTaskThread,
|
||||
base::Unretained(this), state->port_index, data,
|
||||
@ -772,7 +773,7 @@ class MidiServiceWinImpl : public MidiServiceWin,
|
||||
input_ports_ages_[port_number] += 1;
|
||||
unused_input_ports_[device_info].push(port_number);
|
||||
}
|
||||
task_thread_.message_loop()->PostTask(
|
||||
task_thread_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&MidiServiceWinImpl::SetInputPortStateOnTaskThread,
|
||||
base::Unretained(this), port_number,
|
||||
@ -854,11 +855,11 @@ class MidiServiceWinImpl : public MidiServiceWin,
|
||||
base::WideToUTF8(state_device_info.product_name),
|
||||
MmversionToString(state_device_info.driver_version),
|
||||
MIDI_PORT_OPENED);
|
||||
task_thread_.message_loop()->PostTask(
|
||||
task_thread_.task_runner()->PostTask(
|
||||
FROM_HERE, base::Bind(&MidiServiceWinImpl::AddOutputPortOnTaskThread,
|
||||
base::Unretained(this), port_info));
|
||||
} else {
|
||||
task_thread_.message_loop()->PostTask(
|
||||
task_thread_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&MidiServiceWinImpl::SetOutputPortStateOnTaskThread,
|
||||
base::Unretained(this), port_number, MIDI_PORT_CONNECTED));
|
||||
@ -895,7 +896,7 @@ class MidiServiceWinImpl : public MidiServiceWin,
|
||||
unused_output_ports_[device_info].push(port_number);
|
||||
state->closed = true;
|
||||
}
|
||||
task_thread_.message_loop()->PostTask(
|
||||
task_thread_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&MidiServiceWinImpl::SetOutputPortStateOnTaskThread,
|
||||
base::Unretained(this), port_number,
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "net/base/network_change_notifier.h"
|
||||
#include "net/base/network_change_notifier_factory.h"
|
||||
#include "net/base/network_change_notifier_win.h"
|
||||
@ -89,7 +90,7 @@ class NetworkChangeNotifierWinTest : public testing::Test {
|
||||
|
||||
// If a task to notify observers of the IP address change event was
|
||||
// incorrectly posted, make sure it gets run to trigger a failure.
|
||||
base::MessageLoop::current()->RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
// Calls WatchForAddressChange, and simulates a WatchForAddressChangeInternal
|
||||
@ -112,7 +113,7 @@ class NetworkChangeNotifierWinTest : public testing::Test {
|
||||
|
||||
// If a task to notify observers of the IP address change event was
|
||||
// incorrectly posted, make sure it gets run.
|
||||
base::MessageLoop::current()->RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
// Simulates a network change event, resulting in a call to OnObjectSignaled.
|
||||
@ -132,7 +133,7 @@ class NetworkChangeNotifierWinTest : public testing::Test {
|
||||
EXPECT_EQ(0, network_change_notifier_.sequential_failures());
|
||||
|
||||
// Run the task to notify observers of the IP address change event.
|
||||
base::MessageLoop::current()->RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
// Simulates a network change event, resulting in a call to OnObjectSignaled.
|
||||
@ -154,7 +155,7 @@ class NetworkChangeNotifierWinTest : public testing::Test {
|
||||
EXPECT_LT(0, network_change_notifier_.sequential_failures());
|
||||
|
||||
// Run the task to notify observers of the IP address change event.
|
||||
base::MessageLoop::current()->RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
// Runs the message loop until WatchForAddressChange is called again, as a
|
||||
@ -172,7 +173,7 @@ class NetworkChangeNotifierWinTest : public testing::Test {
|
||||
EXPECT_CALL(network_change_notifier_, WatchForAddressChangeInternal())
|
||||
.Times(1).WillOnce(Return(true));
|
||||
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_TRUE(network_change_notifier_.is_watching());
|
||||
EXPECT_EQ(0, network_change_notifier_.sequential_failures());
|
||||
@ -196,7 +197,7 @@ class NetworkChangeNotifierWinTest : public testing::Test {
|
||||
.Times(AtLeast(1))
|
||||
.WillRepeatedly(Invoke(ExitMessageLoopAndReturnFalse));
|
||||
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
EXPECT_FALSE(network_change_notifier_.is_watching());
|
||||
EXPECT_LT(initial_sequential_failures,
|
||||
@ -204,7 +205,7 @@ class NetworkChangeNotifierWinTest : public testing::Test {
|
||||
|
||||
// If a task to notify observers of the IP address change event was
|
||||
// incorrectly posted, make sure it gets run.
|
||||
base::MessageLoop::current()->RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "base/time/clock.h"
|
||||
@ -465,7 +466,7 @@ void MDnsTest::RunFor(base::TimeDelta time_period) {
|
||||
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
||||
FROM_HERE, callback.callback(), time_period);
|
||||
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
callback.Cancel();
|
||||
}
|
||||
|
||||
@ -1185,7 +1186,7 @@ TEST_F(MDnsConnectionTest, ReceiveAsynchronous) {
|
||||
|
||||
EXPECT_CALL(delegate_, HandlePacketInternal(sample_packet_));
|
||||
|
||||
base::MessageLoop::current()->RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
TEST_F(MDnsConnectionTest, Error) {
|
||||
@ -1200,7 +1201,7 @@ TEST_F(MDnsConnectionTest, Error) {
|
||||
|
||||
EXPECT_CALL(delegate_, OnConnectionError(ERR_SOCKET_NOT_CONNECTED));
|
||||
callback.Run(ERR_SOCKET_NOT_CONNECTED);
|
||||
base::MessageLoop::current()->RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
class MDnsConnectionSendTest : public MDnsConnectionTest {
|
||||
@ -1235,7 +1236,7 @@ TEST_F(MDnsConnectionSendTest, SendError) {
|
||||
|
||||
connection_.Send(sample_buffer_, sample_packet_.size());
|
||||
EXPECT_CALL(delegate_, OnConnectionError(ERR_SOCKET_NOT_CONNECTED));
|
||||
base::MessageLoop::current()->RunUntilIdle();
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
TEST_F(MDnsConnectionSendTest, SendQueued) {
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/files/scoped_temp_dir.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "net/http/transport_security_state.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
@ -28,14 +30,15 @@ class TransportSecurityPersisterTest : public testing::Test {
|
||||
}
|
||||
|
||||
~TransportSecurityPersisterTest() override {
|
||||
base::MessageLoopForIO::current()->RunUntilIdle();
|
||||
EXPECT_TRUE(base::MessageLoopForIO::IsCurrent());
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
void SetUp() override {
|
||||
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
|
||||
ASSERT_TRUE(base::MessageLoopForIO::IsCurrent());
|
||||
persister_.reset(new TransportSecurityPersister(
|
||||
&state_, temp_dir_.path(),
|
||||
base::MessageLoopForIO::current()->task_runner(), false));
|
||||
&state_, temp_dir_.path(), base::ThreadTaskRunnerHandle::Get(), false));
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/process/launch.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
@ -51,7 +52,7 @@ bool ReadData(HANDLE read_fd,
|
||||
|
||||
// Prepare a timeout in case the server fails to start.
|
||||
bool unblocked = false;
|
||||
thread.message_loop()->PostDelayedTask(
|
||||
thread.task_runner()->PostDelayedTask(
|
||||
FROM_HERE, base::Bind(UnblockPipe, write_fd, bytes_max, &unblocked),
|
||||
TestTimeouts::action_max_timeout());
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user