Skip to content

Commit

Permalink
Use WaitForResizeComplete() instead of waiting for first paint.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mlamouri@chromium.org committed Aug 5, 2014
1 parent 0bdf803 commit 3415cf7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();

Expand Down
38 changes: 1 addition & 37 deletions content/public/test/test_navigation_observer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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();
}
Expand Down
15 changes: 0 additions & 15 deletions content/public/test/test_navigation_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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();
Expand All @@ -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_;
Expand All @@ -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_;

Expand Down

0 comments on commit 3415cf7

Please sign in to comment.