Author: bugman Date: Mon Apr 23 10:10:22 2012 New Revision: 15794 URL: http://svn.gna.org/viewcvs/relax?rev=15794&view=rev Log: The GUI tests now work in the GUI!! This is thanks to a lot of GUI black magic. The tests' tearDown() method now carefully deconstructs the GUI element prior to the next test being run. In the normal 'relax --gui-test' mode, the GUI object is destroyed and recreated for each test. However when run from the GUI, the GUI object is always there and must remain intact. Some of the careful deconstruction includes the deletion of each analysis tab, the selective destruction of all non-main windows (excluding the controller which shows the test suite progress). The relax data store GUI object is also reconstructed in the tearDown() method, and all wx events flushed at the very end to prevent clashes with the next GUI test. Modified: 1.3/test_suite/gui_tests/base_classes.py 1.3/test_suite/gui_tests/model_free.py 1.3/test_suite/gui_tests/noe.py 1.3/test_suite/gui_tests/rx.py Modified: 1.3/test_suite/gui_tests/base_classes.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/gui_tests/base_classes.py?rev=15794&r1=15793&r2=15794&view=diff ============================================================================== --- 1.3/test_suite/gui_tests/base_classes.py (original) +++ 1.3/test_suite/gui_tests/base_classes.py Mon Apr 23 10:10:22 2012 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2006-2011 Edward d'Auvergne # +# Copyright (C) 2006-2012 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -35,13 +35,11 @@ # relax module imports. from data import Relax_data_store; ds = Relax_data_store() +from data.gui import Gui from generic_fns.reset import reset from prompt.interpreter import Interpreter from status import Status; status = Status() -# relax GUI imports. -if dep_check.wx_module: - from gui.relax_gui import Main class GuiTestCase(TestCase): """The GUI specific test case.""" @@ -92,6 +90,10 @@ if not self._gui_launch: self.app = wx.App(redirect=False) + # relax GUI imports (here to prevent a circular import from the test suite in the GUI). + if dep_check.wx_module: + from gui.relax_gui import Main + # Build the GUI. self.app.gui = Main(parent=None, id=-1, title="") @@ -131,12 +133,34 @@ # Remove the variable. del self.tmpfile + # Delete all the GUI analysis tabs. + self.app.gui.analysis.delete_all() + # Reset relax. reset() # Reset the observers. status._setup_observers() + # Destroy some GUI windows, if open. + windows = ['pipe_editor', 'relax_prompt', 'results_viewer', 'spin_viewer'] + for window in windows: + if hasattr(self.app.gui, window): + # Get the object. + win_obj = getattr(self.app.gui, window) + + # Destroy the wxWidget part. + win_obj.Destroy() + + # 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() + + # Flush all wx events to make sure the GUI is ready for the next test. + wx.Yield() Modified: 1.3/test_suite/gui_tests/model_free.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/gui_tests/model_free.py?rev=15794&r1=15793&r2=15794&view=diff ============================================================================== --- 1.3/test_suite/gui_tests/model_free.py (original) +++ 1.3/test_suite/gui_tests/model_free.py Mon Apr 23 10:10:22 2012 @@ -169,9 +169,10 @@ self.check_exceptions() # Check the relax controller. - self.assertEqual(self.app.gui.controller.mc_gauge_mf.GetValue(), 100) - self.assertEqual(self.app.gui.controller.progress_gauge_mf.GetValue(), 100) - self.assertEqual(self.app.gui.controller.main_gauge.GetValue(), 100) + if status.relax_mode != 'gui': + self.assertEqual(self.app.gui.controller.mc_gauge_mf.GetValue(), 100) + self.assertEqual(self.app.gui.controller.progress_gauge_mf.GetValue(), 100) + self.assertEqual(self.app.gui.controller.main_gauge.GetValue(), 100) # Check the diffusion tensor. self.assertEqual(cdp.diff_tensor.type, 'sphere') Modified: 1.3/test_suite/gui_tests/noe.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/gui_tests/noe.py?rev=15794&r1=15793&r2=15794&view=diff ============================================================================== --- 1.3/test_suite/gui_tests/noe.py (original) +++ 1.3/test_suite/gui_tests/noe.py Mon Apr 23 10:10:22 2012 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2006-2011 Edward d'Auvergne # +# Copyright (C) 2006-2012 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -148,7 +148,8 @@ self.check_exceptions() # Check the relax controller. - self.assertEqual(self.app.gui.controller.main_gauge.GetValue(), 100) + if status.relax_mode != 'gui': + self.assertEqual(self.app.gui.controller.main_gauge.GetValue(), 100) # The real data. res_nums = [4, 5, 6] Modified: 1.3/test_suite/gui_tests/rx.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/gui_tests/rx.py?rev=15794&r1=15793&r2=15794&view=diff ============================================================================== --- 1.3/test_suite/gui_tests/rx.py (original) +++ 1.3/test_suite/gui_tests/rx.py Mon Apr 23 10:10:22 2012 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2006-2011 Edward d'Auvergne # +# Copyright (C) 2006-2012 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -232,8 +232,9 @@ self.check_exceptions() # Check the relax controller. - self.assertEqual(self.app.gui.controller.mc_gauge_rx.GetValue(), 100) - self.assertEqual(self.app.gui.controller.main_gauge.GetValue(), 100) + if status.relax_mode != 'gui': + self.assertEqual(self.app.gui.controller.mc_gauge_rx.GetValue(), 100) + self.assertEqual(self.app.gui.controller.main_gauge.GetValue(), 100) # Check the data pipe. self.assertEqual(cdp_name(), ds.relax_gui.analyses[0].pipe_name)