diff --git a/src/vs/editor/browser/view/viewImpl.ts b/src/vs/editor/browser/view/viewImpl.ts index b8c5900a2d2..79cf5f2c105 100644 --- a/src/vs/editor/browser/view/viewImpl.ts +++ b/src/vs/editor/browser/view/viewImpl.ts @@ -308,7 +308,8 @@ export class View extends ViewEventHandler { } private getEditorClassName() { - return this._context.configuration.editor.editorClassName + ' ' + getThemeTypeSelector(this._context.theme.type); + let focused = this._textAreaHandler.isFocused() ? ' focused' : ''; + return this._context.configuration.editor.editorClassName + ' ' + getThemeTypeSelector(this._context.theme.type) + focused; } // --- begin event handlers @@ -323,7 +324,7 @@ export class View extends ViewEventHandler { return false; } public onFocusChanged(e: viewEvents.ViewFocusChangedEvent): boolean { - this.domNode.toggleClassName('focused', e.isFocused); + this.domNode.setClassName(this.getEditorClassName()); if (e.isFocused) { this.outgoingEvents.emitViewFocusGained(); } else { diff --git a/src/vs/editor/browser/widget/codeEditorWidget.ts b/src/vs/editor/browser/widget/codeEditorWidget.ts index fe646ba39e4..22efae7b65e 100644 --- a/src/vs/editor/browser/widget/codeEditorWidget.ts +++ b/src/vs/editor/browser/widget/codeEditorWidget.ts @@ -400,6 +400,7 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito this._view.render(false, true); this.hasView = true; + this._view.domNode.domNode.setAttribute('data-uri', model.uri.toString()); } } diff --git a/test/smoke/package.json b/test/smoke/package.json index 6237dc93093..1ab31447938 100644 --- a/test/smoke/package.json +++ b/test/smoke/package.json @@ -23,6 +23,7 @@ "spectron": "~3.6.4", "strip-json-comments": "^2.0.1", "tmp": "0.0.33", - "typescript": "^2.2.2" + "typescript": "^2.2.2", + "vscode-uri": "^1.0.1" } } diff --git a/test/smoke/src/areas/debug/debug.test.ts b/test/smoke/src/areas/debug/debug.test.ts index 163b92f1487..e3f2a52b980 100644 --- a/test/smoke/src/areas/debug/debug.test.ts +++ b/test/smoke/src/areas/debug/debug.test.ts @@ -9,7 +9,7 @@ import * as os from 'os'; import * as path from 'path'; import * as fs from 'fs'; import * as stripJsonComments from 'strip-json-comments'; -import { SpectronApplication, VSCODE_BUILD, EXTENSIONS_DIR, WORKSPACE_PATH } from '../../spectron/application'; +import { SpectronApplication, VSCODE_BUILD, EXTENSIONS_DIR } from '../../spectron/application'; describe('Debug', () => { let app: SpectronApplication = new SpectronApplication(); @@ -47,7 +47,7 @@ describe('Debug', () => { await app.workbench.openFile('app.js'); await app.workbench.debug.configure(); await app.screenCapturer.capture('launch.json file'); - const content = fs.readFileSync(path.join(WORKSPACE_PATH, '.vscode', 'launch.json'), 'utf8'); + const content = await app.workbench.editor.getEditorVisibleText(); const json = JSON.parse(stripJsonComments(content)); assert.equal(json.configurations[0].request, 'launch'); diff --git a/test/smoke/src/areas/editor/editor.ts b/test/smoke/src/areas/editor/editor.ts index 36b326b2f56..e37d916cedf 100644 --- a/test/smoke/src/areas/editor/editor.ts +++ b/test/smoke/src/areas/editor/editor.ts @@ -102,6 +102,13 @@ export class Editor { await this.spectron.client.waitAndClick(selector); } + public async getFocusedEditorUri(): Promise { + return this.spectron.webclient.selectorExecute(`.editor-container .monaco-editor.focused`, (elements: HTMLElement[]) => { + elements = Array.isArray(elements) ? elements : [elements]; + return elements[0].getAttribute('data-uri'); + }); + } + private async getClassSelectors(term: string, viewline: number): Promise { const result: { text: string, className: string }[] = await this.spectron.webclient.selectorExecute(`${Editor.VIEW_LINES}>:nth-child(${viewline}) span span`, elements => (Array.isArray(elements) ? elements : [elements]) diff --git a/test/smoke/src/areas/explorer/explorer.ts b/test/smoke/src/areas/explorer/explorer.ts index d59f02244d2..904afdbc170 100644 --- a/test/smoke/src/areas/explorer/explorer.ts +++ b/test/smoke/src/areas/explorer/explorer.ts @@ -25,14 +25,8 @@ export class Explorer extends Viewlet { } public async openFile(fileName: string): Promise { - let selector = `div[class="monaco-icon-label file-icon ${fileName}-name-file-icon ${this.getExtensionSelector(fileName)} explorer-item"]`; - try { - await this.spectron.client.doubleClickAndWait(selector); - await this.spectron.client.waitForElement(`.tabs-container div[aria-label="${fileName}, tab"]`); - await this.spectron.client.waitForElement(`.monaco-editor.focused`); - } catch (e) { - return Promise.reject(`Cannot fine ${fileName} in a viewlet.`); - } + await this.spectron.client.doubleClickAndWait(`div[class="monaco-icon-label file-icon ${fileName}-name-file-icon ${this.getExtensionSelector(fileName)} explorer-item"]`); + await this.spectron.workbench.waitForEditorFocus(fileName); } public getExtensionSelector(fileName: string): string { diff --git a/test/smoke/src/areas/workbench/workbench.ts b/test/smoke/src/areas/workbench/workbench.ts index bf8743e6d8f..1d04da84db5 100644 --- a/test/smoke/src/areas/workbench/workbench.ts +++ b/test/smoke/src/areas/workbench/workbench.ts @@ -3,6 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import * as path from 'path'; +import URI from 'vscode-uri'; import { SpectronApplication } from '../../spectron/application'; import { Explorer } from '../explorer/explorer'; import { ActivityBar } from '../activitybar/activityBar'; @@ -68,7 +70,10 @@ export class Workbench { public async waitForEditorFocus(fileName: string, untitled: boolean = false): Promise { await this.waitForActiveTab(fileName); - await this.spectron.client.waitForElement(`.editor-container[aria-label="${fileName}. ${untitled ? 'Untitled file text editor.' : 'Text file editor.'}, Group 1."] .monaco-editor textarea:focus`); + await this.spectron.client.waitFor(async () => { + const uri = await this.editor.getFocusedEditorUri(); + return uri && path.basename(URI.parse(uri).path) === fileName; + }, void 0, `Wait for editor with ${fileName} is focussed`); } public async waitForActiveTab(fileName: string, isDirty: boolean = false): Promise {