testinggtk r444 - trunk/tests
- From: bjornl svn gnome org
- To: svn-commits-list gnome org
- Subject: testinggtk r444 - trunk/tests
- Date: Wed, 10 Sep 2008 14:29:42 +0000 (UTC)
Author: bjornl
Date: Wed Sep 10 14:29:42 2008
New Revision: 444
URL: http://svn.gnome.org/viewvc/testinggtk?rev=444&view=rev
Log:
Organize the different test categories in groups, it makes the generated epydoc documentation look better
Modified:
trunk/tests/test_widget.py
Modified: trunk/tests/test_widget.py
==============================================================================
--- trunk/tests/test_widget.py (original)
+++ trunk/tests/test_widget.py Wed Sep 10 14:29:42 2008
@@ -1,6 +1,17 @@
'''
Tests for the ``gtk.Widget`` class. Since that class is abstract,
subclasses of it is used in these tests.
+
+:group Tooltip Tests: test_set_get_has_tooltip, test_set_tooltip_text,
+ test_set_empty_tooltip, test_get_has_tooltip,
+ test_tooltip_overlapping_widgets
+:group Unparenting Tests: test_unparent,
+ test_unparent_with_parent_clears_parent_window,
+ test_unparent_without_parent_leaves_parent_window,
+ test_unparent_clears_parent_focus_child
+:group Focus and Grab Tests: test_set_get_can_focus, test_grab_add,
+ test_has_grab_flag, test_grab_insensitive_widget, test_grab_focus,
+ test_grab_focus_unfocusable
'''
import atk
import gobject
@@ -119,42 +130,6 @@
widget.set_child_visible(True)
assert widget.get_child_visible()
-def test_set_tooltip_text():
- '''
- Ensure that setting and getting the tooltip text attribute works
- as expected.
- '''
- widget = gtk.Button()
- widget.set_tooltip_text('foo')
- assert widget.get_tooltip_text() == 'foo'
- widget.set_tooltip_text('bar')
- assert widget.get_tooltip_text() == 'bar'
-
-def test_set_empty_tooltip():
- '''
- Setting an empty string as the tooltip for a widget, unsets that
- widgets tooltip.
-
- :bug: #504456, #541399
- '''
- widget = gtk.Button()
- widget.set_tooltip_text('hello')
- assert widget.get_tooltip_text() == 'hello'
- assert widget.get_has_tooltip()
- widget.set_tooltip_text('')
- assert not widget.get_tooltip_text()
- assert not widget.get_has_tooltip()
-
-def test_get_has_tooltip():
- '''
- Ensure that ``get_has_tooltip`` returns ``True`` if the widget has
- a tooltip, ``False`` otherwise.
- '''
- widget = gtk.Button()
- assert not widget.get_has_tooltip()
- widget.set_tooltip_text('hello')
- assert widget.get_has_tooltip()
-
def test_widget_visibility():
'''
Ensure that changing the ``visible`` property works as
@@ -167,57 +142,6 @@
widget.hide()
assert not widget.get_property('visible')
-def test_tooltip_overlapping_widgets():
- '''
- Ensure that the correct tooltip is shown when two widgets inside a
- ``gtk.Layout`` overlaps each other.
-
- :bug: #550345
- '''
- b1 = gtk.Button('1')
- b1.set_size_request(100, 100)
- b1.set_tooltip_text('button1')
-
- b2 = gtk.Button('2')
- b2.set_size_request(100, 100)
- b2.set_tooltip_text('button2')
-
- # Note that in this layout b2 overlaps b1.
- layout = gtk.Layout()
- layout.set_size_request(400, 400)
- layout.put(b1, 0, 0)
- layout.put(b2, 50, 0)
- win = gtk.Window()
- win.add(layout)
- win.show_all()
-
- # By setting the timeout to 0 the tooltip should show after one
- # iteration of the mainloop.
- settings = gtk.settings_get_default()
- settings.set_property('gtk-tooltip-timeout', 0)
-
- # Simulate a motion notify over the second button on a location
- # where it overlaps the first button.
- ev = gdk.Event(gdk.MOTION_NOTIFY)
- ev.window = win.window
- ev.x = ev.x_root = 80.0
- ev.y = ev.y_root = 10.0
- ev.is_hint = False
-
- # GTK gets the motion notify event and shows the tooltip in
- # response.
- gtk.main_do_event(ev)
- gtk.main_iteration()
-
- # Find the tooltip window in the toplevel list.
- tooltip_win = None
- for w in gtk.window_list_toplevels():
- if w.name == 'gtk-tooltip':
- tooltip_win = w
-
- # The tooltip label shown should be the second buttons.
- tooltip_label = tooltip_win.get_child().get_child().get_children()[1]
- assert tooltip_label.get_text() == 'button2'
@utils.pass_on_warnings
@@ -240,14 +164,6 @@
except TypeError:
assert True
-def test_set_get_has_tooltip():
- widget = gtk.Button()
- assert not widget.get_has_tooltip()
- widget.set_has_tooltip(True)
- assert widget.get_has_tooltip()
- widget.set_has_tooltip(False)
- assert not widget.get_has_tooltip()
-
def test_set_get_no_window_flag():
widget = gtk.Button()
assert widget.flags() & gtk.NO_WINDOW
@@ -354,6 +270,106 @@
# t.realize()
######################################################################
+##### Tooltip Tests ##################################################
+######################################################################
+def test_set_get_has_tooltip():
+ widget = gtk.Button()
+ assert not widget.get_has_tooltip()
+ widget.set_has_tooltip(True)
+ assert widget.get_has_tooltip()
+ widget.set_has_tooltip(False)
+ assert not widget.get_has_tooltip()
+
+
+def test_set_tooltip_text():
+ '''
+ Ensure that setting and getting the tooltip text attribute works
+ as expected.
+ '''
+ widget = gtk.Button()
+ widget.set_tooltip_text('foo')
+ assert widget.get_tooltip_text() == 'foo'
+ widget.set_tooltip_text('bar')
+ assert widget.get_tooltip_text() == 'bar'
+
+def test_set_empty_tooltip():
+ '''
+ Setting an empty string as the tooltip for a widget, unsets that
+ widgets tooltip.
+
+ :bug: #504456, #541399
+ '''
+ widget = gtk.Button()
+ widget.set_tooltip_text('hello')
+ assert widget.get_tooltip_text() == 'hello'
+ assert widget.get_has_tooltip()
+ widget.set_tooltip_text('')
+ assert not widget.get_tooltip_text()
+ assert not widget.get_has_tooltip()
+
+def test_get_has_tooltip():
+ '''
+ Ensure that ``get_has_tooltip`` returns ``True`` if the widget has
+ a tooltip, ``False`` otherwise.
+ '''
+ widget = gtk.Button()
+ assert not widget.get_has_tooltip()
+ widget.set_tooltip_text('hello')
+ assert widget.get_has_tooltip()
+
+def test_tooltip_overlapping_widgets():
+ '''
+ Ensure that the correct tooltip is shown when two widgets inside a
+ ``gtk.Layout`` overlaps each other.
+
+ :bug: #550345
+ '''
+ b1 = gtk.Button('1')
+ b1.set_size_request(100, 100)
+ b1.set_tooltip_text('button1')
+
+ b2 = gtk.Button('2')
+ b2.set_size_request(100, 100)
+ b2.set_tooltip_text('button2')
+
+ # Note that in this layout b2 overlaps b1.
+ layout = gtk.Layout()
+ layout.set_size_request(400, 400)
+ layout.put(b1, 0, 0)
+ layout.put(b2, 50, 0)
+ win = gtk.Window()
+ win.add(layout)
+ win.show_all()
+
+ # By setting the timeout to 0 the tooltip should show after one
+ # iteration of the mainloop.
+ settings = gtk.settings_get_default()
+ settings.set_property('gtk-tooltip-timeout', 0)
+
+ # Simulate a motion notify over the second button on a location
+ # where it overlaps the first button.
+ ev = gdk.Event(gdk.MOTION_NOTIFY)
+ ev.window = win.window
+ ev.x = ev.x_root = 80.0
+ ev.y = ev.y_root = 10.0
+ ev.is_hint = False
+
+ # GTK gets the motion notify event and shows the tooltip in
+ # response.
+ gtk.main_do_event(ev)
+ gtk.main_iteration()
+
+ # Find the tooltip window in the toplevel list.
+ tooltip_win = None
+ for w in gtk.window_list_toplevels():
+ if w.name == 'gtk-tooltip':
+ tooltip_win = w
+
+ # The tooltip label shown should be the second buttons.
+ tooltip_label = tooltip_win.get_child().get_child().get_children()[1]
+ assert tooltip_label.get_text() == 'button2'
+
+######################################################################
##### Unparenting tests ##############################################
######################################################################
def test_unparent():
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]