Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module.exports = (function() {
- let isEmpty = true
- let scriptPath = {
- scriptPath: './pyforJS'
- };
- var library = English.library()
- .given("The player has opened and has no advertisement in playList and train is in station",function(){
- return new Promise(function(resolve,reject){
- launch.app.webContents.send('playProgramRequest',undefined,0)
- var pyshell = new PythonShell('detect_arrive.py',scriptPath);
- pyshell.on('message', function (result) {
- if(result){
- let _emptyProgramTable = utils.getProgramTable()
- for(var index in _emptyProgramTable) {
- if(_emptyProgramTable[index].length !=0) assert.fail('there is already a program in CMS')
- }
- isEmpty = true
- resolve()
- }
- })
- })
- })
- .when("Train depart the station over $NUM seconds", function(number) {
- let seconds = parseInt(number*1000)
- return new Promise(function(resolve, reject) {
- setTimeout(function() {
- var pyshell = new PythonShell('detect_depart.py',scriptPath);
- pyshell.on('message', function (result) {
- if(result) {
- setTimeout(() => {
- if(isEmpty){
- launch.app.webContents.send('playProgramRequest',undefined,0)
- }
- else{
- launch.app.webContents.send('playProgramRequest',program,0)
- }
- resolve(result)
- }, seconds);
- assert(true)
- }
- else {
- reject(result)
- assert.fail()
- }
- });
- }, 100);
- })
- })
- .then("The player should start to play", function() {
- return new Promise(function(resolve,reject){
- setTimeout(() => {
- resolve()
- }, 5000);
- })
- return launch.app.client.getAttribute('video','src')
- .then(result=>{
- if(result === ''){
- assert.fail('the program does not start')
- }
- })
- })
- .then("The player should stay paused",function(){
- return new Promise(function(resolve,reject){
- setTimeout(() => {
- resolve()
- }, 5000);
- })
- return launch.app.client.getAttribute('video','src')
- .then(result=>{
- if(result !== ''){
- assert.fail('the player should stay stopped')
- }
- })
- })
- return library;
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement