Merge from vscode e0762af258c0b20320ed03f3871a41967acc4421 (#7404)

* Merge from vscode e0762af258c0b20320ed03f3871a41967acc4421

* readd svgs
This commit is contained in:
Anthony Dresser
2019-09-27 11:13:19 -07:00
committed by GitHub
parent 6385443a4c
commit 07109617b5
348 changed files with 4219 additions and 4307 deletions

View File

@@ -14,9 +14,14 @@ import { Color, RGBA } from 'vs/base/common/color';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { TestThemeService, TestTheme } from 'vs/platform/theme/test/common/testThemeService';
import { ansiColorMap } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry';
import { DebugModel } from 'vs/workbench/contrib/debug/common/debugModel';
import { DebugSession } from 'vs/workbench/contrib/debug/browser/debugSession';
import { NullOpenerService } from 'vs/platform/opener/common/opener';
suite('Debug - ANSI Handling', () => {
let model: DebugModel;
let session: DebugSession;
let linkDetector: LinkDetector;
let themeService: IThemeService;
@@ -24,6 +29,9 @@ suite('Debug - ANSI Handling', () => {
* Instantiate services for use by the functions being tested.
*/
setup(() => {
model = new DebugModel([], [], [], [], [], <any>{ isDirty: (e: any) => false });
session = new DebugSession({ resolved: { name, type: 'node', request: 'launch' }, unresolved: undefined }, undefined!, model, undefined, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, NullOpenerService);
const instantiationService: TestInstantiationService = <TestInstantiationService>workbenchInstantiationService();
linkDetector = instantiationService.createInstance(LinkDetector);

View File

@@ -464,11 +464,12 @@ suite('Debug - Model', () => {
// Repl output
test('repl output', () => {
const session = createMockSession(model);
const repl = new ReplModel();
repl.appendToRepl('first line\n', severity.Error);
repl.appendToRepl('second line ', severity.Error);
repl.appendToRepl('third line ', severity.Error);
repl.appendToRepl('fourth line', severity.Error);
repl.appendToRepl(session, 'first line\n', severity.Error);
repl.appendToRepl(session, 'second line ', severity.Error);
repl.appendToRepl(session, 'third line ', severity.Error);
repl.appendToRepl(session, 'fourth line', severity.Error);
let elements = <SimpleReplElement[]>repl.getReplElements();
assert.equal(elements.length, 2);
@@ -477,14 +478,14 @@ suite('Debug - Model', () => {
assert.equal(elements[1].value, 'second line third line fourth line');
assert.equal(elements[1].severity, severity.Error);
repl.appendToRepl('1', severity.Warning);
repl.appendToRepl(session, '1', severity.Warning);
elements = <SimpleReplElement[]>repl.getReplElements();
assert.equal(elements.length, 3);
assert.equal(elements[2].value, '1');
assert.equal(elements[2].severity, severity.Warning);
const keyValueObject = { 'key1': 2, 'key2': 'value' };
repl.appendToRepl(new RawObjectReplElement('fakeid', 'fake', keyValueObject), severity.Info);
repl.appendToRepl(session, new RawObjectReplElement('fakeid', 'fake', keyValueObject), severity.Info);
const element = <RawObjectReplElement>repl.getReplElements()[3];
assert.equal(element.value, 'Object');
assert.deepEqual(element.valueObj, keyValueObject);
@@ -492,11 +493,11 @@ suite('Debug - Model', () => {
repl.removeReplExpressions();
assert.equal(repl.getReplElements().length, 0);
repl.appendToRepl('1\n', severity.Info);
repl.appendToRepl('2', severity.Info);
repl.appendToRepl('3\n4', severity.Info);
repl.appendToRepl('5\n', severity.Info);
repl.appendToRepl('6', severity.Info);
repl.appendToRepl(session, '1\n', severity.Info);
repl.appendToRepl(session, '2', severity.Info);
repl.appendToRepl(session, '3\n4', severity.Info);
repl.appendToRepl(session, '5\n', severity.Info);
repl.appendToRepl(session, '6', severity.Info);
elements = <SimpleReplElement[]>repl.getReplElements();
assert.equal(elements.length, 3);
assert.equal(elements[0], '1\n');
@@ -512,7 +513,11 @@ suite('Debug - Model', () => {
const grandChild = createMockSession(model, 'grandChild', { parentSession: child2, repl: 'mergeWithParent' });
const child3 = createMockSession(model, 'child3', { parentSession: parent });
let parentChanges = 0;
parent.onDidChangeReplElements(() => ++parentChanges);
parent.appendToRepl('1\n', severity.Info);
assert.equal(parentChanges, 1);
assert.equal(parent.getReplElements().length, 1);
assert.equal(child1.getReplElements().length, 0);
assert.equal(child2.getReplElements().length, 1);
@@ -520,6 +525,7 @@ suite('Debug - Model', () => {
assert.equal(child3.getReplElements().length, 0);
grandChild.appendToRepl('1\n', severity.Info);
assert.equal(parentChanges, 2);
assert.equal(parent.getReplElements().length, 2);
assert.equal(child1.getReplElements().length, 0);
assert.equal(child2.getReplElements().length, 2);
@@ -527,6 +533,7 @@ suite('Debug - Model', () => {
assert.equal(child3.getReplElements().length, 0);
child3.appendToRepl('1\n', severity.Info);
assert.equal(parentChanges, 2);
assert.equal(parent.getReplElements().length, 2);
assert.equal(child1.getReplElements().length, 0);
assert.equal(child2.getReplElements().length, 2);
@@ -534,6 +541,7 @@ suite('Debug - Model', () => {
assert.equal(child3.getReplElements().length, 1);
child1.appendToRepl('1\n', severity.Info);
assert.equal(parentChanges, 2);
assert.equal(parent.getReplElements().length, 2);
assert.equal(child1.getReplElements().length, 1);
assert.equal(child2.getReplElements().length, 2);

View File

@@ -8,6 +8,8 @@ import { TestInstantiationService } from 'vs/platform/instantiation/test/common/
import { workbenchInstantiationService } from 'vs/workbench/test/workbenchTestServices';
import { LinkDetector } from 'vs/workbench/contrib/debug/browser/linkDetector';
import { isWindows } from 'vs/base/common/platform';
import { WorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { URI } from 'vs/base/common/uri';
suite('Debug - Link Detector', () => {
@@ -22,19 +24,18 @@ suite('Debug - Link Detector', () => {
});
/**
* Assert that a given Element is an anchor element with an onClick event.
* Assert that a given Element is an anchor element.
*
* @param element The Element to verify.
*/
function assertElementIsLink(element: Element) {
assert(element instanceof HTMLAnchorElement);
assert.notEqual(null, (element as HTMLAnchorElement).onclick);
}
test('noLinks', () => {
const input = 'I am a string';
const expectedOutput = '<span>I am a string</span>';
const output = linkDetector.handleLinks(input);
const output = linkDetector.linkify(input);
assert.equal(0, output.children.length);
assert.equal('SPAN', output.tagName);
@@ -44,7 +45,17 @@ suite('Debug - Link Detector', () => {
test('trailingNewline', () => {
const input = 'I am a string\n';
const expectedOutput = '<span>I am a string\n</span>';
const output = linkDetector.handleLinks(input);
const output = linkDetector.linkify(input);
assert.equal(0, output.children.length);
assert.equal('SPAN', output.tagName);
assert.equal(expectedOutput, output.outerHTML);
});
test('trailingNewlineSplit', () => {
const input = 'I am a string\n';
const expectedOutput = '<span>I am a string\n</span>';
const output = linkDetector.linkify(input, true);
assert.equal(0, output.children.length);
assert.equal('SPAN', output.tagName);
@@ -52,65 +63,71 @@ suite('Debug - Link Detector', () => {
});
test('singleLineLink', () => {
const input = isWindows ? 'C:/foo/bar.js:12:34' : '/Users/foo/bar.js:12:34';
const expectedOutput = /^<span><a title=".*">.*\/foo\/bar.js:12:34<\/a><\/span>$/;
const output = linkDetector.handleLinks(input);
const input = isWindows ? 'C:\\foo\\bar.js:12:34' : '/Users/foo/bar.js:12:34';
const expectedOutput = isWindows ? '<span><a>C:\\foo\\bar.js:12:34<\/a><\/span>' : '<span><a>/Users/foo/bar.js:12:34<\/a><\/span>';
const output = linkDetector.linkify(input);
assert.equal(1, output.children.length);
assert.equal('SPAN', output.tagName);
assert.equal('A', output.firstElementChild!.tagName);
assert(expectedOutput.test(output.outerHTML));
assert.equal(expectedOutput, output.outerHTML);
assertElementIsLink(output.firstElementChild!);
assert.equal(isWindows ? 'C:/foo/bar.js:12:34' : '/Users/foo/bar.js:12:34', output.firstElementChild!.textContent);
assert.equal(isWindows ? 'C:\\foo\\bar.js:12:34' : '/Users/foo/bar.js:12:34', output.firstElementChild!.textContent);
});
test('relativeLink', () => {
const input = '\./foo/bar.js';
const expectedOutput = '<span>\./foo/bar.js</span>';
const output = linkDetector.handleLinks(input);
const output = linkDetector.linkify(input);
assert.equal(0, output.children.length);
assert.equal('SPAN', output.tagName);
assert.equal(expectedOutput, output.outerHTML);
});
test('relativeLinkWithWorkspace', () => {
const input = '\./foo/bar.js';
const expectedOutput = /^<span><a class="link" title=".*">\.\/foo\/bar\.js<\/a><\/span>$/;
const output = linkDetector.linkify(input, false, new WorkspaceFolder({ uri: URI.file('/path/to/workspace'), name: 'ws', index: 0 }));
assert.equal('SPAN', output.tagName);
assert(expectedOutput.test(output.outerHTML));
});
test('singleLineLinkAndText', function () {
const input = isWindows ? 'The link: C:/foo/bar.js:12:34' : 'The link: /Users/foo/bar.js:12:34';
const expectedOutput = /^<span><span>The link: <\/span><a title=".*">.*\/foo\/bar.js:12:34<\/a><\/span>$/;
const output = linkDetector.handleLinks(input);
const expectedOutput = /^<span>The link: <a>.*\/foo\/bar.js:12:34<\/a><\/span>$/;
const output = linkDetector.linkify(input);
assert.equal(2, output.children.length);
assert.equal(1, output.children.length);
assert.equal('SPAN', output.tagName);
assert.equal('SPAN', output.children[0].tagName);
assert.equal('A', output.children[1].tagName);
assert.equal('A', output.children[0].tagName);
assert(expectedOutput.test(output.outerHTML));
assertElementIsLink(output.children[1]);
assert.equal(isWindows ? 'C:/foo/bar.js:12:34' : '/Users/foo/bar.js:12:34', output.children[1].textContent);
assertElementIsLink(output.children[0]);
assert.equal(isWindows ? 'C:/foo/bar.js:12:34' : '/Users/foo/bar.js:12:34', output.children[0].textContent);
});
test('singleLineMultipleLinks', () => {
const input = isWindows ? 'Here is a link C:/foo/bar.js:12:34 and here is another D:/boo/far.js:56:78' :
'Here is a link /Users/foo/bar.js:12:34 and here is another /Users/boo/far.js:56:78';
const expectedOutput = /^<span><span>Here is a link <\/span><a title=".*">.*\/foo\/bar.js:12:34<\/a><span> and here is another <\/span><a title=".*">.*\/boo\/far.js:56:78<\/a><\/span>$/;
const output = linkDetector.handleLinks(input);
const expectedOutput = /^<span>Here is a link <a>.*\/foo\/bar.js:12:34<\/a> and here is another <a>.*\/boo\/far.js:56:78<\/a><\/span>$/;
const output = linkDetector.linkify(input);
assert.equal(4, output.children.length);
assert.equal(2, output.children.length);
assert.equal('SPAN', output.tagName);
assert.equal('SPAN', output.children[0].tagName);
assert.equal('A', output.children[0].tagName);
assert.equal('A', output.children[1].tagName);
assert.equal('SPAN', output.children[2].tagName);
assert.equal('A', output.children[3].tagName);
assert(expectedOutput.test(output.outerHTML));
assertElementIsLink(output.children[0]);
assertElementIsLink(output.children[1]);
assertElementIsLink(output.children[3]);
assert.equal(isWindows ? 'C:/foo/bar.js:12:34' : '/Users/foo/bar.js:12:34', output.children[1].textContent);
assert.equal(isWindows ? 'D:/boo/far.js:56:78' : '/Users/boo/far.js:56:78', output.children[3].textContent);
assert.equal(isWindows ? 'C:/foo/bar.js:12:34' : '/Users/foo/bar.js:12:34', output.children[0].textContent);
assert.equal(isWindows ? 'D:/boo/far.js:56:78' : '/Users/boo/far.js:56:78', output.children[1].textContent);
});
test('multilineNoLinks', () => {
const input = 'Line one\nLine two\nLine three';
const expectedOutput = /^<span><span>Line one\n<\/span><span>Line two\n<\/span><span>Line three<\/span><\/span>$/;
const output = linkDetector.handleLinks(input);
const output = linkDetector.linkify(input, true);
assert.equal(3, output.children.length);
assert.equal('SPAN', output.tagName);
@@ -123,7 +140,7 @@ suite('Debug - Link Detector', () => {
test('multilineTrailingNewline', () => {
const input = 'I am a string\nAnd I am another\n';
const expectedOutput = '<span><span>I am a string\n<\/span><span>And I am another\n<\/span><\/span>';
const output = linkDetector.handleLinks(input);
const output = linkDetector.linkify(input, true);
assert.equal(2, output.children.length);
assert.equal('SPAN', output.tagName);
@@ -135,19 +152,17 @@ suite('Debug - Link Detector', () => {
test('multilineWithLinks', () => {
const input = isWindows ? 'I have a link for you\nHere it is: C:/foo/bar.js:12:34\nCool, huh?' :
'I have a link for you\nHere it is: /Users/foo/bar.js:12:34\nCool, huh?';
const expectedOutput = /^<span><span>I have a link for you\n<\/span><span><span>Here it is: <\/span><a title=".*">.*\/foo\/bar.js:12:34<\/a><span>\n<\/span><\/span><span>Cool, huh\?<\/span><\/span>$/;
const output = linkDetector.handleLinks(input);
const expectedOutput = /^<span><span>I have a link for you\n<\/span><span>Here it is: <a>.*\/foo\/bar.js:12:34<\/a>\n<\/span><span>Cool, huh\?<\/span><\/span>$/;
const output = linkDetector.linkify(input, true);
assert.equal(3, output.children.length);
assert.equal('SPAN', output.tagName);
assert.equal('SPAN', output.children[0].tagName);
assert.equal('SPAN', output.children[1].tagName);
assert.equal('SPAN', output.children[2].tagName);
assert.equal('SPAN', output.children[1].children[0].tagName);
assert.equal('A', output.children[1].children[1].tagName);
assert.equal('SPAN', output.children[1].children[2].tagName);
assert.equal('A', output.children[1].children[0].tagName);
assert(expectedOutput.test(output.outerHTML));
assertElementIsLink(output.children[1].children[1]);
assert.equal(isWindows ? 'C:/foo/bar.js:12:34' : '/Users/foo/bar.js:12:34', output.children[1].children[1].textContent);
assertElementIsLink(output.children[1].children[0]);
assert.equal(isWindows ? 'C:/foo/bar.js:12:34' : '/Users/foo/bar.js:12:34', output.children[1].children[0].textContent);
});
});