Integration test: video playback

This commit is contained in:
DC
2016-09-14 20:10:43 -07:00
parent 75a4655a0f
commit bdb733352a
7 changed files with 62 additions and 6 deletions

View File

@@ -98,14 +98,16 @@ function init () {
/**
* File handlers
*/
ipc.on('setDefaultFileHandler', (e, flag) => {
if (flag) handlers.install()
else handlers.uninstall()
})
/**
* Startup
* Auto start on login
*/
ipc.on('setStartup', (e, flag) => {
if (flag) startup.install()
else startup.uninstall()
@@ -143,7 +145,25 @@ function init () {
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
ipc.emit = function (name, e, ...args) {
// Relay messages between the main window and the WebTorrent hidden window

View File

@@ -15,10 +15,9 @@ test('app runs', function (t) {
})
require('./test-torrent-list')
require('./test-add-torrent')
// TODO:
// require('./test-add-torrent')
// require('./test-video')
// require('./test-audio')
// require('./test-cast')
// require('./test-prefs')

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 KiB

View File

@@ -44,6 +44,8 @@ function waitForLoad (app, t, opts) {
return app.client.windowByIndex(1)
}).then(function () {
return app.client.waitUntilWindowLoaded()
}).then(function () {
if (!opts.online) app.electron.ipcRenderer.send('testOffline', true)
}).then(function () {
return app.webContents.getTitle()
}).then(function (title) {

View File

@@ -3,7 +3,7 @@ const fs = require('fs-extra')
const setup = require('./setup')
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()
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
.then(() => app.client.click('.icon.download'))
.then(() => app.client.waitUntilTextExists('.torrent-list', 'peer'))
.then(() => setup.wait(100e3))
.then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-start-download'))
// Click download on the first torrent again, stop downloading
.then(() => app.client.click('.icon.download'))

34
test/test-video.js Normal file
View 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'))
})