Integration test: yet another round of fixes

This commit is contained in:
DC
2016-09-21 12:51:37 -07:00
parent b57ee73035
commit 82c49b5fc5
4 changed files with 12 additions and 10 deletions

View File

@@ -27,7 +27,8 @@ function createApp (t) {
path: path.join(__dirname, '..', 'node_modules', '.bin',
'electron' + (process.platform === 'win32' ? '.cmd' : '')),
args: ['-r', path.join(__dirname, 'mocks.js'), path.join(__dirname, '..')],
env: {NODE_ENV: 'test'}
env: {NODE_ENV: 'test'},
waitTimeout: 10e3
})
}
@@ -101,6 +102,7 @@ function compareIgnoringTransparency (bufActual, bufExpected) {
// Otherwise, compare pixel by pixel
let sumSquareDiff = 0
let numDiff = 0
const pngA = PNG.sync.read(bufActual)
const pngE = PNG.sync.read(bufExpected)
if (pngA.width !== pngE.width || pngA.height !== pngE.height) return false
@@ -119,14 +121,16 @@ function compareIgnoringTransparency (bufActual, bufExpected) {
// Add pixel diff to running sum
// This is necessary on Windows, where rendering apparently isn't quite deterministic
// and a few pixels in the screenshot will sometimes be off by 1. (Visually identical.)
numDiff++
sumSquareDiff += (da[i] - de[i]) * (da[i] - de[i])
sumSquareDiff += (da[i + 1] - de[i + 1]) * (da[i + 1] - de[i + 1])
sumSquareDiff += (da[i + 2] - de[i + 2]) * (da[i + 2] - de[i + 2])
}
}
const rms = Math.sqrt(sumSquareDiff / (numDiff + 1))
const l2Distance = Math.round(Math.sqrt(sumSquareDiff))
console.log('screenshot diff l2 distance: ' + l2Distance)
return l2Distance < 2000
console.log('screenshot diff l2 distance: ' + l2Distance + ', rms: ' + rms)
return l2Distance < 4000 && rms < 100
}
// Resets the test directory, containing config.json, torrents, downloads, etc

View File

@@ -45,11 +45,11 @@ test('create-torrent', function (t) {
.then(() => app.client.waitUntilTextExists('.torrent-list', 'Big Buck Bunny'))
// Click the + button, open a non-torrent file to seed
.then(() => app.client.click('.icon.add'))
.then(() => app.client.waitUntilTextExists('.create-torrent', 'Create'))
.then(() => app.client.waitUntilTextExists('h1', 'Create'))
.then(() => setup.screenshotCreateOrCompare(app, t, 'create-torrent-simple'))
// Click to show advanced settings
.then(() => app.client.click('.show-more .control'))
.then(() => app.client.waitUntilTextExists('.create-torrent', 'Comment'))
.then(() => app.client.waitUntilTextExists('.create-torrent-advanced', 'Comment'))
.then(() => setup.screenshotCreateOrCompare(app, t, 'create-torrent-advanced'))
// Click OK to create the torrent
.then(() => app.client.click('.control.create-torrent'))

View File

@@ -22,7 +22,6 @@ test('audio-streaming', function (t) {
// Click next
.then(() => app.client.click('.skip-next'))
.then(() => app.client.waitUntilTextExists('.player', 'David Byrne'))
.then(() => setup.wait(5e3))
.then(() => app.client.moveToObject('.letterbox'))
.then(() => app.webContents.executeJavaScript('dispatch("playPause")'))
.then(() => app.webContents.executeJavaScript('dispatch("skipTo", 2)'))
@@ -31,8 +30,7 @@ test('audio-streaming', function (t) {
.then(() => app.webContents.executeJavaScript('dispatch("skipTo", 206)'))
.then(() => app.webContents.executeJavaScript('dispatch("playPause")'))
// Play past the end of the song, then pause after the start of the next song by Zap Mama
.then(() => app.client.waitUntilTextExists('.player', 'Zap Mama'), 15e3)
.then(() => setup.wait(5e3))
.then(() => app.client.waitUntilTextExists('.player', 'Zap Mama', 15e3))
.then(() => app.webContents.executeJavaScript('dispatch("playPause")'))
.then(() => app.webContents.executeJavaScript('dispatch("skipTo", 2)'))
.then(() => setup.screenshotCreateOrCompare(app, t, 'play-torrent-wired-3'))

View File

@@ -35,7 +35,7 @@ test('torrent-list: start, stop, and delete torrents', function (t) {
.then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-hover'))
// Click download on the first torrent, start downloading
.then(() => app.client.click('.icon.download'))
.then(() => app.client.waitUntilTextExists('.torrent-list', '276MB'))
.then(() => app.client.waitUntilTextExists('.torrent-list', '276 MB'))
.then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-start-download'))
// Click download on the first torrent again, stop downloading
.then(() => app.client.click('.icon.download'))
@@ -73,7 +73,7 @@ test('torrent-list: expand torrent, unselect file', function (t) {
.then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-cosmos-expand-deselect'))
// Start the torrent
.then(() => app.client.click('#torrent-cosmos .icon.download'))
.then(() => app.client.waitUntilTextExists('.torrent-list', 'peers'))
.then(() => app.client.waitUntilTextExists('.torrent-list', '0%'))
.then(() => setup.screenshotCreateOrCompare(app, t, 'torrent-list-cosmos-expand-start'))
// Make sure that it creates all files EXCEPT the deslected one
.then(() => setup.compareDownloadFolder(t, 'CosmosLaundromatFirstCycle', [