diff --git a/test/smoke/src/api.ts b/test/smoke/src/api.ts index cbe43c9da2507d0f009bc7996f71ceb91cae27a6..d548ea39f6b976b0b02f3650c189c8c5086a2030 100644 --- a/test/smoke/src/api.ts +++ b/test/smoke/src/api.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { ScreenCapturer } from './helpers/screenshot'; import { Driver, Element } from './driver'; export class API { @@ -15,7 +14,6 @@ export class API { constructor( private driver: Driver, - private screenCapturer: ScreenCapturer, waitTime: number ) { this.retryCount = (waitTime * 1000) / this.retryDuration; @@ -99,7 +97,6 @@ export class API { while (true) { if (trial > retryCount) { - await this.screenCapturer.capture('timeout'); throw new Error(`${timeoutMessage}: Timed out after ${(retryCount * this.retryDuration) / 1000} seconds.`); } diff --git a/test/smoke/src/application.ts b/test/smoke/src/application.ts index 8a7cb11142d009c5cd6d2b2842aba380352019db..5ab35ebb77d00bb492eb99d628c7b6e11b3c9189 100644 --- a/test/smoke/src/application.ts +++ b/test/smoke/src/application.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import { API } from './api'; -import { ScreenCapturer } from './helpers/screenshot'; import { Workbench } from './areas/workbench/workbench'; import * as fs from 'fs'; import * as cp from 'child_process'; @@ -36,7 +35,6 @@ export class SpectronApplication { private _api: API; private _workbench: Workbench; - private _screenCapturer: ScreenCapturer; private codeInstance: Code | undefined; private keybindings: any[]; private stopLogCollection: (() => Promise) | undefined; @@ -53,10 +51,6 @@ export class SpectronApplication { return this._api; } - get screenCapturer(): ScreenCapturer { - return this._screenCapturer; - } - get workbench(): Workbench { return this._workbench; } @@ -81,7 +75,6 @@ export class SpectronApplication { set suiteName(suiteName: string) { this._suiteName = suiteName; - this._screenCapturer.suiteName = suiteName; } async start(waitForWelcome: boolean = true): Promise { @@ -135,10 +128,8 @@ export class SpectronApplication { verbose: this.options.verbose }); - this._screenCapturer = new ScreenCapturer(null as any, this._suiteName, ''); - const driver = new CodeDriver(this.codeInstance.driver, this.options.verbose); - this._api = new API(driver, this.screenCapturer, this.options.waitTime); + this._api = new API(driver, this.options.waitTime); this._workbench = new Workbench(this._api, this.keybindings, this.userDataPath); } diff --git a/test/smoke/src/areas/css/css.test.ts b/test/smoke/src/areas/css/css.test.ts index 6b187d53a28975920653c16c905e0600bd58d9a2..cce6027a18402fc0cbefc2cbfa729b3c57afb01d 100644 --- a/test/smoke/src/areas/css/css.test.ts +++ b/test/smoke/src/areas/css/css.test.ts @@ -26,11 +26,9 @@ export function setup() { await app.workbench.editor.waitForTypeInEditor('style.css', '.foo{}'); await app.api.waitForElement(Problems.getSelectorInEditor(ProblemSeverity.WARNING)); - await app.screenCapturer.capture('CSS Warning in editor'); await app.workbench.problems.showProblemsView(); await app.api.waitForElement(Problems.getSelectorInProblemsView(ProblemSeverity.WARNING)); - await app.screenCapturer.capture('CSS Warning in problems view'); await app.workbench.problems.hideProblemsView(); }); @@ -41,12 +39,10 @@ export function setup() { await app.workbench.editor.waitForTypeInEditor('style.css', '.foo{}'); await app.api.waitForElement(Problems.getSelectorInEditor(ProblemSeverity.ERROR)); - await app.screenCapturer.capture('CSS Error in editor'); const problems = new Problems(app.api, app.workbench); await problems.showProblemsView(); await app.api.waitForElement(Problems.getSelectorInProblemsView(ProblemSeverity.ERROR)); - await app.screenCapturer.capture('CSS Error in probles view'); await problems.hideProblemsView(); }); }); diff --git a/test/smoke/src/areas/debug/debug.test.ts b/test/smoke/src/areas/debug/debug.test.ts index 4223c58bee3525f7e4737f88470ab165000ed1cb..392a8c87e48744d99b8d61facd1418b2bcdb69ab 100644 --- a/test/smoke/src/areas/debug/debug.test.ts +++ b/test/smoke/src/areas/debug/debug.test.ts @@ -31,7 +31,6 @@ export function setup() { fs.writeFileSync(launchJsonPath, JSON.stringify(config, undefined, 4), 'utf8'); await app.workbench.editor.waitForEditorContents('launch.json', contents => /"protocol": "inspector"/.test(contents)); - await app.screenCapturer.capture('launch.json file'); assert.equal(config.configurations[0].request, 'launch'); assert.equal(config.configurations[0].type, 'node'); @@ -47,7 +46,6 @@ export function setup() { await app.workbench.quickopen.openFile('index.js'); await app.workbench.debug.setBreakpointOnLine(6); - await app.screenCapturer.capture('breakpoints are set'); }); let port: number; @@ -58,15 +56,12 @@ export function setup() { await new Promise(c => setTimeout(c, 100)); port = await app.workbench.debug.startDebugging(); - await app.screenCapturer.capture('debugging has started'); await new Promise((c, e) => { const request = http.get(`http://localhost:${port}`); request.on('error', e); app.workbench.debug.waitForStackFrame(sf => sf.name === 'index.js' && sf.lineNumber === 6, 'looking for index.js and line 6').then(c, e); }); - - await app.screenCapturer.capture('debugging is paused'); }); it('focus stack frames and variables', async function () { @@ -88,15 +83,12 @@ export function setup() { const app = this.app as SpectronApplication; await app.workbench.debug.stepIn(); - await app.screenCapturer.capture('debugging has stepped in'); const first = await app.workbench.debug.waitForStackFrame(sf => sf.name === 'response.js', 'looking for response.js'); await app.workbench.debug.stepOver(); - await app.screenCapturer.capture('debugging has stepped over'); await app.workbench.debug.waitForStackFrame(sf => sf.name === 'response.js' && sf.lineNumber === first.lineNumber + 1, `looking for response.js and line ${first.lineNumber + 1}`); await app.workbench.debug.stepOut(); - await app.screenCapturer.capture('debugging has stepped out'); await app.workbench.debug.waitForStackFrame(sf => sf.name === 'index.js' && sf.lineNumber === 7, `looking for index.js and line 7`); }); @@ -105,7 +97,6 @@ export function setup() { const app = this.app as SpectronApplication; await app.workbench.debug.continue(); - await app.screenCapturer.capture('debugging has continued'); await new Promise((c, e) => { const request = http.get(`http://localhost:${port}`); @@ -113,7 +104,6 @@ export function setup() { app.workbench.debug.waitForStackFrame(sf => sf.name === 'index.js' && sf.lineNumber === 6, `looking for index.js and line 6`).then(c, e); }); - await app.screenCapturer.capture('debugging is paused'); }); it('debug console', async function () { @@ -126,7 +116,6 @@ export function setup() { const app = this.app as SpectronApplication; await app.workbench.debug.stopDebugging(); - await app.screenCapturer.capture('debugging has stopped'); }); }); } \ No newline at end of file diff --git a/test/smoke/src/areas/editor/editor.test.ts b/test/smoke/src/areas/editor/editor.test.ts index 257905b12894af9919ee1bacede3799e84b462ba..4f7267fef95074928bfad3fdcaa235fdf88722a5 100644 --- a/test/smoke/src/areas/editor/editor.test.ts +++ b/test/smoke/src/areas/editor/editor.test.ts @@ -35,7 +35,6 @@ export function setup() { await app.workbench.quickopen.openFile('www'); await app.workbench.editor.rename('www', 7, 'app', 'newApp'); await app.workbench.editor.waitForEditorContents('www', contents => contents.indexOf('newApp') > -1); - await app.screenCapturer.capture('Rename result'); }); // it('folds/unfolds the code correctly', async function () { diff --git a/test/smoke/src/areas/extensions/extensions.test.ts b/test/smoke/src/areas/extensions/extensions.test.ts index 703581dc99eb217bf910a2270fc1e2510b552ac5..ca3c2820676aee22f7e782ca9052a3a050bb13fb 100644 --- a/test/smoke/src/areas/extensions/extensions.test.ts +++ b/test/smoke/src/areas/extensions/extensions.test.ts @@ -31,7 +31,6 @@ export function setup() { await app.workbench.runCommand('Smoke Test Check'); const statusbarText = await app.workbench.statusbar.getStatusbarTextByTitle('smoke test'); - await app.screenCapturer.capture('Statusbar'); assert.equal(statusbarText, 'VS Code Smoke Test Check'); }); }); diff --git a/test/smoke/src/areas/git/git.test.ts b/test/smoke/src/areas/git/git.test.ts index 1be1f6c3a4165c80bdf964b4b68c9b52918bca24..1135877da50dc01935aa3609623032db9830c481 100644 --- a/test/smoke/src/areas/git/git.test.ts +++ b/test/smoke/src/areas/git/git.test.ts @@ -32,7 +32,6 @@ export function setup() { await app.workbench.scm.refreshSCMViewlet(); await app.workbench.scm.waitForChange('app.js', 'Modified'); await app.workbench.scm.waitForChange('index.jade', 'Modified'); - await app.screenCapturer.capture('changes'); }); it('opens diff editor', async function () { diff --git a/test/smoke/src/areas/multiroot/multiroot.test.ts b/test/smoke/src/areas/multiroot/multiroot.test.ts index 750845ded80b18e7432e1fcf310277b1302cbfc3..a5e1b9c92699e8a7cea0b61719f82dbbed0184ec 100644 --- a/test/smoke/src/areas/multiroot/multiroot.test.ts +++ b/test/smoke/src/areas/multiroot/multiroot.test.ts @@ -30,7 +30,6 @@ export function setup() { it('shows workspace name in title', async function () { const app = this.app as SpectronApplication; const title = await app.api.getTitle(); - await app.screenCapturer.capture('window title'); assert.ok(title.indexOf('smoketest (Workspace)') >= 0); }); }); diff --git a/test/smoke/src/areas/preferences/preferences.test.ts b/test/smoke/src/areas/preferences/preferences.test.ts index e0d0e8223ab3f9b29ae4f85bb53900a40befe345..76bddda4621b7726ad5706bba3bd8df6843709fa 100644 --- a/test/smoke/src/areas/preferences/preferences.test.ts +++ b/test/smoke/src/areas/preferences/preferences.test.ts @@ -19,13 +19,10 @@ export function setup() { await app.workbench.explorer.openFile('app.js'); await app.api.waitForElements('.line-numbers', false, elements => !!elements.length); - await app.screenCapturer.capture('app.js has line numbers'); await app.workbench.settingsEditor.addUserSetting('editor.lineNumbers', '"off"'); await app.workbench.editors.selectTab('app.js'); await app.api.waitForElements('.line-numbers', false, result => !result || result.length === 0); - - await app.screenCapturer.capture('line numbers hidden'); }); it(`changes 'workbench.action.toggleSidebarPosition' command key binding and verifies it`, async function () { diff --git a/test/smoke/src/areas/workbench/data-loss.test.ts b/test/smoke/src/areas/workbench/data-loss.test.ts index 9d5298bbed8e029099f2f9330bdc9f409a8f8812..50d477f2803a7160d80ab4133a3f974aedd6fae7 100644 --- a/test/smoke/src/areas/workbench/data-loss.test.ts +++ b/test/smoke/src/areas/workbench/data-loss.test.ts @@ -18,24 +18,19 @@ export function setup() { const untitled = 'Untitled-1'; const textToTypeInUntitled = 'Hello, Unitled Code'; await app.workbench.editor.waitForTypeInEditor(untitled, textToTypeInUntitled); - await app.screenCapturer.capture('Untitled file before reload'); const readmeMd = 'readme.md'; const textToType = 'Hello, Code'; await app.workbench.explorer.openFile(readmeMd); await app.workbench.editor.waitForTypeInEditor(readmeMd, textToType); - await app.screenCapturer.capture(`${readmeMd} before reload`); await app.reload(); - await app.screenCapturer.capture('After reload'); await app.workbench.editors.waitForActiveTab(readmeMd, true); - await app.screenCapturer.capture(`${readmeMd} after reload`); await app.workbench.editor.waitForEditorContents(readmeMd, c => c.indexOf(textToType) > -1); await app.workbench.editors.waitForTab(untitled, true); await app.workbench.editors.selectTab(untitled, true); - await app.screenCapturer.capture('Untitled file after reload'); await app.workbench.editor.waitForEditorContents(untitled, c => c.indexOf(textToTypeInUntitled) > -1); }); }); diff --git a/test/smoke/src/areas/workbench/data-migration.test.ts b/test/smoke/src/areas/workbench/data-migration.test.ts index 582331b6aa9e92580d29490e35fc2ed5edeee981..3dc5a8e44d89933c7bcb94d882d4b45c5fdc1996 100644 --- a/test/smoke/src/areas/workbench/data-migration.test.ts +++ b/test/smoke/src/areas/workbench/data-migration.test.ts @@ -51,7 +51,6 @@ export function setup(userDataDir: string, createApp: ICreateAppFn) { assert.ok(await app.workbench.editors.waitForActiveTab('Untitled-1', true), `Untitled-1 tab is not present after migration.`); await app.workbench.editor.waitForEditorContents('Untitled-1', c => c.indexOf(textToType) > -1); - await app.screenCapturer.capture('Untitled file text'); await app.stop(); }); diff --git a/test/smoke/src/areas/workbench/localization.test.ts b/test/smoke/src/areas/workbench/localization.test.ts index ed1f88b0cf1951735b1bcd4c2637f29635f0ad01..a39722858e47071a3adad67b13c08fb11e8b0087 100644 --- a/test/smoke/src/areas/workbench/localization.test.ts +++ b/test/smoke/src/areas/workbench/localization.test.ts @@ -29,27 +29,22 @@ export function setup() { } let text = await app.workbench.explorer.getOpenEditorsViewTitle(); - await app.screenCapturer.capture('Open editors title'); assert(/geƶffnete editoren/i.test(text)); await app.workbench.search.openSearchViewlet(); text = await app.workbench.search.getTitle(); - await app.screenCapturer.capture('Search title'); assert(/suchen/i.test(text)); await app.workbench.scm.openSCMViewlet(); text = await app.workbench.scm.getTitle(); - await app.screenCapturer.capture('Scm title'); assert(/quellcodeverwaltung/i.test(text)); await app.workbench.debug.openDebugViewlet(); text = await app.workbench.debug.getTitle(); - await app.screenCapturer.capture('Debug title'); assert(/debuggen/i.test(text)); await app.workbench.extensions.openExtensionsViewlet(); text = await app.workbench.extensions.getTitle(); - await app.screenCapturer.capture('Extensions title'); assert(/erweiterungen/i.test(text)); }); }); diff --git a/test/smoke/src/helpers/screenshot.ts b/test/smoke/src/helpers/screenshot.ts deleted file mode 100644 index 18a068ec388b31045098321ef5c41d64483cdc08..0000000000000000000000000000000000000000 --- a/test/smoke/src/helpers/screenshot.ts +++ /dev/null @@ -1,37 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import * as path from 'path'; -import * as fs from 'fs'; -import * as mkdirp from 'mkdirp'; -import { Application } from 'spectron'; -import { sanitize } from './utilities'; - -export class ScreenCapturer { - - private static counter = 0; - - constructor( - private application: Application, - public suiteName: string, - private screenshotsDirPath: string | undefined, - ) { } - - async capture(name: string): Promise { - if (!this.screenshotsDirPath) { - return; - } - - const screenshotPath = path.join( - this.screenshotsDirPath, - sanitize(this.suiteName), - `${ScreenCapturer.counter++}-${sanitize(name)}.png` - ); - - const image = await this.application.browserWindow.capturePage(); - await new Promise((c, e) => mkdirp(path.dirname(screenshotPath), err => err ? e(err) : c())); - await new Promise((c, e) => fs.writeFile(screenshotPath, image, err => err ? e(err) : c())); - } -} diff --git a/test/smoke/src/helpers/utilities.ts b/test/smoke/src/helpers/utilities.ts deleted file mode 100644 index 8b86d31c9576573f6cf1cf60a124602f2a4456ff..0000000000000000000000000000000000000000 --- a/test/smoke/src/helpers/utilities.ts +++ /dev/null @@ -1,53 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import * as fs from 'fs'; -import { dirname } from 'path'; - -export function nfcall(fn: Function, ...args): Promise { - return new Promise((c, e) => fn(...args, (err, r) => err ? e(err) : c(r))); -} - -export async function mkdirp(path: string, mode?: number): Promise { - const mkdir = async () => { - try { - await nfcall(fs.mkdir, path, mode); - } catch (err) { - if (err.code === 'EEXIST') { - const stat = await nfcall(fs.stat, path); - - if (stat.isDirectory) { - return; - } - - throw new Error(`'${path}' exists and is not a directory.`); - } - - throw err; - } - }; - - // is root? - if (path === dirname(path)) { - return true; - } - - try { - await mkdir(); - } catch (err) { - if (err.code !== 'ENOENT') { - throw err; - } - - await mkdirp(dirname(path), mode); - await mkdir(); - } - - return true; -} - -export function sanitize(name: string): string { - return name.replace(/[&*:\/]/g, ''); -} \ No newline at end of file