Salome HOME
Fix issue #1127: parameter is not created
[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")