Permalink
Browse files

Bug 851548 - Fix launching apps via agent when no user serial availab…

…le;r=mcote

This can happen with older versions of the agent without user serial
support.
  • Loading branch information...
1 parent 2057da5 commit a930b261bef9867e5381b7a6c005154d07ce2857 @wlach wlach committed Mar 15, 2013
Showing with 44 additions and 5 deletions.
  1. +7 −5 mozdevice/mozdevice/droid.py
  2. +36 −0 mozdevice/tests/droidsut_launch.py
  3. +1 −0 mozdevice/tests/manifest.ini
@@ -100,20 +100,22 @@ def _getExtraAmStartArgs(self):
# a different process than the one that started the app. In this case,
# we need to get back the original user serial number and then pass
# that to the 'am start' command line
- if not hasattr(self, 'userSerial'):
+ if not hasattr(self, '_userSerial'):
infoDict = self.getInfo(directive="sutuserinfo")
if infoDict.get('sutuserinfo') and \
len(infoDict['sutuserinfo']) > 0:
userSerialString = infoDict['sutuserinfo'][0]
# user serial always an integer, see: http://developer.android.com/reference/android/os/UserManager.html#getSerialNumberForUser%28android.os.UserHandle%29
m = re.match('User Serial:([0-9]+)', userSerialString)
if m:
- self.userSerial = m.group(1)
+ self._userSerial = m.group(1)
else:
- self.userSerial = None
+ self._userSerial = None
+ else:
+ self._userSerial = None
- if self.userSerial is not None:
- return [ "--user", self.userSerial ]
+ if self._userSerial is not None:
+ return [ "--user", self._userSerial ]
return []
@@ -0,0 +1,36 @@
+from sut import MockAgent
+import mozdevice
+import unittest
+
+class LaunchTest(unittest.TestCase):
+
+ def test_nouserserial(self):
+ a = MockAgent(self, commands = [("ps",
+ "10029 549 com.android.launcher\n"
+ "10066 1198 com.twitter.android"),
+ ("info sutuserinfo", ""),
+ ("exec am start -W -n "
+ "org.mozilla.fennec/.App -a "
+ "android.intent.action.VIEW",
+ "OK\nreturn code [0]")])
+ mozdevice.DroidSUT.debug = 4
+ d = mozdevice.DroidSUT("127.0.0.1", port=a.port)
+ d.launchFennec("org.mozilla.fennec")
+ a.wait()
+
+ def test_userserial(self):
+ a = MockAgent(self, commands = [("ps",
+ "10029 549 com.android.launcher\n"
+ "10066 1198 com.twitter.android"),
+ ("info sutuserinfo", "User Serial:0"),
+ ("exec am start --user 0 -W -n "
+ "org.mozilla.fennec/.App -a "
+ "android.intent.action.VIEW",
+ "OK\nreturn code [0]")])
+ mozdevice.DroidSUT.debug = 4
+ d = mozdevice.DroidSUT("127.0.0.1", port=a.port)
+ d.launchFennec("org.mozilla.fennec")
+ a.wait()
+
+if __name__ == '__main__':
+ unittest.main()
@@ -3,3 +3,4 @@
[sut_push.py]
[sut_pull.py]
[sut_ps.py]
+[droidsut_launch.py]

0 comments on commit a930b26

Please sign in to comment.