Skip to content

Commit

Permalink
Merge pull request #100 from simongranger/1.1.3
Browse files Browse the repository at this point in the history
1.1.3
  • Loading branch information
nickwangyoui authored May 15, 2019
2 parents c712bb9 + b4583c7 commit cefb0ce
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 68 deletions.
10 changes: 5 additions & 5 deletions lib/basedevice.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class BaseDevice {
closeApp () {
let msg = `closeApp is not supported on this platform`;
logger.errorAndThrow(msg);
};
}

endSession () {
let msg = `endSession is not supported on this platform`;
Expand All @@ -18,22 +18,22 @@ class BaseDevice {
installApp (appPath) {
let msg = `installApp is not supported on this platform`;
logger.errorAndThrow(msg);
};
}

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

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

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

startSession (caps) {
let msg = `startSession is not supported on this platform`;
Expand Down
18 changes: 9 additions & 9 deletions lib/bluesky.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BlueSky extends BaseDevice {
closeApp () {
logger.info(`BlueSky: Close App`);
this.shell.exec(`curl -d '' http://${this.caps.youiEngineAppAddress}:8060/keypress/home`);
};
}

endSession () {
logger.info(`BlueSky: End Session`);
Expand All @@ -22,16 +22,16 @@ class BlueSky extends BaseDevice {
} else {
this.closeApp();
}
};
}

installApp (appPath) {
logger.info(`BlueSky: Installing and launching app`);
if (this.isAppInstalled(this.channelId)){
if (this.isAppInstalled(this.channelId)) {
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();
};
}
isAppInstalled (channelId = this.channelId) {
logger.info(`BlueSky: Check if App is installed`);
// Check if app is installed
Expand All @@ -41,17 +41,17 @@ class BlueSky extends BaseDevice {
devAppInstalled = true;
}
return devAppInstalled;
};
}

launchApp () {
logger.info(`BlueSky: Launch app`);
this.shell.exec(`curl -d '' http://${this.caps.youiEngineAppAddress}:8060/launch/${this.channelId}`);
};
}

removeApp (channelId = this.channelId) {
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'`);
};
}

startSession (caps) {
logger.info(`BlueSky: Start Session`);
Expand All @@ -66,10 +66,10 @@ class BlueSky extends BaseDevice {

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

}

Expand Down
29 changes: 13 additions & 16 deletions lib/tvos.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import logger from './logger';
import commands from './commands/index';
import IOSDeploy from './ios-deploy';
import { sleep } from 'asyncbox';
import { youiEngineDriverReturnValues } from './utils';
import BaseDevice from './basedevice';

Expand All @@ -24,9 +22,8 @@ class TvOs extends BaseDevice {
} catch (err) {
logger.debug(`Stdout: '${err.stdout}'. Stderr: '${err.stderr}'.`);
throw new Error(`Could not run '${script}': '${err.message}'`);
return false;
}
};
}

async closeApp () {
logger.info(`tvOS: Close App`);
Expand All @@ -35,7 +32,7 @@ class TvOs extends BaseDevice {
};
let commandJSON = JSON.stringify(commandObject);
let data = await this.driver.executeSocketCommand(commandJSON);
let result;
let result;

try {
result = JSON.parse(data);
Expand All @@ -46,7 +43,7 @@ class TvOs extends BaseDevice {
if (result.status === youiEngineDriverReturnValues.WEBDRIVER_UNKNOWN_COMMAND) {
throw new Error("This command is only supported in You.i Engine v5.1.0+");
}
};
}

async endSession () {
logger.info(`tvOS: End Session`);
Expand All @@ -57,27 +54,27 @@ class TvOs extends BaseDevice {
} else {
await this.closeApp();
}
};
}

async installApp (appPath) {
logger.info(`tvOS: Installing and launching app`);
await this.iosdeploy.installApp(appPath);
};
}

async isAppInstalled (bundleId) {
logger.info(`tvOS: Check if App is installed`);
return await this.iosdeploy.isAppInstalled(bundleId);
};
}

async launchApp () {
logger.info(`tvOS: Launching app`);
await this.iosdeploy.launchApp(this.caps.app);
};
}

async removeApp (bundleId) {
logger.info(`tvOS: Deleting app`);
await this.iosdeploy.removeApp(bundleId)
};
await this.iosdeploy.removeApp(bundleId);
}

async startSession (caps, driver) {
logger.info(`tvOS: Start Session`);
Expand All @@ -88,15 +85,15 @@ class TvOs extends BaseDevice {

// Check if app is installed
let shell = require('shelljs');
this.bundleId = await shell.exec(`osascript -e 'id of app "${caps.app}"'`).replace(/(\r\n|\n|\r)/gm,"");
this.bundleId = await shell.exec(`osascript -e 'id of app "${caps.app}"'`).replace(/(\r\n|\n|\r)/gm, "");
let devAppInstalled = await this.isAppInstalled(this.bundleId);
if (caps.fullReset || !devAppInstalled) {
await this.installApp(caps.app);
//await this.launchApp(caps.app);
await this.installApp(caps.app);
//await this.launchApp(caps.app);
} else {
await this.launchApp();
}
};
}

}
export default TvOs;
30 changes: 14 additions & 16 deletions lib/tvossimulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import logger from './logger';
import { sleep } from 'asyncbox';
import { getSimulator } from 'appium-ios-simulator';
import * as simctl from 'node-simctl';
import { killAllSimulators } from './utils.js';
import BaseDevice from './basedevice';

