1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2014-2019 CEA/DEN, EDF R&D
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # A quick introduction to implementing scripts for BDD tests:
24 # This file contains snippets of script code to be executed as the .feature
25 # file is processed. See the section 'Behaviour Driven Testing' in the 'API
26 # Reference Manual' chapter of the Squish manual for a comprehensive reference.
28 # The decorators Given/When/Then/Step can be used to associate a script snippet
29 # with a pattern which is matched against the steps being executed. Optional
30 # table/multi-line string arguments of the step are passed via a mandatory
31 # 'context' parameter:
33 # @When("I enter the text")
34 # def whenTextEntered(context):
37 # The pattern is a plain string without the leading keyword, but a couple of
38 # placeholders including |any|, |word| and |integer| are supported which can be
39 # used to extract arbitrary, alphanumeric and integer values resp. from the
40 # pattern; the extracted values are passed as additional arguments:
42 # @Then("I get |integer| different names")
43 # def namesReceived(context, numNames):
46 # Instead of using a string with placeholders, a regular expression can be
47 # specified. In that case, make sure to set the (optional) 'regexp' argument
52 @Given("Launch application in salome mode")
54 startApplication("salome_run.sh")
55 clickButton(waitForObject(":SALOME*.Shaper_QToolButton"))
56 clickButton(waitForObject(":Activate module.New_QPushButton"))
58 @When("Create parameter a=30")
60 activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
61 activateItem(waitForObjectItem(":Part_QMenu", "Parameter"))
62 mouseClick(waitForObject(":Parameter_QLineEdit"), 10, 10, 0, Qt.LeftButton)
63 type(waitForObject(":Parameter_QLineEdit"), "a")
64 mouseClick(waitForObject(":Parameter_ExpressionEditor"), 10, 10, 0, Qt.LeftButton)
65 type(waitForObject(":Parameter_ExpressionEditor"), "30")
66 clickButton(waitForObject(":Boolean.property_panel_ok_QToolButton"))
70 activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
71 activateItem(waitForObjectItem(":Part_QMenu", "New part"))
73 @When("Create parameter a=a+2")
75 activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
76 activateItem(waitForObjectItem(":Part_QMenu", "Parameter"))
77 mouseClick(waitForObject(":Parameter_QLineEdit"), 10, 10, 0, Qt.LeftButton)
78 type(waitForObject(":Parameter_QLineEdit"), "a")
79 mouseClick(waitForObject(":Parameter_ExpressionEditor"), 10, 10, 0, Qt.LeftButton)
80 type(waitForObject(":Parameter_ExpressionEditor"), "a+2")
81 clickButton(waitForObject(":Boolean.property_panel_ok_QToolButton"))
83 @Then("the parameter in the part should exist")
85 waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1.Parameters (1)")
86 clickItem(":Object browser_XGUI_DataTree", "Part\\_1.Parameters (1)", -10, 10, 0, Qt.LeftButton)
87 waitFor("object.exists(':Parameters (1).a = 32_QModelIndex')", 20000)
88 test.compare(findObject(":Parameters (1).a = 32_QModelIndex").text, "a = 32")
90 @When("Create sketch")
92 clickButton(waitForObject(":SALOME*.Sketch_QToolButton"))
93 clickButton(waitForObject(":SALOME*.-OZ_QToolButton"))
94 mouseClick(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 247, 126, 0, Qt.LeftButton)
95 clickButton(waitForObject(":Sketcher plane.Set plane view_QPushButton"))
97 @Then("Check that Point does not allow using expressions")
99 activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Sketch"))
100 activateItem(waitForObjectItem(":Sketch_QMenu", "Point"))
101 mouseClick(waitForObject(":Point.qt_spinbox_lineedit_QLineEdit"), 41, 6, 0, Qt.LeftButton)
102 type(waitForObject(":Point.X _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
103 type(waitForObject(":Point.X _ModuleBase_ParamSpinBox"), "a")
104 mouseClick(waitForObject(":Point.qt_spinbox_lineedit_QLineEdit_2"), 40, 9, 0, Qt.LeftButton)
105 type(waitForObject(":Point.Y _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
106 type(waitForObject(":Point.Y _ModuleBase_ParamSpinBox"), "a")
107 waitFor("object.exists(':Point.qt_spinbox_lineedit_QLineEdit')", 20000)
108 test.compare(str(findObject(":Point.qt_spinbox_lineedit_QLineEdit").text), "0")
109 waitFor("object.exists(':Point.qt_spinbox_lineedit_QLineEdit_2')", 20000)
110 test.compare(str(findObject(":Point.qt_spinbox_lineedit_QLineEdit_2").text), "0")
111 clickButton(waitForObject(":Point.property_panel_cancel_QToolButton"))
113 @Then("Check that Line does not allow using expressions")
115 clickButton(waitForObject(":SALOME*.Line_QToolButton"))
116 mouseClick(waitForObject(":Start point.qt_spinbox_lineedit_QLineEdit_2"), 89, 9, 0, Qt.LeftButton)
117 type(waitForObject(":Start point.X _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
118 type(waitForObject(":Start point.X _ModuleBase_ParamSpinBox"), "a")
119 mouseClick(waitForObject(":Start point.qt_spinbox_lineedit_QLineEdit_3"), 72, 10, 0, Qt.LeftButton)
120 type(waitForObject(":Start point.Y _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
121 type(waitForObject(":Start point.Y _ModuleBase_ParamSpinBox"), "a")
122 mouseClick(waitForObject(":End point.qt_spinbox_lineedit_QLineEdit_2"), 62, 8, 0, Qt.LeftButton)
123 type(waitForObject(":End point.X _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
124 type(waitForObject(":End point.X _ModuleBase_ParamSpinBox"), "a")
125 mouseClick(waitForObject(":End point.qt_spinbox_lineedit_QLineEdit_3"), 59, 6, 0, Qt.LeftButton)
126 type(waitForObject(":End point.Y _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
127 type(waitForObject(":End point.Y _ModuleBase_ParamSpinBox"), "a")
128 waitFor("object.exists(':Start point.qt_spinbox_lineedit_QLineEdit_2')", 20000)
129 test.compare(str(findObject(":Start point.qt_spinbox_lineedit_QLineEdit_2").text), "0")
130 waitFor("object.exists(':Start point.qt_spinbox_lineedit_QLineEdit_3')", 20000)
131 test.compare(str(findObject(":Start point.qt_spinbox_lineedit_QLineEdit_3").text), "0")
132 waitFor("object.exists(':End point.qt_spinbox_lineedit_QLineEdit_2')", 20000)
133 test.compare(str(findObject(":End point.qt_spinbox_lineedit_QLineEdit_2").text), "0")
134 waitFor("object.exists(':End point.qt_spinbox_lineedit_QLineEdit_3')", 20000)
135 test.compare(str(findObject(":End point.qt_spinbox_lineedit_QLineEdit_3").text), "0")
136 clickButton(waitForObject(":Line.property_panel_cancel_QToolButton"))
138 @Then("Check that Circle does not allow using expressions")
140 activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Sketch"))
141 activateItem(waitForObjectItem(":Sketch_QMenu", "Circle"))
142 mouseClick(waitForObject(":Center.qt_spinbox_lineedit_QLineEdit"), 90, 4, 0, Qt.LeftButton)
143 type(waitForObject(":Center.X _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
144 type(waitForObject(":Center.X _ModuleBase_ParamSpinBox"), "a")
145 mouseClick(waitForObject(":Center.qt_spinbox_lineedit_QLineEdit_2"), 71, 8, 0, Qt.LeftButton)
146 type(waitForObject(":Center.Y _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
147 type(waitForObject(":Center.Y _ModuleBase_ParamSpinBox"), "a")
148 mouseClick(waitForObject(":Circle.qt_spinbox_lineedit_QLineEdit"), 58, 6, 0, Qt.LeftButton)
149 type(waitForObject(":Circle.CircleRadius_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
150 type(waitForObject(":Circle.CircleRadius_ModuleBase_ParamSpinBox"), "a")
151 waitFor("object.exists(':Center.qt_spinbox_lineedit_QLineEdit')", 20000)
152 test.compare(str(findObject(":Center.qt_spinbox_lineedit_QLineEdit").text), "0")
153 waitFor("object.exists(':Center.qt_spinbox_lineedit_QLineEdit_2')", 20000)
154 test.compare(str(findObject(":Center.qt_spinbox_lineedit_QLineEdit_2").text), "0")
155 waitFor("object.exists(':Circle.qt_spinbox_lineedit_QLineEdit')", 20000)
156 test.compare(str(findObject(":Circle.qt_spinbox_lineedit_QLineEdit").text), "0")
157 clickButton(waitForObject(":Circle.property_panel_cancel_QToolButton"))
159 @Then("Check that Arc does not allow using expressions")
161 activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Sketch"))
162 activateItem(waitForObjectItem(":Sketch_QMenu", "Arc"))
163 mouseClick(waitForObject(":Center.qt_spinbox_lineedit_QLineEdit_3"), 156, 6, 0, Qt.LeftButton)
164 type(waitForObject(":Center.X _ModuleBase_ParamSpinBox_2"), "A")
165 type(waitForObject(":Center.X _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
166 type(waitForObject(":Center.X _ModuleBase_ParamSpinBox_2"), "a")
167 mouseClick(waitForObject(":Arc.Center_QGroupBox"), 135, 41, 0, Qt.LeftButton)
168 mouseClick(waitForObject(":Center.qt_spinbox_lineedit_QLineEdit_4"), 115, 3, 0, Qt.LeftButton)
169 type(waitForObject(":Center.Y _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
170 type(waitForObject(":Center.Y _ModuleBase_ParamSpinBox_2"), "a")
171 mouseClick(waitForObject(":Start point.qt_spinbox_lineedit_QLineEdit_4"), 103, 9, 0, Qt.LeftButton)
172 type(waitForObject(":Start point.X _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
173 type(waitForObject(":Start point.X _ModuleBase_ParamSpinBox_2"), "a")
174 mouseClick(waitForObject(":Start point.qt_spinbox_lineedit_QLineEdit_5"), 99, 8, 0, Qt.LeftButton)
175 type(waitForObject(":Start point.Y _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
176 type(waitForObject(":Start point.Y _ModuleBase_ParamSpinBox_2"), "a")
177 mouseClick(waitForObject(":End point.qt_spinbox_lineedit_QLineEdit_4"), 99, 1, 0, Qt.LeftButton)
178 type(waitForObject(":End point.X _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
179 type(waitForObject(":End point.X _ModuleBase_ParamSpinBox_2"), "a")
180 mouseClick(waitForObject(":End point.qt_spinbox_lineedit_QLineEdit_5"), 99, 1, 0, Qt.LeftButton)
181 type(waitForObject(":End point.Y _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
182 type(waitForObject(":End point.Y _ModuleBase_ParamSpinBox_2"), "a")
183 waitFor("object.exists(':Center.qt_spinbox_lineedit_QLineEdit_3')", 20000)
184 test.compare(str(findObject(":Center.qt_spinbox_lineedit_QLineEdit_3").text), "0")
185 waitFor("object.exists(':Center.qt_spinbox_lineedit_QLineEdit_4')", 20000)
186 test.compare(str(findObject(":Center.qt_spinbox_lineedit_QLineEdit_4").text), "0")
187 waitFor("object.exists(':Start point.qt_spinbox_lineedit_QLineEdit_4')", 20000)
188 test.compare(str(findObject(":Start point.qt_spinbox_lineedit_QLineEdit_4").text), "0")
189 waitFor("object.exists(':Start point.qt_spinbox_lineedit_QLineEdit_5')", 20000)
190 test.compare(str(findObject(":Start point.qt_spinbox_lineedit_QLineEdit_5").text), "0")
191 waitFor("object.exists(':End point.qt_spinbox_lineedit_QLineEdit_4')", 20000)
192 test.compare(str(findObject(":End point.qt_spinbox_lineedit_QLineEdit_4").text), "0")
193 waitFor("object.exists(':End point.qt_spinbox_lineedit_QLineEdit_5')", 20000)
194 test.compare(str(findObject(":End point.qt_spinbox_lineedit_QLineEdit_5").text), "0")
195 clickButton(waitForObject(":Arc.property_panel_cancel_QToolButton"))
197 @Then("Check that Fillet does not allow using expressions")
199 activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Sketch"))
200 activateItem(waitForObjectItem(":Sketch_QMenu", "Line"))
201 mouseClick(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 131, 282, 0, Qt.LeftButton)
202 mouseClick(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 209, 98, 0, Qt.LeftButton)
203 mouseClick(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 283, 275, 0, Qt.LeftButton)
204 #TODO_1 clickButton(waitForObject(":Line.property_panel_cancel_QToolButton"))
205 activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Sketch"))
206 activateItem(waitForObjectItem(":Sketch_QMenu", "Fillet"))
207 mouseClick(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 211, 99, 0, Qt.LeftButton)
208 type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
209 type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "<Keypad_1>")
210 type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "<Keypad_0>")
211 type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "<Keypad_Enter>")
212 waitFor("object.exists(':Fillet.qt_spinbox_lineedit_QLineEdit')", 20000)
213 test.compare(str(findObject(":Fillet.qt_spinbox_lineedit_QLineEdit").text), "10")
214 mouseClick(waitForObject(":Fillet.qt_spinbox_lineedit_QLineEdit"), 48, 6, 0, Qt.LeftButton)
215 type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
216 type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "a")
217 waitFor("object.exists(':Fillet.qt_spinbox_lineedit_QLineEdit')", 20000)
218 test.compare(str(findObject(":Fillet.qt_spinbox_lineedit_QLineEdit").text), "10")
219 clickButton(waitForObject(":Fillet.property_panel_cancel_QToolButton"))