Salome HOME
Add Squish test for the issue #1157
[modules/shaper.git] / test.squish / suite_FEATURE_PARAMETERS / shared / steps / steps.py
1 # -*- coding: utf-8 -*-
2
3 # A quick introduction to implementing scripts for BDD tests:
4 #
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.
8 #
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:
13 #
14 #   @When("I enter the text")
15 #   def whenTextEntered(context):
16 #      <code here>
17 #
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:
22 #
23 #   @Then("I get |integer| different names")
24 #   def namesReceived(context, numNames):
25 #      <code here>
26 #
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
29 # to True.
30
31 import __builtin__
32
33 @Given("Launch application in salome mode")
34 def step(context):
35     startApplication("salome_run.sh")
36     clickButton(waitForObject(":SALOME*.NewGeom_QToolButton"))
37     clickButton(waitForObject(":Activate module.New_QPushButton"))
38
39 @When("Create parameter a=30")
40 def step(context):
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"))
48
49 @When("Create part")
50 def step(context):
51     activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
52     activateItem(waitForObjectItem(":Part_QMenu", "New part"))
53
54 @When("Create parameter a=a+2")
55 def step(context):
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"))
63
64 @Then("the parameter in the part should exist")
65 def step(context):
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")
70
71 @When("Create sketch")
72 def step(context):
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"))
77
78 @Then("Check that Point does not allow using expressions")
79 def step(context):
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"))
92
93 @Then("Check that Line does not allow using expressions")
94 def step(context):
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"))
117
118 @Then("Check that Circle does not allow using expressions")
119 def step(context):
120     clickButton(waitForObject(":SALOME*.Circle_QToolButton"))
121     mouseClick(waitForObject(":Center.qt_spinbox_lineedit_QLineEdit"), 90, 4, 0, Qt.LeftButton)
122     type(waitForObject(":Center.X _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
123     type(waitForObject(":Center.X _ModuleBase_ParamSpinBox"), "a")
124     mouseClick(waitForObject(":Center.qt_spinbox_lineedit_QLineEdit_2"), 71, 8, 0, Qt.LeftButton)
125     type(waitForObject(":Center.Y _ModuleBase_ParamSpinBox"), "<Ctrl+A>")
126     type(waitForObject(":Center.Y _ModuleBase_ParamSpinBox"), "a")
127     mouseClick(waitForObject(":Circle.qt_spinbox_lineedit_QLineEdit"), 58, 6, 0, Qt.LeftButton)
128     type(waitForObject(":Circle.CircleRadius_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
129     type(waitForObject(":Circle.CircleRadius_ModuleBase_ParamSpinBox"), "a")
130     waitFor("object.exists(':Center.qt_spinbox_lineedit_QLineEdit')", 20000)
131     test.compare(str(findObject(":Center.qt_spinbox_lineedit_QLineEdit").text), "0")
132     waitFor("object.exists(':Center.qt_spinbox_lineedit_QLineEdit_2')", 20000)
133     test.compare(str(findObject(":Center.qt_spinbox_lineedit_QLineEdit_2").text), "0")
134     waitFor("object.exists(':Circle.qt_spinbox_lineedit_QLineEdit')", 20000)
135     test.compare(str(findObject(":Circle.qt_spinbox_lineedit_QLineEdit").text), "0")
136     clickButton(waitForObject(":Circle.property_panel_cancel_QToolButton"))
137
138 @Then("Check that Arc does not allow using expressions")
139 def step(context):
140     clickButton(waitForObject(":SALOME*.Arc_QToolButton"))
141     mouseClick(waitForObject(":Center.qt_spinbox_lineedit_QLineEdit_3"), 156, 6, 0, Qt.LeftButton)
142     type(waitForObject(":Center.X _ModuleBase_ParamSpinBox_2"), "A")
143     type(waitForObject(":Center.X _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
144     type(waitForObject(":Center.X _ModuleBase_ParamSpinBox_2"), "a")
145     mouseClick(waitForObject(":Arc.Center_QGroupBox"), 135, 41, 0, Qt.LeftButton)
146     mouseClick(waitForObject(":Center.qt_spinbox_lineedit_QLineEdit_4"), 115, 3, 0, Qt.LeftButton)
147     type(waitForObject(":Center.Y _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
148     type(waitForObject(":Center.Y _ModuleBase_ParamSpinBox_2"), "a")
149     mouseClick(waitForObject(":Start point.qt_spinbox_lineedit_QLineEdit_4"), 103, 9, 0, Qt.LeftButton)
150     type(waitForObject(":Start point.X _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
151     type(waitForObject(":Start point.X _ModuleBase_ParamSpinBox_2"), "a")
152     mouseClick(waitForObject(":Start point.qt_spinbox_lineedit_QLineEdit_5"), 99, 8, 0, Qt.LeftButton)
153     type(waitForObject(":Start point.Y _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
154     type(waitForObject(":Start point.Y _ModuleBase_ParamSpinBox_2"), "a")
155     mouseClick(waitForObject(":End point.qt_spinbox_lineedit_QLineEdit_4"), 99, 1, 0, Qt.LeftButton)
156     type(waitForObject(":End point.X _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
157     type(waitForObject(":End point.X _ModuleBase_ParamSpinBox_2"), "a")
158     mouseClick(waitForObject(":End point.qt_spinbox_lineedit_QLineEdit_5"), 99, 1, 0, Qt.LeftButton)
159     type(waitForObject(":End point.Y _ModuleBase_ParamSpinBox_2"), "<Ctrl+A>")
160     type(waitForObject(":End point.Y _ModuleBase_ParamSpinBox_2"), "a")
161     waitFor("object.exists(':Center.qt_spinbox_lineedit_QLineEdit_3')", 20000)
162     test.compare(str(findObject(":Center.qt_spinbox_lineedit_QLineEdit_3").text), "0")
163     waitFor("object.exists(':Center.qt_spinbox_lineedit_QLineEdit_4')", 20000)
164     test.compare(str(findObject(":Center.qt_spinbox_lineedit_QLineEdit_4").text), "0")
165     waitFor("object.exists(':Start point.qt_spinbox_lineedit_QLineEdit_4')", 20000)
166     test.compare(str(findObject(":Start point.qt_spinbox_lineedit_QLineEdit_4").text), "0")
167     waitFor("object.exists(':Start point.qt_spinbox_lineedit_QLineEdit_5')", 20000)
168     test.compare(str(findObject(":Start point.qt_spinbox_lineedit_QLineEdit_5").text), "0")
169     waitFor("object.exists(':End point.qt_spinbox_lineedit_QLineEdit_4')", 20000)
170     test.compare(str(findObject(":End point.qt_spinbox_lineedit_QLineEdit_4").text), "0")
171     waitFor("object.exists(':End point.qt_spinbox_lineedit_QLineEdit_5')", 20000)
172     test.compare(str(findObject(":End point.qt_spinbox_lineedit_QLineEdit_5").text), "0")
173     clickButton(waitForObject(":Arc.property_panel_cancel_QToolButton"))
174
175 @Then("Check that Fillet does not allow using expressions")
176 def step(context):
177     clickButton(waitForObject(":SALOME*.Line_QToolButton"))
178     mouseClick(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 131, 282, 0, Qt.LeftButton)
179     mouseClick(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 209, 98, 0, Qt.LeftButton)
180     mouseClick(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 283, 275, 0, Qt.LeftButton)
181     clickButton(waitForObject(":Line.property_panel_cancel_QToolButton"))
182     clickButton(waitForObject(":SALOME*.Fillet_QToolButton"))
183     mouseClick(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 211, 99, 0, Qt.LeftButton)
184     type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
185     type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "<Keypad_1>")
186     type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "<Keypad_0>")
187     type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "<Keypad_Enter>")
188     waitFor("object.exists(':Fillet.qt_spinbox_lineedit_QLineEdit')", 20000)
189     test.compare(str(findObject(":Fillet.qt_spinbox_lineedit_QLineEdit").text), "10")
190     mouseClick(waitForObject(":Fillet.qt_spinbox_lineedit_QLineEdit"), 48, 6, 0, Qt.LeftButton)
191     type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "<Ctrl+A>")
192     type(waitForObject(":Fillet.ConstraintValue_ModuleBase_ParamSpinBox"), "a")
193     waitFor("object.exists(':Fillet.qt_spinbox_lineedit_QLineEdit')", 20000)
194     test.compare(str(findObject(":Fillet.qt_spinbox_lineedit_QLineEdit").text), "10")
195     clickButton(waitForObject(":Fillet.property_panel_cancel_QToolButton"))