class TvOsSimulator extends BaseDevice {
Expand All @@ -23,15 +22,14 @@ class TvOsSimulator extends BaseDevice {
} catch (err) {
logger.debug(`Stdout: '${err.stdout}'. Stderr: '${err.stderr}'.`);
throw new Error(`Could not run '${script}': '${err.message}'`);
return false;
}
};
}


async closeApp () {
logger.info(`tvOS simulator: Close app`);
await simctl.terminate(this.caps.udid, this.bundleId);
};
}

async endSession () {
logger.info(`tvOS simulator: End Session`);
Expand All @@ -42,11 +40,11 @@ class TvOsSimulator extends BaseDevice {
} else {
await this.closeApp();
}
};
}

async installApp (appPath) {
logger.info(`tvOS simulator: Installing and launching app`);
this.bundleId = this.shell.exec(`osascript -e 'id of app "${appPath}"'`).replace(/(\r\n|\n|\r)/gm,"");
this.bundleId = this.shell.exec(`osascript -e 'id of app "${appPath}"'`).replace(/(\r\n|\n|\r)/gm, "");
let retry = false;
do {
try {
Expand All @@ -56,41 +54,41 @@ class TvOsSimulator extends BaseDevice {
retry = true;
}
}
while (retry == true);
while (retry === true);
await simctl.launch(this.caps.udid, this.bundleId);
};
}

async isAppInstalled (bundleId) {
logger.info(`tvOS simulator: Check if App is installed`);
return await this.sim.isAppInstalled(bundleId);
};
}

async launchApp () {
logger.info(`tvOS simulator: Launching app`);
await simctl.launch(this.caps.udid, this.bundleId);
};
}

async removeApp (bundleId) {
logger.info(`tvOS simulator: Deleting app`);
await this.sim.removeApp(bundleId);
};
}

async startSession (caps) {
logger.info(`tvOS simulator: Start Session`);
this.caps = caps;
this.shell = require('shelljs');

this.sim = await getSimulator(this.caps.udid);
await this.sim.run({startupTimeout: 10000});
this.sim = await getSimulator(this.caps.udid);
await this.sim.run({startupTimeout: 10000});
await sleep(4000);
// Check if app is installed
this.bundleId = this.shell.exec(`osascript -e 'id of app "${caps.app}"'`).replace(/(\r\n|\n|\r)/gm,"");
this.bundleId = this.shell.exec(`osascript -e 'id of app "${caps.app}"'`).replace(/(\r\n|\n|\r)/gm, "");
let devAppInstalled = await this.isAppInstalled(this.bundleId);
if (caps.fullReset || !devAppInstalled) {
await this.installApp(caps.app);
await this.installApp(caps.app);
} else {
await this.launchApp(caps.app);
}
};
}
}
export default TvOsSimulator;
40 changes: 20 additions & 20 deletions lib/yimac.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class YiMac extends BaseDevice {
logger.info(`YiMac: Close App`);
let process_name = this.caps.app.substring(this.caps.app.lastIndexOf("/") + 1);
this.shell.exec(`killall ${process_name}`);
};
}

endSession () {
logger.info(`YiMac: End Session`);
Expand All @@ -28,25 +28,25 @@ class YiMac extends BaseDevice {
let showXcodeLog = this.caps.showXcodeLog; //For some reason stderr statement sees this.caps as undefined?!

//Print Xcode logs (STDOUT)
ls.stdout.on('data', function (data) {
if (showXcodeLog === true && data != null) {
logger.debug(`Xcode Log Output: ${data.toString()}`);
}
});

//Print Xcode logs (STDERR)
ls.stderr.on('data', function (data) {
if (showXcodeLog === true && data != null) {
logger.debug(`Xcode Log Error: ${data.toString()}`);
}
});

ls.on('exit', function (code) {
if (showXcodeLog === true && code != null) {
logger.debug(`Application exited with code ${code.toString()}`);
}
});
};
ls.stdout.on('data', function (data) {
if (showXcodeLog === true && data != null) {
logger.debug(`Xcode Log Output: ${data.toString()}`);
}
});

//Print Xcode logs (STDERR)
ls.stderr.on('data', function (data) {
if (showXcodeLog === true && data != null) {
logger.debug(`Xcode Log Error: ${data.toString()}`);
}
});

ls.on('exit', function (code) {
if (showXcodeLog === true && code != null) {
logger.debug(`Application exited with code ${code.toString()}`);
}
});
}

startSession (caps) {
logger.info(`YiMac: Start Session`);
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"keywords": [
"appium"
],
"version": "1.1.2",
"version": "1.1.3",
"author": "youi.tv",
"license": "Apache-2.0",
"repository": {
Expand Down Expand Up @@ -37,9 +37,11 @@
"asyncbox": "2.x",
"bluebird": "3.x",
"lodash": "4.x",
"node-simctl": "^5.0.1",
"selenium-webdriver": "3.x",
"shelljs": "0.8.x",
"source-map-support": "^0.5.9"
"source-map-support": "^0.5.9",
"teen_process": "^1.14.1"
},
"scripts": {
"prepare": "gulp prepublish",
Expand Down

0 comments on commit cefb0ce

Please sign in to comment.