Commit a2e42006 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Thumbnail capturing: Try to deflake SlowPageLoad test

This CL adds an explicit wait after the navigation to the page in
question has finished, to give the renderer some time to actually paint
it before we attempt to take a screenshot.

Bug: 778248, 784300
Change-Id: I2a0ecd73b6f182a064728d03a380d2ed40fa50f8
Reviewed-on: https://chromium-review.googlesource.com/765828
Commit-Queue: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#515943}
parent bfd292e6
...@@ -85,6 +85,13 @@ std::string MakeHtmlDocument(const std::string& background_color) { ...@@ -85,6 +85,13 @@ std::string MakeHtmlDocument(const std::string& background_color) {
background_color.c_str()); background_color.c_str());
} }
void Sleep(base::TimeDelta delta) {
base::RunLoop run_loop;
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, run_loop.QuitClosure(), delta);
run_loop.Run();
}
class MockThumbnailService : public ThumbnailService { class MockThumbnailService : public ThumbnailService {
public: public:
MOCK_METHOD2(SetPageThumbnail, MOCK_METHOD2(SetPageThumbnail,
...@@ -285,9 +292,14 @@ IN_PROC_BROWSER_TEST_F(ThumbnailTest, ...@@ -285,9 +292,14 @@ IN_PROC_BROWSER_TEST_F(ThumbnailTest,
SetPageThumbnail(Field(&ThumbnailingContext::url, about_blank_url), _)) SetPageThumbnail(Field(&ThumbnailingContext::url, about_blank_url), _))
.Times(0); .Times(0);
// Navigate to some page. // Navigate to the red page.
ui_test_utils::NavigateToURL(browser(), red_url); ui_test_utils::NavigateToURL(browser(), red_url);
// Give the renderer process some time to actually paint it. Without this,
// there's a chance we might attempt to take a screenshot before the first
// paint, which would fail.
Sleep(base::TimeDelta::FromMilliseconds(100));
// Before navigating away from the red page, we should take a thumbnail. // Before navigating away from the red page, we should take a thumbnail.
// Note that the page load is deliberately slowed down, so that the // Note that the page load is deliberately slowed down, so that the
// thumbnailing process has time to finish before the new page comes in. // thumbnailing process has time to finish before the new page comes in.
......
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