Bug 705175: update devicemanager, devicemanagerSUT versions of getAppRoot; r=jmaher

This commit is contained in:
Geoff Brown 2012-01-07 08:25:05 -05:00
parent e754a06e12
commit 8bdede3a06
5 changed files with 35 additions and 27 deletions

View File

@ -346,24 +346,7 @@ class DeviceManager:
# success: path for app root
# failure: None
def getAppRoot(self):
devroot = self.getDeviceRoot()
if (devroot == None):
return None
if (self.dirExists(devroot + '/fennec')):
return devroot + '/fennec'
elif (self.dirExists(devroot + '/firefox')):
return devroot + '/firefox'
elif (self.dirExsts('/data/data/org.mozilla.fennec')):
return 'org.mozilla.fennec'
elif (self.dirExists('/data/data/org.mozilla.firefox')):
return 'org.mozilla.firefox'
elif (self.dirExists('/data/data/org.mozilla.fennec_aurora')):
return 'org.mozilla.fennec_aurora'
elif (self.dirExists('/data/data/org.mozilla.firefox_beta')):
return 'org.mozilla.firefox_beta'
# Failure (either not installed or not a recognized platform)
assert 0 == 1
return None
# Gets the directory location on the device for a specific test type

View File

@ -426,15 +426,14 @@ class DeviceManagerADB(DeviceManager):
# returns:
# success: path for app root
# failure: None
def getAppRoot(self):
def getAppRoot(self, packageName):
devroot = self.getDeviceRoot()
if (devroot == None):
return None
if (self.dirExists(devroot + '/fennec')):
return devroot + '/fennec'
elif (self.dirExists(devroot + '/firefox')):
return devroot + '/firefox'
if (packageName and self.dirExists('/data/data/' + packageName)):
self.packageName = packageName
return '/data/data/' + packageName
elif (self.packageName and self.dirExists('/data/data/' + self.packageName)):
return '/data/data/' + self.packageName

View File

@ -858,6 +858,15 @@ class DeviceManagerSUT(DeviceManager):
return deviceRoot
def getAppRoot(self, packageName):
try:
data = self.verifySendCMD(['getapproot '+packageName])
except:
return None
appRoot = self.stripPrompt(data).strip('\n')
return appRoot
# external function
# returns:
# success: output of unzip command

View File

@ -137,7 +137,7 @@ public class DoCommand {
String ffxProvider = "org.mozilla.ffxcp";
String fenProvider = "org.mozilla.fencp";
private final String prgVersion = "SUTAgentAndroid Version 1.03";
private final String prgVersion = "SUTAgentAndroid Version 1.04";
public enum Command
{
@ -1285,7 +1285,7 @@ private void CancelNotification()
try {
Context appCtx = ctx.createPackageContext(AppName, 0);
ContextWrapper appCtxW = new ContextWrapper(appCtx);
sRet = appCtxW.getPackageResourcePath();
sRet = appCtxW.getApplicationInfo().dataDir;
appCtxW = null;
appCtx = null;
ctx = null;

View File

@ -37,6 +37,7 @@
# ***** END LICENSE BLOCK ***** */
import re, sys, os
import subprocess
import runxpcshelltests as xpcshell
from automationutils import *
import devicemanager, devicemanagerADB, devicemanagerSUT
@ -66,6 +67,22 @@ class XPCShellRemote(xpcshell.XPCShellTests, object):
self.remoteAPK = self.remoteJoin(self.remoteBinDir, os.path.basename(options.localAPK))
self.remoteDebugger = options.debugger
self.remoteDebuggerArgs = options.debuggerArgs
self.setAppRoot()
def setAppRoot(self):
# Determine the application root directory associated with the package
# name used by the Fennec APK.
self.appRoot = None
packageName = None
if self.options.localAPK:
try:
packageName = subprocess.check_output(["unzip", "-p", self.options.localAPK, "package-name.txt"])
if packageName:
self.appRoot = self.device.getAppRoot(packageName.strip())
except Exception as detail:
print "unable to determine app root: " + detail
pass
return None
def remoteJoin(self, path1, path2):
joined = os.path.join(path1, path2)
@ -203,9 +220,9 @@ class XPCShellRemote(xpcshell.XPCShellTests, object):
shellArgs = "cd "+self.remoteHere
shellArgs += "; LD_LIBRARY_PATH="+self.remoteBinDir
shellArgs += "; export CACHE_PATH="+self.remoteBinDir
if (self.device.getAppRoot()):
if (self.appRoot):
# xpcshell still runs without GRE_HOME; it may not be necessary
shellArgs += "; export GRE_HOME="+self.device.getAppRoot()
shellArgs += "; export GRE_HOME="+self.appRoot
shellArgs += "; export XPCSHELL_TEST_PROFILE_DIR="+self.profileDir
shellArgs += "; "+xpcshell+" "
shellArgs += " ".join(cmd[1:])