Skip to content

Commit f6711f0

Browse files
committed
debug: statusbar color tests
1 parent d5bc0df commit f6711f0

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

src/vs/workbench/contrib/debug/browser/statusbarColorProvider.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { localize } from 'vs/nls';
88
import { registerColor, contrastBorder } from 'vs/platform/theme/common/colorRegistry';
99
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
1010
import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService';
11-
import { IDebugService, State } from 'vs/workbench/contrib/debug/common/debug';
11+
import { IDebugService, State, IDebugSession } from 'vs/workbench/contrib/debug/common/debug';
1212
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
1313
import { STATUS_BAR_NO_FOLDER_BACKGROUND, STATUS_BAR_NO_FOLDER_FOREGROUND, STATUS_BAR_BACKGROUND, Themable, STATUS_BAR_FOREGROUND, STATUS_BAR_NO_FOLDER_BORDER, STATUS_BAR_BORDER } from 'vs/workbench/common/theme';
1414
import { addClass, removeClass, createStyleSheet } from 'vs/base/browser/dom';
@@ -58,7 +58,7 @@ export class StatusBarColorProvider extends Themable implements IWorkbenchContri
5858
super.updateStyles();
5959

6060
const container = assertIsDefined(this.layoutService.getContainer(Parts.STATUSBAR_PART));
61-
if (isStatusbarInDebugMode(this.debugService)) {
61+
if (isStatusbarInDebugMode(this.debugService.state, this.debugService.getViewModel().focusedSession)) {
6262
addClass(container, 'debugging');
6363
} else {
6464
removeClass(container, 'debugging');
@@ -90,7 +90,7 @@ export class StatusBarColorProvider extends Themable implements IWorkbenchContri
9090
private getColorKey(noFolderColor: string, debuggingColor: string, normalColor: string): string {
9191

9292
// Not debugging
93-
if (!isStatusbarInDebugMode(this.debugService)) {
93+
if (!isStatusbarInDebugMode(this.debugService.state, this.debugService.getViewModel().focusedSession)) {
9494
if (this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY) {
9595
return normalColor;
9696
}
@@ -103,12 +103,10 @@ export class StatusBarColorProvider extends Themable implements IWorkbenchContri
103103
}
104104
}
105105

106-
function isStatusbarInDebugMode(debugService: IDebugService): boolean {
107-
if (debugService.state === State.Inactive || debugService.state === State.Initializing) {
106+
export function isStatusbarInDebugMode(state: State, session: IDebugSession | undefined): boolean {
107+
if (state === State.Inactive || state === State.Initializing) {
108108
return false;
109109
}
110-
111-
const session = debugService.getViewModel().focusedSession;
112110
const isRunningWithoutDebug = session?.configuration?.noDebug;
113111
if (isRunningWithoutDebug) {
114112
return false;

src/vs/workbench/contrib/debug/test/browser/baseDebugView.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
import * as assert from 'assert';
77
import { replaceWhitespace, renderExpressionValue, renderVariable, renderViewTree } from 'vs/workbench/contrib/debug/browser/baseDebugView';
88
import * as dom from 'vs/base/browser/dom';
9-
import { Expression, Variable, Scope, StackFrame, Thread } from 'vs/workbench/contrib/debug/common/debugModel';
9+
import { Expression, Variable, Scope, StackFrame, Thread, DebugModel } from 'vs/workbench/contrib/debug/common/debugModel';
1010
import { MockSession } from 'vs/workbench/contrib/debug/test/common/mockDebug';
1111
import { HighlightedLabel } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel';
1212
import { LinkDetector } from 'vs/workbench/contrib/debug/browser/linkDetector';
1313
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
1414
import { workbenchInstantiationService } from 'vs/workbench/test/workbenchTestServices';
15+
import { createMockSession } from 'vs/workbench/contrib/debug/test/browser/callStack.test';
16+
import { isStatusbarInDebugMode } from 'vs/workbench/contrib/debug/browser/statusbarColorProvider';
17+
import { State } from 'vs/workbench/contrib/debug/common/debug';
1518
const $ = dom.$;
1619

1720
suite('Debug - Base Debug View', () => {
@@ -124,4 +127,15 @@ suite('Debug - Base Debug View', () => {
124127
assert.equal(label.element.title, 'console');
125128
assert.equal(value.className, 'value number');
126129
});
130+
131+
test('statusbar in debug mode', () => {
132+
const model = new DebugModel([], [], [], [], [], <any>{ isDirty: (e: any) => false });
133+
const session = createMockSession(model);
134+
assert.equal(isStatusbarInDebugMode(State.Inactive, undefined), false);
135+
assert.equal(isStatusbarInDebugMode(State.Initializing, session), false);
136+
assert.equal(isStatusbarInDebugMode(State.Running, session), true);
137+
assert.equal(isStatusbarInDebugMode(State.Stopped, session), true);
138+
session.configuration.noDebug = true;
139+
assert.equal(isStatusbarInDebugMode(State.Running, session), false);
140+
});
127141
});

0 commit comments

Comments
 (0)