Commit daba3262 authored by Andrey Kosyakov's avatar Andrey Kosyakov Committed by Chromium LUCI CQ

Add a test of screenshot with overridden device scale factor

This is a regression test for issue 1164610.

Bug: 1164610
Change-Id: I1671fadf581778ddd2d90c310c1574a91ecdd967
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2621962
Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842201}
parent 6cf2df89
Tests screenshot with overridden device scale factor
requested url: http://example.com/
Screenshot size: 200 x 200
rgba @(175,175) 0,0,255,255
\ No newline at end of file
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(async function(testRunner) {
const {page, session, dp} = await testRunner.startWithFrameControl(
'Tests screenshot with overridden device scale factor');
await dp.Runtime.enable();
await dp.HeadlessExperimental.enable();
dp.Emulation.enable();
await dp.Emulation.setDeviceMetricsOverride({
deviceScaleFactor: 2,
width: 100,
height: 100,
screenHeight: 100,
screenWidth: 100,
mobile: true,
viewport: {x: 0, y: 0, width: 100, height: 100, scale: 1}
});
const RendererTestHelper =
await testRunner.loadScript('../helpers/renderer-test-helper.js');
const {httpInterceptor, frameNavigationHelper, virtualTimeController} =
await (new RendererTestHelper(testRunner, dp, page)).init();
httpInterceptor.addResponse(`http://example.com/`,
`<!doctype html>
<html>
<meta name=viewport content="width=device-width">
<style>
html, body { width: 100%; height: 100%; margin:0; padding:0; }
div {
width: 100%; height: 100%; margin:0; padding:0;
background-size: 100% 100%;
background-color: blue;
}
</style>
<body>
<div></div>
</body>
</html>
`);
let ctx = await new Promise(async fulfill => {
await virtualTimeController.grantInitialTime(500, 100,
null,
async () => fulfill(await virtualTimeController.captureScreenshot())
);
frameNavigationHelper.navigate('http://example.com/');
});
// We use a screen and viewport of 100x100 DIP, which is 200 physical pixels
// due to deviceScaleFactor of 2. Make sure the screenshot is not clipped.
let rgba = ctx.getImageData(175, 175, 1, 1).data;
testRunner.log(`rgba @(175,175) ${rgba}`);
testRunner.completeTest();
})
\ No newline at end of file
......@@ -157,5 +157,7 @@ HEADLESS_COMPOSITOR_TEST(RendererOpacityAnimation,
"sanity/renderer-opacity-animation.js")
HEADLESS_COMPOSITOR_TEST(ScreenshotAfterMetricsOverride,
"sanity/screenshot-after-metrics-override.js")
HEADLESS_COMPOSITOR_TEST(ScreenshotDeviceScaleFactor,
"emulation/screenshot-device-scale-factor.js")
} // namespace headless
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