Script ui-test scenes

This commit is contained in:
Thomas Nordquist
2019-04-15 10:15:06 +02:00
parent 499dfd1b68
commit 2de7840897
5 changed files with 908 additions and 24 deletions

View File

@@ -94,6 +94,7 @@
"electron-log": "^2.2.17",
"electron-telemetry": "git+https://github.com/thomasnordquist/electron-telemetry.git#dist",
"electron-updater": "^4.0.6",
"ffmpeg-concat": "^1.0.13",
"js-base64": "^2.5.1",
"lowdb": "^1.0.0",
"mqtt": "^2.18.8",

56
scripts/cutScenes.ts Executable file
View File

@@ -0,0 +1,56 @@
#!./node_modules/.bin/ts-node
import * as fs from 'fs'
import { Scene, SceneNames } from '../src/spec/SceneBuilder'
import { exec } from './util'
const concat = require('ffmpeg-concat')
async function cutScenes(scenes: Array<Scene>) {
for (const scene of scenes) {
const outputFile = `${scene.name}.mp4`
if (fs.existsSync(outputFile)) {
fs.unlinkSync(outputFile)
}
await exec('ffmpeg', `-i app2.mp4 -ss ${scene.start / 1000} -t ${scene.duration / 1000} ${scene.name}.mp4`.split(' '))
}
}
type Transistions = 'none' | 'pixelize' | 'cube' | 'directionalWarp' | 'hexagonalize'
class TransitionBuilder {
private scenes: Array<string> = []
private transitions: Array<string> = []
public startWith(scene: SceneNames): TransitionBuilder {
this.scenes.push(scene)
return this
}
public transitionTo(scene: SceneNames, transition: Transistions): TransitionBuilder {
this.scenes.push(scene)
this.transitions.push(transition)
return this
}
public buildOptions(outputFile: string) {
return {
output: outputFile,
videos: this.scenes.map(s => `${s}.mp4`),
transistions: this.transitions.map(name => ({
name: name !== 'none' ? name : 'fade',
duration: name !== 'none' ? 1000 : 10,
})),
}
}
}
// const scenes: Array<Scene> = JSON.parse(fs.readFileSync('./scenes.json').toString())
// cutScenes(scenes)
let builder = new TransitionBuilder()
.startWith('connect')
.transitionTo('numeric_plots', 'cube')
.transitionTo('diffs', 'pixelize')
.transitionTo('customize_subscriptions', 'hexagonalize')
concat(builder.buildOptions('test.mp4'))

View File

@@ -1,15 +1,30 @@
export interface Scene {
name: string,
name: SceneNames,
start: number
stop: number
duration: number
}
export type SceneNames = 'connect'
| 'topic_updates'
| 'numeric_plots'
| 'json-formatting'
| 'diffs'
| 'publish_topic'
| 'json_formatting_publish'
| 'clipboard'
| 'topic_filter'
| 'delete_retained_topics'
| 'settings'
| 'customize_subscriptions'
| 'keyboard_shortcuts'
| 'end'
export class SceneBuilder {
public scenes: Array<Scene> = []
public offset = Date.now()
public async record(name: string, callback: () => Promise<any>): Promise<any> {
public async record(name: SceneNames, callback: () => Promise<any>): Promise<any> {
const start = Date.now() - this.offset
await callback()
const stop = Date.now() - this.offset
@@ -21,4 +36,4 @@ export class SceneBuilder {
duration: stop - start,
})
}
}
}

View File

@@ -58,7 +58,6 @@ async function doStuff() {
// Wait for Username input to be visible
await browser.$(`//label[contains(text(), "Username")]/..//input`)
const scenes = new SceneBuilder()
await scenes.record('connect', async () => {
await connectTo('127.0.0.1', browser)
await sleep(2000)

853
yarn.lock

File diff suppressed because it is too large Load Diff