Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/test/automation/src/explorer.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 { Viewlet } from './viewlet';
7
import { Code } from './code';
8
9
export class Explorer extends Viewlet {
10
11
private static readonly EXPLORER_VIEWLET = 'div[id="workbench.view.explorer"]';
12
private static readonly OPEN_EDITORS_VIEW = `${Explorer.EXPLORER_VIEWLET} .split-view-view:nth-child(1) .title`;
13
14
constructor(code: Code) {
15
super(code);
16
}
17
18
async openExplorerView(): Promise<any> {
19
await this.code.dispatchKeybinding(process.platform === 'darwin' ? 'cmd+shift+e' : 'ctrl+shift+e', async () => {
20
await this.code.waitForElement(Explorer.EXPLORER_VIEWLET);
21
});
22
}
23
24
async waitForOpenEditorsViewTitle(fn: (title: string) => boolean): Promise<void> {
25
await this.code.waitForTextContent(Explorer.OPEN_EDITORS_VIEW, undefined, fn);
26
}
27
28
getExtensionSelector(fileName: string): string {
29
const extension = fileName.split('.')[1];
30
if (extension === 'js') {
31
return 'js-ext-file-icon ext-file-icon javascript-lang-file-icon';
32
} else if (extension === 'json') {
33
return 'json-ext-file-icon ext-file-icon json-lang-file-icon';
34
} else if (extension === 'md') {
35
return 'md-ext-file-icon ext-file-icon markdown-lang-file-icon';
36
}
37
throw new Error('No class defined for this file extension');
38
}
39
40
}
41
42