diff --git a/tests/call.py b/tests/call.py new file mode 100644 index 000000000..e102481df --- /dev/null +++ b/tests/call.py @@ -0,0 +1,34 @@ +from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice +from com.android.monkeyrunner.easy import EasyMonkeyDevice + +from lib.LinphoneTest import LinphoneTest + +class CallTest(LinphoneTest): + def precond(self): + # Be sure to be on dialer screen + dialer = self.find('dialer') + self.easyDevice.touch(dialer, MonkeyDevice.DOWN_AND_UP) + MonkeyRunner.sleep(1) + + def test(self): + # Type a SIP address + address = self.find('Adress') + self.easyDevice.type(address, 'cotcot@sip.linphone.org') + self.device.press('KEYCODE_BACK', MonkeyDevice.DOWN_AND_UP) + + # Try to call previously typed address + call = self.find('Call') + self.easyDevice.touch(call, MonkeyDevice.DOWN_AND_UP) + MonkeyRunner.sleep(2) + + # Check if the call is outgoing correctly + contact = self.find('contactNameOrNumber') + return contact + + def postcond(self): + # Stop the call + hangUp = self.find('hangUp') + self.easyDevice.touch(hangUp, MonkeyDevice.DOWN_AND_UP) + +callTest = CallTest('Call') +callTest.run() \ No newline at end of file diff --git a/tests/install.py b/tests/install.py new file mode 100644 index 000000000..77a21a02e --- /dev/null +++ b/tests/install.py @@ -0,0 +1,28 @@ +from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice +from com.android.monkeyrunner.easy import EasyMonkeyDevice + +from lib.LinphoneTest import LinphoneTest + +class InstallTest(LinphoneTest): + def test(self): + # Parameters, must be the same as in the build.xml file + package = 'org.linphone' + appname = 'Linphone' + activity = 'org.linphone.LinphoneLauncherActivity' + + # Installs the Android package. Notice that this method returns a boolean, so you can test + # to see if the installation worked. + self.device.installPackage('../bin/' + appname + '-debug.apk') + + # sets the name of the component to start + runComponent = package + '/' + activity + + # Runs the component and wait for it to be launched + self.device.startActivity(component=runComponent) + MonkeyRunner.sleep(7) + + menu = self.find('menu') + return menu + +installTest = InstallTest('Install') +installTest.run() \ No newline at end of file diff --git a/tests/lib/LinphoneTest$py.class b/tests/lib/LinphoneTest$py.class new file mode 100644 index 000000000..1bd69ba0e Binary files /dev/null and b/tests/lib/LinphoneTest$py.class differ diff --git a/tests/lib/LinphoneTest.py b/tests/lib/LinphoneTest.py new file mode 100644 index 000000000..1c7175c58 --- /dev/null +++ b/tests/lib/LinphoneTest.py @@ -0,0 +1,55 @@ +from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice +from com.android.monkeyrunner.easy import EasyMonkeyDevice +from com.android.monkeyrunner.easy import By + +class colors: + OK = '\033[92m' + KO = '\033[91m' + END = '\033[0m' + +class LinphoneTest(): + def __init__(self, test_name): + self.test_name = test_name + + # Connects to the current device + self.device = MonkeyRunner.waitForConnection() + self.easyDevice = EasyMonkeyDevice(self.device) + + def run(self): + self.precond() + + try: + result = self.test() + if result : + self.print_result_ok() + else : + self.print_result_ko() + + except Exception: + self.print_result_ko() + + finally: + self.postcond() + + def find(self, id): + view = By.id('id/' + id) + if not view: + raise Exception("View with id/" + id + " not found") + return view + + def print_result_ok(self): + print self.test_name + colors.OK + ' OK' + colors.END + + def print_result_ko(self): + print self.test_name + colors.KO + ' KO' + colors.END + + # Override following methods + def precond(self): + pass + + def test(self): + pass + + def postcond(self): + pass + \ No newline at end of file diff --git a/tests/lib/__init__$py.class b/tests/lib/__init__$py.class new file mode 100644 index 000000000..d70f26635 Binary files /dev/null and b/tests/lib/__init__$py.class differ diff --git a/tests/lib/__init__.py b/tests/lib/__init__.py new file mode 100644 index 000000000..e69de29bb