Author: bugman Date: Wed May 23 11:13:21 2012 New Revision: 16413 URL: http://svn.gna.org/viewcvs/relax?rev=16413&view=rev Log: The GUI tests are now recycling the GUI user function wizards and pages as well. This required a number of modifications: - The user function object wizard creation has been shifted into the create_wizard() method. - The status.gui_uf_force_sync flag has been introduced to force synchronous operation of the GUI user functions. - The wx_wizard_run keyword arg has been added to the user function object to prevent the automatic running of the wizard. - The GUI test tearDown() base method no longer destroys the GUI or wizards, as they are needed in subsequent tests. Modified: branches/uf_redesign/gui/uf_objects.py branches/uf_redesign/status.py branches/uf_redesign/test_suite/gui_tests/base_classes.py Modified: branches/uf_redesign/gui/uf_objects.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/uf_objects.py?rev=16413&r1=16412&r2=16413&view=diff ============================================================================== --- branches/uf_redesign/gui/uf_objects.py (original) +++ branches/uf_redesign/gui/uf_objects.py Wed May 23 11:13:21 2012 @@ -150,43 +150,31 @@ class Uf_object(object): """The object for auto-generating the GUI user functions.""" - def __call__(self, event=None, parent=None, **kwds): + def __call__(self, event=None, wx_parent=None, wx_wizard_run=True, **kwds): """Make the GUI user function executable. - All keyword args, apart from 'event' and 'parent' will be assumed to be user function arguments and the Uf_page.SetValue() method of the page will be used to set the GUI arg elements to the values supplied. - - - @keyword event: The wx event. - @type event: wx event or None - @keyword parent: The parent wx object to associate the user function wizard to. - @type parent: wx object - """ - - # The parent object defaults to the main relax window. - if parent == None: - app = wx.GetApp() - parent = app.gui - - # Do not reuse an old wizard (checking that the parent of an old wizard is not the same). - if self.wizard == None or parent != self.wizard.GetParent(): - # Create the wizard dialog. - self.wizard = Wiz_window(parent=parent, size_x=self._size[0], size_y=self._size[1], title=self._title) - - # Create the page. - self.page = self.create_page(self.wizard, sync=self._sync) - - # For an update of the argument data. - self.page.update_args() - - # Add the page to the wizard. - self.wizard.add_page(self.page, apply_button=self._apply_button) + All keyword args, apart from 'event', 'wx_parent' and 'wx_wizard_run' will be assumed to be user function arguments and the Uf_page.SetValue() method of the page will be used to set the GUI arg elements to the values supplied. + + + @keyword event: The wx event. + @type event: wx event or None + @keyword wx_parent: The parent wx object to associate the user function wizard to. + @type wx_parent: wx object + @keyword wx_wizard_run: A flag which if True will call the wizard run() method. + @type wx_wizard_run: bool + """ + + # Create a new wizard if needed (checking that the parent of an old wizard is not the same). + if self.wizard == None or (wx_parent != None and wx_parent != self.wizard.GetParent()): + self.create_wizard(wx_parent) # Loop over the keyword args, using the Uf_page.SetValue() method to set the user function argument GUI element values. for key in kwds: self.page.SetValue(key, kwds[key]) - # Execute the wizard. - self.wizard.run() + # Execute the wizard when asked. + if wx_wizard_run: + self.wizard.run() def __init__(self, name, title=None, size=None, height_desc=None, apply_button=True, sync=False): @@ -219,7 +207,7 @@ def create_page(self, wizard=None, sync=False): - """Create the user function page object. + """Create the user function wizard page GUI object. @keyword wizard: The parent wizard. @type wizard: Wiz_window instance @@ -231,6 +219,31 @@ # Initialise and return the page. return Uf_page(self._name, parent=wizard, height_desc=self._height_desc, sync=self._sync) + + + def create_wizard(self, parent=None): + """Create the user function wizard GUI object, with embedded wizard page. + + @keyword parent: The parent wx window. + @type parent: wx.Window instance + """ + + # The parent object defaults to the main relax window. + if parent == None: + app = wx.GetApp() + parent = app.gui + + # Create the wizard dialog. + self.wizard = Wiz_window(parent=parent, size_x=self._size[0], size_y=self._size[1], title=self._title) + + # Create the page. + self.page = self.create_page(self.wizard, sync=self._sync) + + # For an update of the argument data. + self.page.update_args() + + # Add the page to the wizard. + self.wizard.add_page(self.page, apply_button=self._apply_button) @@ -604,7 +617,7 @@ """ # Synchronous execution. - if self.sync: + if self.sync or status.gui_uf_force_sync: interpreter.apply(uf, *args, **kwds) # Asynchronous execution. Modified: branches/uf_redesign/status.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/status.py?rev=16413&r1=16412&r2=16413&view=diff ============================================================================== --- branches/uf_redesign/status.py (original) +++ branches/uf_redesign/status.py Wed May 23 11:13:21 2012 @@ -57,6 +57,7 @@ self._instance.test_mode = False self._instance.prompt_intro = False self._instance.show_gui = False + self._instance.gui_uf_force_sync = False self._instance.install_path = self._instance._det_install_path() # Set up the singleton. Modified: branches/uf_redesign/test_suite/gui_tests/base_classes.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/test_suite/gui_tests/base_classes.py?rev=16413&r1=16412&r2=16413&view=diff ============================================================================== --- branches/uf_redesign/test_suite/gui_tests/base_classes.py (original) +++ branches/uf_redesign/test_suite/gui_tests/base_classes.py Wed May 23 11:13:21 2012 @@ -46,7 +46,7 @@ # relax GUI module imports. from gui.interpreter import Interpreter; interpreter = Interpreter() from gui.wizard import Wiz_window -from gui.uf_objects import Uf_page +from gui.uf_objects import Uf_storage; uf_store = Uf_storage() class GuiTestCase(TestCase): @@ -83,10 +83,6 @@ # Process the user function name. uf_name = kargs.pop('uf_name') - - # Create and store a wizard instance to be used in all user function pages (if needed). - if not hasattr(self, '_wizard'): - self._wizard = Wiz_window(self.app.gui) # Get the user function data object. uf_data = uf_info.get_uf(uf_name) @@ -134,18 +130,20 @@ # Remove the directory argument. kargs.pop(arg['name']) - # Create the page. - uf_page = Uf_page(uf_name, parent=self._wizard, sync=True) - - # Update the user function page. - uf_page.on_display() - - # Set all the values. - for key in kargs: - uf_page.SetValue(key=key, value=kargs[key]) + # The user function object. + uf = uf_store[uf_name] + + # Force synchronous operation of the user functions. + status.gui_uf_force_sync = True + + # Call the GUI user function object with all keyword args, but do not execute the wizard. + uf(wx_wizard_run=False, **kargs) # Execute the user function. - uf_page.on_execute() + uf.page.on_execute() + + # Restore the synchronous or asynchronous operation of the user functions so the GUI can return to normal. + status.gui_uf_force_sync = False def check_exceptions(self): @@ -250,16 +248,8 @@ # Destroy the Python object part. delattr(self.app.gui, window) - # Destroy the GUI. - if not self._gui_launch and hasattr(self.app, 'gui'): - self.app.gui.Destroy() - # Recreate the GUI data object. ds.relax_gui = Gui() - # Delete any wizard objects. - if hasattr(self, '_wizard'): - del self._wizard - # Flush all wx events to make sure the GUI is ready for the next test. wx.Yield()