103 lines
2.0 KiB
JavaScript
103 lines
2.0 KiB
JavaScript
/* globals chai, describe, it, beforeEach, testFrame, UITest */
|
|
/* eslint no-console: ["error", { allow: ["log", "info", "error"] }] */
|
|
|
|
/**
|
|
* Imports
|
|
*/
|
|
|
|
/**
|
|
* Setup
|
|
*/
|
|
|
|
/**
|
|
* Tests
|
|
*/
|
|
describe('Zoom in, zoom out', function () {
|
|
|
|
before('load index.html in testFrame', function(done) {
|
|
|
|
if (window.testType !== 'all' && window.testType !== 'zoomInZoomOut') {
|
|
this.skip()
|
|
}
|
|
|
|
done()
|
|
})
|
|
|
|
it('should zoom in, zoom out, zoom in, zoom out, ... for one hour', function(done) {
|
|
|
|
this.timeout(1000 * 60 * 70)
|
|
this.slow(1000 * 60 * 61)
|
|
|
|
const app = testFrame.contentWindow.app3
|
|
|
|
const scale = app._deepZoomImage3.scatter.scale
|
|
const center = app._deepZoomImage3.scatter.center
|
|
|
|
function test() {
|
|
|
|
app._deepZoomImage3.scatter.scale = scale
|
|
app._deepZoomImage3.scatter.centerAt(center)
|
|
|
|
const fingers = fingersFromCenter(randomCenter(app.center))
|
|
|
|
new UITest()
|
|
.pinch(app.view, fingers.zoomIn, 1, {
|
|
distance: 200,
|
|
duration: 3
|
|
})
|
|
.pinch(app.view, fingers.zoomOut, 5, {
|
|
distance: -58,
|
|
duration: 2
|
|
})
|
|
.start()
|
|
}
|
|
|
|
setInterval(test, 9000)
|
|
|
|
test()
|
|
})
|
|
})
|
|
|
|
/**
|
|
* Utils
|
|
*/
|
|
function randomCenter(center) {
|
|
|
|
let x = Math.random() * 200
|
|
if (Math.random() < .5) {
|
|
x *= -1
|
|
}
|
|
|
|
let y = Math.random() * 200
|
|
if (Math.random() < .5) {
|
|
y *= -1
|
|
}
|
|
|
|
return {
|
|
x: center.x + x,
|
|
y: center.y + y
|
|
}
|
|
}
|
|
|
|
function fingersFromCenter(center) {
|
|
|
|
const finger1 = {
|
|
x: center.x - 3,
|
|
y: center.y
|
|
}
|
|
const finger2 = {
|
|
x: center.x + 3,
|
|
y: center.y
|
|
}
|
|
const finger3 = {
|
|
x: center.x - 30,
|
|
y: center.y
|
|
}
|
|
const finger4 = {
|
|
x: center.x + 30,
|
|
y: center.y
|
|
}
|
|
|
|
return {zoomIn: [finger1, finger2], zoomOut: [finger3, finger4]}
|
|
}
|