Commit 3415cf74 authored by mlamouri@chromium.org's avatar mlamouri@chromium.org

Use WaitForResizeComplete() instead of waiting for first paint.

That should fix flakyness for the test on Windows with cl 134623005.

BUG=None

Review URL: https://codereview.chromium.org/441713002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287526 0039d316-1c4b-4281-b951-d872f2087c98
parent 0bdf8037
......@@ -11,6 +11,7 @@
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
......@@ -115,16 +116,12 @@ IN_PROC_BROWSER_TEST_F(ScreenOrientationBrowserTest, ScreenOrientationChange) {
GURL test_url = GetTestUrl("screen_orientation",
"screen_orientation_screenorientationchange.html");
TestNavigationObserver navigation_observer(
shell()->web_contents(), 1
// Android doesn't paint (ie. UseSoftwareCompositing() has no effect) so we
// shouldn't wait for the first paint.
#if !defined(OS_ANDROID)
, TestNavigationObserver::FirstPaintRequired
#endif
);
TestNavigationObserver navigation_observer(shell()->web_contents(), 1);
shell()->LoadURL(test_url);
navigation_observer.Wait();
#if USE_AURA
WaitForResizeComplete(shell()->web_contents());
#endif // USE_AURA
int angle = GetOrientationAngle();
......
......@@ -46,39 +46,17 @@ class TestNavigationObserver::TestWebContentsObserver
parent_->OnDidStopLoading(web_contents());
}
virtual void DidFirstVisuallyNonEmptyPaint() OVERRIDE {
parent_->OnDidFirstVisuallyNonEmptyPaint(web_contents());
}
TestNavigationObserver* parent_;
DISALLOW_COPY_AND_ASSIGN(TestWebContentsObserver);
};
TestNavigationObserver::TestNavigationObserver(
WebContents* web_contents,
int number_of_navigations,
FirstPaint first_paint)
: navigation_started_(false),
navigations_completed_(0),
number_of_navigations_(number_of_navigations),
first_paint_(first_paint),
message_loop_runner_(new MessageLoopRunner),
web_contents_created_callback_(
base::Bind(
&TestNavigationObserver::OnWebContentsCreated,
base::Unretained(this))) {
if (web_contents)
RegisterAsObserver(web_contents);
}
TestNavigationObserver::TestNavigationObserver(
WebContents* web_contents,
int number_of_navigations)
: navigation_started_(false),
navigations_completed_(0),
number_of_navigations_(number_of_navigations),
first_paint_(FirstPaintNotRequired),
message_loop_runner_(new MessageLoopRunner),
web_contents_created_callback_(
base::Bind(
......@@ -93,7 +71,6 @@ TestNavigationObserver::TestNavigationObserver(
: navigation_started_(false),
navigations_completed_(0),
number_of_navigations_(1),
first_paint_(FirstPaintNotRequired),
message_loop_runner_(new MessageLoopRunner),
web_contents_created_callback_(
base::Bind(
......@@ -161,20 +138,7 @@ void TestNavigationObserver::OnDidStopLoading(WebContents* web_contents) {
return;
++navigations_completed_;
if ((navigations_completed_ == number_of_navigations_) &&
first_paint_ == FirstPaintNotRequired) {
navigation_started_ = false;
message_loop_runner_->Quit();
}
}
void TestNavigationObserver::OnDidFirstVisuallyNonEmptyPaint(
WebContents* web_contents) {
if (!navigation_started_)
return;
if ((navigations_completed_ == number_of_navigations_) &&
first_paint_ == FirstPaintRequired) {
if (navigations_completed_ == number_of_navigations_) {
navigation_started_ = false;
message_loop_runner_->Quit();
}
......
......@@ -20,17 +20,8 @@ struct LoadCommittedDetails;
// MessageLoop and quit when the navigation completes loading.
class TestNavigationObserver {
public:
enum FirstPaint {
FirstPaintRequired,
FirstPaintNotRequired
};
// Create and register a new TestNavigationObserver against the
// |web_contents|.
TestNavigationObserver(WebContents* web_contents,
int number_of_navigations,
FirstPaint first_paint);
// Like above but doesn't wait for the first paint after the navigations.
TestNavigationObserver(WebContents* web_contents,
int number_of_navigations);
// Like above but waits for one navigation.
......@@ -42,8 +33,6 @@ class TestNavigationObserver {
// navigations are complete.
void Wait();
// Runs a nested message loop and blocks until the expected
// Start/stop watching newly created WebContents.
void StartWatchingNewWebContents();
void StopWatchingNewWebContents();
......@@ -66,7 +55,6 @@ class TestNavigationObserver {
void OnDidAttachInterstitialPage(WebContents* web_contents);
void OnDidStartLoading(WebContents* web_contents);
void OnDidStopLoading(WebContents* web_contents);
void OnDidFirstVisuallyNonEmptyPaint(WebContents* web_contents);
// If true the navigation has started.
bool navigation_started_;
......@@ -77,9 +65,6 @@ class TestNavigationObserver {
// The number of navigations to wait for.
int number_of_navigations_;
// Whether we want to wait for first paint after navigations.
FirstPaint first_paint_;
// The MessageLoopRunner used to spin the message loop.
scoped_refptr<MessageLoopRunner> message_loop_runner_;
......
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