From 9278783913187e1b748817f96b445e1d5c23339e Mon Sep 17 00:00:00 2001 From: William Hua Date: Mon, 17 Jun 2013 18:40:11 -0400 Subject: Bare setup autopilot testing. --- .bzrignore | 1 + Makefile.am | 2 +- debian/control | 10 +++++ debian/indicator-keyboard-autopilot.install | 1 + tests/Makefile.am | 1 + tests/autopilot/Makefile.am | 5 +++ tests/autopilot/__init__.py | 6 +++ tests/autopilot/test.sh | 6 +++ tests/autopilot/tests/Makefile.am | 1 + tests/autopilot/tests/__init__.py | 0 tests/autopilot/tests/test_indicator_keyboard.py | 55 ++++++++++++++++++++++++ 11 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 debian/indicator-keyboard-autopilot.install create mode 100644 tests/Makefile.am create mode 100644 tests/autopilot/Makefile.am create mode 100644 tests/autopilot/__init__.py create mode 100755 tests/autopilot/test.sh create mode 100644 tests/autopilot/tests/Makefile.am create mode 100644 tests/autopilot/tests/__init__.py create mode 100644 tests/autopilot/tests/test_indicator_keyboard.py diff --git a/.bzrignore b/.bzrignore index 10bb2b7e..54d2de9e 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1,6 +1,7 @@ *.c *.log *.m4 +*.pyc *.stamp *.substvars *.valid diff --git a/Makefile.am b/Makefile.am index b19f3988..c0d4a471 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,3 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = po lib data +SUBDIRS = po lib data tests diff --git a/debian/control b/debian/control index 2ae5ffaa..74fef31b 100644 --- a/debian/control +++ b/debian/control @@ -35,3 +35,13 @@ Depends: ${shlibs:Depends}, ${misc:Depends} Description: Keyboard indicator schema This package contains the keyboard indicator schema. + +Package: indicator-keyboard-autopilot +Architecture: all +Depends: ${misc:Depends}, + indicator-keyboard (>= ${source:Version}), + libautopilot-gtk, + python-pyatspi, + python-autopilot +Description: Keyboard indicator autopilot tests + This package provides autopilot integration tests for indicator-keyboard. diff --git a/debian/indicator-keyboard-autopilot.install b/debian/indicator-keyboard-autopilot.install new file mode 100644 index 00000000..48b4ad56 --- /dev/null +++ b/debian/indicator-keyboard-autopilot.install @@ -0,0 +1 @@ +usr/lib/python*/dist-packages/indicator_keyboard/* diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 00000000..ac047e60 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = autopilot diff --git a/tests/autopilot/Makefile.am b/tests/autopilot/Makefile.am new file mode 100644 index 00000000..2af361a7 --- /dev/null +++ b/tests/autopilot/Makefile.am @@ -0,0 +1,5 @@ +autopilotdir = $(pythondir)/indicator_keyboard +autopilot_DATA = __init__.py + +autopilottestsdir = $(autopilotdir)/tests +autopilottests_DATA = tests/__init__.py tests/test_indicator_keyboard.py diff --git a/tests/autopilot/__init__.py b/tests/autopilot/__init__.py new file mode 100644 index 00000000..c9bdd5c3 --- /dev/null +++ b/tests/autopilot/__init__.py @@ -0,0 +1,6 @@ +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- +# Copyright 2013 Canonical +# +# This file is part of indicator-keyboard. + +"""indicator-keyboard autopilot tests - top level package.""" diff --git a/tests/autopilot/test.sh b/tests/autopilot/test.sh new file mode 100755 index 00000000..7c3a0ad4 --- /dev/null +++ b/tests/autopilot/test.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +for name in `autopilot list tests | head -n -3 | tail -n +3` +do + autopilot run $name || exit 1 +done diff --git a/tests/autopilot/tests/Makefile.am b/tests/autopilot/tests/Makefile.am new file mode 100644 index 00000000..06deff91 --- /dev/null +++ b/tests/autopilot/tests/Makefile.am @@ -0,0 +1 @@ +check_PYTHON = __init__.py test_indicator_keyboard.py diff --git a/tests/autopilot/tests/__init__.py b/tests/autopilot/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/autopilot/tests/test_indicator_keyboard.py b/tests/autopilot/tests/test_indicator_keyboard.py new file mode 100644 index 00000000..4327d26d --- /dev/null +++ b/tests/autopilot/tests/test_indicator_keyboard.py @@ -0,0 +1,55 @@ +import autopilot.introspection.gtk +import os +import pyatspi.registry +import pyatspi.utils +import time +import unity.tests + +def print_accessible(root, level=0): + print level * ' ', root + + for node in root: + print_accessible(node, level + 1) + +def get_accessible_with_name_and_role(root, name, role): + is_accessible = lambda a: a.name == name and a.get_role_name() == role + return pyatspi.utils.findDescendant(root, is_accessible, True); + +def get_panel_accessible(root): + return get_accessible_with_name_and_role(root, 'unity-panel-service', 'application') + +def get_app_menu_accessible(root): + is_app_menu = lambda a: len(a) > 0 and a[0].name == 'File' and a[0].get_role_name() == 'label' + return pyatspi.utils.findDescendant(root, is_app_menu, True) + +def get_label_accessible_with_name(root, name): + return get_accessible_with_name_and_role(root, name, 'label') + +def get_submenu_accessible(root): + return root[0] + +def get_menu_item_accessible_with_name(root, name): + is_menu_item = lambda a: a.name == name and a.get_role_name() in ('menu item', 'check menu item', 'radio menu item') + return pyatspi.utils.findDescendant(root, is_menu_item, True); + +def get_accessible_index(root, node): + for i in xrange(len(root)): + if root[i] == node: + return i + + return -1 + +class IndicatorKeyboardTestCase(unity.tests.UnityTestCase): + + def setUp(self): + super(IndicatorKeyboardTestCase, self).setUp() + + registry = pyatspi.registry.Registry() + self.desktop = registry.getDesktop(0) + + # This is needed on systems other than the EN locale + os.putenv("LC_ALL", "C") + self.addCleanup(os.unsetenv, "LC_ALL") + + def test_character_map(self): + print_accessible(self.desktop) -- cgit v1.2.3