[POS-commit] r146 - in Kiwi2: . tests
Lorenzo Gil Sanchez
lgs at async.com.br
Fri Mar 18 14:55:56 BRT 2005
Author: lgs
Date: 2005-03-18 14:55:56 -0300 (Fri, 18 Mar 2005)
New Revision: 146
Added:
Kiwi2/tests/actions.glade
Kiwi2/tests/simple_button.glade
Kiwi2/tests/test_Action.py
Modified:
Kiwi2/ChangeLog
Kiwi2/tests/test_Delegate.py
Log:
* tests/test_Action.py: test that menubars and toolbars work with
Kiwi autoconnect mechanism
* tests/test_Delegate.py: added tests to make sure that a signal
handler is only called once
Modified: Kiwi2/ChangeLog
===================================================================
--- Kiwi2/ChangeLog 2005-03-18 13:35:30 UTC (rev 145)
+++ Kiwi2/ChangeLog 2005-03-18 17:55:56 UTC (rev 146)
@@ -1,3 +1,11 @@
+2005-03-18 Lorenzo Gil Sanchez <lgs at sicem.biz>
+
+ * tests/test_Action.py: test that menubars and toolbars work with
+ Kiwi autoconnect mechanism
+
+ * tests/test_Delegate.py: added tests to make sure that a signal
+ handler is only called once
+
2005-03-16 Lorenzo Gil Sanchez <lgs at sicem.biz>
* Kiwi2/Views.py (SlaveView._init_glade_adaptor): allow the container
Added: Kiwi2/tests/actions.glade
===================================================================
--- Kiwi2/tests/actions.glade 2005-03-18 13:35:30 UTC (rev 145)
+++ Kiwi2/tests/actions.glade 2005-03-18 17:55:56 UTC (rev 146)
@@ -0,0 +1,156 @@
+<?xml version="1.0" ?>
+<glade-interface>
+ <object class="GtkUIManager" id="uimanager">
+ <child>
+ <object class="GtkActionGroup" id="DefaultActions">
+ <child>
+ <object class="GtkAction" id="FileMenu">
+ <property name="label">_File</property>
+ <property name="tooltip"></property>
+ <property name="callback"></property>
+ <property name="accelerator"></property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="New">
+ <property name="label">_New</property>
+ <property name="tooltip">Create a new file</property>
+ <property name="stock_id">gtk-new</property>
+ <property name="callback"></property>
+ <property name="accelerator"><control>N</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="Open">
+ <property name="label">_Open</property>
+ <property name="tooltip">Open a file</property>
+ <property name="stock_id">gtk-open</property>
+ <property name="callback"></property>
+ <property name="accelerator"><control>O</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="Save">
+ <property name="label">_Save</property>
+ <property name="tooltip">Save a file</property>
+ <property name="stock_id">gtk-save</property>
+ <property name="callback"></property>
+ <property name="accelerator"><control>S</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="SaveAs">
+ <property name="label">Save _as</property>
+ <property name="tooltip">Save with a differente name</property>
+ <property name="stock_id">gtk-save-as</property>
+ <property name="callback"></property>
+ <property name="accelerator"></property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="Quit">
+ <property name="label">_Quit</property>
+ <property name="tooltip">Quit the program</property>
+ <property name="stock_id">gtk-quit</property>
+ <property name="callback"></property>
+ <property name="accelerator"><control>Q</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="EditMenu">
+ <property name="label">_Edit</property>
+ <property name="tooltip"></property>
+ <property name="callback"></property>
+ <property name="accelerator"></property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="Copy">
+ <property name="label">_Copy</property>
+ <property name="tooltip">Copy selected object into the clipboard</property>
+ <property name="stock_id">gtk-copy</property>
+ <property name="callback"></property>
+ <property name="accelerator"><control>C</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="Cut">
+ <property name="label">C_ut</property>
+ <property name="tooltip">Cut selected object into the clipboard</property>
+ <property name="stock_id">gtk-cut</property>
+ <property name="callback"></property>
+ <property name="accelerator"><control>X</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="Paste">
+ <property name="label">_Paste</property>
+ <property name="tooltip">Paste object from the Clipboard</property>
+ <property name="stock_id">gtk-paste</property>
+ <property name="callback"></property>
+ <property name="accelerator"><control>V</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <widget class="GtkWindow" id="window1">
+ <property name="title" translatable="True"></property>
+ <property name="role"></property>
+ <property name="events">all-events-mask | button-motion-mask | button-press-mask | button-release-mask | button1-motion-mask | button2-motion-mask | button3-motion-mask | enter-notify-mask | exposure-mask | focus-change-mask | key-press-mask | key-release-mask | leave-notify-mask | pointer-motion-hint-mask | pointer-motion-mask | property-change-mask | proximity-in-mask | proximity-out-mask | scroll-mask | structure-mask | substructure-mask | visibility-notify-mask</property>
+ <child>
+ <widget class="GtkVBox" id="vbox1">
+ <property name="events">all-events-mask | button-motion-mask | button-press-mask | button-release-mask | button1-motion-mask | button2-motion-mask | button3-motion-mask | enter-notify-mask | exposure-mask | focus-change-mask | key-press-mask | key-release-mask | leave-notify-mask | pointer-motion-hint-mask | pointer-motion-mask | property-change-mask | proximity-in-mask | proximity-out-mask | scroll-mask | structure-mask | substructure-mask | visibility-notify-mask</property>
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkMenuBar" id="menubar1">
+ <property name="events">all-events-mask | button-motion-mask | button-press-mask | button-release-mask | button1-motion-mask | button2-motion-mask | button3-motion-mask | enter-notify-mask | exposure-mask | focus-change-mask | key-press-mask | key-release-mask | leave-notify-mask | pointer-motion-hint-mask | pointer-motion-mask | property-change-mask | proximity-in-mask | proximity-out-mask | scroll-mask | structure-mask | substructure-mask | visibility-notify-mask</property>
+ <property name="ui"><![CDATA[
+ <menubar action="menubar1" name="menubar1">
+ <menu action="FileMenu" name="FileMenu">
+ <menuitem action="New" name="New"/>
+ <menuitem action="Open" name="Open"/>
+ <menuitem action="Save" name="Save"/>
+ <menuitem action="SaveAs" name="SaveAs"/>
+ <separator name="sep1"/>
+ <menuitem action="Quit" name="Quit"/>
+ </menu>
+ <menu action="EditMenu" name="EditMenu">
+ <menuitem action="Copy" name="Copy"/>
+ <menuitem action="Cut" name="Cut"/>
+ <menuitem action="Paste" name="Paste"/>
+ </menu>
+ </menubar>
+ ]]></property>
+ <property name="visible">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkToolbar" id="toolbar1">
+ <property name="toolbar_style">both</property>
+ <property name="events">all-events-mask | button-motion-mask | button-press-mask | button-release-mask | button1-motion-mask | button2-motion-mask | button3-motion-mask | enter-notify-mask | exposure-mask | focus-change-mask | key-press-mask | key-release-mask | leave-notify-mask | pointer-motion-hint-mask | pointer-motion-mask | property-change-mask | proximity-in-mask | proximity-out-mask | scroll-mask | structure-mask | substructure-mask | visibility-notify-mask</property>
+ <property name="ui"><![CDATA[
+ <toolbar action="toolbar1" name="toolbar1">
+ <toolitem action="New" name="New"/>
+ <toolitem action="Open" name="Open"/>
+ <toolitem action="Save" name="Save"/>
+ <separator name="sep2"/>
+ <toolitem action="Copy" name="Copy"/>
+ <toolitem action="Cut" name="Cut"/>
+ <toolitem action="Paste" name="Paste"/>
+ </toolbar>
+ ]]></property>
+ <property name="visible">True</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+</glade-interface>
Added: Kiwi2/tests/simple_button.glade
===================================================================
--- Kiwi2/tests/simple_button.glade 2005-03-18 13:35:30 UTC (rev 145)
+++ Kiwi2/tests/simple_button.glade 2005-03-18 17:55:56 UTC (rev 146)
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<glade-interface>
+ <widget class="GtkWindow" id="simple_button">
+ <property name="role"></property>
+ <property name="events">all-events-mask | button-motion-mask | button-press-mask | button-release-mask | button1-motion-mask | button2-motion-mask | button3-motion-mask | enter-notify-mask | exposure-mask | focus-change-mask | key-press-mask | key-release-mask | leave-notify-mask | pointer-motion-hint-mask | pointer-motion-mask | property-change-mask | proximity-in-mask | proximity-out-mask | scroll-mask | structure-mask | substructure-mask | visibility-notify-mask</property>
+ <property name="title" context="True" translatable="True"></property>
+ <child>
+ <widget class="GtkButton" id="button">
+ <property name="receives_default">True</property>
+ <property name="label" context="True" translatable="True">Click me!</property>
+ <property name="events">all-events-mask | button-motion-mask | button-press-mask | button-release-mask | button1-motion-mask | button2-motion-mask | button3-motion-mask | enter-notify-mask | exposure-mask | focus-change-mask | key-press-mask | key-release-mask | leave-notify-mask | pointer-motion-hint-mask | pointer-motion-mask | property-change-mask | proximity-in-mask | proximity-out-mask | scroll-mask | structure-mask | substructure-mask | visibility-notify-mask</property>
+ <property name="can_focus">True</property>
+ <property name="visible">True</property>
+ </widget>
+ </child>
+ </widget>
+</glade-interface>
Added: Kiwi2/tests/test_Action.py
===================================================================
--- Kiwi2/tests/test_Action.py 2005-03-18 13:35:30 UTC (rev 145)
+++ Kiwi2/tests/test_Action.py 2005-03-18 17:55:56 UTC (rev 146)
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+from utils import refresh_gui
+
+from Kiwi2 import Delegates
+from Kiwi2.initgtk import gtk, quit_if_last
+
+from unittest import TestCase, TestSuite, makeSuite, TextTestRunner
+import sys
+
+class ActionDelegate(Delegates.Delegate):
+ def __init__(self):
+ Delegates.Delegate.__init__(self, gladefile="actions.glade",
+ toplevel_name='window1',
+ widgets=['New'],
+ delete_handler=quit_if_last)
+ self.new_activated = False
+
+ def on_New__activate(self, *args):
+ self.new_activated = True
+
+# this is the delay between each refresh of the screen in seconds
+delay = 0
+
+class ActionTest(TestCase):
+ def testButtons(self):
+ global delay
+ action_delegate = ActionDelegate()
+ action_delegate.show_all()
+ refresh_gui(delay)
+ action_delegate.New.activate()
+ refresh_gui(delay)
+ self.assertEqual(action_delegate.new_activated, True)
+
+if __name__ == '__main__':
+ import sys
+ if len(sys.argv) == 2:
+ delay = float(sys.argv[1])
+ suite = TestSuite()
+ suite.addTest(makeSuite(ActionTest))
+ TextTestRunner(verbosity=2).run(suite)
+
Property changes on: Kiwi2/tests/test_Action.py
___________________________________________________________________
Name: svn:executable
+ *
Modified: Kiwi2/tests/test_Delegate.py
===================================================================
--- Kiwi2/tests/test_Delegate.py 2005-03-18 13:35:30 UTC (rev 145)
+++ Kiwi2/tests/test_Delegate.py 2005-03-18 17:55:56 UTC (rev 146)
@@ -64,6 +64,17 @@
def on_button__clicked(self, *args):
self.clicks += 1
+class GladeClickCounter(Delegates.Delegate):
+ def __init__(self):
+ Delegates.Delegate.__init__(self, gladefile="simple_button",
+ widgets=['button'],
+ delete_handler=quit_if_last)
+
+ self.clicks = 0
+
+ def on_button__clicked(self, *args):
+ self.clicks += 1
+
# this is the delay between each refresh of the screen in seconds
delay = 0
@@ -93,7 +104,21 @@
# one for the girls
clickcounter.button.clicked()
self.assertEqual(clickcounter.clicks, 2)
+
+ def testClickCounterGlade(self):
+ global delay
+ clickcounter = GladeClickCounter()
+ clickcounter.show_all()
+ refresh_gui(delay)
+ # one for the boys
+ clickcounter.button.clicked()
+ self.assertEqual(clickcounter.clicks, 1)
+
+ # one for the girls
+ clickcounter.button.clicked()
+ self.assertEqual(clickcounter.clicks, 2)
+
if __name__ == '__main__':
import sys
if len(sys.argv) == 2:
More information about the POS-commit
mailing list