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