Salome HOME
Update copyrights
[modules/shaper.git] / test.squish / suite_STANDALONE / shared / scripts / common.py
1 # Copyright (C) 2015-2019  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 testSettings.logScreenshotOnError = True
20 testSettings.logScreenshotOnFail = True
21
22 g_points = {"XY_plane": (320, 320)} # one of the construction planes
23 def help_points(name):
24     return g_points[name]
25
26 def set_defaults():
27     waitForObject(":OpenParts*_AppElements_MainWindow").resize(1024, 768)
28
29 def close_application():
30     sendEvent("QCloseEvent", waitForObject(":OpenParts*_AppElements_MainWindow"))
31     if object.exists(":Save current file.Discard_QPushButton"):
32         clickButton(waitForObject(":Save current file.Discard_QPushButton"))
33
34 def parameter_create(name, expression):
35     clickButton(waitForObject(":Parameters.Parameter_AppElements_Button"))
36     type(waitForObject(":Parameter_QLineEdit"), name)
37     type(waitForObject(":Parameter_ExpressionEditor"), expression)
38     clickButton(waitForObject(":Parameter.property_panel_ok_QToolButton"))
39
40 def part_create():
41     clickTab(waitForObject(":General.qt_tabwidget_tabbar_QTabBar"), "Part")
42     clickButton(waitForObject(":Operations.New part_AppElements_Button"))
43
44 def sketch_create(point, actions):
45     clickTab(waitForObject(":General.qt_tabwidget_tabbar_QTabBar"), "Sketch")
46     clickButton(waitForObject(":Basic.Sketch_AppElements_Button"))
47     mouseClick(waitForObject(":OpenParts*_AppElements_ViewPort"), point[0], point[1], 0, Qt.LeftButton)
48
49     actions()
50
51     clickButton(waitForObject(":Sketch.Ok_QToolButton"))
52
53 def point_create(point):
54     clickButton(waitForObject(":Basic.Point_AppElements_Button"))
55
56     type(waitForObject(":Point.X:_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
57     type(waitForObject(":Point.X:_ModuleBase_ParamSpinBox"), point[0])
58     type(waitForObject(":Point.Y:_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
59     type(waitForObject(":Point.Y:_ModuleBase_ParamSpinBox"), point[1])
60
61     clickButton(waitForObject(":Point.property_panel_ok_QToolButton"))
62
63 def line_create(start_point, end_point):
64     clickButton(waitForObject(":Basic.Line_AppElements_Button"))
65
66     type(waitForObject(":Start point.X:_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
67     type(waitForObject(":Start point.X:_ModuleBase_ParamSpinBox"), start_point[0])
68     type(waitForObject(":Start point.Y:_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
69     type(waitForObject(":Start point.Y:_ModuleBase_ParamSpinBox"), start_point[1])
70
71     type(waitForObject(":End point.X:_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
72     type(waitForObject(":End point.X:_ModuleBase_ParamSpinBox"), end_point[0])
73     type(waitForObject(":End point.Y:_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
74     type(waitForObject(":End point.Y:_ModuleBase_ParamSpinBox"), end_point[1])
75
76     clickButton(waitForObject(":Line.property_panel_ok_QToolButton"))
77
78 def line_create_in_view(start_point, end_point):
79     clickButton(waitForObject(":Basic.Line_AppElements_Button"))
80
81     mouseClick(waitForObject(":OpenParts*_AppElements_ViewPort"), start_point[0], start_point[1], 0, Qt.LeftButton)
82     mouseClick(waitForObject(":OpenParts*_AppElements_ViewPort"), end_point[0], end_point[1], 0, Qt.LeftButton)
83
84 def auxiliary_line_create(start_point, end_point):
85     clickButton(waitForObject(":Basic.Line_AppElements_Button"))
86     clickButton(waitForObject(":Line.Auxiliary_QCheckBox"))
87
88     type(waitForObject(":Start point.X:_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
89     type(waitForObject(":Start point.X:_ModuleBase_ParamSpinBox"), start_point[0])
90     type(waitForObject(":Start point.Y:_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
91     type(waitForObject(":Start point.Y:_ModuleBase_ParamSpinBox"), start_point[1])
92
93     type(waitForObject(":End point.X:_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
94     type(waitForObject(":End point.X:_ModuleBase_ParamSpinBox"), end_point[0])
95     type(waitForObject(":End point.Y:_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
96     type(waitForObject(":End point.Y:_ModuleBase_ParamSpinBox"), end_point[1])
97
98     #clickButton(waitForObject(":Line.property_panel_ok_QToolButton"))
99
100 def circle_create(x, y, radius):
101     clickButton(waitForObject(":Basic.Circle_AppElements_Button"))
102
103     type(waitForObject(":Center.X:_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
104     type(waitForObject(":Center.X:_ModuleBase_ParamSpinBox"), x)
105     type(waitForObject(":Center.Y:_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
106     type(waitForObject(":Center.Y:_ModuleBase_ParamSpinBox"), y)
107
108     type(waitForObject(":Circle.CircleRadius_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
109     type(waitForObject(":Circle.CircleRadius_ModuleBase_ParamSpinBox"), radius)
110
111     clickButton(waitForObject(":Circle.property_panel_ok_QToolButton"))
112
113 def circle_create_in_view(point_1, point_2):
114     clickButton(waitForObject(":Basic.Circle_AppElements_Button"))
115
116     mouseClick(waitForObject(":OpenParts*_AppElements_ViewPort"), point_1[0], point_1[1], 0, Qt.LeftButton)
117     mouseClick(waitForObject(":OpenParts*_AppElements_ViewPort"), point_2[0], point_2[1], 0, Qt.LeftButton)
118
119     clickButton(waitForObject(":Basic.Circle_AppElements_Button"))
120
121 def distance_create(point_1, point_2, annotaion_point, distance):
122     clickButton(waitForObject(":Constraints.Distance_AppElements_Button"))
123
124     mouseClick(waitForObject(":OpenParts*_AppElements_ViewPort"), point_1[0], point_1[1], 0, Qt.LeftButton)
125     mouseClick(waitForObject(":OpenParts*_AppElements_ViewPort"), point_2[0], point_2[1], 0, Qt.LeftButton)
126     mouseClick(waitForObject(":OpenParts*_AppElements_ViewPort"), annotaion_point[0], annotaion_point[1], 0, Qt.LeftButton) # move annotation
127
128     type(waitForObject(":_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
129     type(waitForObject(":_ModuleBase_ParamSpinBox"), distance)
130     type(waitForObject(":_ModuleBase_ParamSpinBox"), "<Keypad_Enter>")
131
132     clickButton(waitForObject(":Constraints.Distance_AppElements_Button"))
133
134 def parallel_create(point_1, point_2):
135     clickButton(waitForObject(":Constraints.Parallel_AppElements_Button"))
136
137     mouseClick(waitForObject(":OpenParts*_AppElements_ViewPort"), point_1[0], point_1[1], 0, Qt.LeftButton)
138     mouseClick(waitForObject(":OpenParts*_AppElements_ViewPort"), point_2[0], point_2[1], 0, Qt.LeftButton)
139
140     clickButton(waitForObject(":Constraints.Parallel_AppElements_Button"))
141
142 def perpendicular_create(point_1, point_2):
143     clickButton(waitForObject(":Constraints.Perpendicular_AppElements_Button"))
144
145     mouseClick(waitForObject(":OpenParts*_AppElements_ViewPort"), point_1[0], point_1[1], 0, Qt.LeftButton)
146     mouseClick(waitForObject(":OpenParts*_AppElements_ViewPort"), point_2[0], point_2[1], 0, Qt.LeftButton)
147
148     clickButton(waitForObject(":Perpendicular.property_panel_cancel_QToolButton"))
149
150 def horizontal_create(point_1):
151     clickButton(waitForObject(":Constraints.Horizontal_AppElements_Button"))
152
153     mouseClick(waitForObject(":OpenParts*_AppElements_ViewPort"), point_1[0], point_1[1], 0, Qt.LeftButton)
154
155     clickButton(waitForObject(":Constraints.Horizontal_AppElements_Button"))
156
157 def vertical_create(point_1):
158     cclickButton(waitForObject(":Constraints.Vertical_AppElements_Button"))
159
160     mouseClick(waitForObject(":OpenParts*_AppElements_ViewPort"), point_1[0], point_1[1], 0, Qt.LeftButton)
161
162     clickButton(waitForObject(":Constraints.Vertical_AppElements_Button"))
163
164 def radius_create(point_1, point_2, radius):
165     clickButton(waitForObject(":Constraints.Radius_AppElements_Button"))
166
167     mouseClick(waitForObject(":OpenParts*_AppElements_ViewPort"), point_1[0], point_1[1], 0, Qt.LeftButton)
168     mouseClick(waitForObject(":OpenParts*_AppElements_ViewPort"), point_2[0], point_2[1], 0, Qt.LeftButton)
169     type(waitForObject(":_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
170     type(waitForObject(":_ModuleBase_ParamSpinBox"), radius)
171     type(waitForObject(":_ModuleBase_ParamSpinBox"), "<Keypad_Enter>")
172
173     clickButton(waitForObject(":Constraints.Radius_AppElements_Button"))
174
175 def part_create():
176     clickTab(waitForObject(":General.qt_tabwidget_tabbar_QTabBar"), "Part")
177     clickButton(waitForObject(":Operations.New part_AppElements_Button"))
178
179 def extrusion_feature(points, to_size=0, from_size=0):
180     clickTab(waitForObject(":General.qt_tabwidget_tabbar_QTabBar"), "Features")
181     clickButton(waitForObject(":Extrusion.Extrusion_AppElements_Button"))
182
183     mouseClick(waitForObject(":Extrusion.Select a sketch face_QListWidget"), 10, 10, 0, Qt.LeftButton)
184     for point in points:
185         mouseClick(waitForObject(":OpenParts*_AppElements_ViewPort"), point[0], point[1], 0, Qt.LeftButton)
186
187     type(waitForObject(":to_size_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
188     type(waitForObject(":to_size_ModuleBase_ParamSpinBox"), to_size)
189
190     type(waitForObject(":Extrusion.from_size_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
191     type(waitForObject(":Extrusion.from_size_ModuleBase_ParamSpinBox"), from_size)
192
193     clickButton(waitForObject(":Extrusion.property_panel_ok_QToolButton"))
194
195 def extrusion_cut_by_sizes_feature(point, actions, to_size, from_size):
196     clickTab(waitForObject(":General.qt_tabwidget_tabbar_QTabBar"), "Features")
197     clickButton(waitForObject(":Extrusion.ExtrusionCut_AppElements_Button"))
198
199     mouseClick(waitForObject(":OpenParts*_AppElements_ViewPort"), point[0], point[1], 0, Qt.LeftButton)
200
201     actions()
202
203     clickButton(waitForObject(":Sketch.Ok_QToolButton"))
204
205     type(waitForObject(":Extrusion.to_size_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
206     type(waitForObject(":Extrusion.to_size_ModuleBase_ParamSpinBox"), to_size)
207
208     type(waitForObject(":Extrusion.from_size_ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
209     type(waitForObject(":Extrusion.from_size_ModuleBase_ParamSpinBox_2"), from_size)
210
211     clickButton(waitForObject(":ExtrusionCut.property_panel_ok_QToolButton"))
212     #clickButton(waitForObject(":Sketch.property_panel_cancel_QToolButton"))
213
214 def extrusion_fuse_by_sizes_feature(point, actions, to_size, from_size):
215
216     clickTab(waitForObject(":General.qt_tabwidget_tabbar_QTabBar"), "Features")
217     clickButton(waitForObject(":Extrusion.ExtrusionFuse_AppElements_Button"))
218
219     mouseClick(waitForObject(":OpenParts*_AppElements_ViewPort"), point[0], point[1], 0, Qt.LeftButton)
220
221     actions()
222
223     clickButton(waitForObject(":Sketch.Ok_QToolButton"))
224
225     type(waitForObject(":Extrusion.to_size_ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
226     type(waitForObject(":Extrusion.to_size_ModuleBase_ParamSpinBox_2"), to_size)
227
228     type(waitForObject(":Extrusion.from_size_ModuleBase_ParamSpinBox_3"), "<Ctrl+A>")
229     type(waitForObject(":Extrusion.from_size_ModuleBase_ParamSpinBox_3"), from_size)
230
231     clickButton(waitForObject(":ExtrusionFuse.property_panel_ok_QToolButton"))
232     #clickButton(waitForObject(":Sketch.property_panel_cancel_QToolButton"))
233
234