test: update screencast test to actually require red color (#4745)

This commit is contained in:
Dmitry Gozman 2021-01-05 20:31:50 -08:00 committed by GitHub
parent b6cd385a67
commit 9bbabaaa74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,25 +90,26 @@ export class VideoPlayer {
}
function almostRed(r, g, b, alpha) {
expect(g).toBeLessThan(50);
expect(b).toBeLessThan(50);
expect(r).toBeGreaterThan(185);
expect(g).toBeLessThan(70);
expect(b).toBeLessThan(70);
expect(alpha).toBe(255);
}
function almostBlack(r, g, b, alpha) {
expect(r).toBeLessThan(30);
expect(g).toBeLessThan(30);
expect(b).toBeLessThan(30);
expect(r).toBeLessThan(70);
expect(g).toBeLessThan(70);
expect(b).toBeLessThan(70);
expect(alpha).toBe(255);
}
function almostGrey(r, g, b, alpha) {
function almostGray(r, g, b, alpha) {
expect(r).toBeGreaterThan(70);
expect(g).toBeGreaterThan(70);
expect(b).toBeGreaterThan(70);
expect(r).toBeLessThan(130);
expect(g).toBeLessThan(130);
expect(b).toBeLessThan(130);
expect(r).toBeLessThan(185);
expect(g).toBeLessThan(185);
expect(b).toBeLessThan(185);
expect(alpha).toBe(255);
}
@ -286,12 +287,13 @@ describe('screencast', suite => {
{
const pixels = videoPlayer.seekLastFrame().data;
expectAll(pixels, almostGrey);
expectAll(pixels, almostGray);
}
});
it('should capture css transformation', (test, { headful }) => {
it('should capture css transformation', (test, { headful, browserName, platform }) => {
test.fixme(headful, 'Fails on headful');
test.fixme(browserName === 'webkit' && platform === 'win32', 'Fails on headful');
}, async ({browser, server, testInfo}) => {
const size = { width: 320, height: 240 };
// Set viewport equal to screencast frame size to avoid scaling.
@ -385,11 +387,11 @@ describe('screencast', suite => {
}
{
const pixels = videoPlayer.seekLastFrame({x: 300, y: 0}).data;
expectAll(pixels, almostGrey);
expectAll(pixels, almostGray);
}
{
const pixels = videoPlayer.seekLastFrame({x: 0, y: 200}).data;
expectAll(pixels, almostGrey);
expectAll(pixels, almostGray);
}
{
const pixels = videoPlayer.seekLastFrame({x: 300, y: 200}).data;