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 @@ ...@@ -11,6 +11,7 @@
#include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.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.h"
#include "content/public/test/content_browser_test_utils.h" #include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h" #include "content/public/test/test_navigation_observer.h"
...@@ -115,16 +116,12 @@ IN_PROC_BROWSER_TEST_F(ScreenOrientationBrowserTest, ScreenOrientationChange) { ...@@ -115,16 +116,12 @@ IN_PROC_BROWSER_TEST_F(ScreenOrientationBrowserTest, ScreenOrientationChange) {
GURL test_url = GetTestUrl("screen_orientation", GURL test_url = GetTestUrl("screen_orientation",
"screen_orientation_screenorientationchange.html"); "screen_orientation_screenorientationchange.html");
TestNavigationObserver navigation_observer( TestNavigationObserver navigation_observer(shell()->web_contents(), 1);
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
);
shell()->LoadURL(test_url); shell()->LoadURL(test_url);
navigation_observer.Wait(); navigation_observer.Wait();
#if USE_AURA
WaitForResizeComplete(shell()->web_contents());
#endif // USE_AURA
int angle = GetOrientationAngle(); int angle = GetOrientationAngle();
......
...@@ -46,39 +46,17 @@ class TestNavigationObserver::TestWebContentsObserver ...@@ -46,39 +46,17 @@ class TestNavigationObserver::TestWebContentsObserver
parent_->OnDidStopLoading(web_contents()); parent_->OnDidStopLoading(web_contents());
} }
virtual void DidFirstVisuallyNonEmptyPaint() OVERRIDE {
parent_->OnDidFirstVisuallyNonEmptyPaint(web_contents());
}
TestNavigationObserver* parent_; TestNavigationObserver* parent_;
DISALLOW_COPY_AND_ASSIGN(TestWebContentsObserver); 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( TestNavigationObserver::TestNavigationObserver(
WebContents* web_contents, WebContents* web_contents,
int number_of_navigations) int number_of_navigations)
: navigation_started_(false), : navigation_started_(false),
navigations_completed_(0), navigations_completed_(0),
number_of_navigations_(number_of_navigations), number_of_navigations_(number_of_navigations),
first_paint_(FirstPaintNotRequired),
message_loop_runner_(new MessageLoopRunner), message_loop_runner_(new MessageLoopRunner),
web_contents_created_callback_( web_contents_created_callback_(
base::Bind( base::Bind(
...@@ -93,7 +71,6 @@ TestNavigationObserver::TestNavigationObserver( ...@@ -93,7 +71,6 @@ TestNavigationObserver::TestNavigationObserver(
: navigation_started_(false), : navigation_started_(false),
navigations_completed_(0), navigations_completed_(0),
number_of_navigations_(1), number_of_navigations_(1),
first_paint_(FirstPaintNotRequired),
message_loop_runner_(new MessageLoopRunner), message_loop_runner_(new MessageLoopRunner),
web_contents_created_callback_( web_contents_created_callback_(
base::Bind( base::Bind(
...@@ -161,20 +138,7 @@ void TestNavigationObserver::OnDidStopLoading(WebContents* web_contents) { ...@@ -161,20 +138,7 @@ void TestNavigationObserver::OnDidStopLoading(WebContents* web_contents) {
return; return;
++navigations_completed_; ++navigations_completed_;
if ((navigations_completed_ == number_of_navigations_) && 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) {
navigation_started_ = false; navigation_started_ = false;
message_loop_runner_->Quit(); message_loop_runner_->Quit();
} }
......
...@@ -20,17 +20,8 @@ struct LoadCommittedDetails; ...@@ -20,17 +20,8 @@ struct LoadCommittedDetails;
// MessageLoop and quit when the navigation completes loading. // MessageLoop and quit when the navigation completes loading.
class TestNavigationObserver { class TestNavigationObserver {
public: public:
enum FirstPaint {
FirstPaintRequired,
FirstPaintNotRequired
};
// Create and register a new TestNavigationObserver against the // Create and register a new TestNavigationObserver against the
// |web_contents|. // |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, TestNavigationObserver(WebContents* web_contents,
int number_of_navigations); int number_of_navigations);
// Like above but waits for one navigation. // Like above but waits for one navigation.
...@@ -42,8 +33,6 @@ class TestNavigationObserver { ...@@ -42,8 +33,6 @@ class TestNavigationObserver {
// navigations are complete. // navigations are complete.
void Wait(); void Wait();
// Runs a nested message loop and blocks until the expected
// Start/stop watching newly created WebContents. // Start/stop watching newly created WebContents.
void StartWatchingNewWebContents(); void StartWatchingNewWebContents();
void StopWatchingNewWebContents(); void StopWatchingNewWebContents();
...@@ -66,7 +55,6 @@ class TestNavigationObserver { ...@@ -66,7 +55,6 @@ class TestNavigationObserver {
void OnDidAttachInterstitialPage(WebContents* web_contents); void OnDidAttachInterstitialPage(WebContents* web_contents);
void OnDidStartLoading(WebContents* web_contents); void OnDidStartLoading(WebContents* web_contents);
void OnDidStopLoading(WebContents* web_contents); void OnDidStopLoading(WebContents* web_contents);
void OnDidFirstVisuallyNonEmptyPaint(WebContents* web_contents);
// If true the navigation has started. // If true the navigation has started.
bool navigation_started_; bool navigation_started_;
...@@ -77,9 +65,6 @@ class TestNavigationObserver { ...@@ -77,9 +65,6 @@ class TestNavigationObserver {
// The number of navigations to wait for. // The number of navigations to wait for.
int number_of_navigations_; 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. // The MessageLoopRunner used to spin the message loop.
scoped_refptr<MessageLoopRunner> message_loop_runner_; 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