autopilot-gtk-1.4+14.04.20140107/ 0000755 0000150 0000156 00000000000 12263102111 016475 5 ustar pbuser pbgroup 0000000 0000000 autopilot-gtk-1.4+14.04.20140107/tests/ 0000755 0000150 0000156 00000000000 12263102111 017637 5 ustar pbuser pbgroup 0000000 0000000 autopilot-gtk-1.4+14.04.20140107/tests/hello_color.ui 0000644 0000150 0000156 00000027425 12263101673 022525 0 ustar pbuser pbgroup 0000000 0000000
This is a test application.FalseHello ColorTrueFalseverticalTrueFalseTrueFalse_FileTrueTrueFalsegtk-openTrueFalseTrueTrueTrueFalsegtk-quitTrueFalseTrueTrueTrueFalse_HelpTrueTrueFalsegtk-aboutTrueFalseTrueTrueFalseTrue0TrueFalsestart555555TrueFalseName0011TrueFalseColor0111TrueTrueTrue•1011TrueTrue•1111TrueTrue1TrueFalse0510FalseTrue2TrueFalse10TrueendGreetTrueTrueTrueFalseTrue0gtk-deleteTrueTrueTrueTrueFalseTrue1gtk-quitTrueTrueTrueTruerightFalseTrue2FalseTrue3
autopilot-gtk-1.4+14.04.20140107/tests/hello_color.py 0000755 0000150 0000156 00000003422 12263101673 022532 0 ustar pbuser pbgroup 0000000 0000000 #!/usr/bin/python
import sys
import os.path
from gi.repository import Gtk
class HelloColorApp(Gtk.Application):
def __init__(self):
self.widgets = Gtk.Builder.new()
self.widgets.add_from_file((os.path.join(os.path.dirname(sys.argv[0]), 'hello_color.ui')))
assert self.widgets.connect_signals(self) is None
def run(self):
self.widgets.get_object('window_app').show()
Gtk.main()
def on_quit(self, *args):
Gtk.main_quit()
def on_file_open(self, *args):
md = Gtk.FileChooserDialog('Select a file..',
parent=self.widgets.get_object('window_app'),
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
result = md.run()
md.hide()
if result == Gtk.ResponseType.OK:
self.widgets.get_object('label_status').set_text('Loaded %s' % md.get_filenames()[0])
def on_button_greet(self, *args):
name = self.widgets.get_object('entry_name').get_text()
color = self.widgets.get_object('entry_color').get_text()
md = Gtk.MessageDialog(message_type=Gtk.MessageType.INFO,
buttons=Gtk.ButtonsType.CLOSE,
text='Hello %s, you like %s.' % (name, color))
md.run()
md.hide()
def on_button_clear(self, *args):
self.widgets.get_object('entry_name').set_text('')
self.widgets.get_object('entry_color').set_text('')
self.widgets.get_object('label_status').set_text('')
def on_about(self, *args):
d = self.widgets.get_object('dialog_about')
d.run()
d.hide()
if __name__ == '__main__':
HelloColorApp().run()
autopilot-gtk-1.4+14.04.20140107/tests/autopilot/ 0000755 0000150 0000156 00000000000 12263102111 021657 5 ustar pbuser pbgroup 0000000 0000000 autopilot-gtk-1.4+14.04.20140107/tests/autopilot/tests/ 0000755 0000150 0000156 00000000000 12263102111 023021 5 ustar pbuser pbgroup 0000000 0000000 autopilot-gtk-1.4+14.04.20140107/tests/autopilot/tests/test_gnome_system_log.py 0000644 0000150 0000156 00000005020 12263101673 030015 0 ustar pbuser pbgroup 0000000 0000000 # blackbox testing of autopilot API against gnome-system-log
# Author: Martin Pitt
# Copyright (C) 2013 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
from autopilot.testcase import AutopilotTestCase
from autopilot.matchers import Eventually
from testtools.matchers import Equals, NotEquals
class GnomeAppTest(AutopilotTestCase):
"""Test autopilot against an actual GNOME application"""
def setUp(self):
super(GnomeAppTest, self).setUp()
self.patch_environment('LANGUAGE', '')
self.patch_environment('LANG', '')
self.patch_environment('LC_MESSAGES', 'C')
self.app = self.launch_test_application('gnome-system-log', '/etc/issue')
def test_filename_label(self):
"""Find file name label"""
l = self.app.select_single('GtkLabel', label=u'issue')
self.assertNotEqual(l, None)
self.assertEqual(l.visible, True)
def test_search(self):
"""Run a search"""
revealer = self.app.select_single('GdRevealer')
if revealer:
# search bar not visible by default
self.assertEqual(revealer.child_revealed, False)
else:
# g-s-l < 3.8 did not have the GdRevealer object yet
findbar = self.app.select_single('LogviewFindbar')
self.assertEqual(findbar.visible, False)
search_btn = self.app.select_single('GtkToggleButton')
self.assertNotEqual(search_btn, None)
self.mouse.click_object(search_btn)
# should trigger search bar
if revealer:
self.assertThat(lambda: revealer.child_revealed, Eventually(Equals(True)))
else:
self.assertThat(lambda: findbar.visible, Eventually(Equals(True)))
search = self.app.select_single('GtkSearchEntry', visible=True)
self.assertTrue(search.has_focus)
# something that will not be in /etc/issue
self.keyboard.type('Bogus12!')
self.app.wait_select_single('GtkLabel', label=u'No matches found')
autopilot-gtk-1.4+14.04.20140107/tests/autopilot/tests/test_xpath_query.py 0000644 0000150 0000156 00000010300 12263101673 027011 0 ustar pbuser pbgroup 0000000 0000000 # blackbox testing of autopilot API against our hello_color.py test GTK program
# Author: Martin Pitt
# Copyright (C) 2013 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
import os.path
import unittest
from autopilot.testcase import AutopilotTestCase
tests_dir = os.path.dirname(os.path.dirname(os.path.dirname(
os.path.realpath(__file__))))
test_app = os.path.join(tests_dir, 'hello_color.py')
class XPathQueryTest(AutopilotTestCase):
"""XPath queries"""
def setUp(self):
super(XPathQueryTest, self).setUp()
self.app = self.launch_test_application(test_app, app_type='gtk')
def xtest_have_path(self):
"""All children have a unique path"""
widgets = set()
self._get_widgets(self.app, widgets)
seen_paths = set()
for widget in widgets:
path = widget.get_class_query_string()
self.assertNotIn(path, seen_paths)
seen_paths.add(path)
# we can resolve the path back to the widget
state = self.app.get_state_by_path(path)
# state is an array with one (path, props) element
props = state[0][1]
self.assertEqual(props['id'], widget.id)
self.assertEqual(props['visible'], widget.visible)
def xtest_select_full_path(self):
"""Select widgets with full XPath"""
# three buttons in main dialog's ButtonBox
state = self.app.get_state_by_path('/Root/GtkWindow/GtkBox/GtkButtonBox/GtkButton')
self.assertEqual(len(state), 3)
labels = [str(props[1]['label']) for props in state]
labels.sort()
self.assertEqual(labels, ['Greet', 'gtk-delete', 'gtk-quit'])
# select button with particular label
for l in ['Greet', 'gtk-delete', 'gtk-quit']:
state = self.app.get_state_by_path('/Root/GtkWindow/GtkBox/GtkButtonBox/GtkButton[label=%s]' % l)
self.assertEqual(len(state), 1)
self.assertEqual(state[0][1]['label'], l)
def xtest_select_path_pattern(self):
"""Select widgets with XPath path pattern"""
# three buttons in main dialog's ButtonBox
state = self.app.get_state_by_path('//GtkWindow//GtkButton')
self.assertEqual(len(state), 3)
labels = [str(props[1]['label']) for props in state]
labels.sort()
self.assertEqual(labels, ['Greet', 'gtk-delete', 'gtk-quit'])
# at least four buttons in the whole tree
state = self.app.get_state_by_path('/Root//GtkButton')
self.assertGreaterEqual(len(state), 4)
def test_select_by_attribute(self):
"""Select widgets with attribute pattern"""
state = self.app.get_state_by_path('//*[label="gtk-delete"]')
self.assertEqual(len(state), 1, state)
self.assertEqual(state[0][1]['label'], [0, 'gtk-delete'])
self.assertTrue(state[0][0].endswith('/GtkButton'), state[0][0])
# https://launchpad.net/bugs/1179806
# TODO: Make this pass!
@unittest.expectedFailure
def test_select_by_attribute_spaces(self):
"""Select widgets with attribute pattern containing spaces"""
for state_str in ('//*[label="Hello\\x20Color!"]', '//*[label="Hello Color!"]'):
state = self.app.get_state_by_path(state_str)
self.assertEqual(len(state), 1, str(state))
self.assertEqual(state[0][1]['label'], 'Hello Color!')
self.assertTrue(state[0][0].endswith('/GtkLabel'), state[0][0])
@classmethod
def _get_widgets(klass, obj, widget_set):
"""Recursively add all children of obj to widget_set"""
for c in obj.get_children():
widget_set.add(c)
klass._get_widgets(c, widget_set)
autopilot-gtk-1.4+14.04.20140107/tests/autopilot/tests/test_properties.py 0000644 0000150 0000156 00000012770 12263101673 026651 0 ustar pbuser pbgroup 0000000 0000000 # blackbox testing of autopilot API against our hello_color.py test GTK program
# Author: Martin Pitt
# Copyright (C) 2013 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
import os.path
import unittest
from autopilot.testcase import AutopilotTestCase
tests_dir = os.path.dirname(os.path.dirname(os.path.dirname(
os.path.realpath(__file__))))
test_app = os.path.join(tests_dir, 'hello_color.py')
class PropertyTest(AutopilotTestCase):
"""Widget properties"""
def setUp(self):
super(PropertyTest, self).setUp()
self.app = self.launch_test_application(test_app, app_type='gtk')
def test_gtk_builder_name(self):
"""GtkBuilder name lookup"""
w = self.app.select_single(BuilderName='button_greet')
self.assertNotEqual(w, None)
self.assertEqual(w.label, 'Greet')
w = self.app.select_single(BuilderName='button_quit')
self.assertNotEqual(w, None)
self.assertEqual(w.label, 'gtk-quit')
w = self.app.select_single(BuilderName='entry_color')
self.assertNotEqual(w, None)
def test_button(self):
"""GtkButton properties"""
btn_greet = self.app.select_single('GtkButton', label='Greet')
self.assertNotEqual(btn_greet, None)
btn_quit = self.app.select_single('GtkButton', label='gtk-quit')
self.assertNotEqual(btn_quit, None)
self.assertEqual(btn_greet.use_stock, False)
self.assertEqual(btn_quit.use_stock, True)
# only GtkButton, GtkFileChooserButton, and GtkComboBox have
# focus-on-click, and we don't use the latter two
self.assertEqual(btn_greet.focus_on_click, True)
self.assertEqual(btn_quit.focus_on_click, True)
# all buttons are visible and thus should have a rect
self.assertTrue(btn_greet.visible)
self.assertTrue(btn_quit.visible)
self.assertEqual(len(btn_greet.globalRect), 4)
self.assertEqual(len(btn_quit.globalRect), 4)
# all our buttons have a GtkBuilder ID
self.assertEqual(btn_greet.BuilderName, 'button_greet')
self.assertEqual(btn_quit.BuilderName, 'button_quit')
def test_entry(self):
"""GtkEntry properties"""
entry_name = self.app.select_single(BuilderName='entry_name')
entry_color = self.app.select_single(BuilderName='entry_color')
self.assertTrue(entry_name.visible)
self.assertTrue(entry_color.visible)
# the entries should have the same size and x alignment
self.assertEqual(entry_name.globalRect[0], entry_color.globalRect[0])
self.assertEqual(entry_name.globalRect[2:], entry_color.globalRect[2:])
# FIXME: This isn't necessary for real X, but under Xvfb there is no
# default focus sometimes
if not entry_name.has_focus:
self.mouse.click_object(entry_name)
# the color entry is below the name entry
self.assertLess(entry_name.globalRect[1], entry_color.globalRect[1])
# first entry has default focus
self.assertEqual(entry_name.has_focus, True)
self.assertEqual(entry_color.has_focus, False)
# both entries are empty by default
self.assertEqual(entry_name.text, '')
self.assertEqual(entry_color.text, '')
# text-length is an unique property for GtkEntry
self.assertEqual(entry_name.text_length, 0)
self.assertEqual(entry_color.text_length, 0)
def test_enum_flags_properties(self):
'''enum and flags properties'''
# enum
btn_greet = self.app.select_single('GtkButton', label='Greet')
self.assertEqual(btn_greet.relief, 'GTK_RELIEF_NORMAL')
self.assertEqual(btn_greet.resize_mode, 'GTK_RESIZE_PARENT')
res = self.app.select_many(relief='GTK_RELIEF_NORMAL', visible=True)
self.assertGreaterEqual(len(res), 3)
self.assertIn('Button', str(type(res[0])))
# flags
self.assertGreaterEqual(btn_greet.events, 0)
res = self.app.select_many('GtkButton', events=btn_greet.events)
self.assertGreater(len(res), 0)
def test_textview_properties(self):
"""GtkTextView properties"""
t = self.app.select_single(BuilderName='textview_demo')
self.assertNotEqual(t, None)
self.assertEqual(t.editable, True)
self.assertEqual(t.overwrite, False)
# the buffer property points to a GtkTextBuffer object, which we want
# to translate to a plain string
self.assertEqual(t.buffer, 'This is a test application.')
# select by buffer contents
w = self.app.select_single(buffer='This is a test application.')
self.assertEqual(w.BuilderName, 'textview_demo')
def test_stress(self):
"""Query lots widgets in a tight loop"""
for i in range(300):
w = self.app.select_single(BuilderName='button_greet')
self.assertEqual(w.label, 'Greet')
w = self.app.select_single('GtkButton', label='gtk-quit')
self.assertEqual(w.use_stock, True)
autopilot-gtk-1.4+14.04.20140107/tests/autopilot/tests/__init__.py 0000644 0000150 0000156 00000000000 12263101673 025134 0 ustar pbuser pbgroup 0000000 0000000 autopilot-gtk-1.4+14.04.20140107/tests/autopilot/tests/test_actions.py 0000644 0000150 0000156 00000015005 12263101673 026107 0 ustar pbuser pbgroup 0000000 0000000 # blackbox testing of autopilot API against our hello_color.py test GTK program
# Author: Martin Pitt
# Copyright (C) 2013 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
import os.path
import os
from autopilot.testcase import AutopilotTestCase
from autopilot.introspection.dbus import StateNotFoundError
from autopilot.matchers import Eventually
from testtools.matchers import Equals, NotEquals, raises
tests_dir = os.path.dirname(os.path.dirname(os.path.dirname(
os.path.realpath(__file__))))
test_app = os.path.join(tests_dir, 'hello_color.py')
class ActionsTest(AutopilotTestCase):
"""Test performing actions in the UI and verify results"""
def setUp(self):
super(ActionsTest, self).setUp()
# we want to test the position of GtkMenuItems here, disable global menubar
os.environ['UBUNTU_MENUPROXY'] = '0'
self.app = self.launch_test_application(test_app, app_type='gtk')
def test_greeting_keyboard(self):
"""Greeting with keyboard navigation"""
entry_name = self.app.select_single(BuilderName='entry_name')
entry_color = self.app.select_single(BuilderName='entry_color')
# FIXME: This isn't necessary for real X, but under Xvfb there is no
# default focus sometimes
if not entry_name.has_focus:
self.mouse.click_object(entry_name)
# type in name and color
self.keyboard.type('Joe')
self.keyboard.press_and_release('Tab')
self.keyboard.type('red')
# entries should now have the typed text
self.assertThat(entry_name.text, Eventually(Equals('Joe')))
self.assertThat(entry_color.text, Eventually(Equals('red')))
# should not have any dialogs
self.assertThat(
lambda: self.app.select_single('GtkMessageDialog'),
raises(StateNotFoundError)
)
# focus and activate the "Greet" button
self.keyboard.press_and_release('Tab')
self.keyboard.press_and_release('Enter')
# should get the greeting dialog
md = self.app.wait_select_single('GtkMessageDialog', visible=True)
# we expect the message dialog to show the corresponding greeting
self.assertNotEqual(md.select_single('GtkLabel',
label=u'Hello Joe, you like red.'),
None)
# close the dialog
self.keyboard.press_and_release('Enter')
self.assertThat(
lambda: self.app.select_single('GtkMessageDialog', visible=True),
raises(StateNotFoundError)
)
def test_greeting_mouse(self):
"""Greeting with mouse navigation"""
entry_name = self.app.select_single(BuilderName='entry_name')
entry_color = self.app.select_single(BuilderName='entry_color')
# FIXME: This isn't necessary for real X, but under Xvfb there is no
# default focus sometimes
if not entry_name.has_focus:
self.mouse.click_object(entry_name)
# type in name and color
self.keyboard.type('Joe')
self.mouse.click_object(entry_color)
self.keyboard.type('blue')
# entries should now have the typed text
self.assertThat(entry_name.text, Eventually(Equals('Joe')))
self.assertThat(entry_color.text, Eventually(Equals('blue')))
# should not have any dialogs
self.assertThat(
lambda: self.app.select_single('GtkMessageDialog'),
raises(StateNotFoundError)
)
# focus and activate the "Greet" button
btn = self.app.select_single('GtkButton', label='Greet')
self.assertNotEqual(btn, None)
self.mouse.click_object(btn)
# should get the greeting dialog
md = self.app.wait_select_single('GtkMessageDialog', visible=True)
# we expect the message dialog to show the corresponding greeting
self.assertNotEqual(md.select_single('GtkLabel',
label=u'Hello Joe, you like blue.'),
None)
# close the dialog
btn = md.select_single('GtkButton')
self.mouse.click_object(btn)
self.assertThat(
lambda: self.app.select_single('GtkMessageDialog', visible=True),
raises(StateNotFoundError)
)
def test_clear(self):
"""Using Clear button with mouse"""
# type in name and color
self.keyboard.type('Joe')
self.keyboard.press_and_release('Tab')
self.keyboard.type('blue')
# clear
btn = self.app.select_single('GtkButton', label='gtk-delete')
self.mouse.click_object(btn)
# entries should be clear now
entries = self.app.select_many('GtkEntry')
self.assertEqual(len(entries), 2)
for e in entries:
self.assertThat(e.text, Eventually(Equals('')))
def test_menu(self):
"""Browse the menu"""
file_menu = self.app.select_single('GtkMenuItem', label='_File')
help_menu = self.app.select_single('GtkMenuItem', label='_Help')
self.assertNotEqual(file_menu, None)
self.assertNotEqual(help_menu, None)
# the top-level menus should be visible and thus have a rect
for m in (file_menu, help_menu):
self.assertGreaterEqual(m.globalRect[0], 0)
self.assertGreaterEqual(m.globalRect[1], 0)
self.assertGreater(m.globalRect[2], 0)
self.assertGreater(m.globalRect[3], 0)
# the submenus are not visible by default
m = self.app.select_single('GtkImageMenuItem', label='gtk-open')
self.assertFalse(hasattr(m, 'globalRect'))
# after opening, submenus should become visible
self.mouse.click_object(file_menu)
m = self.app.wait_select_single('GtkImageMenuItem', label='gtk-open', visible=True)
self.assertGreaterEqual(m.globalRect[0], 0)
self.assertGreaterEqual(m.globalRect[1], 0)
self.assertGreater(m.globalRect[2], 0)
self.assertGreater(m.globalRect[3], 0)
autopilot-gtk-1.4+14.04.20140107/tests/autopilot/tests/test_widget_tree.py 0000644 0000150 0000156 00000015425 12263101673 026757 0 ustar pbuser pbgroup 0000000 0000000 # blackbox testing of autopilot API against our hello_color.py test GTK program
# Author: Martin Pitt
# Copyright (C) 2013 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
import os.path
import unittest
from autopilot.introspection.dbus import StateNotFoundError
from autopilot.testcase import AutopilotTestCase
from testtools.matchers import raises
tests_dir = os.path.dirname(os.path.dirname(os.path.dirname(
os.path.realpath(__file__))))
test_app = os.path.join(tests_dir, 'hello_color.py')
class WidgetTreeTest(AutopilotTestCase):
"""Widget tree iteration and search"""
def setUp(self):
super(WidgetTreeTest, self).setUp()
self.app = self.launch_test_application(test_app, app_type='gtk')
def test_get_children_recursive(self):
"""Recursive get_children()
This should not crash, and deliver valid widgets.
"""
widgets = set()
self._get_widgets(self.app, widgets)
for c in widgets:
self.assertIn('.Gtk', str(type(c)))
self.assertGreaterEqual(c.id, 0)
# uncomment this to get a dump of all widgets and properties
#print(type(c))
#for p in c.get_properties():
# print ' ', p, repr(getattr(c, p))
def test_get_children_by_type(self):
# multiple instances
res = self.app.get_children_by_type('GtkWindow')
self.assertGreaterEqual(len(res), 3)
self.assertIn('.GtkWindow', str(type(res[0])))
# one qualified instance
res = self.app.get_children_by_type('GtkWindow', Children=['GtkBox'])
self.assertGreaterEqual(len(res), 1)
# no instances
self.assertEqual(self.app.get_children_by_type('GtkTable'), [])
def test_select_single_unique(self):
"""select_single() on widget types with only one instance"""
for wtype in ('GtkMenuBar', 'GtkAboutDialog'):
w = self.app.select_single(wtype)
self.assertIn('.' + wtype, str(type(w)))
def test_select_single_nonunique(self):
"""select_single() on widget types with multiple instances"""
# we have more than one instance of these
for wtype in ('GtkButton', 'GtkEntry'):
self.assertRaises(ValueError, self.app.select_single, wtype)
# we have no instances of these
for wtype in ('GtkTable', 'GtkRadioButton'):
self.assertThat(
lambda: self.app.select_single(wtype),
raises(StateNotFoundError)
)
# qualified: visible property is not unique
self.assertRaises(ValueError,
self.app.select_single, 'GtkButton', visible=True)
# qualified: label property is unique within GtkButton
w = self.app.select_single('GtkButton', label='gtk-quit')
self.assertIn('.GtkButton', str(type(w)))
self.assertEqual(w.label, 'gtk-quit')
def test_select_single_noclass(self):
"""select_single() without specifying a class"""
# gtk-delete label is unique to our Button
w = self.app.select_single(label='gtk-delete')
self.assertIn('.GtkButton', str(type(w)))
self.assertEqual(w.label, 'gtk-delete')
# gtk-quit label is not unique globally, it's also a menu item
self.assertRaises(ValueError, self.app.select_single, label='gtk-quit')
# ... but it is unique for focussable widgets (menus don't allow that)
w = self.app.select_single(label='gtk-quit', can_focus=True)
self.assertIn('.GtkButton', str(type(w)))
self.assertEqual(w.label, 'gtk-quit')
def test_select_many_string(self):
"""select_many() with string properties"""
# by class, unqualified, multiple instances
res = self.app.select_many('GtkButton')
# we have three in our main window, plus some in the about dialog
self.assertGreaterEqual(len(res), 3)
self.assertIn('.GtkButton', str(type(res[0])))
# .. but exactly three in the main window
main_window = self.app.select_single('GtkWindow', Children=['GtkBox'], visible=True)
res = main_window.select_many('GtkButton')
self.assertEqual(len(res), 3)
# by class, unqualified, single instance
res = self.app.select_many('GtkMenuBar')
self.assertEqual(len(res), 1)
self.assertIn('.GtkMenuBar', str(type(res[0])))
# by class, unqualified, no instance
res = self.app.select_many('GtkTable')
self.assertEqual(res, [])
# by class, qualified
res = self.app.select_many('GtkButton', label='Greet')
self.assertEqual(len(res), 1)
self.assertIn('.GtkButton', str(type(res[0])))
self.assertEqual(res[0].label, 'Greet')
# untyped
res = self.app.select_many(label='gtk-delete')
self.assertEqual(len(res), 1)
self.assertIn('.GtkButton', str(type(res[0])))
self.assertEqual(res[0].label, 'gtk-delete')
res = self.app.select_many(label='gtk-quit')
# button and menu item
self.assertEqual(len(res), 2)
def test_select_int(self):
"""select_*() with int properties"""
# with class
res = self.app.select_many('GtkButtonBox', border_width=5)
self.assertEqual(len(res), 1)
self.assertNotEqual(self.app.select_single('GtkButtonBox', border_width=5), None)
# without class
res = self.app.select_many(border_width=5)
self.assertGreater(len(res), 2)
self.assertNotEqual(self.app.select_single(border_width=2), None)
def test_select_bool(self):
"""select_*() with boolean properties"""
# with class
res = self.app.select_many('GtkButton', visible=True)
self.assertGreater(len(res), 2)
res = self.app.select_many('GtkAboutDialog', visible=False)
self.assertGreater(len(res), 0)
# without class
res = self.app.select_many(visible=True)
self.assertGreater(len(res), 5)
res = self.app.select_many(visible=False)
self.assertGreater(len(res), 4)
@classmethod
def _get_widgets(klass, obj, widget_set):
"""Recursively add all children of obj to widget_set"""
for c in obj.get_children():
widget_set.add(c)
klass._get_widgets(c, widget_set)
autopilot-gtk-1.4+14.04.20140107/CMakeLists.txt 0000644 0000150 0000156 00000000604 12263101673 021251 0 ustar pbuser pbgroup 0000000 0000000
cmake_minimum_required(VERSION 2.6)
project(autopilot-gtk)
include (GNUInstallDirs)
set (VERSION 0.2)
set (CMAKE_CXX_FLAGS "-DGNOME_DESKTOP_USE_UNSTABLE_API -std=c++11 -fno-permissive")
INCLUDE(FindPkgConfig)
add_subdirectory(lib)
enable_testing()
add_test(nose sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/tests/autopilot; GTK_PATH=${CMAKE_CURRENT_BINARY_DIR}/lib autopilot run -v tests")
autopilot-gtk-1.4+14.04.20140107/lib/ 0000755 0000150 0000156 00000000000 12263102111 017243 5 ustar pbuser pbgroup 0000000 0000000 autopilot-gtk-1.4+14.04.20140107/lib/Variant.h 0000644 0000150 0000156 00000003506 12263101673 021040 0 ustar pbuser pbgroup 0000000 0000000 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
/*
* Copyright (C) 2011 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authored by: Tim Penhey
*/
#ifndef VARIANT_H
#define VARIANT_H
#include
#include
#include
#include