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

Unified Diff: content/renderer/render_view_browsertest.cc

Issue 2870633002: Use ScopedTaskEnvironment instead of MessageLoop in RenderViewTest. (Closed)
Patch Set: fix-build-error Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/render_frame_impl_browsertest.cc ('k') | content/renderer/render_view_browsertest_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view_browsertest.cc
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index 42d0e35ccf9f0e5f10621eb90f4f49e7d3a19d36..31fdebdde696683507409ed4cbe0bde6074189e0 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -13,6 +13,7 @@
#include "base/json/json_writer.h"
#include "base/location.h"
#include "base/macros.h"
+#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -262,7 +263,7 @@ class RenderViewImplTest : public RenderViewTest {
template<class T>
typename T::Param ProcessAndReadIPC() {
- ProcessPendingMessages();
+ base::RunLoop().RunUntilIdle();
const IPC::Message* message =
render_thread_->sink().GetUniqueMessageMatching(T::ID);
typename T::Param param;
@@ -588,7 +589,7 @@ TEST_F(RenderViewImplTest, OnNavStateChanged) {
// notification. We need to spin the message loop to catch this update.
ExecuteJavaScriptForTests(
"document.getElementById('elt_text').value = 'foo';");
- ProcessPendingMessages();
+ base::RunLoop().RunUntilIdle();
EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching(
FrameHostMsg_UpdateState::ID));
@@ -612,7 +613,7 @@ TEST_F(RenderViewImplTest, OnNavigationHttpPost) {
common_params.post_data = post_data;
frame()->Navigate(common_params, start_params, request_params);
- ProcessPendingMessages();
+ base::RunLoop().RunUntilIdle();
const IPC::Message* frame_navigate_msg =
render_thread_->sink().GetUniqueMessageMatching(
@@ -653,7 +654,7 @@ TEST_F(RenderViewImplTest, OnNavigationLoadDataWithBaseURL) {
request_params);
const IPC::Message* frame_title_msg = nullptr;
do {
- ProcessPendingMessages();
+ base::RunLoop().RunUntilIdle();
frame_title_msg = render_thread_->sink().GetUniqueMessageMatching(
FrameHostMsg_UpdateTitle::ID);
} while (!frame_title_msg);
@@ -932,7 +933,7 @@ TEST_F(RenderViewImplTest, DISABLED_LastCommittedUpdateState) {
LoadHTML("<div>Page B</div>");
// Check for a valid UpdateState message for page A.
- ProcessPendingMessages();
+ base::RunLoop().RunUntilIdle();
const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching(
FrameHostMsg_UpdateState::ID);
ASSERT_TRUE(msg_A);
@@ -945,7 +946,7 @@ TEST_F(RenderViewImplTest, DISABLED_LastCommittedUpdateState) {
LoadHTML("<div>Page C</div>");
// Check for a valid UpdateState for page B.
- ProcessPendingMessages();
+ base::RunLoop().RunUntilIdle();
const IPC::Message* msg_B = render_thread_->sink().GetUniqueMessageMatching(
FrameHostMsg_UpdateState::ID);
ASSERT_TRUE(msg_B);
@@ -958,7 +959,7 @@ TEST_F(RenderViewImplTest, DISABLED_LastCommittedUpdateState) {
LoadHTML("<div>Page D</div>");
// Check for a valid UpdateState for page C.
- ProcessPendingMessages();
+ base::RunLoop().RunUntilIdle();
const IPC::Message* msg_C = render_thread_->sink().GetUniqueMessageMatching(
FrameHostMsg_UpdateState::ID);
ASSERT_TRUE(msg_C);
@@ -979,7 +980,7 @@ TEST_F(RenderViewImplTest, DISABLED_LastCommittedUpdateState) {
request_params_C.nav_entry_id = 3;
request_params_C.page_state = state_C;
frame()->Navigate(common_params_C, StartNavigationParams(), request_params_C);
- ProcessPendingMessages();
+ base::RunLoop().RunUntilIdle();
render_thread_->sink().ClearMessages();
// Go back twice quickly, such that page B does not have a chance to commit.
@@ -1011,7 +1012,7 @@ TEST_F(RenderViewImplTest, DISABLED_LastCommittedUpdateState) {
request_params.nav_entry_id = 1;
request_params.page_state = state_A;
frame()->Navigate(common_params, StartNavigationParams(), request_params);
- ProcessPendingMessages();
+ base::RunLoop().RunUntilIdle();
// Now ensure that the UpdateState message we receive is consistent
// and represents page C in state.
@@ -1080,7 +1081,7 @@ TEST_F(RenderViewImplTest, OnImeTypeChanged) {
// Move the input focus to the first <input> element, where we should
// activate IMEs.
ExecuteJavaScriptForTests("document.getElementById('test1').focus();");
- ProcessPendingMessages();
+ base::RunLoop().RunUntilIdle();
render_thread_->sink().ClearMessages();
// Update the IME status and verify if our IME backend sends an IPC message
@@ -1101,7 +1102,7 @@ TEST_F(RenderViewImplTest, OnImeTypeChanged) {
// Move the input focus to the second <input> element, where we should
// de-activate IMEs.
ExecuteJavaScriptForTests("document.getElementById('test2').focus();");
- ProcessPendingMessages();
+ base::RunLoop().RunUntilIdle();
render_thread_->sink().ClearMessages();
// Update the IME status and verify if our IME backend sends an IPC message
@@ -1124,13 +1125,13 @@ TEST_F(RenderViewImplTest, OnImeTypeChanged) {
// Move the input focus to the target <input> element, where we should
// activate IMEs.
ExecuteJavaScriptAndReturnIntValue(base::ASCIIToUTF16(javascript), NULL);
- ProcessPendingMessages();
+ base::RunLoop().RunUntilIdle();
render_thread_->sink().ClearMessages();
// Update the IME status and verify if our IME backend sends an IPC
// message to activate IMEs.
view()->UpdateTextInputState();
- ProcessPendingMessages();
+ base::RunLoop().RunUntilIdle();
const IPC::Message* msg = render_thread_->sink().GetMessageAt(0);
EXPECT_TRUE(msg != NULL);
EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type());
@@ -1270,7 +1271,7 @@ TEST_F(RenderViewImplTest, ImeComposition) {
// Update the status of our IME back-end.
// TODO(hbono): we should verify messages to be sent from the back-end.
view()->UpdateTextInputState();
- ProcessPendingMessages();
+ base::RunLoop().RunUntilIdle();
render_thread_->sink().ClearMessages();
if (ime_message->result) {
@@ -2056,7 +2057,7 @@ TEST_F(RenderViewImplTest, BrowserNavigationStartSanitized) {
frame()->Navigate(late_common_params, StartNavigationParams(),
RequestNavigationParams());
- ProcessPendingMessages();
+ base::RunLoop().RunUntilIdle();
base::Time after_navigation =
base::Time::Now() + base::TimeDelta::FromDays(1);
@@ -2090,7 +2091,7 @@ TEST_F(RenderViewImplTest, NavigationStartForReload) {
const char url_string[] = "data:text/html,<div>Page</div>";
// Navigate once, then reload.
LoadHTML(url_string);
- ProcessPendingMessages();
+ base::RunLoop().RunUntilIdle();
render_thread_->sink().ClearMessages();
CommonNavigationParams common_params;
@@ -2124,7 +2125,7 @@ TEST_F(RenderViewImplTest, NavigationStartForSameProcessHistoryNavigation) {
PageState back_state = GetCurrentPageState();
LoadHTML("<div id=pagename>Page C</div>");
PageState forward_state = GetCurrentPageState();
- ProcessPendingMessages();
+ base::RunLoop().RunUntilIdle();
render_thread_->sink().ClearMessages();
// Go back.
« no previous file with comments | « content/renderer/render_frame_impl_browsertest.cc ('k') | content/renderer/render_view_browsertest_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698