|
1 """ This test opens, builds and runs exemple project named "python". |
|
2 Test succeeds if runtime's stdout behaves as expected |
|
3 """ |
|
4 |
|
5 import os |
|
6 import time |
|
7 |
|
8 # allow module import from current test directory's parent |
|
9 addImportPath(os.path.dirname(getBundlePath())) |
|
10 |
|
11 # common test definitions module |
|
12 from sikuliberemiz import * |
|
13 |
|
14 # Start the app without any project given |
|
15 proc,app = StartBeremizApp() |
|
16 |
|
17 new_project_path = os.path.join(os.path.abspath(os.path.curdir), "new_test_project") |
|
18 |
|
19 # New project path must exist (usually created in directory selection dialog) |
|
20 os.mkdir(new_project_path) |
|
21 |
|
22 # To detect when actions did finish because IDE content isn't changing |
|
23 idle = IDEIdleObserver(app) |
|
24 |
|
25 # To send keyboard shortuts |
|
26 k = KBDShortcut(app) |
|
27 |
|
28 idle.Wait(1,15) |
|
29 |
|
30 # Create new project (opens new project directory selection dialog) |
|
31 k.New() |
|
32 |
|
33 idle.Wait(1,15) |
|
34 |
|
35 # Move to "Home" section of file selecor, otherwise address is |
|
36 # "file ignored" at first run |
|
37 type("f", Key.CTRL) |
|
38 type(Key.ESC) |
|
39 type(Key.TAB) |
|
40 |
|
41 # Enter directory by name |
|
42 k.Address() |
|
43 |
|
44 # Fill address bar |
|
45 type(new_project_path + Key.ENTER) |
|
46 |
|
47 idle.Wait(1,15) |
|
48 |
|
49 # When prompted for creating first program select type ST |
|
50 type(Key.TAB*4) # go to lang dropdown |
|
51 type(Key.DOWN*2) # change selected language |
|
52 type(Key.ENTER) # validate |
|
53 |
|
54 idle.Wait(1,15) |
|
55 |
|
56 # Name created program |
|
57 type("Test program") |
|
58 |
|
59 idle.Wait(1,15) |
|
60 |
|
61 # Focus on Variable grid |
|
62 type(Key.TAB*4) |
|
63 |
|
64 # Add 2 variables |
|
65 type(Key.ADD*2) |
|
66 |
|
67 # Focus on ST text |
|
68 idle.Wait(1,15) |
|
69 |
|
70 type(Key.TAB*8) |
|
71 |
|
72 type("""\ |
|
73 LocalVar0 := LocalVar1; |
|
74 {printf("Test OK\\n");fflush(stdout);} |
|
75 """) |
|
76 |
|
77 k.Save() |
|
78 |
|
79 # Close ST POU |
|
80 type("w", Key.CTRL) |
|
81 |
|
82 idle.Wait(1,15) |
|
83 |
|
84 # Focus project tree and select root item |
|
85 type(Key.TAB) |
|
86 |
|
87 type(Key.LEFT) |
|
88 |
|
89 type(Key.UP) |
|
90 |
|
91 # Edit root item |
|
92 type(Key.ENTER) |
|
93 |
|
94 idle.Wait(1,15) |
|
95 |
|
96 # Switch to config tab |
|
97 type(Key.RIGHT*2) |
|
98 |
|
99 # Focus on URI |
|
100 type(Key.TAB) |
|
101 |
|
102 # Set URI |
|
103 type("LOCAL://") |
|
104 |
|
105 # FIXME: Select other field to ensure URI is validated |
|
106 type(Key.TAB) |
|
107 |
|
108 k.Save() |
|
109 |
|
110 # Close project config editor |
|
111 type("w", Key.CTRL) |
|
112 |
|
113 idle.Wait(1,15) |
|
114 |
|
115 # Focus seems undefined at that time (FIXME) |
|
116 # Force focussing on "something" so that next shortcut is taken |
|
117 type(Key.TAB) |
|
118 |
|
119 del idle |
|
120 |
|
121 stdoutIdle = stdoutIdleObserver(proc) |
|
122 stdoutIdle.Wait(2,15) |
|
123 |
|
124 k.Build() |
|
125 |
|
126 stdoutIdle.Wait(5,15) |
|
127 |
|
128 k.Connect() |
|
129 |
|
130 stdoutIdle.Wait(2,15) |
|
131 |
|
132 k.Transfer() |
|
133 |
|
134 stdoutIdle.Wait(2,15) |
|
135 |
|
136 del stdoutIdle |
|
137 |
|
138 k.Run() |
|
139 |
|
140 # wait 10 seconds |
|
141 found = waitPatternInStdout(proc, "Test OK", 10) |
|
142 |
|
143 app.close() |
|
144 |
|
145 if found: |
|
146 exit(0) |
|
147 else: |
|
148 exit(1) |
|
149 |