Add canvas renderer tests

This commit is contained in:
Daniel Imms
2023-09-08 12:16:16 -07:00
parent 34933d2c76
commit 98e8c6ac73
10 changed files with 131 additions and 10 deletions
+2 -2
View File
@@ -5,10 +5,10 @@
import { test } from '@playwright/test';
import { ITestContext, createTestContext, openTerminal } from './TestUtils';
import { injectSharedRendererTests } from './SharedRendererTests';
import { ISharedRendererTestContext, injectSharedRendererTests } from './SharedRendererTests';
let ctx: ITestContext;
const ctxWrapper: { value: ITestContext } = { value: undefined } as any;
const ctxWrapper: ISharedRendererTestContext = { value: undefined } as any;
test.beforeAll(async ({ browser }) => {
ctx = await createTestContext(browser);
ctxWrapper.value = ctx;
+9 -4
View File
@@ -8,7 +8,12 @@ import { LocatorScreenshotOptions, test } from '@playwright/test';
import { ITheme } from 'xterm';
import { ITestContext, MaybeAsync, pollFor } from './TestUtils';
export function injectSharedRendererTests(ctx: { value: ITestContext }): void {
export interface ISharedRendererTestContext {
value: ITestContext;
skipCanvasExceptions?: boolean;
}
export function injectSharedRendererTests(ctx: ISharedRendererTestContext): void {
test.beforeEach(async () => {
await ctx.value.proxy.reset();
ctx.value.page.evaluate(`
@@ -934,7 +939,7 @@ export function injectSharedRendererTests(ctx: { value: ITestContext }): void {
});
});
test.describe('selectionBackground', async () => {
(ctx.skipCanvasExceptions ? test.describe.skip : test.describe)('selectionBackground', async () => {
test('should resolve the inverse foreground color based on the original background color, not the selection', async () => {
const theme: ITheme = {
foreground: '#FF0000',
@@ -970,7 +975,7 @@ export function injectSharedRendererTests(ctx: { value: ITestContext }): void {
});
});
test.describe('selectionForeground', () => {
(ctx.skipCanvasExceptions ? test.describe.skip : test.describe)('selectionForeground', () => {
test('transparent background inverse', async () => {
const theme: ITheme = {
selectionForeground: '#ff0000'
@@ -1050,7 +1055,7 @@ export function injectSharedRendererTests(ctx: { value: ITestContext }): void {
await ctx.value.proxy.write( data);
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 1), [0, 0, 255, 255]);
});
test('backgroundColor should ignore inverse (only bg on decoration)', async () => {
(ctx.skipCanvasExceptions ? test.skip : test)('backgroundColor should ignore inverse (only bg on decoration)', async () => {
const data = `\x1b[7m█ \x1b[0m`;
await ctx.value.proxy.write( data);
await ctx.value.page.evaluate(`