Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/test/automation/src/statusbar.ts
3520 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { Code } from './code';
7
8
export const enum StatusBarElement {
9
BRANCH_STATUS = 0,
10
SYNC_STATUS = 1,
11
PROBLEMS_STATUS = 2,
12
SELECTION_STATUS = 3,
13
INDENTATION_STATUS = 4,
14
ENCODING_STATUS = 5,
15
EOL_STATUS = 6,
16
LANGUAGE_STATUS = 7
17
}
18
19
export class StatusBar {
20
21
private readonly mainSelector = 'footer[id="workbench.parts.statusbar"]';
22
23
constructor(private code: Code) { }
24
25
async waitForStatusbarElement(element: StatusBarElement): Promise<void> {
26
await this.code.waitForElement(this.getSelector(element));
27
}
28
29
async clickOn(element: StatusBarElement): Promise<void> {
30
await this.code.waitAndClick(this.getSelector(element));
31
}
32
33
async waitForEOL(eol: string): Promise<string> {
34
return this.code.waitForTextContent(this.getSelector(StatusBarElement.EOL_STATUS), eol);
35
}
36
37
async waitForStatusbarText(title: string, text: string): Promise<void> {
38
await this.code.waitForTextContent(`${this.mainSelector} .statusbar-item[aria-label="${title}"]`, text);
39
}
40
41
private getSelector(element: StatusBarElement): string {
42
switch (element) {
43
case StatusBarElement.BRANCH_STATUS:
44
return `.statusbar-item[id^="status.scm."] .codicon.codicon-git-branch`;
45
case StatusBarElement.SYNC_STATUS:
46
return `.statusbar-item[id^="status.scm."] .codicon.codicon-sync`;
47
case StatusBarElement.PROBLEMS_STATUS:
48
return `.statusbar-item[id="status.problems"]`;
49
case StatusBarElement.SELECTION_STATUS:
50
return `.statusbar-item[id="status.editor.selection"]`;
51
case StatusBarElement.INDENTATION_STATUS:
52
return `.statusbar-item[id="status.editor.indentation"]`;
53
case StatusBarElement.ENCODING_STATUS:
54
return `.statusbar-item[id="status.editor.encoding"]`;
55
case StatusBarElement.EOL_STATUS:
56
return `.statusbar-item[id="status.editor.eol"]`;
57
case StatusBarElement.LANGUAGE_STATUS:
58
return `.statusbar-item[id="status.editor.mode"]`;
59
default:
60
throw new Error(element);
61
}
62
}
63
}
64
65