testinggtk r431 - trunk/tests



Author: bjornl
Date: Tue Sep  9 13:05:49 2008
New Revision: 431
URL: http://svn.gnome.org/viewvc/testinggtk?rev=431&view=rev

Log:
Tests for when widget.unparent() touches the parent window attribute

Modified:
   trunk/tests/test_widget.py

Modified: trunk/tests/test_widget.py
==============================================================================
--- trunk/tests/test_widget.py	(original)
+++ trunk/tests/test_widget.py	Tue Sep  9 13:05:49 2008
@@ -310,6 +310,43 @@
     child.unparent()
     assert not child.get_parent()
 
+def test_unparent_with_parent_clears_parent_window():
+    '''
+    Ensure that unparenting a widget clears its parent window. If the
+    widget has a parent.
+    '''
+    window = gdk.Window(None,
+                        100, 100,
+                        gdk.WINDOW_TOPLEVEL,
+                        0,
+                        gdk.INPUT_OUTPUT,
+                        x = 100, y = 100)
+    widget = gtk.Button()
+    parent = gtk.HBox()
+    widget.set_parent(parent)
+    widget.set_parent_window(window)
+
+    assert widget.get_parent_window()
+    widget.unparent()
+    assert not widget.get_parent_window()
+
+def test_unparent_without_parent_leaves_parent_window():
+    '''
+    Ensure that unparenting a widget without a parent leaves its
+    parent window attribute untouched.
+    '''
+    window = gdk.Window(None,
+                        100, 100,
+                        gdk.WINDOW_TOPLEVEL,
+                        0,
+                        gdk.INPUT_OUTPUT,
+                        x = 100, y = 100)
+    widget = gtk.Button()
+    widget.set_parent_window(window)
+    assert widget.get_parent_window()
+    widget.unparent()
+    assert widget.get_parent_window()
+
 ######################################################################
 ##### Focus and grab tests ###########################################
 ######################################################################



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]