forked from xtermjs/xterm.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
585 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* Copyright (c) 2017 The xterm.js authors. All rights reserved. | ||
* @license MIT | ||
*/ | ||
|
||
import { test } from '@playwright/test'; | ||
import { createTestContext, ITestContext, openTerminal, pollFor } from './TestUtils'; | ||
|
||
let ctx: ITestContext; | ||
test.beforeAll(async ({ browser }) => { | ||
ctx = await createTestContext(browser); | ||
await openTerminal(ctx); | ||
}); | ||
test.afterAll(async () => await ctx.page.close()); | ||
|
||
test.beforeEach(async () => await ctx.proxy.reset()); | ||
|
||
test.describe('CharWidth Integration Tests', function(): void { | ||
test.describe('getStringCellWidth', () => { | ||
test('ASCII chars', async () => { | ||
await ctx.proxy.write('This is just ASCII text.#'); | ||
await pollFor(ctx.page, () => sumWidths(0, 1, '#'), 25); | ||
}); | ||
|
||
test('combining chars', async () => { | ||
await ctx.proxy.write('e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301#'); | ||
await pollFor(ctx.page, () => sumWidths(0, 1, '#'), 10); | ||
}); | ||
|
||
test('surrogate chars', async () => { | ||
await ctx.proxy.write('πππππππππππππππππππππππππππ#'); | ||
await pollFor(ctx.page, () => sumWidths(0, 1, '#'), 28); | ||
}); | ||
|
||
test('surrogate combining chars', async () => { | ||
await ctx.proxy.write('π\u0301π\u0301π\u0301π\u0301π\u0301π\u0301π\u0301π\u0301π\u0301π\u0301π\u0301#'); | ||
await pollFor(ctx.page, () => sumWidths(0, 1, '#'), 12); | ||
}); | ||
|
||
test('fullwidth chars', async () => { | ||
await ctx.proxy.write('οΌοΌοΌοΌοΌοΌοΌοΌοΌοΌ#'); | ||
await pollFor(ctx.page, () => sumWidths(0, 1, '#'), 21); | ||
}); | ||
|
||
test('fullwidth chars offset 1', async () => { | ||
await ctx.proxy.write('aοΌοΌοΌοΌοΌοΌοΌοΌοΌοΌ#'); | ||
await pollFor(ctx.page, () => sumWidths(0, 1, '#'), 22); | ||
}); | ||
|
||
// TODO: multiline tests once #1685 is resolved | ||
}); | ||
}); | ||
|
||
async function sumWidths(start: number, end: number, sentinel: string): Promise<number> { | ||
await ctx.page.evaluate(` | ||
(function() { | ||
window.result = 0; | ||
const buffer = window.term.buffer.active; | ||
for (let i = ${start}; i < ${end}; i++) { | ||
const line = buffer.getLine(i); | ||
let j = 0; | ||
while (true) { | ||
const cell = line.getCell(j++); | ||
if (!cell) { | ||
break; | ||
} | ||
window.result += cell.getWidth(); | ||
if (cell.getChars() === '${sentinel}') { | ||
return; | ||
} | ||
} | ||
} | ||
})(); | ||
`); | ||
return await ctx.page.evaluate(`window.result`); | ||
} |
Oops, something went wrong.