equal
deleted
inserted
replaced
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 |
24 |
25 import os |
25 import os |
26 import sys |
26 import sys |
27 import unittest |
27 import unittest |
|
28 import pytest |
28 import wx |
29 import wx |
29 import time |
30 import time |
30 import traceback |
31 import traceback |
|
32 import ddt |
31 |
33 |
32 import conftest |
34 import conftest |
33 import Beremiz |
35 import Beremiz |
34 |
36 |
35 |
37 |
46 self.app = None |
48 self.app = None |
47 |
49 |
48 def FinishApp(self): |
50 def FinishApp(self): |
49 wx.CallAfter(self.app.frame.Close) |
51 wx.CallAfter(self.app.frame.Close) |
50 self.app.MainLoop() |
52 self.app.MainLoop() |
|
53 self.app = None |
|
54 |
|
55 def setUp(self): |
51 self.app = None |
56 self.app = None |
52 |
57 |
53 def tearDown(self): |
58 def tearDown(self): |
54 if self.app is not None and self.app.frame is not None: |
59 if self.app is not None and self.app.frame is not None: |
55 self.FinishApp() |
60 self.FinishApp() |
69 self.CheckForErrors() |
74 self.CheckForErrors() |
70 wx.Yield() |
75 wx.Yield() |
71 time.sleep(0.01) |
76 time.sleep(0.01) |
72 |
77 |
73 |
78 |
|
79 @ddt.ddt |
74 class BeremizApplicationTest(UserApplicationTest): |
80 class BeremizApplicationTest(UserApplicationTest): |
75 """Test Beremiz as whole application""" |
81 """Test Beremiz as whole application""" |
76 def StartApp(self): |
82 def StartApp(self): |
77 self.app = Beremiz.BeremizIDELauncher() |
83 self.app = Beremiz.BeremizIDELauncher() |
78 # disable default exception handler in Beremiz |
84 # disable default exception handler in Beremiz |
100 id, item) |
106 id, item) |
101 self.app.frame.OnProjectTreeItemActivated(event) |
107 self.app.frame.OnProjectTreeItemActivated(event) |
102 self.ProcessEvents() |
108 self.ProcessEvents() |
103 item = self.app.frame.ProjectTree.GetNextVisible(item) |
109 item = self.app.frame.ProjectTree.GetNextVisible(item) |
104 |
110 |
105 def CheckTestProject(self, project): |
111 def CheckTestProject(self, name): |
|
112 project = self.GetProjectPath(name) |
|
113 print "Testing example " + name |
106 sys.argv = ["", project] |
114 sys.argv = ["", project] |
107 self.StartApp() |
115 self.StartApp() |
108 self.OpenAllProjectElements() |
116 self.OpenAllProjectElements() |
109 |
117 |
110 user_actions = [ |
118 user_actions = [ |
128 def testStartUp(self): |
136 def testStartUp(self): |
129 """Checks whether the app starts and finishes correctly""" |
137 """Checks whether the app starts and finishes correctly""" |
130 self.StartApp() |
138 self.StartApp() |
131 self.FinishApp() |
139 self.FinishApp() |
132 |
140 |
133 # @unittest.skip("") |
141 @ddt.data( |
134 def testOpenExampleProjects(self): |
142 "first_steps", |
135 """Opens, builds and runs user PLC examples from tests directory""" |
143 "logging", |
136 prj = [ |
144 "svgui", |
137 "first_steps", |
145 "traffic_lights", |
138 "logging", |
146 "wxGlade", |
139 "svgui", |
147 "python", |
140 "traffic_lights", |
148 "wiimote", |
141 "wxGlade", |
149 "wxHMI", |
142 "python", |
150 ) |
143 "wiimote", |
151 @pytest.mark.timeout(30) |
144 "wxHMI", |
152 def testCheckProject(self, name): |
145 ] |
153 self.CheckTestProject(name) |
146 for name in prj: |
|
147 project = self.GetProjectPath(name) |
|
148 print "Testing example " + name |
|
149 self.CheckTestProject(project) |
|
150 |
154 |
151 |
155 |
152 if __name__ == '__main__': |
156 if __name__ == '__main__': |
153 unittest.main() |
157 unittest.main() |