1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
#!/usr/bin/python
import unittest
import ooldtp
import os
import shutil
import subprocess
import time
class SoftwareCenterLdtp(unittest.TestCase):
WINDOW = "frmUbuntuSoftwareCenter"
LAUNCHER = "software-center"
CLOSE_NAME = "mnuClose"
def setUp(self):
env = os.environ.copy()
env["PYTHONPATH="] = "."
#self.atspi = subprocess.Popen(["/usr/lib/at-spi/at-spi-registryd"])
#print "starting at-spi", self.atspi
#time.sleep(5)
self.p = subprocess.Popen(["./software-center"],
cwd="..", env=env)
# wait for app
self._wait_for_sc()
def _wait_for_sc(self):
""" wait unil the software-center window becomes ready """
while True:
try:
comp = ooldtp.component(self.WINDOW, self.CLOSE_NAME)
close_menu_label = comp.gettextvalue()
except Exception as e:
print "waiting ...", e
time.sleep(2)
continue
else:
break
print comp, close_menu_label
def tearDown(self):
self.p.kill()
# remove the local db
shutil.rmtree("../data/xapian")
def test_search(self):
application = ooldtp.context(self.WINDOW)
# get search entry
search = application.getchild("txtSearch")
search.enterstring("ab")
time.sleep(2)
# check label
label = application.getchild("status_text")
label_str = label.gettextvalue()
# make sure ab always hits the query limit (200 currently)
self.assertEqual(label_str, "200 matching items")
if __name__ == "__main__":
# kill locale stuff
for k in ["LANGUAGE", "LANG"]:
if k in os.environ:
del os.environ[k]
# FIXME: this does not work as at-spi-registryd is not started
# and starting it manually does not work for whatever reason
# re-exec in xvfb if needed
#if os.environ.get("DISPLAY") != ":99":
# # the xvfb window can be viewed with "xwud < Xvfb_screen0"
# cmd = ["xvfb-run", "-e", "xvfb.log", "-s", "-fbdir .",
# "python"]+sys.argv
# logging.warn("re-execing inside xvfb: %s" % cmd)
# subprocess.call(cmd)
#else:
# unittest.main()
unittest.main()
|