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

Side by Side Diff: content/renderer/visual_state_browsertest.cc

Issue 2515823002: Remove WebContents::GetRoutingID(). (Closed)
Patch Set: add render_view_host.h include in resource_dispatcher_host_unittest.cc Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "content/public/browser/render_frame_host.h" 7 #include "content/public/browser/render_frame_host.h"
8 #include "content/public/browser/render_view_host.h"
8 #include "content/public/browser/web_contents.h" 9 #include "content/public/browser/web_contents.h"
9 #include "content/public/common/content_switches.h" 10 #include "content/public/common/content_switches.h"
10 #include "content/public/renderer/render_view.h" 11 #include "content/public/renderer/render_view.h"
11 #include "content/public/renderer/render_view_observer.h" 12 #include "content/public/renderer/render_view_observer.h"
12 #include "content/public/test/browser_test_utils.h" 13 #include "content/public/test/browser_test_utils.h"
13 #include "content/public/test/content_browser_test.h" 14 #include "content/public/test/content_browser_test.h"
14 #include "content/public/test/content_browser_test_utils.h" 15 #include "content/public/test/content_browser_test_utils.h"
15 #include "content/public/test/test_utils.h" 16 #include "content/public/test/test_utils.h"
16 #include "content/renderer/render_frame_impl.h" 17 #include "content/renderer/render_frame_impl.h"
17 #include "content/shell/browser/shell.h" 18 #include "content/shell/browser/shell.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // single commit. We first load "about:blank" and wait for this single 95 // single commit. We first load "about:blank" and wait for this single
95 // commit. At that point we know that the page has stabilized and no 96 // commit. At that point we know that the page has stabilized and no
96 // further commits are expected. We then insert a visual state callback 97 // further commits are expected. We then insert a visual state callback
97 // and verify that this causes an additional commit in order to deliver 98 // and verify that this causes an additional commit in order to deliver
98 // the callback. 99 // the callback.
99 // Unfortunately, if loading "about:blank" changes and starts requiring 100 // Unfortunately, if loading "about:blank" changes and starts requiring
100 // two commits then this test will prove nothing. We could detect this 101 // two commits then this test will prove nothing. We could detect this
101 // with a high level of confidence if we used a timeout, but that's 102 // with a high level of confidence if we used a timeout, but that's
102 // discouraged (see https://codereview.chromium.org/939673002). 103 // discouraged (see https://codereview.chromium.org/939673002).
103 NavigateToURL(shell(), GURL("about:blank")); 104 NavigateToURL(shell(), GURL("about:blank"));
104 CommitObserver observer( 105 CommitObserver observer(RenderView::FromRoutingID(
105 RenderView::FromRoutingID(shell()->web_contents()->GetRoutingID())); 106 shell()->web_contents()->GetRenderViewHost()->GetRoutingID()));
106 107
107 // Wait for the commit corresponding to the load. 108 // Wait for the commit corresponding to the load.
108 109
109 PostTaskToInProcessRendererAndWait(base::Bind( 110 PostTaskToInProcessRendererAndWait(base::Bind(
110 &VisualStateTest::WaitForCommit, base::Unretained(this), &observer, 1)); 111 &VisualStateTest::WaitForCommit, base::Unretained(this), &observer, 1));
111 112
112 // Try our best to check that there are no pending updates or commits. 113 // Try our best to check that there are no pending updates or commits.
113 PostTaskToInProcessRendererAndWait( 114 PostTaskToInProcessRendererAndWait(
114 base::Bind(&VisualStateTest::AssertIsIdle, base::Unretained(this))); 115 base::Bind(&VisualStateTest::AssertIsIdle, base::Unretained(this)));
115 116
116 // Insert a visual state callback. 117 // Insert a visual state callback.
117 shell()->web_contents()->GetMainFrame()->InsertVisualStateCallback(base::Bind( 118 shell()->web_contents()->GetMainFrame()->InsertVisualStateCallback(base::Bind(
118 &VisualStateTest::InvokeVisualStateCallback, base::Unretained(this))); 119 &VisualStateTest::InvokeVisualStateCallback, base::Unretained(this)));
119 120
120 // Verify that the callback is invoked and a new commit completed. 121 // Verify that the callback is invoked and a new commit completed.
121 PostTaskToInProcessRendererAndWait(base::Bind( 122 PostTaskToInProcessRendererAndWait(base::Bind(
122 &VisualStateTest::WaitForCommit, base::Unretained(this), &observer, 2)); 123 &VisualStateTest::WaitForCommit, base::Unretained(this), &observer, 2));
123 EXPECT_EQ(1, GetCallbackCount()); 124 EXPECT_EQ(1, GetCallbackCount());
124 } 125 }
125 126
126 } // namespace content 127 } // namespace content
OLDNEW
« no previous file with comments | « content/public/browser/web_contents_observer.cc ('k') | content/shell/browser/layout_test/blink_test_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698