Adding the ability to test on Chrome for Android.
use "android-chrome" as type in rtcbot running command. Example: node test.js android-chrome R=andresp@webrtc.org Review URL: https://webrtc-codereview.appspot.com/20329004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7102 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -22,6 +22,7 @@ access its exposed API. Details are in botmanager.js.
|
||||
<bot_type> — the type of the running bot. For example:
|
||||
- chrome: chrome on host machine.
|
||||
- android: android device. Details in "Android" Section.
|
||||
- android-chrome: chrome on android device. Details in "Android" Section.
|
||||
|
||||
== Example on how to install nodejs ==
|
||||
$ cd /work/tools/
|
||||
@@ -35,5 +36,6 @@ Before running test with Android one MUST forward the device port 8080 to the
|
||||
host machine. That is easy to achieve with chrome port forwarding tools.
|
||||
- Visit chrome://inspect/devices on the host machine.
|
||||
- Configure and enable port forwarding 8080 -> localhost:8080
|
||||
- Leave chrome running in the background on your Android device till
|
||||
the test is done.
|
||||
- Open chrome on you Android device before running test, and leave it
|
||||
running until the end of test.
|
||||
- Run your test.
|
||||
|
@@ -26,10 +26,12 @@ BotManager = function () {
|
||||
this.webSocketServer_ = null;
|
||||
this.bots_ = [];
|
||||
this.pendingConnections_ = [];
|
||||
this.androidDeviceManager_ = new AndroidDeviceManager();
|
||||
}
|
||||
|
||||
BotManager.BotTypes = {
|
||||
CHROME : 'chrome',
|
||||
ANDROID_CHROME : 'android-chrome',
|
||||
};
|
||||
|
||||
BotManager.prototype = {
|
||||
@@ -37,6 +39,9 @@ BotManager.prototype = {
|
||||
switch(botType) {
|
||||
case BotManager.BotTypes.CHROME:
|
||||
return new BrowserBot(name, callback);
|
||||
case BotManager.BotTypes.ANDROID_CHROME:
|
||||
return new AndroidChromeBot(name, this.androidDeviceManager_,
|
||||
callback);
|
||||
default:
|
||||
console.log('Error: Type ' + botType + ' not supported by rtc-Bot!');
|
||||
process.exit(1);
|
||||
@@ -129,6 +134,35 @@ BrowserBot.prototype = {
|
||||
__proto__: Bot.prototype
|
||||
}
|
||||
|
||||
// AndroidChromeBot spawns a process to open
|
||||
// "http://localhost:8080/bot/browser/" on chrome for Android.
|
||||
AndroidChromeBot = function (name, androidDeviceManager, callback) {
|
||||
Bot.call(this, name, callback);
|
||||
androidDeviceManager.getNewDevice(function (serialNumber) {
|
||||
this.serialNumber_ = serialNumber;
|
||||
this.spawnBotProcess_();
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
AndroidChromeBot.prototype = {
|
||||
spawnBotProcess_: function () {
|
||||
this.log('Spawning Android device with serial ' + this.serialNumber_);
|
||||
var runChrome = 'adb -s ' + this.serialNumber_ + ' shell am start ' +
|
||||
'-n com.android.chrome/com.google.android.apps.chrome.Main ' +
|
||||
'-d http://localhost:8080/bot/';
|
||||
child.exec(runChrome, function (error, stdout, stderr) {
|
||||
if (error) {
|
||||
this.log(error);
|
||||
process.exit(1);
|
||||
}
|
||||
this.log('Opening Chrome for Android...');
|
||||
this.log(stdout);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
__proto__: Bot.prototype
|
||||
}
|
||||
|
||||
AndroidDeviceManager = function () {
|
||||
this.connectedDevices_ = [];
|
||||
}
|
||||
@@ -156,13 +190,13 @@ AndroidDeviceManager.prototype = {
|
||||
child.exec('adb devices' , function (error, stdout, stderr) {
|
||||
var devices = [];
|
||||
if (error || stderr) {
|
||||
console.log('' + (error || stderr));
|
||||
console.log(error || stderr);
|
||||
}
|
||||
if (stdout) {
|
||||
// The first line is "List of devices attached"
|
||||
// and the following lines:
|
||||
// <serial number> <device/emulator>
|
||||
var tempList = ('' + stdout).split("\n").slice(1);
|
||||
var tempList = stdout.split("\n").slice(1);
|
||||
for (var i = 0; i < tempList.length; i++) {
|
||||
if (tempList[i] == "") {
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user