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 activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Sketch"))
81 activateItem(waitForObjectItem(":Sketch_QMenu", "Point"))
82 mouseClick(waitForObject(":Point.qt_spinbox_lineedit_QLineEdit"), 41, 6, 0, Qt.LeftButton)
83 type(waitForObject(":Point.X _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
84 type(waitForObject(":Point.X _ModuleBase_ParamSpinBox"), "a")
85 mouseClick(waitForObject(":Point.qt_spinbox_lineedit_QLineEdit_2"), 40, 9, 0, Qt.LeftButton)
86 type(waitForObject(":Point.Y _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
87 type(waitForObject(":Point.Y _ModuleBase_ParamSpinBox"), "a")
88 waitFor("object.exists(':Point.qt_spinbox_lineedit_QLineEdit')", 20000)
89 test.compare(str(findObject(":Point.qt_spinbox_lineedit_QLineEdit").text), "0")
90 waitFor("object.exists(':Point.qt_spinbox_lineedit_QLineEdit_2')", 20000)
91 test.compare(str(findObject(":Point.qt_spinbox_lineedit_QLineEdit_2").text), "0")
92 clickButton(waitForObject(":Point.property_panel_cancel_QToolButton"))
94 @Then("Check that Line does not allow using expressions")
96 clickButton(waitForObject(":SALOME*.Line_QToolButton"))
97 mouseClick(waitForObject(":Start point.qt_spinbox_lineedit_QLineEdit_2"), 89, 9, 0, Qt.LeftButton)
98 type(waitForObject(":Start point.X _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
99 type(waitForObject(":Start point.X _ModuleBase_ParamSpinBox"), "a")
100 mouseClick(waitForObject(":Start point.qt_spinbox_lineedit_QLineEdit_3"), 72, 10, 0, Qt.LeftButton)
101 type(waitForObject(":Start point.Y _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
102 type(waitForObject(":Start point.Y _ModuleBase_ParamSpinBox"), "a")
103 mouseClick(waitForObject(":End point.qt_spinbox_lineedit_QLineEdit_2"), 62, 8, 0, Qt.LeftButton)
104 type(waitForObject(":End point.X _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
105 type(waitForObject(":End point.X _ModuleBase_ParamSpinBox"), "a")
106 mouseClick(waitForObject(":End point.qt_spinbox_lineedit_QLineEdit_3"), 59, 6, 0, Qt.LeftButton)
107 type(waitForObject(":End point.Y _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
108 type(waitForObject(":End point.Y _ModuleBase_ParamSpinBox"), "a")
109 waitFor("object.exists(':Start point.qt_spinbox_lineedit_QLineEdit_2')", 20000)
110 test.compare(str(findObject(":Start point.qt_spinbox_lineedit_QLineEdit_2").text), "0")
111 waitFor("object.exists(':Start point.qt_spinbox_lineedit_QLineEdit_3')", 20000)
112 test.compare(str(findObject(":Start point.qt_spinbox_lineedit_QLineEdit_3").text), "0")
113 waitFor("object.exists(':End point.qt_spinbox_lineedit_QLineEdit_2')", 20000)
114 test.compare(str(findObject(":End point.qt_spinbox_lineedit_QLineEdit_2").text), "0")
115 waitFor("object.exists(':End point.qt_spinbox_lineedit_QLineEdit_3')", 20000)
116 test.compare(str(findObject(":End point.qt_spinbox_lineedit_QLineEdit_3").text), "0")
117 clickButton(waitForObject(":Line.property_panel_cancel_QToolButton"))
119 @Then("Check that Circle does not allow using expressions")
121 activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Sketch"))
122 activateItem(waitForObjectItem(":Sketch_QMenu", "Circle"))
123 mouseClick(waitForObject(":Center.qt_spinbox_lineedit_QLineEdit"), 90, 4, 0, Qt.LeftButton)
124 type(waitForObject(":Center.X _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
125 type(waitForObject(":Center.X _ModuleBase_ParamSpinBox"), "a")
126 mouseClick(waitForObject(":Center.qt_spinbox_lineedit_QLineEdit_2"), 71, 8, 0, Qt.LeftButton)
127 type(waitForObject(":Center.Y _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
128 type(waitForObject(":Center.Y _ModuleBase_ParamSpinBox"), "a")
129 mouseClick(waitForObject(":Circle.qt_spinbox_lineedit_QLineEdit"), 58, 6, 0, Qt.LeftButton)
130 type(waitForObject(":Circle.CircleRadius_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
131 type(waitForObject(":Circle.CircleRadius_ModuleBase_ParamSpinBox"), "a")
132 waitFor("object.exists(':Center.qt_spinbox_lineedit_QLineEdit')", 20000)
133 test.compare(str(findObject(":Center.qt_spinbox_lineedit_QLineEdit").text), "0")
134 waitFor("object.exists(':Center.qt_spinbox_lineedit_QLineEdit_2')", 20000)
135 test.compare(str(findObject(":Center.qt_spinbox_lineedit_QLineEdit_2").text), "0")
136 waitFor("object.exists(':Circle.qt_spinbox_lineedit_QLineEdit')", 20000)
137 test.compare(str(findObject(":Circle.qt_spinbox_lineedit_QLineEdit").text), "0")
138 clickButton(waitForObject(":Circle.property_panel_cancel_QToolButton"))
140 @Then("Check that Arc does not allow using expressions")
142 activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Sketch"))
143 activateItem(waitForObjectItem(":Sketch_QMenu", "Arc"))
144 mouseClick(waitForObject(":Center.qt_spinbox_lineedit_QLineEdit_3"), 156, 6, 0, Qt.LeftButton)
145 type(waitForObject(":Center.X _ModuleBase_ParamSpinBox_2"), "A")
146 type(waitForObject(":Center.X _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
147 type(waitForObject(":Center.X _ModuleBase_ParamSpinBox_2"), "a")
148 mouseClick(waitForObject(":Arc.Center_QGroupBox"), 135, 41, 0, Qt.LeftButton)
149 mouseClick(waitForObject(":Center.qt_spinbox_lineedit_QLineEdit_4"), 115, 3, 0, Qt.LeftButton)
150 type(waitForObject(":Center.Y _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
151 type(waitForObject(":Center.Y _ModuleBase_ParamSpinBox_2"), "a")
152 mouseClick(waitForObject(":Start point.qt_spinbox_lineedit_QLineEdit_4"), 103, 9, 0, Qt.LeftButton)
153 type(waitForObject(":Start point.X _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
154 type(waitForObject(":Start point.X _ModuleBase_ParamSpinBox_2"), "a")
155 mouseClick(waitForObject(":Start point.qt_spinbox_lineedit_QLineEdit_5"), 99, 8, 0, Qt.LeftButton)
156 type(waitForObject(":Start point.Y _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
157 type(waitForObject(":Start point.Y _ModuleBase_ParamSpinBox_2"), "a")
158 mouseClick(waitForObject(":End point.qt_spinbox_lineedit_QLineEdit_4"), 99, 1, 0, Qt.LeftButton)
159 type(waitForObject(":End point.X _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
160 type(waitForObject(":End point.X _ModuleBase_ParamSpinBox_2"), "a")
161 mouseClick(waitForObject(":End point.qt_spinbox_lineedit_QLineEdit_5"), 99, 1, 0, Qt.LeftButton)
162 type(waitForObject(":End point.Y _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
163 type(waitForObject(":End point.Y _ModuleBase_ParamSpinBox_2"), "a")
164 waitFor("object.exists(':Center.qt_spinbox_lineedit_QLineEdit_3')", 20000)
165 test.compare(str(findObject(":Center.qt_spinbox_lineedit_QLineEdit_3").text), "0")
166 waitFor("object.exists(':Center.qt_spinbox_lineedit_QLineEdit_4')", 20000)
167 test.compare(str(findObject(":Center.qt_spinbox_lineedit_QLineEdit_4").text), "0")
168 waitFor("object.exists(':Start point.qt_spinbox_lineedit_QLineEdit_4')", 20000)
169 test.compare(str(findObject(":Start point.qt_spinbox_lineedit_QLineEdit_4").text), "0")
170 waitFor("object.exists(':Start point.qt_spinbox_lineedit_QLineEdit_5')", 20000)
171 test.compare(str(findObject(":Start point.qt_spinbox_lineedit_QLineEdit_5").text), "0")
172 waitFor("object.exists(':End point.qt_spinbox_lineedit_QLineEdit_4')", 20000)
173 test.compare(str(findObject(":End point.qt_spinbox_lineedit_QLineEdit_4").text), "0")
174 waitFor("object.exists(':End point.qt_spinbox_lineedit_QLineEdit_5')", 20000)
175 test.compare(str(findObject(":End point.qt_spinbox_lineedit_QLineEdit_5").text), "0")
176 clickButton(waitForObject(":Arc.property_panel_cancel_QToolButton"))
178 @Then("Check that Fillet does not allow using expressions")
180 activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Sketch"))
181 activateItem(waitForObjectItem(":Sketch_QMenu", "Line"))
182 mouseClick(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 131, 282, 0, Qt.LeftButton)
183 mouseClick(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 209, 98, 0, Qt.LeftButton)
184 mouseClick(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 283, 275, 0, Qt.LeftButton)
185 #TODO_1 clickButton(waitForObject(":Line.property_panel_cancel_QToolButton"))
186 activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Sketch"))
187 activateItem(waitForObjectItem(":Sketch_QMenu", "Fillet"))
188 mouseClick(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 211, 99, 0, Qt.LeftButton)
189 type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
190 type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "<Keypad_1>")
191 type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "<Keypad_0>")
192 type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "<Keypad_Enter>")
193 waitFor("object.exists(':Fillet.qt_spinbox_lineedit_QLineEdit')", 20000)
194 test.compare(str(findObject(":Fillet.qt_spinbox_lineedit_QLineEdit").text), "10")
195 mouseClick(waitForObject(":Fillet.qt_spinbox_lineedit_QLineEdit"), 48, 6, 0, Qt.LeftButton)
196 type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
197 type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "a")
198 waitFor("object.exists(':Fillet.qt_spinbox_lineedit_QLineEdit')", 20000)
199 test.compare(str(findObject(":Fillet.qt_spinbox_lineedit_QLineEdit").text), "10")
200 clickButton(waitForObject(":Fillet.property_panel_cancel_QToolButton"))