aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac3
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/autopilot/Makefile.am5
-rw-r--r--tests/autopilot/__init__.py6
-rwxr-xr-xtests/autopilot/test.sh6
-rw-r--r--tests/autopilot/tests/Makefile.am1
-rw-r--r--tests/autopilot/tests/__init__.py0
-rw-r--r--tests/autopilot/tests/test_indicator_keyboard.py60
8 files changed, 82 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 6cc1beb6..31640e6b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,6 +21,8 @@ PKG_PROG_PKG_CONFIG([0.26])
AC_ARG_WITH([dbus-service-dir], [AS_HELP_STRING([--with-dbus-service-dir=DIR], [D-Bus service directory [default=$datadir/dbus-1/services]])], [], [with_dbus_service_dir=$datadir/dbus-1/services])
AC_ARG_WITH([indicator-dir], [AS_HELP_STRING([--with-indicator-dir=DIR], [Indicator directory [default=$datadir/unity/indicators]])], [], [with_indicator_dir=$datadir/unity/indicators])
+AM_PATH_PYTHON
+
AC_SUBST([DBUS_SERVICE_DIR], [$with_dbus_service_dir])
AC_SUBST([INDICATOR_DIR], [$with_indicator_dir])
@@ -77,6 +79,7 @@ AC_CONFIG_FILES([Makefile
lib/Makefile
po/Makefile.in
tests/Makefile
+ tests/autopilot/Makefile
tests/config.vala
tests/services/indicator-keyboard.service])
AC_CONFIG_FILES([tests/indicator-keyboard-test],
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2e0e0287..da083318 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,3 +1,4 @@
+SUBDIRS = autopilot
TESTS = indicator-keyboard-test
check_PROGRAMS = indicator-keyboard-tests
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
--- /dev/null
+++ b/tests/autopilot/tests/__init__.py
diff --git a/tests/autopilot/tests/test_indicator_keyboard.py b/tests/autopilot/tests/test_indicator_keyboard.py
new file mode 100644
index 00000000..0ef197db
--- /dev/null
+++ b/tests/autopilot/tests/test_indicator_keyboard.py
@@ -0,0 +1,60 @@
+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 is_indicator_accessible(root):
+ return root.get_role_name() == 'panel' and \
+ len(root) == 1 and \
+ root[0].get_role_name() == 'image' and \
+ len(root[0]) == 1 and \
+ root[0][0].get_role_name() == 'menu' and \
+ len(root[0][0]) > 3 and \
+ root[0][0][-3].name == 'Character Map' and \
+ root[0][0][-3].get_role_name() == 'check menu item' and \
+ root[0][0][-2].name == 'Keyboard Layout Chart' and \
+ root[0][0][-2].get_role_name() == 'check menu item' and \
+ root[0][0][-1].name == 'Text Entry Settings...' and \
+ root[0][0][-1].get_role_name() == 'check menu item'
+
+def get_indicator_accessible(root):
+ return pyatspi.utils.findDescendant(root, is_indicator_accessible, 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()
+ desktop = registry.getDesktop(0)
+ panel = get_panel_accessible(desktop)
+ self.indicator = get_indicator_accessible(panel)
+
+ # This is needed on systems other than the EN locale
+ os.putenv("LC_ALL", "C")
+ self.addCleanup(os.unsetenv, "LC_ALL")
+
+ def test_indicator(self):
+ print_accessible(self.indicator)