From 8bdede3a0621cccc911a08bf90115810108785e6 Mon Sep 17 00:00:00 2001 From: Geoff Brown Date: Sat, 7 Jan 2012 08:25:05 -0500 Subject: [PATCH] Bug 705175: update devicemanager, devicemanagerSUT versions of getAppRoot; r=jmaher --- build/mobile/devicemanager.py | 19 +----------------- build/mobile/devicemanagerADB.py | 9 ++++----- build/mobile/devicemanagerSUT.py | 9 +++++++++ build/mobile/sutagent/android/DoCommand.java | 4 ++-- testing/xpcshell/remotexpcshelltests.py | 21 ++++++++++++++++++-- 5 files changed, 35 insertions(+), 27 deletions(-) diff --git a/build/mobile/devicemanager.py b/build/mobile/devicemanager.py index 1dd730c30ffb..302be8b87cab 100755 --- a/build/mobile/devicemanager.py +++ b/build/mobile/devicemanager.py @@ -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 diff --git a/build/mobile/devicemanagerADB.py b/build/mobile/devicemanagerADB.py index 4a89dc600cdc..62705c18f9d6 100644 --- a/build/mobile/devicemanagerADB.py +++ b/build/mobile/devicemanagerADB.py @@ -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 diff --git a/build/mobile/devicemanagerSUT.py b/build/mobile/devicemanagerSUT.py index b249b50610db..1997fa722eb0 100644 --- a/build/mobile/devicemanagerSUT.py +++ b/build/mobile/devicemanagerSUT.py @@ -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 diff --git a/build/mobile/sutagent/android/DoCommand.java b/build/mobile/sutagent/android/DoCommand.java index 4ac7e06c8b19..d1e842e94ac3 100755 --- a/build/mobile/sutagent/android/DoCommand.java +++ b/build/mobile/sutagent/android/DoCommand.java @@ -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; diff --git a/testing/xpcshell/remotexpcshelltests.py b/testing/xpcshell/remotexpcshelltests.py index edbbd426f897..33878cff047a 100644 --- a/testing/xpcshell/remotexpcshelltests.py +++ b/testing/xpcshell/remotexpcshelltests.py @@ -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:])