add integration tests for pixel reports

This commit is contained in:
Jörg Breitbart
2019-10-29 15:50:54 +01:00
parent da3ae79c37
commit 2cad586ccc
2 changed files with 60 additions and 1 deletions
+1 -1
View File
@@ -2094,7 +2094,7 @@ export class InputHandler extends Disposable implements IInputHandler {
if (rs) {
const w = rs.dimensions.actualCellWidth.toFixed(0);
const h = rs.dimensions.actualCellHeight.toFixed(0);
this._coreService.triggerDataEvent(`${C0.ESC}[4;${h};${w}t`);
this._coreService.triggerDataEvent(`${C0.ESC}[6;${h};${w}t`);
}
break;
case 18: // GetWinSizeChars, returns CSI 8 ; height ; width t
+59
View File
@@ -346,6 +346,51 @@ describe('InputHandler Integration Tests', function(): void {
`);
assert.deepEqual(await getLinesAsArray(3), ['#', ' #', 'abcd####']);
});
describe.only('Window Options - CSI Ps ; Ps ; Ps t', () => {
it('should be disabled by default', async function() {
assert.equal(await page.evaluate(`(() => window.term.getOption('allowedWindowOps'))()`), '');
await page.evaluate(`(() => {
window._stack = [];
const _h = window.term.onData(data => window._stack.push(data));
window.term.write('\x1b[14t');
window.term.write('\x1b[16t');
window.term.write('\x1b[18t');
window.term.write('\x1b[20t');
window.term.write('\x1b[21t');
return new Promise((r) => window.term.write('', () => { _h.dispose(); r(); }));
})()`);
assert.deepEqual(await page.evaluate(`(() => _stack)()`), []);
});
it('14 - GetWinSizePixels', async function() {
assert.equal(await page.evaluate(`(() => {
window.term.setOption('allowedWindowOps', 'GetWinSizePixels');
return window.term.getOption('allowedWindowOps');
})()`), '14');
await page.evaluate(`(() => {
window._stack = [];
const _h = window.term.onData(data => window._stack.push(data));
window.term.write('\x1b[14t');
return new Promise((r) => window.term.write('', () => { _h.dispose(); r(); }));
})()`);
const d = await getDimensions();
assert.deepEqual(await page.evaluate(`(() => _stack)()`), [`\x1b[4;${d.height};${d.width}t`]);
});
it('16 - GetCellSizePixels', async function() {
assert.equal(await page.evaluate(`(() => {
window.term.setOption('allowedWindowOps', 'GetCellSizePixels');
return window.term.getOption('allowedWindowOps');
})()`), '16');
await page.evaluate(`(() => {
window._stack = [];
const _h = window.term.onData(data => window._stack.push(data));
window.term.write('\x1b[16t');
return new Promise((r) => window.term.write('', () => { _h.dispose(); r(); }));
})()`);
const d = await getDimensions();
assert.deepEqual(await page.evaluate(`(() => _stack)()`), [`\x1b[6;${d.cellHeight};${d.cellWidth}t`]);
});
});
});
describe('ESC', () => {
@@ -404,3 +449,17 @@ async function getCursor(): Promise<{col: number, row: number}> {
})();
`);
}
async function getDimensions(): Promise<any> {
const dim = await page.evaluate(`
(function() {
return term._core._renderService.dimensions;
})();
`);
return {
cellWidth: dim.actualCellWidth.toFixed(0),
cellHeight: dim.actualCellHeight.toFixed(0),
width: dim.canvasWidth.toFixed(0),
height: dim.canvasHeight.toFixed(0)
};
}