summaryrefslogtreecommitdiffstats
path: root/testing/mozbase/mozdevice/tests
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/mozbase/mozdevice/tests
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/mozbase/mozdevice/tests')
-rw-r--r--testing/mozbase/mozdevice/tests/droidsut_launch.py36
-rw-r--r--testing/mozbase/mozdevice/tests/manifest.ini23
-rw-r--r--testing/mozbase/mozdevice/tests/sut.py89
-rw-r--r--testing/mozbase/mozdevice/tests/sut_app.py20
-rw-r--r--testing/mozbase/mozdevice/tests/sut_basic.py73
-rw-r--r--testing/mozbase/mozdevice/tests/sut_chmod.py22
-rw-r--r--testing/mozbase/mozdevice/tests/sut_copytree.py67
-rw-r--r--testing/mozbase/mozdevice/tests/sut_fileExists.py29
-rw-r--r--testing/mozbase/mozdevice/tests/sut_fileMethods.py72
-rw-r--r--testing/mozbase/mozdevice/tests/sut_info.py49
-rw-r--r--testing/mozbase/mozdevice/tests/sut_ip.py37
-rw-r--r--testing/mozbase/mozdevice/tests/sut_kill.py24
-rw-r--r--testing/mozbase/mozdevice/tests/sut_list.py22
-rw-r--r--testing/mozbase/mozdevice/tests/sut_logcat.py52
-rw-r--r--testing/mozbase/mozdevice/tests/sut_mkdir.py78
-rw-r--r--testing/mozbase/mozdevice/tests/sut_movetree.py65
-rw-r--r--testing/mozbase/mozdevice/tests/sut_ps.py50
-rw-r--r--testing/mozbase/mozdevice/tests/sut_pull.py47
-rw-r--r--testing/mozbase/mozdevice/tests/sut_push.py88
-rw-r--r--testing/mozbase/mozdevice/tests/sut_remove.py24
-rw-r--r--testing/mozbase/mozdevice/tests/sut_time.py18
-rw-r--r--testing/mozbase/mozdevice/tests/sut_unpackfile.py23
22 files changed, 1008 insertions, 0 deletions
diff --git a/testing/mozbase/mozdevice/tests/droidsut_launch.py b/testing/mozbase/mozdevice/tests/droidsut_launch.py
new file mode 100644
index 000000000..b9872e096
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/droidsut_launch.py
@@ -0,0 +1,36 @@
+from sut import MockAgent
+import mozdevice
+import logging
+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/org.mozilla.gecko.BrowserApp -a "
+ "android.intent.action.VIEW",
+ "OK\nreturn code [0]")])
+ d = mozdevice.DroidSUT("127.0.0.1", port=a.port, logLevel=logging.DEBUG)
+ 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/org.mozilla.gecko.BrowserApp -a "
+ "android.intent.action.VIEW",
+ "OK\nreturn code [0]")])
+ d = mozdevice.DroidSUT("127.0.0.1", port=a.port, logLevel=logging.DEBUG)
+ d.launchFennec("org.mozilla.fennec")
+ a.wait()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/mozdevice/tests/manifest.ini b/testing/mozbase/mozdevice/tests/manifest.ini
new file mode 100644
index 000000000..63825c85b
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/manifest.ini
@@ -0,0 +1,23 @@
+[DEFAULT]
+skip-if = os == 'win'
+
+[sut_app.py]
+[sut_basic.py]
+[sut_chmod.py]
+[sut_copytree.py]
+[sut_fileExists.py]
+[sut_fileMethods.py]
+[sut_info.py]
+[sut_ip.py]
+[sut_kill.py]
+[sut_list.py]
+[sut_logcat.py]
+[sut_mkdir.py]
+[sut_movetree.py]
+[sut_ps.py]
+[sut_push.py]
+[sut_pull.py]
+[sut_remove.py]
+[sut_time.py]
+[sut_unpackfile.py]
+[droidsut_launch.py]
diff --git a/testing/mozbase/mozdevice/tests/sut.py b/testing/mozbase/mozdevice/tests/sut.py
new file mode 100644
index 000000000..76a5ed313
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut.py
@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+
+# Any copyright is dedicated to the Public Domain.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+import datetime
+import socket
+import time
+
+from threading import Thread
+
+
+class MockAgent(object):
+
+ MAX_WAIT_TIME_SECONDS = 10
+ SOCKET_TIMEOUT_SECONDS = 5
+
+ def __init__(self, tester, start_commands=None, commands=[]):
+ if start_commands:
+ self.commands = start_commands
+ else:
+ self.commands = [("ver", "SUTAgentAndroid Version 1.14")]
+ self.commands = self.commands + commands
+
+ self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ self._sock.bind(("127.0.0.1", 0))
+ self._sock.listen(1)
+
+ self.tester = tester
+
+ self.thread = Thread(target=self._serve_thread)
+ self.thread.start()
+
+ self.should_stop = False
+
+ @property
+ def port(self):
+ return self._sock.getsockname()[1]
+
+ def _serve_thread(self):
+ conn = None
+ while self.commands:
+ if not conn:
+ conn, addr = self._sock.accept()
+ conn.settimeout(self.SOCKET_TIMEOUT_SECONDS)
+ conn.send("$>\x00")
+ (command, response) = self.commands.pop(0)
+ data = ''
+ timeout = datetime.datetime.now() + datetime.timedelta(
+ seconds=self.MAX_WAIT_TIME_SECONDS)
+ # The data might come in chunks, particularly if we are expecting
+ # multiple lines, as with push commands.
+ while (len(data) < len(command) and
+ datetime.datetime.now() < timeout):
+ try:
+ data += conn.recv(1024)
+ except socket.timeout:
+ # We handle timeouts in the main loop.
+ pass
+ self.tester.assertEqual(data.strip(), command)
+ # send response and prompt separately to test for bug 789496
+ # FIXME: Improve the mock agent, since overloading the meaning
+ # of 'response' is getting confusing.
+ if response is None: # code for "shut down"
+ conn.shutdown(socket.SHUT_RDWR)
+ conn.close()
+ conn = None
+ elif type(response) is int: # code for "time out"
+ max_timeout = 15.0
+ timeout = 0.0
+ interval = 0.1
+ while not self.should_stop and timeout < max_timeout:
+ time.sleep(interval)
+ timeout += interval
+ if timeout >= max_timeout:
+ raise Exception("Maximum timeout reached! This should not "
+ "happen")
+ return
+ else:
+ # pull is handled specially, as we just pass back the full
+ # command line
+ if "pull" in command:
+ conn.send(response)
+ else:
+ conn.send("%s\n" % response)
+ conn.send("$>\x00")
+
+ def wait(self):
+ self.thread.join()
diff --git a/testing/mozbase/mozdevice/tests/sut_app.py b/testing/mozbase/mozdevice/tests/sut_app.py
new file mode 100644
index 000000000..0a5d996ae
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_app.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+import mozdevice
+import logging
+import unittest
+from sut import MockAgent
+
+
+class TestApp(unittest.TestCase):
+
+ def test_getAppRoot(self):
+ command = [("getapproot org.mozilla.firefox",
+ "/data/data/org.mozilla.firefox")]
+
+ m = MockAgent(self, commands=command)
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+
+ self.assertEqual(command[0][1], d.getAppRoot('org.mozilla.firefox'))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/mozdevice/tests/sut_basic.py b/testing/mozbase/mozdevice/tests/sut_basic.py
new file mode 100644
index 000000000..666d4915c
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_basic.py
@@ -0,0 +1,73 @@
+from sut import MockAgent
+import mozdevice
+import logging
+import unittest
+
+
+class BasicTest(unittest.TestCase):
+
+ def test_init(self):
+ """Tests DeviceManager initialization."""
+ a = MockAgent(self)
+
+ mozdevice.DroidSUT("127.0.0.1", port=a.port, logLevel=logging.DEBUG)
+ # all testing done in device's constructor
+ a.wait()
+
+ def test_init_err(self):
+ """Tests error handling during initialization."""
+ a = MockAgent(self, start_commands=[("ver", "##AGENT-WARNING## No version")])
+ self.assertRaises(mozdevice.DMError,
+ lambda: mozdevice.DroidSUT("127.0.0.1",
+ port=a.port,
+ logLevel=logging.DEBUG))
+ a.wait()
+
+ def test_timeout_normal(self):
+ """Tests DeviceManager timeout, normal case."""
+ a = MockAgent(self, commands=[("isdir /mnt/sdcard/tests", "TRUE"),
+ ("cd /mnt/sdcard/tests", ""),
+ ("ls", "test.txt"),
+ ("rm /mnt/sdcard/tests/test.txt",
+ "Removed the file")])
+ d = mozdevice.DroidSUT("127.0.0.1", port=a.port, logLevel=logging.DEBUG)
+ ret = d.removeFile('/mnt/sdcard/tests/test.txt')
+ self.assertEqual(ret, None) # if we didn't throw an exception, we're ok
+ a.wait()
+
+ def test_timeout_timeout(self):
+ """Tests DeviceManager timeout, timeout case."""
+ a = MockAgent(self, commands=[("isdir /mnt/sdcard/tests", "TRUE"),
+ ("cd /mnt/sdcard/tests", ""),
+ ("ls", "test.txt"),
+ ("rm /mnt/sdcard/tests/test.txt", 0)])
+ d = mozdevice.DroidSUT("127.0.0.1", port=a.port, logLevel=logging.DEBUG)
+ d.default_timeout = 1
+ exceptionThrown = False
+ try:
+ d.removeFile('/mnt/sdcard/tests/test.txt')
+ except mozdevice.DMError:
+ exceptionThrown = True
+ self.assertEqual(exceptionThrown, True)
+ a.should_stop = True
+ a.wait()
+
+ def test_shell(self):
+ """Tests shell command"""
+ for cmd in [("exec foobar", False), ("execsu foobar", True)]:
+ for retcode in [1, 2]:
+ a = MockAgent(self, commands=[(cmd[0],
+ "\nreturn code [%s]" % retcode)])
+ d = mozdevice.DroidSUT("127.0.0.1", port=a.port)
+ exceptionThrown = False
+ try:
+ d.shellCheckOutput(["foobar"], root=cmd[1])
+ except mozdevice.DMError:
+ exceptionThrown = True
+ expectedException = (retcode != 0)
+ self.assertEqual(exceptionThrown, expectedException)
+
+ a.wait()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/mozdevice/tests/sut_chmod.py b/testing/mozbase/mozdevice/tests/sut_chmod.py
new file mode 100644
index 000000000..404330c03
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_chmod.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+import mozdevice
+import logging
+import unittest
+from sut import MockAgent
+
+
+class TestChmod(unittest.TestCase):
+
+ def test_chmod(self):
+
+ command = [('chmod /mnt/sdcard/test',
+ 'Changing permissions for /storage/emulated/legacy/Test\n'
+ ' <empty>\n'
+ 'chmod /storage/emulated/legacy/Test ok\n')]
+ m = MockAgent(self, commands=command)
+ d = mozdevice.DroidSUT('127.0.0.1', port=m.port, logLevel=logging.DEBUG)
+
+ self.assertEqual(None, d.chmodDir('/mnt/sdcard/test'))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/mozdevice/tests/sut_copytree.py b/testing/mozbase/mozdevice/tests/sut_copytree.py
new file mode 100644
index 000000000..ec22828d0
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_copytree.py
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
+# You can obtain one at http://mozilla.org/MPL/2.0/.
+
+import mozdevice
+import logging
+import unittest
+from sut import MockAgent
+
+
+class CopyTreeTest(unittest.TestCase):
+
+ def test_copyFile(self):
+ commands = [('dd if=/mnt/sdcard/tests/test.txt of=/mnt/sdcard/tests/test2.txt', ''),
+ ('isdir /mnt/sdcard/tests', 'TRUE'),
+ ('cd /mnt/sdcard/tests', ''),
+ ('ls', 'test.txt\ntest2.txt')]
+
+ m = MockAgent(self, commands=commands)
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+
+ self.assertEqual(None, d.copyTree('/mnt/sdcard/tests/test.txt',
+ '/mnt/sdcard/tests/test2.txt'))
+ expected = (commands[3][1].strip()).split('\n')
+ self.assertEqual(expected, d.listFiles('/mnt/sdcard/tests'))
+
+ def test_copyDir(self):
+ commands = [('dd if=/mnt/sdcard/tests/foo of=/mnt/sdcard/tests/bar', ''),
+ ('isdir /mnt/sdcard/tests', 'TRUE'),
+ ('cd /mnt/sdcard/tests', ''),
+ ('ls', 'foo\nbar')]
+
+ m = MockAgent(self, commands=commands)
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port,
+ logLevel=logging.DEBUG)
+
+ self.assertEqual(None, d.copyTree('/mnt/sdcard/tests/foo',
+ '/mnt/sdcard/tests/bar'))
+ expected = (commands[3][1].strip()).split('\n')
+ self.assertEqual(expected, d.listFiles('/mnt/sdcard/tests'))
+
+ def test_copyNonEmptyDir(self):
+ commands = [('isdir /mnt/sdcard/tests/foo/bar', 'TRUE'),
+ ('dd if=/mnt/sdcard/tests/foo of=/mnt/sdcard/tests/foo2', ''),
+ ('isdir /mnt/sdcard/tests', 'TRUE'),
+ ('cd /mnt/sdcard/tests', ''),
+ ('ls', 'foo\nfoo2'),
+ ('isdir /mnt/sdcard/tests/foo2', 'TRUE'),
+ ('cd /mnt/sdcard/tests/foo2', ''),
+ ('ls', 'bar')]
+
+ m = MockAgent(self, commands=commands)
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port,
+ logLevel=logging.DEBUG)
+
+ self.assertTrue(d.dirExists('/mnt/sdcard/tests/foo/bar'))
+ self.assertEqual(None, d.copyTree('/mnt/sdcard/tests/foo',
+ '/mnt/sdcard/tests/foo2'))
+ expected = (commands[4][1].strip()).split('\n')
+ self.assertEqual(expected, d.listFiles('/mnt/sdcard/tests'))
+ self.assertTrue(d.fileExists('/mnt/sdcard/tests/foo2/bar'))
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/testing/mozbase/mozdevice/tests/sut_fileExists.py b/testing/mozbase/mozdevice/tests/sut_fileExists.py
new file mode 100644
index 000000000..702fd2de3
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_fileExists.py
@@ -0,0 +1,29 @@
+from sut import MockAgent
+import mozdevice
+import unittest
+
+
+class FileExistsTest(unittest.TestCase):
+
+ commands = [('isdir /', 'TRUE'),
+ ('cd /', ''),
+ ('ls', 'init')]
+
+ def test_onRoot(self):
+ root_commands = [('isdir /', 'TRUE')]
+ a = MockAgent(self, commands=root_commands)
+ d = mozdevice.DroidSUT("127.0.0.1", port=a.port)
+ self.assertTrue(d.fileExists('/'))
+
+ def test_onNonexistent(self):
+ a = MockAgent(self, commands=self.commands)
+ d = mozdevice.DroidSUT("127.0.0.1", port=a.port)
+ self.assertFalse(d.fileExists('/doesNotExist'))
+
+ def test_onRegularFile(self):
+ a = MockAgent(self, commands=self.commands)
+ d = mozdevice.DroidSUT("127.0.0.1", port=a.port)
+ self.assertTrue(d.fileExists('/init'))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/mozdevice/tests/sut_fileMethods.py b/testing/mozbase/mozdevice/tests/sut_fileMethods.py
new file mode 100644
index 000000000..142950a81
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_fileMethods.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+
+import hashlib
+import mozdevice
+import logging
+import shutil
+import tempfile
+import unittest
+from sut import MockAgent
+
+
+class TestFileMethods(unittest.TestCase):
+ """ Class to test misc file methods """
+
+ content = "What is the answer to the life, universe and everything? 42"
+ h = hashlib.md5()
+ h.update(content)
+ temp_hash = h.hexdigest()
+
+ def test_validateFile(self):
+
+ with tempfile.NamedTemporaryFile() as f:
+ f.write(self.content)
+ f.flush()
+
+ # Test Valid Hashes
+ commands_valid = [("hash /sdcard/test/file", self.temp_hash)]
+
+ m = MockAgent(self, commands=commands_valid)
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+ self.assertTrue(d.validateFile('/sdcard/test/file', f.name))
+
+ # Test invalid hashes
+ commands_invalid = [("hash /sdcard/test/file", "0this0hash0is0completely0invalid")]
+
+ m = MockAgent(self, commands=commands_invalid)
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+ self.assertFalse(d.validateFile('/sdcard/test/file', f.name))
+
+ def test_getFile(self):
+
+ fname = "/mnt/sdcard/file"
+ commands = [("pull %s" % fname, "%s,%s\n%s" % (fname, len(self.content), self.content)),
+ ("hash %s" % fname, self.temp_hash)]
+
+ with tempfile.NamedTemporaryFile() as f:
+ m = MockAgent(self, commands=commands)
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+ # No error means success
+ self.assertEqual(None, d.getFile(fname, f.name))
+
+ def test_getDirectory(self):
+
+ fname = "/mnt/sdcard/file"
+ commands = [("isdir /mnt/sdcard", "TRUE"),
+ ("isdir /mnt/sdcard", "TRUE"),
+ ("cd /mnt/sdcard", ""),
+ ("ls", "file"),
+ ("isdir %s" % fname, "FALSE"),
+ ("pull %s" % fname, "%s,%s\n%s" % (fname, len(self.content), self.content)),
+ ("hash %s" % fname, self.temp_hash)]
+
+ tmpdir = tempfile.mkdtemp()
+ m = MockAgent(self, commands=commands)
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+ self.assertEqual(None, d.getDirectory("/mnt/sdcard", tmpdir))
+
+ # Cleanup
+ shutil.rmtree(tmpdir)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/mozdevice/tests/sut_info.py b/testing/mozbase/mozdevice/tests/sut_info.py
new file mode 100644
index 000000000..93f3d4258
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_info.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+import mozdevice
+import logging
+import re
+import unittest
+from sut import MockAgent
+
+
+class TestGetInfo(unittest.TestCase):
+
+ commands = {'os': ('info os', 'JDQ39'),
+ 'id': ('info id', '11:22:33:44:55:66'),
+ 'uptime': ('info uptime', '0 days 0 hours 7 minutes 0 seconds 0 ms'),
+ 'uptimemillis': ('info uptimemillis', '666'),
+ 'systime': ('info systime', '2013/04/2 12:42:00:007'),
+ 'screen': ('info screen', 'X:768 Y:1184'),
+ 'rotation': ('info rotation', 'ROTATION:0'),
+ 'memory': ('info memory', 'PA:1351032832, FREE: 878645248'),
+ 'process': ('info process', '1000 527 system\n'
+ '10091 3443 org.mozilla.firefox\n'
+ '10112 3137 com.mozilla.SUTAgentAndroid\n'
+ '10035 807 com.android.launcher'),
+ 'disk': ('info disk', '/data: 6084923392 total, 980922368 available\n'
+ '/system: 867999744 total, 332333056 available\n'
+ '/mnt/sdcard: 6084923392 total, 980922368 available'),
+ 'power': ('info power', 'Power status:\n'
+ ' AC power OFFLINE\n'
+ ' Battery charge LOW DISCHARGING\n'
+ ' Remaining charge: 20%\n'
+ ' Battery Temperature: 25.2 (c)'),
+ 'sutuserinfo': ('info sutuserinfo', 'User Serial:0'),
+ 'temperature': ('info temperature', 'Temperature: unknown')
+ }
+
+ def test_getInfo(self):
+
+ for directive in self.commands.keys():
+ m = MockAgent(self, commands=[self.commands[directive]])
+ d = mozdevice.DroidSUT('127.0.0.1', port=m.port, logLevel=logging.DEBUG)
+
+ expected = re.sub(r'\ +', ' ', self.commands[directive][1]).split('\n')
+ # Account for slightly different return format for 'process'
+ if directive is 'process':
+ expected = [[x] for x in expected]
+
+ self.assertEqual(d.getInfo(directive=directive)[directive], expected)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/mozdevice/tests/sut_ip.py b/testing/mozbase/mozdevice/tests/sut_ip.py
new file mode 100644
index 000000000..31428a624
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_ip.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+import mozdevice
+import logging
+import unittest
+from sut import MockAgent
+
+
+class TestGetIP(unittest.TestCase):
+ """ class to test IP methods """
+
+ commands = [('exec ifconfig eth0', 'eth0: ip 192.168.0.1 '
+ 'mask 255.255.255.0 flags [up broadcast running multicast]\n'
+ 'return code [0]'),
+ ('exec ifconfig wlan0', 'wlan0: ip 10.1.39.126\n'
+ 'mask 255.255.0.0 flags [up broadcast running multicast]\n'
+ 'return code [0]'),
+ ('exec ifconfig fake0', '##AGENT-WARNING## [ifconfig] '
+ 'command with arg(s) = [fake0] is currently not implemented.')
+ ]
+
+ def test_getIP_eth0(self):
+ m = MockAgent(self, commands=[self.commands[0]])
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+ self.assertEqual('192.168.0.1', d.getIP(interfaces=['eth0']))
+
+ def test_getIP_wlan0(self):
+ m = MockAgent(self, commands=[self.commands[1]])
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+ self.assertEqual('10.1.39.126', d.getIP(interfaces=['wlan0']))
+
+ def test_getIP_error(self):
+ m = MockAgent(self, commands=[self.commands[2]])
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+ self.assertRaises(mozdevice.DMError, d.getIP, interfaces=['fake0'])
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/mozdevice/tests/sut_kill.py b/testing/mozbase/mozdevice/tests/sut_kill.py
new file mode 100644
index 000000000..fea2f57e0
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_kill.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+
+import mozdevice
+import logging
+import unittest
+from sut import MockAgent
+
+
+class TestKill(unittest.TestCase):
+
+ def test_killprocess(self):
+ commands = [("ps", "1000 1486 com.android.settings\n"
+ "10016 420 com.android.location.fused\n"
+ "10023 335 com.android.systemui\n"),
+ ("kill com.android.settings",
+ "Successfully killed com.android.settings\n")]
+ m = MockAgent(self, commands=commands)
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+ # No error raised means success
+ self.assertEqual(None, d.killProcess("com.android.settings"))
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/mozdevice/tests/sut_list.py b/testing/mozbase/mozdevice/tests/sut_list.py
new file mode 100644
index 000000000..a319fd725
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_list.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+import mozdevice
+import logging
+import unittest
+from sut import MockAgent
+
+
+class TestListFiles(unittest.TestCase):
+ commands = [("isdir /mnt/sdcard", "TRUE"),
+ ("cd /mnt/sdcard", ""),
+ ("ls", "Android\nMusic\nPodcasts\nRingtones\nAlarms\n"
+ "Notifications\nPictures\nMovies\nDownload\nDCIM\n")]
+
+ def test_listFiles(self):
+ m = MockAgent(self, commands=self.commands)
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+
+ expected = (self.commands[2][1].strip()).split("\n")
+ self.assertEqual(expected, d.listFiles("/mnt/sdcard"))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/mozdevice/tests/sut_logcat.py b/testing/mozbase/mozdevice/tests/sut_logcat.py
new file mode 100644
index 000000000..b4c1a742d
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_logcat.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+
+import mozdevice
+import logging
+import unittest
+from sut import MockAgent
+
+
+class TestLogCat(unittest.TestCase):
+ """ Class to test methods associated with logcat """
+
+ def test_getLogcat(self):
+
+ logcat_output = (
+ "07-17 00:51:10.377 I/SUTAgentAndroid( 2933): onCreate\r\n"
+ "07-17 00:51:10.457 D/dalvikvm( 2933): GC_CONCURRENT freed 351K, 17% free 2523K/3008K, paused 5ms+2ms, total 38ms\r\n" # noqa
+ "07-17 00:51:10.497 I/SUTAgentAndroid( 2933): Caught exception creating file in /data/local/tmp: open failed: EACCES (Permission denied)\r\n" # noqa
+ "07-17 00:51:10.507 E/SUTAgentAndroid( 2933): ERROR: Cannot access world writeable test root\r\n" # noqa
+ "07-17 00:51:10.547 D/GeckoHealthRec( 3253): Initializing profile cache.\r\n"
+ "07-17 00:51:10.607 D/GeckoHealthRec( 3253): Looking for /data/data/org.mozilla.fennec/files/mozilla/c09kfhne.default/times.json\r\n" # noqa
+ "07-17 00:51:10.637 D/GeckoHealthRec( 3253): Using times.json for profile creation time.\r\n" # noqa
+ "07-17 00:51:10.707 D/GeckoHealthRec( 3253): Incorporating environment: times.json profile creation = 1374026758604\r\n" # noqa
+ "07-17 00:51:10.507 D/GeckoHealthRec( 3253): Requested prefs.\r\n"
+ "07-17 06:50:54.907 I/SUTAgentAndroid( 3876): \r\n"
+ "07-17 06:50:54.907 I/SUTAgentAndroid( 3876): Total Private Dirty Memory 3176 kb\r\n" # noqa
+ "07-17 06:50:54.907 I/SUTAgentAndroid( 3876): Total Proportional Set Size Memory 5679 kb\r\n" # noqa
+ "07-17 06:50:54.907 I/SUTAgentAndroid( 3876): Total Shared Dirty Memory 9216 kb\r\n" # noqa
+ "07-17 06:55:21.627 I/SUTAgentAndroid( 3876): 127.0.0.1 : execsu /system/bin/logcat -v time -d dalvikvm:I " # noqa
+ "ConnectivityService:S WifiMonitor:S WifiStateTracker:S wpa_supplicant:S NetworkStateTracker:S\r\n" # noqa
+ "07-17 06:55:21.827 I/dalvikvm-heap( 3876): Grow heap (frag case) to 3.019MB for 102496-byte allocation\r\n" # noqa
+ "return code [0]")
+
+ inp = ("execsu /system/bin/logcat -v time -d "
+ "dalvikvm:I ConnectivityService:S WifiMonitor:S "
+ "WifiStateTracker:S wpa_supplicant:S NetworkStateTracker:S")
+
+ commands = [(inp, logcat_output)]
+ m = MockAgent(self, commands=commands)
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+ self.assertEqual(logcat_output[:-17].replace('\r\n', '\n').splitlines(True), d.getLogcat())
+
+ def test_recordLogcat(self):
+
+ commands = [("execsu /system/bin/logcat -c", "return code [0]")]
+
+ m = MockAgent(self, commands=commands)
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+ # No error raised means success
+ self.assertEqual(None, d.recordLogcat())
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/mozdevice/tests/sut_mkdir.py b/testing/mozbase/mozdevice/tests/sut_mkdir.py
new file mode 100644
index 000000000..bacaae324
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_mkdir.py
@@ -0,0 +1,78 @@
+# Any copyright is dedicated to the Public Domain.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+import mozdevice
+import logging
+import unittest
+from sut import MockAgent
+
+
+class MkDirsTest(unittest.TestCase):
+
+ def test_mkdirs(self):
+ subTests = [{'cmds': [('isdir /mnt/sdcard/baz/boop', 'FALSE'),
+ ('info os', 'android'),
+ ('isdir /mnt', 'TRUE'),
+ ('isdir /mnt/sdcard', 'TRUE'),
+ ('isdir /mnt/sdcard/baz', 'FALSE'),
+ ('mkdr /mnt/sdcard/baz',
+ '/mnt/sdcard/baz successfully created'),
+ ('isdir /mnt/sdcard/baz/boop', 'FALSE'),
+ ('mkdr /mnt/sdcard/baz/boop',
+ '/mnt/sdcard/baz/boop successfully created')],
+ 'expectException': False},
+ {'cmds': [('isdir /mnt/sdcard/baz/boop', 'FALSE'),
+ ('info os', 'android'),
+ ('isdir /mnt', 'TRUE'),
+ ('isdir /mnt/sdcard', 'TRUE'),
+ ('isdir /mnt/sdcard/baz', 'FALSE'),
+ ('mkdr /mnt/sdcard/baz',
+ "##AGENT-WARNING## "
+ "Could not create the directory /mnt/sdcard/baz")],
+ 'expectException': True},
+ ]
+ for subTest in subTests:
+ a = MockAgent(self, commands=subTest['cmds'])
+
+ exceptionThrown = False
+ try:
+ d = mozdevice.DroidSUT('127.0.0.1', port=a.port,
+ logLevel=logging.DEBUG)
+ d.mkDirs('/mnt/sdcard/baz/boop/bip')
+ except mozdevice.DMError:
+ exceptionThrown = True
+ self.assertEqual(exceptionThrown, subTest['expectException'])
+
+ a.wait()
+
+ def test_repeated_path_part(self):
+ """
+ Ensure that all dirs are created when last path part also found
+ earlier in the path (bug 826492).
+ """
+
+ cmds = [('isdir /mnt/sdcard/foo', 'FALSE'),
+ ('info os', 'android'),
+ ('isdir /mnt', 'TRUE'),
+ ('isdir /mnt/sdcard', 'TRUE'),
+ ('isdir /mnt/sdcard/foo', 'FALSE'),
+ ('mkdr /mnt/sdcard/foo',
+ '/mnt/sdcard/foo successfully created')]
+ a = MockAgent(self, commands=cmds)
+ d = mozdevice.DroidSUT('127.0.0.1', port=a.port,
+ logLevel=logging.DEBUG)
+ d.mkDirs('/mnt/sdcard/foo/foo')
+ a.wait()
+
+ def test_mkdirs_on_root(self):
+ cmds = [('isdir /', 'TRUE')]
+ a = MockAgent(self, commands=cmds)
+ d = mozdevice.DroidSUT('127.0.0.1', port=a.port,
+ logLevel=logging.DEBUG)
+ d.mkDirs('/foo')
+
+ a.wait()
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/mozdevice/tests/sut_movetree.py b/testing/mozbase/mozdevice/tests/sut_movetree.py
new file mode 100644
index 000000000..0e106577c
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_movetree.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
+# You can obtain one at http://mozilla.org/MPL/2.0/.
+
+import mozdevice
+import logging
+import unittest
+from sut import MockAgent
+
+
+class MoveTreeTest(unittest.TestCase):
+
+ def test_moveFile(self):
+ commands = [('mv /mnt/sdcard/tests/test.txt /mnt/sdcard/tests/test1.txt', ''),
+ ('isdir /mnt/sdcard/tests', 'TRUE'),
+ ('cd /mnt/sdcard/tests', ''),
+ ('ls', 'test1.txt'),
+ ('isdir /mnt/sdcard/tests', 'TRUE'),
+ ('cd /mnt/sdcard/tests', ''),
+ ('ls', 'test1.txt')]
+
+ m = MockAgent(self, commands=commands)
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+ self.assertEqual(None, d.moveTree('/mnt/sdcard/tests/test.txt',
+ '/mnt/sdcard/tests/test1.txt'))
+ self.assertFalse(d.fileExists('/mnt/sdcard/tests/test.txt'))
+ self.assertTrue(d.fileExists('/mnt/sdcard/tests/test1.txt'))
+
+ def test_moveDir(self):
+ commands = [("mv /mnt/sdcard/tests/foo /mnt/sdcard/tests/bar", ""),
+ ('isdir /mnt/sdcard/tests', 'TRUE'),
+ ('cd /mnt/sdcard/tests', ''),
+ ('ls', 'bar')]
+
+ m = MockAgent(self, commands=commands)
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+ self.assertEqual(None, d.moveTree('/mnt/sdcard/tests/foo',
+ '/mnt/sdcard/tests/bar'))
+ self.assertTrue(d.fileExists('/mnt/sdcard/tests/bar'))
+
+ def test_moveNonEmptyDir(self):
+ commands = [('isdir /mnt/sdcard/tests/foo/bar', 'TRUE'),
+ ('mv /mnt/sdcard/tests/foo /mnt/sdcard/tests/foo2', ''),
+ ('isdir /mnt/sdcard/tests', 'TRUE'),
+ ('cd /mnt/sdcard/tests', ''),
+ ('ls', 'foo2'),
+ ('isdir /mnt/sdcard/tests/foo2', 'TRUE'),
+ ('cd /mnt/sdcard/tests/foo2', ''),
+ ('ls', 'bar')]
+
+ m = MockAgent(self, commands=commands)
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port,
+ logLevel=logging.DEBUG)
+
+ self.assertTrue(d.dirExists('/mnt/sdcard/tests/foo/bar'))
+ self.assertEqual(None, d.moveTree('/mnt/sdcard/tests/foo',
+ '/mnt/sdcard/tests/foo2'))
+ self.assertTrue(d.fileExists('/mnt/sdcard/tests/foo2'))
+ self.assertTrue(d.fileExists('/mnt/sdcard/tests/foo2/bar'))
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/testing/mozbase/mozdevice/tests/sut_ps.py b/testing/mozbase/mozdevice/tests/sut_ps.py
new file mode 100644
index 000000000..03f431c1d
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_ps.py
@@ -0,0 +1,50 @@
+from sut import MockAgent
+import mozdevice
+import unittest
+
+
+class PsTest(unittest.TestCase):
+
+ pscommands = [('ps',
+ "10029 549 com.android.launcher\n"
+ "10066 1198 com.twitter.android")]
+
+ bad_pscommands = [('ps',
+ "abcdef 549 com.android.launcher\n"
+ "10066 1198 com.twitter.android")]
+
+ def test_processList(self):
+ a = MockAgent(self,
+ commands=self.pscommands)
+ d = mozdevice.DroidSUT("127.0.0.1", port=a.port)
+ pslist = d.getProcessList()
+ self.assertEqual(len(pslist), 2)
+ self.assertEqual(pslist[0], [549, 'com.android.launcher', 10029])
+ self.assertEqual(pslist[1], [1198, 'com.twitter.android', 10066])
+
+ a.wait()
+
+ def test_badProcessList(self):
+ a = MockAgent(self,
+ commands=self.bad_pscommands)
+ d = mozdevice.DroidSUT("127.0.0.1", port=a.port)
+ exceptionTriggered = False
+ try:
+ d.getProcessList()
+ except mozdevice.DMError:
+ exceptionTriggered = True
+
+ self.assertTrue(exceptionTriggered)
+
+ a.wait()
+
+ def test_processExist(self):
+ for i in [('com.android.launcher', 549),
+ ('com.fennec.android', None)]:
+ a = MockAgent(self, commands=self.pscommands)
+ d = mozdevice.DroidSUT("127.0.0.1", port=a.port)
+ self.assertEqual(d.processExist(i[0]), i[1])
+ a.wait()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/mozdevice/tests/sut_pull.py b/testing/mozbase/mozdevice/tests/sut_pull.py
new file mode 100644
index 000000000..c9fcae42a
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_pull.py
@@ -0,0 +1,47 @@
+from sut import MockAgent
+import mozdevice
+import logging
+import unittest
+
+
+class PullTest(unittest.TestCase):
+
+ def test_pull_success(self):
+ for count in [1, 4, 1024, 2048]:
+ cheeseburgers = ""
+ for i in range(count):
+ cheeseburgers += "cheeseburgers"
+
+ # pull file is kind of gross, make sure we can still execute commands after it's done
+ remoteName = "/mnt/sdcard/cheeseburgers"
+ a = MockAgent(self, commands=[("pull %s" % remoteName,
+ "%s,%s\n%s" % (remoteName,
+ len(cheeseburgers),
+ cheeseburgers)),
+ ("isdir /mnt/sdcard", "TRUE")])
+
+ d = mozdevice.DroidSUT("127.0.0.1", port=a.port,
+ logLevel=logging.DEBUG)
+ pulledData = d.pullFile("/mnt/sdcard/cheeseburgers")
+ self.assertEqual(pulledData, cheeseburgers)
+ d.dirExists('/mnt/sdcard')
+
+ def test_pull_failure(self):
+
+ # this test simulates only receiving a few bytes of what we expect
+ # to be larger file
+ remoteName = "/mnt/sdcard/cheeseburgers"
+ a = MockAgent(self, commands=[("pull %s" % remoteName,
+ "%s,15\n%s" % (remoteName,
+ "cheeseburgh"))])
+ d = mozdevice.DroidSUT("127.0.0.1", port=a.port,
+ logLevel=logging.DEBUG)
+ exceptionThrown = False
+ try:
+ d.pullFile("/mnt/sdcard/cheeseburgers")
+ except mozdevice.DMError:
+ exceptionThrown = True
+ self.assertTrue(exceptionThrown)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/mozdevice/tests/sut_push.py b/testing/mozbase/mozdevice/tests/sut_push.py
new file mode 100644
index 000000000..023d5315c
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_push.py
@@ -0,0 +1,88 @@
+from sut import MockAgent
+import mozfile
+import mozdevice
+import logging
+import unittest
+import hashlib
+import tempfile
+import os
+
+
+class PushTest(unittest.TestCase):
+
+ def test_push(self):
+ pushfile = "1234ABCD"
+ mdsum = hashlib.md5()
+ mdsum.update(pushfile)
+ expectedResponse = mdsum.hexdigest()
+
+ # (good response, no exception), (bad response, exception)
+ for response in [(expectedResponse, False), ("BADHASH", True)]:
+ cmd = "push /mnt/sdcard/foobar %s\r\n%s" % (len(pushfile), pushfile)
+ a = MockAgent(self, commands=[("isdir /mnt/sdcard", "TRUE"),
+ (cmd, response[0])])
+ exceptionThrown = False
+ with tempfile.NamedTemporaryFile() as f:
+ try:
+ f.write(pushfile)
+ f.flush()
+ d = mozdevice.DroidSUT("127.0.0.1", port=a.port)
+ d.pushFile(f.name, '/mnt/sdcard/foobar')
+ except mozdevice.DMError:
+ exceptionThrown = True
+ self.assertEqual(exceptionThrown, response[1])
+ a.wait()
+
+ def test_push_dir(self):
+ pushfile = "1234ABCD"
+ mdsum = hashlib.md5()
+ mdsum.update(pushfile)
+ expectedFileResponse = mdsum.hexdigest()
+
+ tempdir = tempfile.mkdtemp()
+ self.addCleanup(mozfile.remove, tempdir)
+ complex_path = os.path.join(tempdir, "baz")
+ os.mkdir(complex_path)
+ f = tempfile.NamedTemporaryFile(dir=complex_path)
+ f.write(pushfile)
+ f.flush()
+
+ subTests = [{'cmds': [("isdir /mnt/sdcard/baz", "TRUE"),
+ ("push /mnt/sdcard/baz/%s %s\r\n%s" %
+ (os.path.basename(f.name), len(pushfile),
+ pushfile),
+ expectedFileResponse)],
+ 'expectException': False},
+ {'cmds': [("isdir /mnt/sdcard/baz", "TRUE"),
+ ("push /mnt/sdcard/baz/%s %s\r\n%s" %
+ (os.path.basename(f.name), len(pushfile),
+ pushfile),
+ "BADHASH")],
+ 'expectException': True},
+ {'cmds': [("isdir /mnt/sdcard/baz", "FALSE"),
+ ('info os', 'android'),
+ ("isdir /mnt", "FALSE"),
+ ("mkdr /mnt",
+ "##AGENT-WARNING## Could not create the directory /mnt")],
+ 'expectException': True},
+
+ ]
+
+ for subTest in subTests:
+ a = MockAgent(self, commands=subTest['cmds'])
+
+ exceptionThrown = False
+ try:
+ d = mozdevice.DroidSUT("127.0.0.1", port=a.port,
+ logLevel=logging.DEBUG)
+ d.pushDir(tempdir, "/mnt/sdcard")
+ except mozdevice.DMError:
+ exceptionThrown = True
+ self.assertEqual(exceptionThrown, subTest['expectException'])
+
+ a.wait()
+
+ # FIXME: delete directory when done
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/mozdevice/tests/sut_remove.py b/testing/mozbase/mozdevice/tests/sut_remove.py
new file mode 100644
index 000000000..636190186
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_remove.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+import mozdevice
+import logging
+import unittest
+from sut import MockAgent
+
+
+class TestRemove(unittest.TestCase):
+
+ def test_removeDir(self):
+ commands = [("isdir /mnt/sdcard/test", "TRUE"),
+ ("rmdr /mnt/sdcard/test", "Deleting file(s) from "
+ "/storage/emulated/legacy/Moztest\n"
+ " <empty>\n"
+ "Deleting directory "
+ "/storage/emulated/legacy/Moztest\n")]
+
+ m = MockAgent(self, commands=commands)
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+ # No error implies we're all good
+ self.assertEqual(None, d.removeDir("/mnt/sdcard/test"))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/mozdevice/tests/sut_time.py b/testing/mozbase/mozdevice/tests/sut_time.py
new file mode 100644
index 000000000..11dc421cb
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_time.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+import mozdevice
+import logging
+import unittest
+from sut import MockAgent
+
+
+class TestGetCurrentTime(unittest.TestCase):
+
+ def test_getCurrentTime(self):
+ command = [('clok', '1349980200')]
+
+ m = MockAgent(self, commands=command)
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+ self.assertEqual(d.getCurrentTime(), int(command[0][1]))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/mozbase/mozdevice/tests/sut_unpackfile.py b/testing/mozbase/mozdevice/tests/sut_unpackfile.py
new file mode 100644
index 000000000..1a531fe17
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_unpackfile.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+
+import mozdevice
+import logging
+import unittest
+from sut import MockAgent
+
+
+class TestUnpack(unittest.TestCase):
+
+ def test_unpackFile(self):
+
+ commands = [("unzp /data/test/sample.zip /data/test/",
+ "Checksum: 653400271\n"
+ "1 of 1 successfully extracted\n")]
+ m = MockAgent(self, commands=commands)
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+ # No error being thrown imples all is well
+ self.assertEqual(None, d.unpackFile("/data/test/sample.zip",
+ "/data/test/"))
+
+if __name__ == '__main__':
+ unittest.main()