Integration test: video playback
This commit is contained in:
@@ -98,14 +98,16 @@ function init () {
|
|||||||
/**
|
/**
|
||||||
* File handlers
|
* File handlers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ipc.on('setDefaultFileHandler', (e, flag) => {
|
ipc.on('setDefaultFileHandler', (e, flag) => {
|
||||||
if (flag) handlers.install()
|
if (flag) handlers.install()
|
||||||
else handlers.uninstall()
|
else handlers.uninstall()
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Startup
|
* Auto start on login
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ipc.on('setStartup', (e, flag) => {
|
ipc.on('setStartup', (e, flag) => {
|
||||||
if (flag) startup.install()
|
if (flag) startup.install()
|
||||||
else startup.uninstall()
|
else startup.uninstall()
|
||||||
@@ -143,7 +145,25 @@ function init () {
|
|||||||
|
|
||||||
ipc.on('quitExternalPlayer', () => externalPlayer.kill())
|
ipc.on('quitExternalPlayer', () => externalPlayer.kill())
|
||||||
|
|
||||||
// Capture all events
|
/**
|
||||||
|
* Test
|
||||||
|
*/
|
||||||
|
|
||||||
|
ipc.on('testOffline', function (e, isOffline) {
|
||||||
|
log('Testing, network ' + (isOffline ? 'OFFLINE' : 'ONLINE'))
|
||||||
|
// Get the two Electron BrowserWindows (main UI window, hidden webtorrent window)
|
||||||
|
const wins = [windows.main.win, windows.webtorrent.win]
|
||||||
|
wins.forEach(function (win) {
|
||||||
|
if (isOffline) win.webContents.session.enableNetworkEmulation({ latency: 10e3 })
|
||||||
|
else win.webContents.session.disableNetworkEmulation()
|
||||||
|
log('WTF')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Message passing
|
||||||
|
*/
|
||||||
|
|
||||||
const oldEmit = ipc.emit
|
const oldEmit = ipc.emit
|
||||||
ipc.emit = function (name, e, ...args) {
|
ipc.emit = function (name, e, ...args) {
|
||||||
// Relay messages between the main window and the WebTorrent hidden window
|
// Relay messages between the main window and the WebTorrent hidden window
|
||||||
|
|||||||
@@ -15,10 +15,9 @@ test('app runs', function (t) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
require('./test-torrent-list')
|
require('./test-torrent-list')
|
||||||
require('./test-add-torrent')
|
// require('./test-add-torrent')
|
||||||
|
|
||||||
// TODO:
|
|
||||||
// require('./test-video')
|
// require('./test-video')
|
||||||
|
|
||||||
// require('./test-audio')
|
// require('./test-audio')
|
||||||
// require('./test-cast')
|
// require('./test-cast')
|
||||||
// require('./test-prefs')
|
// require('./test-prefs')
|
||||||
|
|||||||
BIN
test/resources/monitor-test.mp4
Normal file
BIN
test/resources/monitor-test.mp4
Normal file
Binary file not shown.
BIN
test/screenshots/darwin/play-torrent-bbb.png
Normal file
BIN
test/screenshots/darwin/play-torrent-bbb.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 301 KiB |
@@ -44,6 +44,8 @@ function waitForLoad (app, t, opts) {
|
|||||||
return app.client.windowByIndex(1)
|
return app.client.windowByIndex(1)
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return app.client.waitUntilWindowLoaded()
|
return app.client.waitUntilWindowLoaded()
|
||||||
|
}).then(function () {
|
||||||
|
if (!opts.online) app.electron.ipcRenderer.send('testOffline', true)
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return app.webContents.getTitle()
|
return app.webContents.getTitle()
|
||||||
}).then(function (title) {
|
}).then(function (title) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const fs = require('fs-extra')
|
|||||||
const setup = require('./setup')
|
const setup = require('./setup')
|
||||||
const config = require('./config')
|
const config = require('./config')
|
||||||
|
|
||||||
test('torrent-list: show download path missing', function (t) {
|
test.skip('torrent-list: show download path missing', function (t) {
|
||||||
setup.resetTestDataDir()
|
setup.resetTestDataDir()
|
||||||
fs.removeSync(config.TEST_DIR_DOWNLOAD)
|
fs.removeSync(config.TEST_DIR_DOWNLOAD)
|
||||||
|
|
||||||
@@ -37,6 +37,7 @@ test('torrent-list: start, stop, and delete torrents', function (t) {
|
|||||||
// Click download on the first torrent, start downloading
|
// Click download on the first torrent, start downloading
|
||||||
.then(() => app.client.click('.icon.download'))
|
.then(() => app.client.click('.icon.download'))
|
||||||
.then(() => app.client.waitUntilTextExists('.torrent-list', 'peer'))
|
.then(() => app.client.waitUntilTextExists('.torrent-list', 'peer'))
|
||||||
|
.then(() => setup.wait(100e3))
|
||||||
.then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-start-download'))
|
.then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-start-download'))
|
||||||
// Click download on the first torrent again, stop downloading
|
// Click download on the first torrent again, stop downloading
|
||||||
.then(() => app.client.click('.icon.download'))
|
.then(() => app.client.click('.icon.download'))
|
||||||
|
|||||||
34
test/test-video.js
Normal file
34
test/test-video.js
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
const test = require('tape')
|
||||||
|
const setup = require('./setup')
|
||||||
|
|
||||||
|
test('basic-streaming', function (t) {
|
||||||
|
setup.resetTestDataDir()
|
||||||
|
|
||||||
|
t.timeoutAfter(30e3)
|
||||||
|
const app = setup.createApp()
|
||||||
|
setup.waitForLoad(app, t, {online: true})
|
||||||
|
.then(() => app.client.waitUntilTextExists('.torrent-list', 'Big Buck Bunny'))
|
||||||
|
// Play Big Buck Bunny. Wait for it to start streaming.
|
||||||
|
.then(() => app.client.moveToObject('.torrent.bbb'))
|
||||||
|
.then(() => setup.wait())
|
||||||
|
.then(() => app.client.click('.icon.play'))
|
||||||
|
.then(() => setup.wait(10e3))
|
||||||
|
// Pause. Skip to two seconds in. Wait another two seconds for it to load.
|
||||||
|
.then(() => app.webContents.executeJavaScript('dispatch("playPause")'))
|
||||||
|
.then(() => app.webContents.executeJavaScript('dispatch("skipTo", 2)'))
|
||||||
|
.then(() => setup.wait(5e3))
|
||||||
|
// Take a screenshot to verify video playback
|
||||||
|
.then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-bbb'))
|
||||||
|
// Hit escape
|
||||||
|
.then(() => app.webContents.executeJavaScript('dispatch("escapeBack")'))
|
||||||
|
.then(() => setup.wait())
|
||||||
|
// Delete Big Buck Bunny
|
||||||
|
.then(() => app.client.click('.icon.delete'))
|
||||||
|
.then(() => setup.wait())
|
||||||
|
.then(() => app.client.click('.control.ok'))
|
||||||
|
.then(() => setup.wait())
|
||||||
|
// Take another screenshot to verify that the window resized correctly
|
||||||
|
.then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-return'))
|
||||||
|
.then(() => setup.endTest(app, t),
|
||||||
|
(err) => setup.endTest(app, t, err || 'error'))
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user