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