Salome HOME
Updated copyright comment
[modules/shaper.git] / test.squish / suite_FEATURE_PARAMETERS / shared / steps / steps.py
1 # Copyright (C) 2014-2024  CEA, EDF
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
20 # A quick introduction to implementing scripts for BDD tests:
21 #
22 # This file contains snippets of script code to be executed as the .feature
23 # file is processed. See the section 'Behaviour Driven Testing' in the 'API
24 # Reference Manual' chapter of the Squish manual for a comprehensive reference.
25 #
26 # The decorators Given/When/Then/Step can be used to associate a script snippet
27 # with a pattern which is matched against the steps being executed. Optional
28 # table/multi-line string arguments of the step are passed via a mandatory
29 # 'context' parameter:
30 #
31 #   @When("I enter the text")
32 #   def whenTextEntered(context):
33 #      <code here>
34 #
35 # The pattern is a plain string without the leading keyword, but a couple of
36 # placeholders including |any|, |word| and |integer| are supported which can be
37 # used to extract arbitrary, alphanumeric and integer values resp. from the
38 # pattern; the extracted values are passed as additional arguments:
39 #
40 #   @Then("I get |integer| different names")
41 #   def namesReceived(context, numNames):
42 #      <code here>
43 #
44 # Instead of using a string with placeholders, a regular expression can be
45 # specified. In that case, make sure to set the (optional) 'regexp' argument
46 # to True.
47
48 import builtins
49
50 @Given("Launch application in salome mode")
51 def step(context):
52     startApplication("salome_run.sh")
53     clickButton(waitForObject(":SALOME*.Shaper_QToolButton"))
54     clickButton(waitForObject(":Activate module.New_QPushButton"))
55
56 @When("Create parameter a=30")
57 def step(context):
58     activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
59     activateItem(waitForObjectItem(":Part_QMenu", "Parameter"))
60     mouseClick(waitForObject(":Parameter_QLineEdit"), 10, 10, 0, Qt.LeftButton)
61     type(waitForObject(":Parameter_QLineEdit"), "a")
62     mouseClick(waitForObject(":Parameter_ExpressionEditor"), 10, 10, 0, Qt.LeftButton)
63     type(waitForObject(":Parameter_ExpressionEditor"), "30")
64     clickButton(waitForObject(":Boolean.property_panel_ok_QToolButton"))
65
66 @When("Create part")
67 def step(context):
68     activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
69     activateItem(waitForObjectItem(":Part_QMenu", "New part"))
70
71 @When("Create parameter a=a+2")
72 def step(context):
73     activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
74     activateItem(waitForObjectItem(":Part_QMenu", "Parameter"))
75     mouseClick(waitForObject(":Parameter_QLineEdit"), 10, 10, 0, Qt.LeftButton)
76     type(waitForObject(":Parameter_QLineEdit"), "a")
77     mouseClick(waitForObject(":Parameter_ExpressionEditor"), 10, 10, 0, Qt.LeftButton)
78     type(waitForObject(":Parameter_ExpressionEditor"), "a+2")
79     clickButton(waitForObject(":Boolean.property_panel_ok_QToolButton"))
80
81 @Then("the parameter in the part should exist")
82 def step(context):
83     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1.Parameters (1)")
84     clickItem(":Object browser_XGUI_DataTree", "Part\\_1.Parameters (1)", -10, 10, 0, Qt.LeftButton)
85     waitFor("object.exists(':Parameters (1).a = 32_QModelIndex')", 20000)
86     test.compare(findObject(":Parameters (1).a = 32_QModelIndex").text, "a = 32")
87
88 @When("Create sketch")
89 def step(context):
90     clickButton(waitForObject(":SALOME*.Sketch_QToolButton"))
91     clickButton(waitForObject(":SALOME*.-OZ_QToolButton"))
92     mouseClick(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 247, 126, 0, Qt.LeftButton)
93     clickButton(waitForObject(":Sketcher plane.Set plane view_QPushButton"))
94
95 @Then("Check that Point does not allow using expressions")
96 def step(context):
97     activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Sketch"))
98     activateItem(waitForObjectItem(":Sketch_QMenu", "Point"))
99     mouseClick(waitForObject(":Point.qt_spinbox_lineedit_QLineEdit"), 41, 6, 0, Qt.LeftButton)
100     type(waitForObject(":Point.X _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
101     type(waitForObject(":Point.X _ModuleBase_ParamSpinBox"), "a")
102     mouseClick(waitForObject(":Point.qt_spinbox_lineedit_QLineEdit_2"), 40, 9, 0, Qt.LeftButton)
103     type(waitForObject(":Point.Y _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
104     type(waitForObject(":Point.Y _ModuleBase_ParamSpinBox"), "a")
105     waitFor("object.exists(':Point.qt_spinbox_lineedit_QLineEdit')", 20000)
106     test.compare(str(findObject(":Point.qt_spinbox_lineedit_QLineEdit").text), "0")
107     waitFor("object.exists(':Point.qt_spinbox_lineedit_QLineEdit_2')", 20000)
108     test.compare(str(findObject(":Point.qt_spinbox_lineedit_QLineEdit_2").text), "0")
109     clickButton(waitForObject(":Point.property_panel_cancel_QToolButton"))
110
111 @Then("Check that Line does not allow using expressions")
112 def step(context):
113     clickButton(waitForObject(":SALOME*.Line_QToolButton"))
114     mouseClick(waitForObject(":Start point.qt_spinbox_lineedit_QLineEdit_2"), 89, 9, 0, Qt.LeftButton)
115     type(waitForObject(":Start point.X _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
116     type(waitForObject(":Start point.X _ModuleBase_ParamSpinBox"), "a")
117     mouseClick(waitForObject(":Start point.qt_spinbox_lineedit_QLineEdit_3"), 72, 10, 0, Qt.LeftButton)
118     type(waitForObject(":Start point.Y _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
119     type(waitForObject(":Start point.Y _ModuleBase_ParamSpinBox"), "a")
120     mouseClick(waitForObject(":End point.qt_spinbox_lineedit_QLineEdit_2"), 62, 8, 0, Qt.LeftButton)
121     type(waitForObject(":End point.X _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
122     type(waitForObject(":End point.X _ModuleBase_ParamSpinBox"), "a")
123     mouseClick(waitForObject(":End point.qt_spinbox_lineedit_QLineEdit_3"), 59, 6, 0, Qt.LeftButton)
124     type(waitForObject(":End point.Y _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
125     type(waitForObject(":End point.Y _ModuleBase_ParamSpinBox"), "a")
126     waitFor("object.exists(':Start point.qt_spinbox_lineedit_QLineEdit_2')", 20000)
127     test.compare(str(findObject(":Start point.qt_spinbox_lineedit_QLineEdit_2").text), "0")
128     waitFor("object.exists(':Start point.qt_spinbox_lineedit_QLineEdit_3')", 20000)
129     test.compare(str(findObject(":Start point.qt_spinbox_lineedit_QLineEdit_3").text), "0")
130     waitFor("object.exists(':End point.qt_spinbox_lineedit_QLineEdit_2')", 20000)
131     test.compare(str(findObject(":End point.qt_spinbox_lineedit_QLineEdit_2").text), "0")
132     waitFor("object.exists(':End point.qt_spinbox_lineedit_QLineEdit_3')", 20000)
133     test.compare(str(findObject(":End point.qt_spinbox_lineedit_QLineEdit_3").text), "0")
134     clickButton(waitForObject(":Line.property_panel_cancel_QToolButton"))
135
136 @Then("Check that Circle does not allow using expressions")
137 def step(context):
138     activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Sketch"))
139     activateItem(waitForObjectItem(":Sketch_QMenu", "Circle"))
140     mouseClick(waitForObject(":Center.qt_spinbox_lineedit_QLineEdit"), 90, 4, 0, Qt.LeftButton)
141     type(waitForObject(":Center.X _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
142     type(waitForObject(":Center.X _ModuleBase_ParamSpinBox"), "a")
143     mouseClick(waitForObject(":Center.qt_spinbox_lineedit_QLineEdit_2"), 71, 8, 0, Qt.LeftButton)
144     type(waitForObject(":Center.Y _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
145     type(waitForObject(":Center.Y _ModuleBase_ParamSpinBox"), "a")
146     mouseClick(waitForObject(":Circle.qt_spinbox_lineedit_QLineEdit"), 58, 6, 0, Qt.LeftButton)
147     type(waitForObject(":Circle.CircleRadius_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
148     type(waitForObject(":Circle.CircleRadius_ModuleBase_ParamSpinBox"), "a")
149     waitFor("object.exists(':Center.qt_spinbox_lineedit_QLineEdit')", 20000)
150     test.compare(str(findObject(":Center.qt_spinbox_lineedit_QLineEdit").text), "0")
151     waitFor("object.exists(':Center.qt_spinbox_lineedit_QLineEdit_2')", 20000)
152     test.compare(str(findObject(":Center.qt_spinbox_lineedit_QLineEdit_2").text), "0")
153     waitFor("object.exists(':Circle.qt_spinbox_lineedit_QLineEdit')", 20000)
154     test.compare(str(findObject(":Circle.qt_spinbox_lineedit_QLineEdit").text), "0")
155     clickButton(waitForObject(":Circle.property_panel_cancel_QToolButton"))
156
157 @Then("Check that Arc does not allow using expressions")
158 def step(context):
159     activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Sketch"))
160     activateItem(waitForObjectItem(":Sketch_QMenu", "Arc"))
161     mouseClick(waitForObject(":Center.qt_spinbox_lineedit_QLineEdit_3"), 156, 6, 0, Qt.LeftButton)
162     type(waitForObject(":Center.X _ModuleBase_ParamSpinBox_2"), "A")
163     type(waitForObject(":Center.X _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
164     type(waitForObject(":Center.X _ModuleBase_ParamSpinBox_2"), "a")
165     mouseClick(waitForObject(":Arc.Center_QGroupBox"), 135, 41, 0, Qt.LeftButton)
166     mouseClick(waitForObject(":Center.qt_spinbox_lineedit_QLineEdit_4"), 115, 3, 0, Qt.LeftButton)
167     type(waitForObject(":Center.Y _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
168     type(waitForObject(":Center.Y _ModuleBase_ParamSpinBox_2"), "a")
169     mouseClick(waitForObject(":Start point.qt_spinbox_lineedit_QLineEdit_4"), 103, 9, 0, Qt.LeftButton)
170     type(waitForObject(":Start point.X _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
171     type(waitForObject(":Start point.X _ModuleBase_ParamSpinBox_2"), "a")
172     mouseClick(waitForObject(":Start point.qt_spinbox_lineedit_QLineEdit_5"), 99, 8, 0, Qt.LeftButton)
173     type(waitForObject(":Start point.Y _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
174     type(waitForObject(":Start point.Y _ModuleBase_ParamSpinBox_2"), "a")
175     mouseClick(waitForObject(":End point.qt_spinbox_lineedit_QLineEdit_4"), 99, 1, 0, Qt.LeftButton)
176     type(waitForObject(":End point.X _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
177     type(waitForObject(":End point.X _ModuleBase_ParamSpinBox_2"), "a")
178     mouseClick(waitForObject(":End point.qt_spinbox_lineedit_QLineEdit_5"), 99, 1, 0, Qt.LeftButton)
179     type(waitForObject(":End point.Y _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
180     type(waitForObject(":End point.Y _ModuleBase_ParamSpinBox_2"), "a")
181     waitFor("object.exists(':Center.qt_spinbox_lineedit_QLineEdit_3')", 20000)
182     test.compare(str(findObject(":Center.qt_spinbox_lineedit_QLineEdit_3").text), "0")
183     waitFor("object.exists(':Center.qt_spinbox_lineedit_QLineEdit_4')", 20000)
184     test.compare(str(findObject(":Center.qt_spinbox_lineedit_QLineEdit_4").text), "0")
185     waitFor("object.exists(':Start point.qt_spinbox_lineedit_QLineEdit_4')", 20000)
186     test.compare(str(findObject(":Start point.qt_spinbox_lineedit_QLineEdit_4").text), "0")
187     waitFor("object.exists(':Start point.qt_spinbox_lineedit_QLineEdit_5')", 20000)
188     test.compare(str(findObject(":Start point.qt_spinbox_lineedit_QLineEdit_5").text), "0")
189     waitFor("object.exists(':End point.qt_spinbox_lineedit_QLineEdit_4')", 20000)
190     test.compare(str(findObject(":End point.qt_spinbox_lineedit_QLineEdit_4").text), "0")
191     waitFor("object.exists(':End point.qt_spinbox_lineedit_QLineEdit_5')", 20000)
192     test.compare(str(findObject(":End point.qt_spinbox_lineedit_QLineEdit_5").text), "0")
193     clickButton(waitForObject(":Arc.property_panel_cancel_QToolButton"))
194
195 @Then("Check that Fillet does not allow using expressions")
196 def step(context):
197     activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Sketch"))
198     activateItem(waitForObjectItem(":Sketch_QMenu", "Line"))
199     mouseClick(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 131, 282, 0, Qt.LeftButton)
200     mouseClick(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 209, 98, 0, Qt.LeftButton)
201     mouseClick(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 283, 275, 0, Qt.LeftButton)
202     #TODO_1 clickButton(waitForObject(":Line.property_panel_cancel_QToolButton"))
203     activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Sketch"))
204     activateItem(waitForObjectItem(":Sketch_QMenu", "Fillet"))
205     mouseClick(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 211, 99, 0, Qt.LeftButton)
206     type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
207     type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "<Keypad_1>")
208     type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "<Keypad_0>")
209     type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "<Keypad_Enter>")
210     waitFor("object.exists(':Fillet.qt_spinbox_lineedit_QLineEdit')", 20000)
211     test.compare(str(findObject(":Fillet.qt_spinbox_lineedit_QLineEdit").text), "10")
212     mouseClick(waitForObject(":Fillet.qt_spinbox_lineedit_QLineEdit"), 48, 6, 0, Qt.LeftButton)
213     type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
214     type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "a")
215     waitFor("object.exists(':Fillet.qt_spinbox_lineedit_QLineEdit')", 20000)
216     test.compare(str(findObject(":Fillet.qt_spinbox_lineedit_QLineEdit").text), "10")
217     clickButton(waitForObject(":Fillet.property_panel_cancel_QToolButton"))