Test lib + samples added

This commit is contained in:
Sylvain Berfini 2012-09-04 14:43:08 +02:00
parent df42438dc7
commit 6694eb7a4c
6 changed files with 117 additions and 0 deletions

34
tests/call.py Normal file
View file

@ -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()

28
tests/install.py Normal file
View file

@ -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()

Binary file not shown.

55
tests/lib/LinphoneTest.py Normal file
View file

@ -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

BIN
tests/lib/__init__$py.class Normal file

Binary file not shown.

0
tests/lib/__init__.py Normal file
View file