From 3415cf741765be85f1bd291be5be56c834290749 Mon Sep 17 00:00:00 2001 From: "mlamouri@chromium.org" Date: Tue, 5 Aug 2014 13:09:02 +0000 Subject: [PATCH] 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 --- .../screen_orientation_browsertest.cc | 13 +++---- .../public/test/test_navigation_observer.cc | 38 +------------------ .../public/test/test_navigation_observer.h | 15 -------- 3 files changed, 6 insertions(+), 60 deletions(-) diff --git a/content/browser/screen_orientation/screen_orientation_browsertest.cc b/content/browser/screen_orientation/screen_orientation_browsertest.cc index 670a3d031415b3..daccbd23351f6c 100644 --- a/content/browser/screen_orientation/screen_orientation_browsertest.cc +++ b/content/browser/screen_orientation/screen_orientation_browsertest.cc @@ -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(); diff --git a/content/public/test/test_navigation_observer.cc b/content/public/test/test_navigation_observer.cc index 458c9dcdef037c..bfe74f663589ab 100644 --- a/content/public/test/test_navigation_observer.cc +++ b/content/public/test/test_navigation_observer.cc @@ -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(); } diff --git a/content/public/test/test_navigation_observer.h b/content/public/test/test_navigation_observer.h index 03b3da3ac3b0cd..438af744eb56c0 100644 --- a/content/public/test/test_navigation_observer.h +++ b/content/public/test/test_navigation_observer.h @@ -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 message_loop_runner_;