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*.NewGeom_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")