Commit 1afbb0e4 authored by Wez's avatar Wez Committed by Commit Bot

Migrate //content unit tests off of QuitCurrent*Deprecated().

Cq-Include-Trybots: luci.chromium.try:linux_mojo
Change-Id: If5cf7d3dcda8dc411c6c90de31885dca683354d8
Reviewed-on: https://chromium-review.googlesource.com/1130656Reviewed-by: default avatarBo <boliu@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574006}
parent d2099edb
......@@ -148,11 +148,13 @@ TEST_F(DevToolsManagerTest, NoUnresponsiveDialogInInspectedContents) {
// Start with a short timeout.
inspected_rvh->GetWidget()->StartInputEventAckTimeout(
TimeDelta::FromMilliseconds(10));
// Wait long enough for first timeout and see if it fired.
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
TimeDelta::FromMilliseconds(10));
base::RunLoop().Run();
{
base::RunLoop run_loop;
// Wait long enough for first timeout and see if it fired.
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, run_loop.QuitClosure(), TimeDelta::FromMilliseconds(10));
run_loop.Run();
}
EXPECT_FALSE(delegate.renderer_unresponsive_received());
// Now close devtools and check that the notification is delivered.
......@@ -160,11 +162,13 @@ TEST_F(DevToolsManagerTest, NoUnresponsiveDialogInInspectedContents) {
// Start with a short timeout.
inspected_rvh->GetWidget()->StartInputEventAckTimeout(
TimeDelta::FromMilliseconds(10));
// Wait long enough for first timeout and see if it fired.
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
TimeDelta::FromMilliseconds(10));
base::RunLoop().Run();
{
base::RunLoop run_loop;
// Wait long enough for first timeout and see if it fired.
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, run_loop.QuitClosure(), TimeDelta::FromMilliseconds(10));
run_loop.Run();
}
EXPECT_TRUE(delegate.renderer_unresponsive_received());
contents()->SetDelegate(nullptr);
......
......@@ -10,6 +10,7 @@
#include <vector>
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/files/file_path.h"
#include "base/logging.h"
......@@ -1479,7 +1480,7 @@ TEST_F(MojoAsyncResourceHandlerTest,
request_->Start();
ASSERT_TRUE(CallOnWillStartAndOnResponseStarted());
url_loader_client_.RunUntilComplete();
url_request_delegate_.RunUntilComplete();
net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, net::OK);
ASSERT_EQ(MockResourceLoader::Status::IDLE,
......@@ -1515,7 +1516,7 @@ TEST_F(MojoAsyncResourceHandlerTest,
net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, net::OK);
ASSERT_EQ(MockResourceLoader::Status::IDLE,
mock_loader_->OnResponseCompleted(status));
url_loader_client_.RunUntilComplete();
url_request_delegate_.RunUntilComplete();
EXPECT_TRUE(ResourceRequestInfoImpl::ForRequest(request_.get())
->blocked_response_from_reaching_renderer());
EXPECT_EQ(0, url_loader_client_.body_transfer_size());
......
......@@ -1033,10 +1033,10 @@ TEST_F(GestureEventQueueTest, DebounceDefersFollowingGestureEvents) {
EXPECT_EQ(2U, GestureEventQueueSize());
EXPECT_EQ(2U, GestureEventDebouncingQueueSize());
base::RunLoop run_loop;
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
TimeDelta::FromMilliseconds(5));
base::RunLoop().Run();
FROM_HERE, run_loop.QuitClosure(), TimeDelta::FromMilliseconds(5));
run_loop.Run();
// The deferred events are correctly queued in coalescing queue.
EXPECT_EQ(0U, GetAndResetSentGestureEventCount());
......
......@@ -458,10 +458,10 @@ class InputRouterImplTest : public testing::Test {
}
static void RunTasksAndWait(base::TimeDelta delay) {
base::RunLoop run_loop;
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
delay);
base::RunLoop().Run();
FROM_HERE, run_loop.QuitClosure(), delay);
run_loop.Run();
}
void PressAndSetTouchActionAuto() {
......
......@@ -310,10 +310,10 @@ class PassthroughTouchEventQueueTest : public testing::Test,
}
static void RunTasksAndWait(base::TimeDelta delay) {
base::RunLoop run_loop;
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
delay);
base::RunLoop().Run();
FROM_HERE, run_loop.QuitClosure(), delay);
run_loop.Run();
}
int GetUniqueTouchEventID() { return sent_events_ids_.back(); }
......
......@@ -681,6 +681,13 @@ class RenderWidgetHostTest : public testing::Test {
return handle_mouse_event_;
}
void RunLoopFor(base::TimeDelta duration) {
base::RunLoop run_loop;
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, run_loop.QuitClosure(), duration);
run_loop.Run();
}
protected:
// testing::Test
void SetUp() override {
......@@ -1495,10 +1502,7 @@ TEST_F(RenderWidgetHostTest, DontPostponeInputEventAckTimeout) {
host_->StartInputEventAckTimeout(TimeDelta::FromSeconds(30));
// Wait long enough for first timeout and see if it fired.
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
TimeDelta::FromMilliseconds(10));
base::RunLoop().Run();
RunLoopFor(TimeDelta::FromMilliseconds(10));
EXPECT_TRUE(delegate_->unresponsive_timer_fired());
}
......@@ -1514,10 +1518,7 @@ TEST_F(RenderWidgetHostTest, StopAndStartInputEventAckTimeout) {
host_->StartInputEventAckTimeout(TimeDelta::FromMilliseconds(10));
// Wait long enough for first timeout and see if it fired.
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
TimeDelta::FromMilliseconds(40));
base::RunLoop().Run();
RunLoopFor(TimeDelta::FromMilliseconds(40));
EXPECT_TRUE(delegate_->unresponsive_timer_fired());
}
......@@ -1532,10 +1533,7 @@ TEST_F(RenderWidgetHostTest, ShorterDelayInputEventAckTimeout) {
host_->StartInputEventAckTimeout(TimeDelta::FromMilliseconds(20));
// Wait long enough for the second timeout and see if it fired.
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
TimeDelta::FromMilliseconds(25));
base::RunLoop().Run();
RunLoopFor(TimeDelta::FromMilliseconds(25));
EXPECT_TRUE(delegate_->unresponsive_timer_fired());
}
......@@ -1550,27 +1548,18 @@ TEST_F(RenderWidgetHostTest, InputEventAckTimeoutDisabledForInputWhenHidden) {
// The timeout should not fire.
EXPECT_FALSE(delegate_->unresponsive_timer_fired());
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
TimeDelta::FromMicroseconds(2));
base::RunLoop().Run();
RunLoopFor(TimeDelta::FromMicroseconds(2));
EXPECT_FALSE(delegate_->unresponsive_timer_fired());
// The timeout should never reactivate while hidden.
SimulateMouseEvent(WebInputEvent::kMouseMove, 10, 10, 0, false);
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
TimeDelta::FromMicroseconds(2));
base::RunLoop().Run();
RunLoopFor(TimeDelta::FromMicroseconds(2));
EXPECT_FALSE(delegate_->unresponsive_timer_fired());
// Showing the widget should restore the timeout, as the events have
// not yet been ack'ed.
host_->WasShown(false /* record_presentation_time */);
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
TimeDelta::FromMicroseconds(2));
base::RunLoop().Run();
RunLoopFor(TimeDelta::FromMicroseconds(2));
EXPECT_TRUE(delegate_->unresponsive_timer_fired());
}
......@@ -1595,10 +1584,7 @@ TEST_F(RenderWidgetHostTest, MultipleInputEvents) {
dispatched_events[0]->ToEvent()->CallCallback(INPUT_EVENT_ACK_STATE_CONSUMED);
// Wait long enough for first timeout and see if it fired.
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
TimeDelta::FromMicroseconds(20));
base::RunLoop().Run();
RunLoopFor(TimeDelta::FromMicroseconds(20));
EXPECT_TRUE(delegate_->unresponsive_timer_fired());
}
......@@ -1634,10 +1620,7 @@ TEST_F(RenderWidgetHostTest, NewContentRenderingTimeoutWithoutSurfaceSync) {
.Build();
host_->SubmitCompositorFrame(local_surface_id, std::move(frame),
base::nullopt, 0);
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
TimeDelta::FromMicroseconds(20));
base::RunLoop().Run();
RunLoopFor(TimeDelta::FromMicroseconds(20));
EXPECT_FALSE(host_->new_content_rendering_timeout_fired());
host_->reset_new_content_rendering_timeout_fired();
......@@ -1651,10 +1634,7 @@ TEST_F(RenderWidgetHostTest, NewContentRenderingTimeoutWithoutSurfaceSync) {
.Build();
host_->SubmitCompositorFrame(local_surface_id, std::move(frame),
base::nullopt, 0);
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
TimeDelta::FromMicroseconds(20));
base::RunLoop().Run();
RunLoopFor(TimeDelta::FromMicroseconds(20));
EXPECT_TRUE(host_->new_content_rendering_timeout_fired());
host_->reset_new_content_rendering_timeout_fired();
......@@ -1668,20 +1648,14 @@ TEST_F(RenderWidgetHostTest, NewContentRenderingTimeoutWithoutSurfaceSync) {
host_->SubmitCompositorFrame(local_surface_id, std::move(frame),
base::nullopt, 0);
host_->DidNavigate(7);
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
TimeDelta::FromMicroseconds(20));
base::RunLoop().Run();
RunLoopFor(TimeDelta::FromMicroseconds(20));
EXPECT_FALSE(host_->new_content_rendering_timeout_fired());
host_->reset_new_content_rendering_timeout_fired();
// Don't send any frames after the timer starts. The timer should fire.
host_->DidNavigate(20);
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
TimeDelta::FromMicroseconds(20));
base::RunLoop().Run();
RunLoopFor(TimeDelta::FromMicroseconds(20));
EXPECT_TRUE(host_->new_content_rendering_timeout_fired());
host_->reset_new_content_rendering_timeout_fired();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment