-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add e2e test to ensure we ship with non audio/video codecs (#2604)
- Loading branch information
1 parent
32c4f0d
commit d25ad5c
Showing
10 changed files
with
98 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
* text=auto eol=lf | ||
*.mp3 binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
"**/*.scss.d.ts", | ||
"**/*.snap", | ||
"**/*.svg", | ||
"**/*.mp3", | ||
"Dockerfile", | ||
"yarn.lock" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/tests/electron/common/view-controllers/codecs-test-view-controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<void> { | ||
await this.waitForSelector('#audio'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 no | ||
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.RUN_RELEASE_TESTS === 'true'; | ||
(releaseTests ? describe : describe.skip)( | ||
'electron bundled without proprietary 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 <audio> in renderer process', async () => { | ||
expect(await viewContoller.client.getAttribute('#audio', 'data-err')).toEqual('4'); | ||
}); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
const { app, BrowserWindow } = require('electron'); | ||
|
||
app.whenReady().then(() => { | ||
const win = new BrowserWindow(); | ||
win.loadFile('codecs.html'); | ||
}); |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!-- | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the MIT License. | ||
--> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>electron audio test</title> | ||
</head> | ||
<body> | ||
mp3 playback should fail: | ||
<audio | ||
controls | ||
src="codecs-test.mp3" | ||
id="audio" | ||
onerror="this.setAttribute('data-err', event.target.error.code)" | ||
></audio> | ||
</body> | ||
</html> |