@theia/test 1.45.1 → 1.46.0-next.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/lib/browser/constants.d.ts +45 -45
  2. package/lib/browser/constants.js +17 -17
  3. package/lib/browser/test-service.d.ts +154 -154
  4. package/lib/browser/test-service.js +247 -247
  5. package/lib/browser/view/test-context-key-service.d.ts +7 -7
  6. package/lib/browser/view/test-context-key-service.js +51 -51
  7. package/lib/browser/view/test-execution-state-manager.d.ts +13 -13
  8. package/lib/browser/view/test-execution-state-manager.js +173 -173
  9. package/lib/browser/view/test-output-ui-model.d.ts +47 -47
  10. package/lib/browser/view/test-output-ui-model.js +151 -151
  11. package/lib/browser/view/test-output-view-contribution.d.ts +5 -5
  12. package/lib/browser/view/test-output-view-contribution.js +47 -47
  13. package/lib/browser/view/test-output-widget.d.ts +24 -24
  14. package/lib/browser/view/test-output-widget.js +158 -158
  15. package/lib/browser/view/test-result-view-contribution.d.ts +5 -5
  16. package/lib/browser/view/test-result-view-contribution.js +47 -47
  17. package/lib/browser/view/test-result-widget.d.ts +20 -20
  18. package/lib/browser/view/test-result-widget.js +108 -108
  19. package/lib/browser/view/test-run-view-contribution.d.ts +17 -17
  20. package/lib/browser/view/test-run-view-contribution.js +100 -100
  21. package/lib/browser/view/test-run-widget.d.ts +58 -58
  22. package/lib/browser/view/test-run-widget.js +310 -310
  23. package/lib/browser/view/test-tree-widget.d.ts +67 -67
  24. package/lib/browser/view/test-tree-widget.js +386 -386
  25. package/lib/browser/view/test-view-contribution.d.ts +45 -45
  26. package/lib/browser/view/test-view-contribution.js +288 -288
  27. package/lib/browser/view/test-view-frontend-module.d.ts +6 -6
  28. package/lib/browser/view/test-view-frontend-module.js +121 -121
  29. package/lib/common/collections.d.ts +46 -46
  30. package/lib/common/collections.js +210 -210
  31. package/lib/common/tree-delta.d.ts +51 -51
  32. package/lib/common/tree-delta.js +240 -240
  33. package/lib/common/tree-delta.spec.d.ts +1 -1
  34. package/lib/common/tree-delta.spec.js +139 -139
  35. package/package.json +8 -8
  36. package/src/browser/constants.ts +71 -71
  37. package/src/browser/style/index.css +41 -41
  38. package/src/browser/test-service.ts +355 -355
  39. package/src/browser/view/test-context-key-service.ts +36 -36
  40. package/src/browser/view/test-execution-state-manager.ts +147 -147
  41. package/src/browser/view/test-output-ui-model.ts +156 -156
  42. package/src/browser/view/test-output-view-contribution.ts +34 -34
  43. package/src/browser/view/test-output-widget.ts +148 -148
  44. package/src/browser/view/test-result-view-contribution.ts +34 -34
  45. package/src/browser/view/test-result-widget.ts +92 -92
  46. package/src/browser/view/test-run-view-contribution.ts +89 -89
  47. package/src/browser/view/test-run-widget.tsx +271 -271
  48. package/src/browser/view/test-tree-widget.tsx +360 -360
  49. package/src/browser/view/test-view-contribution.ts +300 -300
  50. package/src/browser/view/test-view-frontend-module.ts +134 -134
  51. package/src/common/collections.ts +223 -223
  52. package/src/common/tree-delta.spec.ts +166 -166
  53. package/src/common/tree-delta.ts +259 -259
