Fix test service injection
This commit is contained in:
@@ -124,7 +124,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
|
|||||||
this._instantiationService.setService(IOscLinkService, this._oscLinkService);
|
this._instantiationService.setService(IOscLinkService, this._oscLinkService);
|
||||||
|
|
||||||
// Register input handler and handle/forward events
|
// Register input handler and handle/forward events
|
||||||
this._inputHandler = new InputHandler(this._bufferService, this._charsetService, this.coreService, this._dirtyRowService, this._logService, this.optionsService, this.coreMouseService, this.unicodeService);
|
this._inputHandler = new InputHandler(this._bufferService, this._charsetService, this.coreService, this._dirtyRowService, this._logService, this.optionsService, this._oscLinkService, this.coreMouseService, this.unicodeService);
|
||||||
this.register(forwardEvent(this._inputHandler.onLineFeed, this._onLineFeed));
|
this.register(forwardEvent(this._inputHandler.onLineFeed, this._onLineFeed));
|
||||||
this.register(this._inputHandler);
|
this.register(this._inputHandler);
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { CellData } from 'common/buffer/CellData';
|
|||||||
import { Attributes, UnderlineStyle } from 'common/buffer/Constants';
|
import { Attributes, UnderlineStyle } from 'common/buffer/Constants';
|
||||||
import { AttributeData } from 'common/buffer/AttributeData';
|
import { AttributeData } from 'common/buffer/AttributeData';
|
||||||
import { Params } from 'common/parser/Params';
|
import { Params } from 'common/parser/Params';
|
||||||
import { MockCoreService, MockBufferService, MockDirtyRowService, MockOptionsService, MockLogService, MockCoreMouseService, MockCharsetService, MockUnicodeService } from 'common/TestUtils.test';
|
import { MockCoreService, MockBufferService, MockDirtyRowService, MockOptionsService, MockLogService, MockCoreMouseService, MockCharsetService, MockUnicodeService, MockOscLinkService } from 'common/TestUtils.test';
|
||||||
import { IBufferService, ICoreService } from 'common/services/Services';
|
import { IBufferService, ICoreService } from 'common/services/Services';
|
||||||
import { DEFAULT_OPTIONS } from 'common/services/OptionsService';
|
import { DEFAULT_OPTIONS } from 'common/services/OptionsService';
|
||||||
import { clone } from 'common/Clone';
|
import { clone } from 'common/Clone';
|
||||||
@@ -67,7 +67,7 @@ describe('InputHandler', () => {
|
|||||||
bufferService.resize(80, 30);
|
bufferService.resize(80, 30);
|
||||||
coreService = new CoreService(() => { }, bufferService, new MockLogService(), optionsService);
|
coreService = new CoreService(() => { }, bufferService, new MockLogService(), optionsService);
|
||||||
|
|
||||||
inputHandler = new TestInputHandler(bufferService, new MockCharsetService(), coreService, new MockDirtyRowService(), new MockLogService(), optionsService, new MockCoreMouseService(), new MockUnicodeService());
|
inputHandler = new TestInputHandler(bufferService, new MockCharsetService(), coreService, new MockDirtyRowService(), new MockLogService(), optionsService, new MockOscLinkService(), new MockCoreMouseService(), new MockUnicodeService());
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('SL/SR/DECIC/DECDC', () => {
|
describe('SL/SR/DECIC/DECDC', () => {
|
||||||
@@ -236,7 +236,7 @@ describe('InputHandler', () => {
|
|||||||
describe('setMode', () => {
|
describe('setMode', () => {
|
||||||
it('should toggle bracketedPasteMode', () => {
|
it('should toggle bracketedPasteMode', () => {
|
||||||
const coreService = new MockCoreService();
|
const coreService = new MockCoreService();
|
||||||
const inputHandler = new TestInputHandler(new MockBufferService(80, 30), new MockCharsetService(), coreService, new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService());
|
const inputHandler = new TestInputHandler(new MockBufferService(80, 30), new MockCharsetService(), coreService, new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockOscLinkService(), new MockCoreMouseService(), new MockUnicodeService());
|
||||||
// Set bracketed paste mode
|
// Set bracketed paste mode
|
||||||
inputHandler.setModePrivate(Params.fromArray([2004]));
|
inputHandler.setModePrivate(Params.fromArray([2004]));
|
||||||
assert.equal(coreService.decPrivateModes.bracketedPasteMode, true);
|
assert.equal(coreService.decPrivateModes.bracketedPasteMode, true);
|
||||||
@@ -261,6 +261,7 @@ describe('InputHandler', () => {
|
|||||||
new MockDirtyRowService(),
|
new MockDirtyRowService(),
|
||||||
new MockLogService(),
|
new MockLogService(),
|
||||||
new MockOptionsService(),
|
new MockOptionsService(),
|
||||||
|
new MockOscLinkService(),
|
||||||
new MockCoreMouseService(),
|
new MockCoreMouseService(),
|
||||||
new MockUnicodeService()
|
new MockUnicodeService()
|
||||||
);
|
);
|
||||||
@@ -307,6 +308,7 @@ describe('InputHandler', () => {
|
|||||||
new MockDirtyRowService(),
|
new MockDirtyRowService(),
|
||||||
new MockLogService(),
|
new MockLogService(),
|
||||||
new MockOptionsService(),
|
new MockOptionsService(),
|
||||||
|
new MockOscLinkService(),
|
||||||
new MockCoreMouseService(),
|
new MockCoreMouseService(),
|
||||||
new MockUnicodeService()
|
new MockUnicodeService()
|
||||||
);
|
);
|
||||||
@@ -357,6 +359,7 @@ describe('InputHandler', () => {
|
|||||||
new MockDirtyRowService(),
|
new MockDirtyRowService(),
|
||||||
new MockLogService(),
|
new MockLogService(),
|
||||||
new MockOptionsService(),
|
new MockOptionsService(),
|
||||||
|
new MockOscLinkService(),
|
||||||
new MockCoreMouseService(),
|
new MockCoreMouseService(),
|
||||||
new MockUnicodeService()
|
new MockUnicodeService()
|
||||||
);
|
);
|
||||||
@@ -394,6 +397,7 @@ describe('InputHandler', () => {
|
|||||||
new MockDirtyRowService(),
|
new MockDirtyRowService(),
|
||||||
new MockLogService(),
|
new MockLogService(),
|
||||||
new MockOptionsService(),
|
new MockOptionsService(),
|
||||||
|
new MockOscLinkService(),
|
||||||
new MockCoreMouseService(),
|
new MockCoreMouseService(),
|
||||||
new MockUnicodeService()
|
new MockUnicodeService()
|
||||||
);
|
);
|
||||||
@@ -444,6 +448,7 @@ describe('InputHandler', () => {
|
|||||||
new MockDirtyRowService(),
|
new MockDirtyRowService(),
|
||||||
new MockLogService(),
|
new MockLogService(),
|
||||||
new MockOptionsService(),
|
new MockOptionsService(),
|
||||||
|
new MockOscLinkService(),
|
||||||
new MockCoreMouseService(),
|
new MockCoreMouseService(),
|
||||||
new MockUnicodeService()
|
new MockUnicodeService()
|
||||||
);
|
);
|
||||||
@@ -570,6 +575,7 @@ describe('InputHandler', () => {
|
|||||||
new MockDirtyRowService(),
|
new MockDirtyRowService(),
|
||||||
new MockLogService(),
|
new MockLogService(),
|
||||||
new MockOptionsService(),
|
new MockOptionsService(),
|
||||||
|
new MockOscLinkService(),
|
||||||
new MockCoreMouseService(),
|
new MockCoreMouseService(),
|
||||||
new MockUnicodeService()
|
new MockUnicodeService()
|
||||||
);
|
);
|
||||||
@@ -593,7 +599,7 @@ describe('InputHandler', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
bufferService = new MockBufferService(80, 30);
|
bufferService = new MockBufferService(80, 30);
|
||||||
handler = new TestInputHandler(bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockCoreMouseService(), new MockUnicodeService());
|
handler = new TestInputHandler(bufferService, new MockCharsetService(), new MockCoreService(), new MockDirtyRowService(), new MockLogService(), new MockOptionsService(), new MockOscLinkService(), new MockCoreMouseService(), new MockUnicodeService());
|
||||||
});
|
});
|
||||||
it('should handle DECSET/DECRST 47 (alt screen buffer)', async () => {
|
it('should handle DECSET/DECRST 47 (alt screen buffer)', async () => {
|
||||||
await handler.parseP('\x1b[?47h\r\n\x1b[31mJUNK\x1b[?47lTEST');
|
await handler.parseP('\x1b[?47h\r\n\x1b[31mJUNK\x1b[?47lTEST');
|
||||||
@@ -790,7 +796,7 @@ describe('InputHandler', () => {
|
|||||||
describe('colon notation', () => {
|
describe('colon notation', () => {
|
||||||
let inputHandler2: TestInputHandler;
|
let inputHandler2: TestInputHandler;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
inputHandler2 = new TestInputHandler(bufferService, new MockCharsetService(), coreService, new MockDirtyRowService(), new MockLogService(), optionsService, new MockCoreMouseService(), new MockUnicodeService());
|
inputHandler2 = new TestInputHandler(bufferService, new MockCharsetService(), coreService, new MockDirtyRowService(), new MockLogService(), optionsService, new MockOscLinkService(), new MockCoreMouseService(), new MockUnicodeService());
|
||||||
});
|
});
|
||||||
describe('should equal to semicolon', () => {
|
describe('should equal to semicolon', () => {
|
||||||
it('CSI 38:2::50:100:150 m', async () => {
|
it('CSI 38:2::50:100:150 m', async () => {
|
||||||
@@ -2156,7 +2162,7 @@ describe('InputHandler - async handlers', () => {
|
|||||||
coreService = new CoreService(() => { }, bufferService, new MockLogService(), optionsService);
|
coreService = new CoreService(() => { }, bufferService, new MockLogService(), optionsService);
|
||||||
coreService.onData(data => { console.log(data); });
|
coreService.onData(data => { console.log(data); });
|
||||||
|
|
||||||
inputHandler = new TestInputHandler(bufferService, new MockCharsetService(), coreService, new MockDirtyRowService(), new MockLogService(), optionsService, new MockCoreMouseService(), new MockUnicodeService());
|
inputHandler = new TestInputHandler(bufferService, new MockCharsetService(), coreService, new MockDirtyRowService(), new MockLogService(), optionsService, new MockOscLinkService(), new MockCoreMouseService(), new MockUnicodeService());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('async CUP with CPR check', async () => {
|
it('async CUP with CPR check', async () => {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { IParsingState, IDcsHandler, IEscapeSequenceParser, IParams, IFunctionId
|
|||||||
import { NULL_CELL_CODE, NULL_CELL_WIDTH, Attributes, FgFlags, BgFlags, Content, UnderlineStyle } from 'common/buffer/Constants';
|
import { NULL_CELL_CODE, NULL_CELL_WIDTH, Attributes, FgFlags, BgFlags, Content, UnderlineStyle } from 'common/buffer/Constants';
|
||||||
import { CellData } from 'common/buffer/CellData';
|
import { CellData } from 'common/buffer/CellData';
|
||||||
import { AttributeData } from 'common/buffer/AttributeData';
|
import { AttributeData } from 'common/buffer/AttributeData';
|
||||||
import { ICoreService, IBufferService, IOptionsService, ILogService, IDirtyRowService, ICoreMouseService, ICharsetService, IUnicodeService, LogLevelEnum } from 'common/services/Services';
|
import { ICoreService, IBufferService, IOptionsService, ILogService, IDirtyRowService, ICoreMouseService, ICharsetService, IUnicodeService, LogLevelEnum, IOscLinkService } from 'common/services/Services';
|
||||||
import { OscHandler } from 'common/parser/OscParser';
|
import { OscHandler } from 'common/parser/OscParser';
|
||||||
import { DcsHandler } from 'common/parser/DcsParser';
|
import { DcsHandler } from 'common/parser/DcsParser';
|
||||||
import { IBuffer } from 'common/buffer/Types';
|
import { IBuffer } from 'common/buffer/Types';
|
||||||
@@ -264,10 +264,6 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|||||||
public get onTitleChange(): IEvent<string> { return this._onTitleChange.event; }
|
public get onTitleChange(): IEvent<string> { return this._onTitleChange.event; }
|
||||||
private _onColor = new EventEmitter<IColorEvent>();
|
private _onColor = new EventEmitter<IColorEvent>();
|
||||||
public get onColor(): IEvent<IColorEvent> { return this._onColor.event; }
|
public get onColor(): IEvent<IColorEvent> { return this._onColor.event; }
|
||||||
private _onStartHyperlink = new EventEmitter<IOscLinkData>();
|
|
||||||
public get onStartHyperlink(): IEvent<IOscLinkData> { return this._onStartHyperlink.event; }
|
|
||||||
private _onFinishHyperlink = new EventEmitter<void>();
|
|
||||||
public get onFinishHyperlink(): IEvent<void> { return this._onFinishHyperlink.event; }
|
|
||||||
|
|
||||||
private _parseStack: IParseStack = {
|
private _parseStack: IParseStack = {
|
||||||
paused: false,
|
paused: false,
|
||||||
@@ -284,6 +280,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|||||||
private readonly _dirtyRowService: IDirtyRowService,
|
private readonly _dirtyRowService: IDirtyRowService,
|
||||||
private readonly _logService: ILogService,
|
private readonly _logService: ILogService,
|
||||||
private readonly _optionsService: IOptionsService,
|
private readonly _optionsService: IOptionsService,
|
||||||
|
private readonly _oscLinkService: IOscLinkService,
|
||||||
private readonly _coreMouseService: ICoreMouseService,
|
private readonly _coreMouseService: ICoreMouseService,
|
||||||
private readonly _unicodeService: IUnicodeService,
|
private readonly _unicodeService: IUnicodeService,
|
||||||
private readonly _parser: IEscapeSequenceParser = new EscapeSequenceParser()
|
private readonly _parser: IEscapeSequenceParser = new EscapeSequenceParser()
|
||||||
@@ -2937,11 +2934,10 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|||||||
id = parsedParams[idParamIndex].slice(3) || undefined;
|
id = parsedParams[idParamIndex].slice(3) || undefined;
|
||||||
}
|
}
|
||||||
this._currentHyperlink = { id, uri };
|
this._currentHyperlink = { id, uri };
|
||||||
console.log('start hyperlink');
|
this._oscLinkService.registerLink(this._currentHyperlink);
|
||||||
this._curAttrData.extended = this._curAttrData.extended.clone();
|
this._curAttrData.extended = this._curAttrData.extended.clone();
|
||||||
this._curAttrData.extended.urlId = 1;
|
this._curAttrData.extended.urlId = 1;
|
||||||
this._curAttrData.updateExtended();
|
this._curAttrData.updateExtended();
|
||||||
this._onStartHyperlink.fire(this._currentHyperlink);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2950,7 +2946,6 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|||||||
this._curAttrData.extended = this._curAttrData.extended.clone();
|
this._curAttrData.extended = this._curAttrData.extended.clone();
|
||||||
this._curAttrData.extended.urlId = 0;
|
this._curAttrData.extended.urlId = 0;
|
||||||
this._curAttrData.updateExtended();
|
this._curAttrData.updateExtended();
|
||||||
this._onFinishHyperlink.fire();
|
|
||||||
this._currentHyperlink = undefined;
|
this._currentHyperlink = undefined;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { IBufferService, ICoreService, ILogService, IOptionsService, ITerminalOptions, IDirtyRowService, ICoreMouseService, ICharsetService, IUnicodeService, IUnicodeVersionProvider, LogLevelEnum, IDecorationService, IInternalDecoration } from 'common/services/Services';
|
import { IBufferService, ICoreService, ILogService, IOptionsService, ITerminalOptions, IDirtyRowService, ICoreMouseService, ICharsetService, IUnicodeService, IUnicodeVersionProvider, LogLevelEnum, IDecorationService, IInternalDecoration, IOscLinkService } from 'common/services/Services';
|
||||||
import { IEvent, EventEmitter } from 'common/EventEmitter';
|
import { IEvent, EventEmitter } from 'common/EventEmitter';
|
||||||
import { clone } from 'common/Clone';
|
import { clone } from 'common/Clone';
|
||||||
import { DEFAULT_OPTIONS } from 'common/services/OptionsService';
|
import { DEFAULT_OPTIONS } from 'common/services/OptionsService';
|
||||||
import { IBufferSet, IBuffer } from 'common/buffer/Types';
|
import { IBufferSet, IBuffer } from 'common/buffer/Types';
|
||||||
import { BufferSet } from 'common/buffer/BufferSet';
|
import { BufferSet } from 'common/buffer/BufferSet';
|
||||||
import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEventType, ICharset, IModes, IAttributeData } from 'common/Types';
|
import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEventType, ICharset, IModes, IAttributeData, IOscLinkData } from 'common/Types';
|
||||||
import { UnicodeV6 } from 'common/input/UnicodeV6';
|
import { UnicodeV6 } from 'common/input/UnicodeV6';
|
||||||
import { IDecorationOptions, IDecoration } from 'xterm';
|
import { IDecorationOptions, IDecoration } from 'xterm';
|
||||||
|
|
||||||
@@ -138,6 +138,16 @@ export class MockOptionsService implements IOptionsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class MockOscLinkService implements IOscLinkService {
|
||||||
|
public serviceBrand: any;
|
||||||
|
public registerLink(linkData: IOscLinkData): number {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
public getLinkData(linkId: number): IOscLinkData | undefined {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// defaults to V6 always to keep tests passing
|
// defaults to V6 always to keep tests passing
|
||||||
export class MockUnicodeService implements IUnicodeService {
|
export class MockUnicodeService implements IUnicodeService {
|
||||||
public serviceBrand: any;
|
public serviceBrand: any;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export class OscLinkService implements IOscLinkService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public registerLink(linkData: IOscLinkData): number {
|
public registerLink(linkData: IOscLinkData): number {
|
||||||
|
console.log('register link');
|
||||||
// TODO: Add and return properly
|
// TODO: Add and return properly
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user