Add Activity Testing API and check command to setup.py

./setup.py check now invokes tests in tests/ directory. tests directory should
have integration(UI tests) and unit(unit tests) sub directories, but it isn't
necessary to have any dir. of the above.
This commit is contained in:
Sai Vineet
2013-12-30 22:20:39 +05:30
committed by Daniel Narvaez
parent d4b4405c6c
commit 29738c9087
2 changed files with 79 additions and 0 deletions
+28
View File
@@ -22,14 +22,26 @@ from __future__ import absolute_import
import logging
import os
import time
import unittest
import subprocess
from contextlib import contextmanager
from sugar3.test import uitree
import dbus
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
class UITestCase(unittest.TestCase):
def __init__(self, *args, **kwargs):
unittest.TestCase(*args, **kwargs)
self.bundle_id = None
def setUp(self):
logger = logging.getLogger()
self._orig_level = logger.getEffectiveLevel()
@@ -51,3 +63,19 @@ class UITestCase(unittest.TestCase):
raise
finally:
process.terminate()
@contextmanager
def run_activity(self):
if bundle_id is not None:
process = subprocess.Popen(["sugar-launch", self.bundle_id])
else:
print "No bundle_id specified."
return
try:
yield
except:
logging.debug(uitree.get_root().dump())
raise
finally:
process.terminate()