--- a/Beremiz.py Fri Sep 08 11:53:48 2017 +0300
+++ b/Beremiz.py Tue Sep 12 10:21:51 2017 +0300
@@ -33,6 +33,8 @@
class BeremizIDELauncher:
self.updateinfo_url = None
self.app_dir = paths.AbsDir(__file__)
@@ -126,7 +128,6 @@
self.BackgroundInitialization()
def BackgroundInitialization(self):
@@ -184,10 +185,17 @@
self.ProcessCommandLineArgs()
if __name__ == '__main__':
beremiz = BeremizIDELauncher()
--- a/bitbucket-pipelines.yml Fri Sep 08 11:53:48 2017 +0300
+++ b/bitbucket-pipelines.yml Tue Sep 12 10:21:51 2017 +0300
@@ -1,22 +1,17 @@
+image: skvorl/beremiz-requirements custom: # Pipelines that are triggered manually
checks: # The name that is displayed in the list in the Bitbucket Cloud GUI
script: # Modify the commands below to build your repository.
- - pip install pycodestyle
- ./tests/tools/check_source.sh
+ - /usr/bin/python ./tests/tools/test_application.py
script: # Modify the commands below to build your repository.
- - pip install pycodestyle
- - ./tests/tools/check_source.sh
\ No newline at end of file
+ - ./tests/tools/check_source.sh + - /usr/bin/python ./tests/tools/test_application.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/tools/test_application.py Tue Sep 12 10:21:51 2017 +0300
@@ -0,0 +1,146 @@
+from xvfbwrapper import Xvfb + vdisplay = Xvfb(width=1280, height=720) + if vdisplay is not None: +class UserApplicationTest(unittest.TestCase): + def InstallExceptionHandler(self): + def handle_exception(e_type, e_value, e_traceback): + # traceback.print_exception(e_type, e_value, e_traceback) + self.exc_info = [e_type, e_value, e_traceback] + self.old_excepthook = sys.excepthook + sys.excepthook = handle_exception + wx.CallAfter(self.app.frame.Close) + if self.app is not None and self.app.frame is not None: + def RunUIActions(self, actions): + def CheckForErrors(self): + if self.exc_info is not None: + # reraise catched previously exception + raise self.exc_info[0], self.exc_info[1], self.exc_info[2] + def ProcessEvents(self): +class BeremizApplicationTest(UserApplicationTest): + """Test Beremiz as whole application""" + self.app = Beremiz.BeremizIDELauncher() + # disable default exception handler in Beremiz + self.app.InstallExceptionHandler = lambda: None + self.InstallExceptionHandler() + wx.CallAfter(self.app.frame.Close) + def OpenAllProjectElements(self): + # open every object in the project tree + self.app.frame.ProjectTree.ExpandAll() + item = self.app.frame.ProjectTree.GetRootItem() + while item is not None: + self.app.frame.ProjectTree.SelectItem(item, True) + id = self.app.frame.ProjectTree.GetId() + event = wx.lib.agw.customtreectrl.TreeEvent( + wx.lib.agw.customtreectrl.wxEVT_TREE_ITEM_ACTIVATED, + self.app.frame.OnProjectTreeItemActivated(event) + item = self.app.frame.ProjectTree.GetNextVisible(item) + def CheckTestProject(self, project): + sys.argv = ["", project] + self.OpenAllProjectElements() + [self.app.frame.SwitchFullScrMode, None], + [self.app.frame.SwitchFullScrMode, None], + [self.app.frame.CTR._Clean], + [self.app.frame.CTR._Build], + [self.app.frame.CTR._Connect], + [self.app.frame.CTR._Transfer], + [self.app.frame.CTR._Run], + [self.app.frame.CTR._Stop], + [self.app.frame.CTR._Disconnect], + # user_actions.append([self.app.frame.OnCloseProjectMenu, None]) + self.RunUIActions(user_actions) + def GetProjectPath(self, project): + return os.path.abspath(os.path.join(os.path.dirname(__file__), "..", project)) + """Checks whether the app starts and finishes correctly""" + def testOpenExampleProjects(self): + """Opens, builds and runs user PLC examples from tests directory""" + project = self.GetProjectPath(name) + print "Testing example " + name + self.CheckTestProject(project) +if __name__ == '__main__': + if __package__ is None: + sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')))