Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module.exports = (function() {
  2.     let isEmpty = true
  3.     let scriptPath = {
  4.         scriptPath: './pyforJS'
  5.     };
  6.     var library = English.library()
  7.     .given("The player has opened and has no advertisement in playList and train is in station",function(){
  8.         return new Promise(function(resolve,reject){
  9.             launch.app.webContents.send('playProgramRequest',undefined,0)
  10.             var pyshell = new PythonShell('detect_arrive.py',scriptPath);
  11.             pyshell.on('message', function (result) {
  12.                 if(result){
  13.                     let _emptyProgramTable = utils.getProgramTable()
  14.                     for(var index in _emptyProgramTable) {
  15.                         if(_emptyProgramTable[index].length !=0) assert.fail('there is already a program')
  16.                     }
  17.                     isEmpty = true
  18.                     resolve()
  19.                 }
  20.             })
  21.         })
  22.     })
  23.     .when("Train depart the station over $NUM seconds", function(number) {  
  24.         let seconds = parseInt(number*1000)  
  25.         return new Promise(function(resolve, reject) {
  26.             setTimeout(function() {
  27.                 var pyshell = new PythonShell('detect_depart.py',scriptPath);
  28.                 pyshell.on('message', function (result) {
  29.                     if(result) {
  30.                         setTimeout(() => {
  31.                             if(isEmpty){
  32.                                 launch.app.webContents.send('playProgramRequest',undefined,0)
  33.                             }
  34.                             else{
  35.                                 launch.app.webContents.send('playProgramRequest',program,0)                                    
  36.                             }
  37.                             resolve(result)
  38.                         }, seconds);
  39.                        
  40.                         assert(true)
  41.                     }
  42.                     else {
  43.                         reject(result)
  44.                         assert.fail()
  45.                     }
  46.                 });
  47.             }, 100);
  48.         })
  49.     })
  50.     .then("The player should start to play", function() {
  51.         return new Promise(function(resolve,reject){
  52.             setTimeout(() => {
  53.                 resolve()
  54.             }, 5000);
  55.         })
  56.         return launch.app.client.getAttribute('video','src')
  57.         .then(result=>{
  58.             if(result === ''){
  59.                 assert.fail('the program does not start')
  60.             }
  61.         })      
  62.     })
  63.     .then("The player should stay paused",function(){
  64.         return new Promise(function(resolve,reject){
  65.             setTimeout(() => {
  66.                 resolve()
  67.             }, 5000);
  68.         })
  69.         return launch.app.client.getAttribute('video','src')
  70.         .then(result=>{
  71.             if(result !== ''){
  72.                 assert.fail('the player should stay stopped')
  73.             }
  74.         })
  75.     })
  76.     return library;
  77. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement