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