@@ -1,148 +1,148 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2023 STMicroelectronics and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
- import { RendererType, Terminal } from 'xterm';
17
- import { FitAddon } from 'xterm-addon-fit';
18
-
19
- import { BaseWidget, Message, Widget, codicon, isFirefox } from '@theia/core/lib/browser';
20
- import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
21
- import { Disposable, DisposableCollection } from '@theia/core';
22
- import { DEFAULT_TERMINAL_RENDERER_TYPE, TerminalPreferences, TerminalRendererType, isTerminalRendererType } from '@theia/terminal/lib/browser/terminal-preferences';
23
- import { TerminalThemeService } from '@theia/terminal/lib/browser/terminal-theme-service';
24
- import { TestOutputSource, TestOutputUIModel } from './test-output-ui-model';
25
- import debounce = require('p-debounce');
26
-
27
- @injectable()
28
- export class TestOutputWidget extends BaseWidget {
29
- @inject(TerminalPreferences) protected readonly preferences: TerminalPreferences;
30
- @inject(TerminalThemeService) protected readonly themeService: TerminalThemeService;
31
- @inject(TestOutputUIModel) protected readonly uiModel: TestOutputUIModel;
32
-
33
- static ID = 'test-output-view';
34
-
35
- protected term: Terminal;
36
- protected disposeOnSetInput = new DisposableCollection();
37
- protected fitAddon: FitAddon;
38
-
39
- constructor() {
40
- super();
41
-
42
- this.id = TestOutputWidget.ID;
43
- this.title.label = 'Test Output';
44
- this.title.caption = 'Test Output';
45
- this.title.iconClass = codicon('symbol-keyword');
46
- this.title.closable = true;
47
- }
48
-
49
- @postConstruct()
50
- init(): void {
51
- this.term = new Terminal({
52
- disableStdin: true,
53
- cursorStyle: 'bar',
54
- fontFamily: this.preferences['terminal.integrated.fontFamily'],
55
- fontSize: this.preferences['terminal.integrated.fontSize'],
56
- fontWeight: this.preferences['terminal.integrated.fontWeight'],
57
- fontWeightBold: this.preferences['terminal.integrated.fontWeightBold'],
58
- drawBoldTextInBrightColors: this.preferences['terminal.integrated.drawBoldTextInBrightColors'],
59
- letterSpacing: this.preferences['terminal.integrated.letterSpacing'],
60
- lineHeight: this.preferences['terminal.integrated.lineHeight'],
61
- scrollback: this.preferences['terminal.integrated.scrollback'],
62
- fastScrollSensitivity: this.preferences['terminal.integrated.fastScrollSensitivity'],
63
- rendererType: this.getTerminalRendererType(this.preferences['terminal.integrated.rendererType']),
64
- theme: this.themeService.theme
65
- });
66
-
67
- this.fitAddon = new FitAddon();
68
- this.term.loadAddon(this.fitAddon);
69
- this.setInput(this.uiModel.selectedOutputSource);
70
- this.uiModel.onDidChangeSelectedOutputSource(source => this.setInput(source));
71
-
72
- this.toDispose.push(Disposable.create(() =>
73
- this.term.dispose()
74
- ));
75
- }
76
-
77
- setInput(selectedOutputSource: TestOutputSource | undefined): void {
78
- this.disposeOnSetInput.dispose();
79
- this.disposeOnSetInput = new DisposableCollection();
80
- this.term.clear();
81
- if (selectedOutputSource) {
82
- selectedOutputSource.output.forEach(item => this.term.writeln(item.output));
83
- this.disposeOnSetInput.push(selectedOutputSource.onDidAddTestOutput(items => {
84
- items.forEach(item => this.term.writeln(item.output));
85
- }));
86
- this.term.scrollToBottom();
87
- }
88
- }
89
-
90
- protected override onAfterAttach(msg: Message): void {
91
- super.onAfterAttach(msg);
92
- this.term.open(this.node);
93
-
94
- if (isFirefox) {
95
- // monkey patching intersection observer handling for secondary window support
96
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
97
- const renderService: any = (this.term as any)._core._renderService;
98
- const originalFunc: (entry: IntersectionObserverEntry) => void = renderService._onIntersectionChange.bind(renderService);
99
- const replacement = function (entry: IntersectionObserverEntry): void {
100
- if (entry.target.ownerDocument !== document) {
101
- // in Firefox, the intersection observer always reports the widget as non-intersecting if the dom element
102
- // is in a different document from when the IntersectionObserver started observing. Since we know
103
- // that the widget is always "visible" when in a secondary window, so we mark the entry as "intersecting"
104
- const patchedEvent: IntersectionObserverEntry = {
105
- ...entry,
106
- isIntersecting: true,
107
- };
108
- originalFunc(patchedEvent);
109
- } else {
110
- originalFunc(entry);
111
- }
112
- };
113
-
114
- renderService._onIntersectionChange = replacement;
115
- }
116
-
117
- if (isFirefox) {
118
- // The software scrollbars don't work with xterm.js, so we disable the scrollbar if we are on firefox.
119
- if (this.term.element) {
120
- (this.term.element.children.item(0) as HTMLElement).style.overflow = 'hidden';
121
- }
122
- }
123
- }
124
-
125
- private getTerminalRendererType(terminalRendererType?: string | TerminalRendererType): RendererType {
126
- if (terminalRendererType && isTerminalRendererType(terminalRendererType)) {
127
- return terminalRendererType;
128
- }
129
- return DEFAULT_TERMINAL_RENDERER_TYPE;
130
- }
131
-
132
- protected override onResize(msg: Widget.ResizeMessage): void {
133
- super.onResize(msg);
134
- this.resizeTerminal();
135
- }
136
-
137
- protected resizeTerminal = debounce(() => this.doResizeTerminal(), 50);
138
-
139
- protected doResizeTerminal(): void {
140
- if (this.isDisposed) {
141
- return;
142
- }
143
- const geo = this.fitAddon.proposeDimensions();
144
- const cols = geo.cols;
145
- const rows = geo.rows - 1; // subtract one row for margin
146
- this.term.resize(cols, rows);
147
- }
148
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 STMicroelectronics and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+ import { RendererType, Terminal } from 'xterm';
17
+ import { FitAddon } from 'xterm-addon-fit';
18
+
19
+ import { BaseWidget, Message, Widget, codicon, isFirefox } from '@theia/core/lib/browser';
20
+ import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
21
+ import { Disposable, DisposableCollection } from '@theia/core';
22
+ import { DEFAULT_TERMINAL_RENDERER_TYPE, TerminalPreferences, TerminalRendererType, isTerminalRendererType } from '@theia/terminal/lib/browser/terminal-preferences';
23
+ import { TerminalThemeService } from '@theia/terminal/lib/browser/terminal-theme-service';
24
+ import { TestOutputSource, TestOutputUIModel } from './test-output-ui-model';
25
+ import debounce = require('p-debounce');
26
+
27
+ @injectable()
28
+ export class TestOutputWidget extends BaseWidget {
29
+ @inject(TerminalPreferences) protected readonly preferences: TerminalPreferences;
30
+ @inject(TerminalThemeService) protected readonly themeService: TerminalThemeService;
31
+ @inject(TestOutputUIModel) protected readonly uiModel: TestOutputUIModel;
32
+
33
+ static ID = 'test-output-view';
34
+
35
+ protected term: Terminal;
36
+ protected disposeOnSetInput = new DisposableCollection();
37
+ protected fitAddon: FitAddon;
38
+
39
+ constructor() {
40
+ super();
41
+
42
+ this.id = TestOutputWidget.ID;
43
+ this.title.label = 'Test Output';
44
+ this.title.caption = 'Test Output';
45
+ this.title.iconClass = codicon('symbol-keyword');
46
+ this.title.closable = true;
47
+ }
48
+
49
+ @postConstruct()
50
+ init(): void {
51
+ this.term = new Terminal({
52
+ disableStdin: true,
53
+ cursorStyle: 'bar',
54
+ fontFamily: this.preferences['terminal.integrated.fontFamily'],
55
+ fontSize: this.preferences['terminal.integrated.fontSize'],
56
+ fontWeight: this.preferences['terminal.integrated.fontWeight'],
57
+ fontWeightBold: this.preferences['terminal.integrated.fontWeightBold'],
58
+ drawBoldTextInBrightColors: this.preferences['terminal.integrated.drawBoldTextInBrightColors'],
59
+ letterSpacing: this.preferences['terminal.integrated.letterSpacing'],
60
+ lineHeight: this.preferences['terminal.integrated.lineHeight'],
61
+ scrollback: this.preferences['terminal.integrated.scrollback'],
62
+ fastScrollSensitivity: this.preferences['terminal.integrated.fastScrollSensitivity'],
63
+ rendererType: this.getTerminalRendererType(this.preferences['terminal.integrated.rendererType']),
64
+ theme: this.themeService.theme
65
+ });
66
+
67
+ this.fitAddon = new FitAddon();
68
+ this.term.loadAddon(this.fitAddon);
69
+ this.setInput(this.uiModel.selectedOutputSource);
70
+ this.uiModel.onDidChangeSelectedOutputSource(source => this.setInput(source));
71
+
72
+ this.toDispose.push(Disposable.create(() =>
73
+ this.term.dispose()
74
+ ));
75
+ }
76
+
77
+ setInput(selectedOutputSource: TestOutputSource | undefined): void {
78
+ this.disposeOnSetInput.dispose();
79
+ this.disposeOnSetInput = new DisposableCollection();
80
+ this.term.clear();
81
+ if (selectedOutputSource) {
82
+ selectedOutputSource.output.forEach(item => this.term.writeln(item.output));
83
+ this.disposeOnSetInput.push(selectedOutputSource.onDidAddTestOutput(items => {
84
+ items.forEach(item => this.term.writeln(item.output));
85
+ }));
86
+ this.term.scrollToBottom();
87
+ }
88
+ }
89
+
90
+ protected override onAfterAttach(msg: Message): void {
91
+ super.onAfterAttach(msg);
92
+ this.term.open(this.node);
93
+
94
+ if (isFirefox) {
95
+ // monkey patching intersection observer handling for secondary window support
96
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
97
+ const renderService: any = (this.term as any)._core._renderService;
98
+ const originalFunc: (entry: IntersectionObserverEntry) => void = renderService._onIntersectionChange.bind(renderService);
99
+ const replacement = function (entry: IntersectionObserverEntry): void {
100
+ if (entry.target.ownerDocument !== document) {
101
+ // in Firefox, the intersection observer always reports the widget as non-intersecting if the dom element
102
+ // is in a different document from when the IntersectionObserver started observing. Since we know
103
+ // that the widget is always "visible" when in a secondary window, so we mark the entry as "intersecting"
104
+ const patchedEvent: IntersectionObserverEntry = {
105
+ ...entry,
106
+ isIntersecting: true,
107
+ };
108
+ originalFunc(patchedEvent);
109
+ } else {
110
+ originalFunc(entry);
111
+ }
112
+ };
113
+
114
+ renderService._onIntersectionChange = replacement;
115
+ }
116
+
117
+ if (isFirefox) {
118
+ // The software scrollbars don't work with xterm.js, so we disable the scrollbar if we are on firefox.
119
+ if (this.term.element) {
120
+ (this.term.element.children.item(0) as HTMLElement).style.overflow = 'hidden';
121
+ }
122
+ }
123
+ }
124
+
125
+ private getTerminalRendererType(terminalRendererType?: string | TerminalRendererType): RendererType {
126
+ if (terminalRendererType && isTerminalRendererType(terminalRendererType)) {
127
+ return terminalRendererType;
128
+ }
129
+ return DEFAULT_TERMINAL_RENDERER_TYPE;
130
+ }
131
+
132
+ protected override onResize(msg: Widget.ResizeMessage): void {
133
+ super.onResize(msg);
134
+ this.resizeTerminal();
135
+ }
136
+
137
+ protected resizeTerminal = debounce(() => this.doResizeTerminal(), 50);
138
+
139
+ protected doResizeTerminal(): void {
140
+ if (this.isDisposed) {
141
+ return;
142
+ }
143
+ const geo = this.fitAddon.proposeDimensions();
144
+ const cols = geo.cols;
145
+ const rows = geo.rows - 1; // subtract one row for margin
146
+ this.term.resize(cols, rows);
147
+ }
148
+ }
@@ -1,34 +1,34 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2023 STMicroelectronics and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { AbstractViewContribution } from '@theia/core/lib/browser';
18
- import { injectable } from '@theia/core/shared/inversify';
19
- import { TestResultWidget } from './test-result-widget';
20
- import { nls } from '@theia/core';
21
-
22
- @injectable()
23
- export class TestResultViewContribution extends AbstractViewContribution<TestResultWidget> {
24
- constructor() {
25
- super({
26
- widgetId: TestResultWidget.ID,
27
- widgetName: nls.localizeByDefault('Test Results'),
28
- defaultWidgetOptions: {
29
- area: 'bottom'
30
- }
31
- });
32
-
33
- }
34
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 STMicroelectronics and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { AbstractViewContribution } from '@theia/core/lib/browser';
18
+ import { injectable } from '@theia/core/shared/inversify';
19
+ import { TestResultWidget } from './test-result-widget';
20
+ import { nls } from '@theia/core';
21
+
22
+ @injectable()
23
+ export class TestResultViewContribution extends AbstractViewContribution<TestResultWidget> {
24
+ constructor() {
25
+ super({
26
+ widgetId: TestResultWidget.ID,
27
+ widgetName: nls.localizeByDefault('Test Results'),
28
+ defaultWidgetOptions: {
29
+ area: 'bottom'
30
+ }
31
+ });
32
+
33
+ }
34
+ }
@@ -1,92 +1,92 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2023 STMicroelectronics and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { BaseWidget, Message, codicon } from '@theia/core/lib/browser';
18
- import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
19
- import { TestOutputUIModel } from './test-output-ui-model';
20
- import { DisposableCollection, nls } from '@theia/core';
21
- import { TestFailure, TestMessage } from '../test-service';
22
- import { MarkdownRenderer } from '@theia/core/lib/browser/markdown-rendering/markdown-renderer';
23
- import { MarkdownString } from '@theia/core/lib/common/markdown-rendering';
24
-
25
- @injectable()
26
- export class TestResultWidget extends BaseWidget {
27
-
28
- static readonly ID = 'test-result-widget';
29
-
30
- @inject(TestOutputUIModel) uiModel: TestOutputUIModel;
31
- @inject(MarkdownRenderer) markdownRenderer: MarkdownRenderer;
32
-
33
- protected toDisposeOnRender = new DisposableCollection();
34
- protected input: TestMessage[] = [];
35
- protected content: HTMLDivElement;
36
-
37
- constructor() {
38
- super();
39
- this.id = TestResultWidget.ID;
40
- this.title.label = nls.localizeByDefault('Test Results');
41
- this.title.caption = nls.localizeByDefault('Test Results');
42
- this.title.iconClass = codicon('checklist');
43
- this.title.closable = true;
44
- this.scrollOptions = {
45
- minScrollbarLength: 35,
46
- };
47
- }
48
-
49
- @postConstruct()
50
- init(): void {
51
- this.uiModel.onDidChangeSelectedTestState(e => {
52
- if (TestFailure.is(e)) {
53
- this.setInput(e.messages);
54
- }
55
- });
56
- }
57
-
58
- protected override onAfterAttach(msg: Message): void {
59
- super.onAfterAttach(msg);
60
- this.content = this.node.ownerDocument.createElement('div');
61
- this.node.append(this.content);
62
- }
63
-
64
- setInput(messages: TestMessage[]): void {
65
- this.input = messages;
66
- this.update();
67
- }
68
-
69
- protected override onUpdateRequest(msg: Message): void {
70
- this.render();
71
- super.onUpdateRequest(msg);
72
- }
73
-
74
- render(): void {
75
- this.toDisposeOnRender.dispose();
76
- this.toDisposeOnRender = new DisposableCollection();
77
- this.content.innerHTML = '';
78
- this.input.forEach(message => {
79
- if (MarkdownString.is(message.message)) {
80
- const line = this.markdownRenderer.render(message.message);
81
- this.content.append(line.element);
82
- this.toDisposeOnRender.push(line);
83
- } else {
84
- this.content.append(this.node.ownerDocument.createTextNode(message.message));
85
- }
86
- });
87
- }
88
-
89
- override dispose(): void {
90
- this.toDisposeOnRender.dispose();
91
- }
92
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 STMicroelectronics and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { BaseWidget, Message, codicon } from '@theia/core/lib/browser';
18
+ import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
19
+ import { TestOutputUIModel } from './test-output-ui-model';
20
+ import { DisposableCollection, nls } from '@theia/core';
21
+ import { TestFailure, TestMessage } from '../test-service';
22
+ import { MarkdownRenderer } from '@theia/core/lib/browser/markdown-rendering/markdown-renderer';
23
+ import { MarkdownString } from '@theia/core/lib/common/markdown-rendering';
24
+
25
+ @injectable()
26
+ export class TestResultWidget extends BaseWidget {
27
+
28
+ static readonly ID = 'test-result-widget';
29
+
30
+ @inject(TestOutputUIModel) uiModel: TestOutputUIModel;
31
+ @inject(MarkdownRenderer) markdownRenderer: MarkdownRenderer;
32
+
33
+ protected toDisposeOnRender = new DisposableCollection();
34
+ protected input: TestMessage[] = [];
35
+ protected content: HTMLDivElement;
36
+
37
+ constructor() {
38
+ super();
39
+ this.id = TestResultWidget.ID;
40
+ this.title.label = nls.localizeByDefault('Test Results');
41
+ this.title.caption = nls.localizeByDefault('Test Results');
42
+ this.title.iconClass = codicon('checklist');
43
+ this.title.closable = true;
44
+ this.scrollOptions = {
45
+ minScrollbarLength: 35,
46
+ };
47
+ }
48
+
49
+ @postConstruct()
50
+ init(): void {
51
+ this.uiModel.onDidChangeSelectedTestState(e => {
52
+ if (TestFailure.is(e)) {
53
+ this.setInput(e.messages);
54
+ }
55
+ });
56
+ }
57
+
58
+ protected override onAfterAttach(msg: Message): void {
59
+ super.onAfterAttach(msg);
60
+ this.content = this.node.ownerDocument.createElement('div');
61
+ this.node.append(this.content);
62
+ }
63
+
64
+ setInput(messages: TestMessage[]): void {
65
+ this.input = messages;
66
+ this.update();
67
+ }
68
+
69
+ protected override onUpdateRequest(msg: Message): void {
70
+ this.render();
71
+ super.onUpdateRequest(msg);
72
+ }
73
+
74
+ render(): void {
75
+ this.toDisposeOnRender.dispose();
76
+ this.toDisposeOnRender = new DisposableCollection();
77
+ this.content.innerHTML = '';
78
+ this.input.forEach(message => {
79
+ if (MarkdownString.is(message.message)) {
80
+ const line = this.markdownRenderer.render(message.message);
81
+ this.content.append(line.element);
82
+ this.toDisposeOnRender.push(line);
83
+ } else {
84
+ this.content.append(this.node.ownerDocument.createTextNode(message.message));
85
+ }
86
+ });
87
+ }
88
+
89
+ override dispose(): void {
90
+ this.toDisposeOnRender.dispose();
91
+ }
92
+ }