1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 """Base classes for the GUI tests."""
25
26
27 import Queue
28 from shutil import rmtree
29 from tempfile import mkdtemp
30 from unittest import TestCase
31 import wx
32
33
34 import dep_check
35
36
37 from data import Relax_data_store; ds = Relax_data_store()
38 from data.gui import Gui
39 from generic_fns.reset import reset
40 from status import Status; status = Status()
41
42
43 from gui.interpreter import Interpreter; interpreter = Interpreter()
44
45
47 """The GUI specific test case."""
48
50 """Set up the test case class for the system tests."""
51
52
53 super(GuiTestCase, self).__init__(methodName)
54
55
56 self.app = wx.GetApp()
57
58
59 self._gui_launch = False
60 if self.app != None:
61 self._gui_launch = True
62
63
65 """Check that no exception has occurred."""
66
67
68 try:
69
70 index, exc = status.exception_queue.get(block=False)
71
72
73 self.fail()
74
75
76 except Queue.Empty:
77 pass
78
79
81 """Execute the given user function.
82
83 @keyword page: The user function page.
84 @type page: Wizard page
85 """
86
87
88 if not hasattr(self, '_wizard'):
89 self._wizard = Wiz_window(self.app.gui)
90
91
92 uf_page = page(self._wizard)
93
94
95 for key in kargs:
96 uf_page.SetValue(key=key, value=kargs[key])
97
98
99 uf_page.on_execute()
100
101
102 interpreter.flush()
103
104
106 """Set up for all the functional tests."""
107
108
109 ds.tmpdir = mkdtemp()
110
111
112 if not self._gui_launch:
113 self.app = wx.App(redirect=False)
114
115
116 if dep_check.wx_module:
117 from gui.relax_gui import Main
118
119
120 self.app.gui = Main(parent=None, id=-1, title="")
121
122
124 """Default tearDown operation - delete temp directories and files and reset relax."""
125
126
127 if hasattr(ds, 'tmpdir'):
128
129 rmtree(ds.tmpdir)
130
131
132 del ds.tmpdir
133
134
135 if hasattr(self, 'tmpdir'):
136
137 rmtree(self.tmpdir)
138
139
140 del self.tmpdir
141
142
143 if hasattr(ds, 'tmpfile'):
144
145 delete(ds.tmpfile, fail=False)
146
147
148 del ds.tmpfile
149
150
151 if hasattr(self, 'tmpfile'):
152
153 delete(self.tmpfile, fail=False)
154
155
156 del self.tmpfile
157
158
159 self.app.gui.analysis.delete_all()
160
161
162 reset()
163
164
165 status._setup_observers()
166
167
168 windows = ['pipe_editor', 'relax_prompt', 'results_viewer', 'spin_viewer']
169 for window in windows:
170 if hasattr(self.app.gui, window):
171
172 win_obj = getattr(self.app.gui, window)
173
174
175 win_obj.Destroy()
176
177
178 delattr(self.app.gui, window)
179
180
181 if not self._gui_launch and hasattr(self.app, 'gui'):
182 self.app.gui.Destroy()
183
184
185 ds.relax_gui = Gui()
186
187
188 if hasattr(self, '_wizard'):
189 del self._wizard
190
191
192 wx.Yield()
193