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