Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PA-99 Fixed app failing to launch on BlueSky #102

Merged
merged 1 commit into from
May 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PA-99 Fixed app failing to launch on BlueSky
Also resoved eslint warnings
  • Loading branch information
simongranger committed May 24, 2019
commit 44ea14a249d028cb29acfadb01b2ad5f236b79b5
29 changes: 11 additions & 18 deletions lib/basedevice.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,31 @@ class BaseDevice {
}

closeApp () {
let msg = `closeApp is not supported on this platform`;
logger.errorAndThrow(msg);
logger.errorAndThrow(`closeApp is not supported on this platform`);
}

endSession () {
let msg = `endSession is not supported on this platform`;
logger.errorAndThrow(msg);
logger.errorAndThrow(`endSession is not supported on this platform`);
}

installApp (appPath) {
let msg = `installApp is not supported on this platform`;
logger.errorAndThrow(msg);
installApp (appPath) { // eslint-disable-line no-unused-vars
logger.errorAndThrow(`installApp is not supported on this platform`);
}

isAppInstalled (channelId) {
let msg = `isAppInstalled is not supported on this platform`;
logger.errorAndThrow(msg);
isAppInstalled (channelId) { // eslint-disable-line no-unused-vars
logger.errorAndThrow(`isAppInstalled is not supported on this platform`);
}

launchApp () {
let msg = `launchApp is not supported on this platform`;
logger.errorAndThrow(msg);
logger.errorAndThrow(`launchApp is not supported on this platform`);
}

removeApp (channelId) {
let msg = `removeApp is not supported on this platform`;
logger.errorAndThrow(msg);
removeApp (channelId) { // eslint-disable-line no-unused-vars
logger.errorAndThrow(`removeApp is not supported on this platform`);
}

startSession (caps) {
let msg = `startSession is not supported on this platform`;
logger.errorAndThrow(msg);
startSession (caps) { // eslint-disable-line no-unused-vars
logger.errorAndThrow(`startSession is not supported on this platform`);
}

}
Expand Down
59 changes: 36 additions & 23 deletions lib/bluesky.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,72 @@
import logger from './logger';
import BaseDevice from './basedevice';
import { sleep } from 'asyncbox';

class BlueSky extends BaseDevice {

constructor () {
super();
let channelId;
let caps;
let shell;
this.channelId;
this.caps;
this.shell;
}

closeApp () {
async closeApp () {
logger.info(`BlueSky: Close App`);
this.shell.exec(`curl -d '' http://${this.caps.youiEngineAppAddress}:8060/keypress/home`);
await this.shell.exec(`curl -d '' http://${this.caps.youiEngineAppAddress}:8060/keypress/home`);
let activeApp;
do {
await sleep (1000);
activeApp = await this.shell.exec(`curl http://${this.caps.youiEngineAppAddress}:8060/query/active-app`);
} while (!(activeApp.includes(`<app>Roku</app>`)));
}

endSession () {
async endSession () {
logger.info(`BlueSky: End Session`);
if (this.caps.fullReset) {
this.removeApp(this.channelId);
await this.removeApp(this.channelId);
} else {
this.closeApp();
await this.closeApp();
}
}

installApp (appPath) {
async installApp (appPath) {
logger.info(`BlueSky: Installing and launching app`);
if (this.isAppInstalled(this.channelId)) {
this.removeApp(this.channelId);
if (await this.isAppInstalled(this.channelId)) {
await this.removeApp(this.channelId);
}
this.shell.exec(`curl -v -# -f -i --user '${this.caps.username}:${this.caps.password}' --digest --progress-bar -F 'mysubmit=Install' -F 'archive=@${appPath}' -F 'passwd=' http://${this.caps.youiEngineAppAddress}/plugin_install | grep '<font color' | sed 's/<font color=\'red\'>//' `);
this.launchApp();
// eslint-disable-next-line no-useless-escape
await this.shell.exec(`curl -v -# -f -i --user '${this.caps.username}:${this.caps.password}' --digest --progress-bar -F 'mysubmit=Install' -F 'archive=@${appPath}' -F 'passwd=' http://${this.caps.youiEngineAppAddress}/plugin_install | grep '<font color' | sed 's/<font color=\'red\'>//' `);
await this.launchApp();
}
isAppInstalled (channelId = this.channelId) {

async isAppInstalled (channelId = this.channelId) {
logger.info(`BlueSky: Check if App is installed`);
// Check if app is installed
let devAppInstalled = false;
let installedApps = this.shell.exec(`curl http://${this.caps.youiEngineAppAddress}:8060/query/apps`);
let installedApps = await this.shell.exec(`curl http://${this.caps.youiEngineAppAddress}:8060/query/apps`);
if (installedApps.includes(`id="${channelId}"`)) {
devAppInstalled = true;
}
return devAppInstalled;
}

launchApp () {
async launchApp () {
logger.info(`BlueSky: Launch app`);
this.shell.exec(`curl -d '' http://${this.caps.youiEngineAppAddress}:8060/launch/${this.channelId}`);
let activeApp;
do {
await sleep(5000);
await this.shell.exec(`curl -d '' http://${this.caps.youiEngineAppAddress}:8060/launch/${this.channelId}`);
activeApp = await this.shell.exec(`curl http://${this.caps.youiEngineAppAddress}:8060/query/active-app`);
} while (!(activeApp.includes(`id="${this.channelId}"`)));
}

removeApp (channelId = this.channelId) {
async removeApp (channelId) { // eslint-disable-line no-unused-vars
logger.info(`BlueSky: Delete app`);
this.shell.exec(`curl --user ${this.caps.username}:${this.caps.password} --digest --progress-bar --show-error -F 'mysubmit=Delete' -F 'archive=' --output /tmp/dev_server_out --write-out '%{http_code}' 'http://${this.caps.youiEngineAppAddress}/plugin_install'`);
await this.shell.exec(`curl --user ${this.caps.username}:${this.caps.password} --digest --progress-bar --show-error -F 'mysubmit=Delete' -F 'archive=' --output /tmp/dev_server_out --write-out '%{http_code}' 'http://${this.caps.youiEngineAppAddress}/plugin_install'`);
}

startSession (caps) {
async startSession (caps) {
logger.info(`BlueSky: Start Session`);
this.caps = caps;
this.shell = require('shelljs');
Expand All @@ -62,12 +75,12 @@ class BlueSky extends BaseDevice {
this.channelId = caps.channelId;
}
// Check if app is installed
let devAppInstalled = this.isAppInstalled(this.channelId);
let devAppInstalled = await this.isAppInstalled(this.channelId);

if (caps.fullReset || !devAppInstalled) {
this.installApp(caps.app);
await this.installApp(caps.app);
} else {
this.launchApp();
await this.launchApp();
}
}

Expand Down
10 changes: 5 additions & 5 deletions lib/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ class YouiEngineDriver extends BaseDriver {
break;
case "yimac":
this.device = new YiMac();
this.device.startSession(caps);
await this.device.startSession(caps);
break;
case "bluesky":
this.device = new BlueSky();
this.device.startSession(caps);
await this.device.startSession(caps);
break;
case "yitvos":
case "yitvos": {
let shell = require('shelljs');
if (shell.exec(`instruments -s devices | grep '${caps.udid}'`).includes('(Simulator)')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be one line, doesnt really matter.
if (shell.exec(instruments -s devices | grep '${caps.udid}').includes('(Simulator)')) this.device = . new TvOsSimulator();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expected bracket after if statement

this.device = new TvOsSimulator();
Expand All @@ -115,12 +115,12 @@ class YouiEngineDriver extends BaseDriver {
}
await this.device.startSession(caps, this);
break;
}
case "noproxy":
case "connecttoapp":
break;
default:
let msg = `Unsupported platformName: ${caps.platformName}`;
logger.errorAndThrow(msg);
logger.errorAndThrow(`Unsupported platformName: ${caps.platformName}`);
}
}

Expand Down
8 changes: 4 additions & 4 deletions lib/tvos.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class TvOs extends BaseDevice {

constructor () {
super();
let bundleId;
let caps;
let iosdeploy;
let driver;
this.bundleId;
this.caps;
this.iosdeploy;
this.driver;
}

async execScript (script) {
Expand Down
8 changes: 4 additions & 4 deletions lib/tvossimulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ class TvOsSimulator extends BaseDevice {

constructor () {
super();
let bundleId;
let caps;
let shell;
let sim;
this.bundleId;
this.caps;
this.shell;
this.sim;
}

execScript (script) {
Expand Down
22 changes: 11 additions & 11 deletions lib/yimac.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ class YiMac extends BaseDevice {

constructor () {
super();
let caps;
let shell;
this.caps;
this.shell;
}

closeApp () {
async closeApp () {
logger.info(`YiMac: Close App`);
let process_name = this.caps.app.substring(this.caps.app.lastIndexOf("/") + 1);
this.shell.exec(`killall ${process_name}`);
await this.shell.exec(`killall ${process_name}`);
}

endSession () {
async endSession () {
logger.info(`YiMac: End Session`);
this.closeApp();
await this.closeApp();
}

launchApp () {
async launchApp () {
logger.info(`YiMac: Launch app`);
let spawn = require('child_process').spawn,
ls = spawn(this.caps.app);
ls = await spawn(this.caps.app);

let showXcodeLog = this.caps.showXcodeLog; //For some reason stderr statement sees this.caps as undefined?!

Expand All @@ -48,12 +48,12 @@ class YiMac extends BaseDevice {
});
}

startSession (caps) {
async startSession (caps) {
logger.info(`YiMac: Start Session`);
this.caps = caps;
this.shell = require('shelljs');
this.closeApp();
this.launchApp();
await this.closeApp();
await this.launchApp();
}

}
Expand Down