From 9c9a330ed29a263d31db62e914f53d9fdde6818f Mon Sep 17 00:00:00 2001 From: karan Date: Fri, 1 May 2020 11:14:10 -0700 Subject: [PATCH 1/9] initial codec test --- .gitattributes | 1 + .../electron/common/create-application.ts | 20 +++++---- .../common/view-controllers/app-controller.ts | 2 +- .../codecs-test-view-controller.ts | 14 +++++++ .../tests/framework-no-codecs.test.ts | 39 ++++++++++++++++++ src/tests/miscellaneous/codecs/codecs-test.js | 8 ++++ .../miscellaneous/codecs/codecs-test.mp3 | Bin 0 -> 4903 bytes src/tests/miscellaneous/codecs/codecs.html | 20 +++++++++ 8 files changed, 94 insertions(+), 10 deletions(-) create mode 100644 src/tests/electron/common/view-controllers/codecs-test-view-controller.ts create mode 100644 src/tests/electron/tests/framework-no-codecs.test.ts create mode 100644 src/tests/miscellaneous/codecs/codecs-test.js create mode 100644 src/tests/miscellaneous/codecs/codecs-test.mp3 create mode 100644 src/tests/miscellaneous/codecs/codecs.html diff --git a/.gitattributes b/.gitattributes index 6313b56c578..0e1e9473cf5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ * text=auto eol=lf +*.mp3 binary diff --git a/src/tests/electron/common/create-application.ts b/src/tests/electron/common/create-application.ts index 4bf920d5404..7ee5fd0f2ee 100644 --- a/src/tests/electron/common/create-application.ts +++ b/src/tests/electron/common/create-application.ts @@ -18,20 +18,22 @@ export async function createApplication(options?: AppOptions): Promise { const app = new Application({ path: Electron as any, args: [targetApp], connectionRetryCount: DEFAULT_APP_CONNECT_RETRIES, connectionRetryTimeout: DEFAULT_APP_CONNECT_TIMEOUT_MS, }); - await app.start(); - - const appController = new AppController(app); - - if (options?.suppressFirstTimeDialog === true) { - await appController.setTelemetryState(false); - } - - return appController; + return new AppController(app); } diff --git a/src/tests/electron/common/view-controllers/app-controller.ts b/src/tests/electron/common/view-controllers/app-controller.ts index b0ced2a688c..340c3af8d9d 100644 --- a/src/tests/electron/common/view-controllers/app-controller.ts +++ b/src/tests/electron/common/view-controllers/app-controller.ts @@ -8,7 +8,7 @@ import { DEFAULT_WAIT_FOR_ELEMENT_TO_BE_VISIBLE_TIMEOUT_MS } from 'tests/electro import { AutomatedChecksViewController } from './automated-checks-view-controller'; export class AppController { - private client: SpectronAsyncClient; + public client: SpectronAsyncClient; constructor(public app: Application) { this.client = app.client as any; diff --git a/src/tests/electron/common/view-controllers/codecs-test-view-controller.ts b/src/tests/electron/common/view-controllers/codecs-test-view-controller.ts new file mode 100644 index 00000000000..ca43d40ef90 --- /dev/null +++ b/src/tests/electron/common/view-controllers/codecs-test-view-controller.ts @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +import { SpectronAsyncClient } from 'tests/electron/common/view-controllers/spectron-async-client'; +import { ViewController } from './view-controller'; + +export class CodecTestViewController extends ViewController { + constructor(client: SpectronAsyncClient) { + super(client); + } + + public async waitForAudioVisible(): Promise { + await this.waitForSelector('#audio'); + } +} diff --git a/src/tests/electron/tests/framework-no-codecs.test.ts b/src/tests/electron/tests/framework-no-codecs.test.ts new file mode 100644 index 00000000000..37647dd1370 --- /dev/null +++ b/src/tests/electron/tests/framework-no-codecs.test.ts @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +import * as path from 'path'; +import { createAppController } from 'tests/electron/common/create-application'; +import { AppController } from 'tests/electron/common/view-controllers/app-controller'; +import { CodecTestViewController } from 'tests/electron/common/view-controllers/codecs-test-view-controller'; + +/* +We bundle a mirrored version of electron with minimal +audio/video codecs to avoid shipping proprietary codecs +we don't need in the release build. This e2e test checks +to ensure we have the right codecs. If this test fails, +it's likely node_modules/electron/dist was not replaced +with the appropriate electron mirror. +*/ + +const releaseTests = process.env['Build.DefinitionName'] === 'build-unsigned-release-packages'; +(releaseTests ? describe : describe.skip)( + 'electron bundled with minimal audio-video codecs', + () => { + let appController: AppController; + let viewContoller: CodecTestViewController; + + beforeEach(async () => { + appController = await createAppController( + path.resolve(__dirname, '..', '..', 'miscellaneous', 'codecs', 'codecs-test.js'), + ); + viewContoller = new CodecTestViewController(appController.client); + await viewContoller.waitForAudioVisible(); + }); + + afterEach(async () => await appController.stop()); + + // https://html.spec.whatwg.org/multipage/media.html#error-codes:dom-mediaerror-media_err_src_not_supported + it('has error when loading mp3