summaryrefslogtreecommitdiffstats
path: root/testing/mozbase/mozdevice/tests/sut_basic.py
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/sut_basic.py
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/sut_basic.py')
-rw-r--r--testing/mozbase/mozdevice/tests/sut_basic.py73
1 files changed, 73 insertions, 0 deletions
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()