Commit e20ce45a authored by jonross's avatar jonross Committed by Commit Bot

Update ThumbnailTest Frame Waiting

ThumbnailTest.ShouldCaptureOnNavigatingAwaySlowPageLoad was using a time based
wait, to simulate awaiting a frame submission. However the timing on viz debug
builds on Linux64 was leading to incorrect results.

This updates the test to use RenderFrameSubmissionObserver to wait directly upon
frame generation.

TEST=ThumbnailTest.ShouldCaptureOnNavigatingAwaySlowPageLoad

Bug: 843921
Change-Id: I71cd8acdc528a3b220c8ccbbbece585ed5cf03bd
Reviewed-on: https://chromium-review.googlesource.com/1097216Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Jonathan Ross <jonross@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566807}
parent 09d21dec
......@@ -23,6 +23,7 @@
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test_utils.h"
#include "net/test/embedded_test_server/controllable_http_response.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gmock/include/gmock/gmock.h"
......@@ -83,13 +84,6 @@ std::string MakeHtmlDocument(const std::string& background_color) {
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 {
public:
MOCK_METHOD2(SetPageThumbnail,
......@@ -323,10 +317,12 @@ IN_PROC_BROWSER_TEST_F(ThumbnailTest,
// Navigate to the red page.
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(200));
// Ensure that the updated WebContents has produced a frame after navigation.
// Without this, there's a chance we might attempt to take a screenshot before
// the first paint, which would fail.
content::RenderFrameSubmissionObserver frame_observer(
browser()->tab_strip_model()->GetActiveWebContents());
frame_observer.WaitForMetadataChange();
// Before navigating away from the red page, we should take a thumbnail.
// Note that the page load is deliberately slowed down, so that the
......
......@@ -10,6 +10,3 @@
# Mac Flaking with missing browser. https://crbug.com/842664
-IndependentOTRProfileManagerTest.DeleteImmediatelyWhenBrowsersAlreadyClosed
# https://crbug.com/843921
-ThumbnailTest.ShouldCaptureOnNavigatingAwaySlowPageLoad
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