edouard@3436: """ This test opens, builds and runs a new project. edouard@3424: Test succeeds if runtime's stdout behaves as expected edouard@3424: """ edouard@3424: edouard@3424: import os edouard@3424: import time edouard@3424: edouard@3424: # allow module import from current test directory's parent edouard@3424: addImportPath(os.path.dirname(getBundlePath())) edouard@3424: edouard@3424: # common test definitions module edouard@3424: from sikuliberemiz import * edouard@3424: edouard@3432: # Start the app without any project given edouard@3432: proc,app = StartBeremizApp() edouard@3432: edouard@3432: new_project_path = os.path.join(os.path.abspath(os.path.curdir), "new_test_project") edouard@3432: edouard@3432: # New project path must exist (usually created in directory selection dialog) edouard@3432: os.mkdir(new_project_path) edouard@3424: edouard@3424: # To detect when actions did finish because IDE content isn't changing edouard@3432: idle = IDEIdleObserver(app) edouard@3424: edouard@3424: # To send keyboard shortuts edouard@3424: k = KBDShortcut(app) edouard@3424: edouard@3432: idle.Wait(1,15) edouard@3424: edouard@3432: # Create new project (opens new project directory selection dialog) edouard@3432: k.New() edouard@3432: edouard@3432: idle.Wait(1,15) edouard@3432: edouard@3432: # Move to "Home" section of file selecor, otherwise address is edouard@3432: # "file ignored" at first run edouard@3432: type("f", Key.CTRL) edouard@3432: type(Key.ESC) edouard@3432: type(Key.TAB) edouard@3432: edouard@3432: # Enter directory by name edouard@3432: k.Address() edouard@3432: edouard@3432: # Fill address bar edouard@3432: type(new_project_path + Key.ENTER) edouard@3432: edouard@3432: idle.Wait(1,15) edouard@3432: edouard@3432: # When prompted for creating first program select type ST edouard@3432: type(Key.TAB*4) # go to lang dropdown edouard@3432: type(Key.DOWN*2) # change selected language edouard@3432: type(Key.ENTER) # validate edouard@3432: edouard@3432: idle.Wait(1,15) edouard@3432: edouard@3432: # Name created program edouard@3432: type("Test program") edouard@3432: edouard@3432: idle.Wait(1,15) edouard@3432: edouard@3432: # Focus on Variable grid edouard@3432: type(Key.TAB*4) edouard@3432: edouard@3432: # Add 2 variables edouard@3432: type(Key.ADD*2) edouard@3432: edouard@3432: # Focus on ST text edouard@3432: idle.Wait(1,15) edouard@3432: edouard@3432: type(Key.TAB*8) edouard@3432: edouard@3432: type("""\ edouard@3432: LocalVar0 := LocalVar1; edouard@3432: {printf("Test OK\\n");fflush(stdout);} edouard@3432: """) edouard@3432: edouard@3432: k.Save() edouard@3432: edouard@3432: # Close ST POU edouard@3432: type("w", Key.CTRL) edouard@3432: edouard@3432: idle.Wait(1,15) edouard@3432: edouard@3432: # Focus project tree and select root item edouard@3432: type(Key.TAB) edouard@3432: edouard@3432: type(Key.LEFT) edouard@3432: edouard@3432: type(Key.UP) edouard@3432: edouard@3432: # Edit root item edouard@3432: type(Key.ENTER) edouard@3432: edouard@3432: idle.Wait(1,15) edouard@3432: edouard@3432: # Switch to config tab edouard@3432: type(Key.RIGHT*2) edouard@3432: edouard@3432: # Focus on URI edouard@3432: type(Key.TAB) edouard@3432: edouard@3432: # Set URI edouard@3432: type("LOCAL://") edouard@3432: edouard@3432: # FIXME: Select other field to ensure URI is validated edouard@3432: type(Key.TAB) edouard@3432: edouard@3432: k.Save() edouard@3432: edouard@3432: # Close project config editor edouard@3432: type("w", Key.CTRL) edouard@3432: edouard@3432: idle.Wait(1,15) edouard@3432: edouard@3432: # Focus seems undefined at that time (FIXME) edouard@3432: # Force focussing on "something" so that next shortcut is taken edouard@3432: type(Key.TAB) edouard@3432: edouard@3432: del idle edouard@3432: edouard@3432: stdoutIdle = stdoutIdleObserver(proc) edouard@3424: stdoutIdle.Wait(2,15) edouard@3424: edouard@3424: k.Build() edouard@3424: edouard@3432: stdoutIdle.Wait(5,15) edouard@3424: edouard@3424: k.Connect() edouard@3424: edouard@3424: stdoutIdle.Wait(2,15) edouard@3424: edouard@3424: k.Transfer() edouard@3424: edouard@3424: stdoutIdle.Wait(2,15) edouard@3424: edouard@3424: del stdoutIdle edouard@3424: edouard@3424: k.Run() edouard@3424: edouard@3432: # wait 10 seconds edouard@3432: found = waitPatternInStdout(proc, "Test OK", 10) edouard@3424: edouard@3424: app.close() edouard@3424: edouard@3424: if found: edouard@3424: exit(0) edouard@3424: else: edouard@3424: exit(1) edouard@3424: