]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix issue #1127: parameter is not created
authorspo <sergey.pokhodenko@opencascade.com>
Mon, 21 Dec 2015 08:54:59 +0000 (11:54 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Mon, 21 Dec 2015 08:55:17 +0000 (11:55 +0300)
src/ParametersPlugin/ParametersPlugin_Parameter.cpp
test.squish/objects_salome.map
test.squish/suite_FEATURE_PARAMETERS/shared/scripts/bdd_hooks.py [new file with mode: 0644]
test.squish/suite_FEATURE_PARAMETERS/shared/steps/steps.py [new file with mode: 0644]
test.squish/suite_FEATURE_PARAMETERS/suite.conf
test.squish/suite_FEATURE_PARAMETERS/tst_1127/test.feature [new file with mode: 0644]
test.squish/suite_FEATURE_PARAMETERS/tst_1127/test.py [new file with mode: 0644]

index 961182a7138aa7218aa957f43921d236932fea24..803ea9e43983c4b7403c967b18120636cb6bb364 100644 (file)
@@ -107,7 +107,7 @@ double ParametersPlugin_Parameter::evaluate(const std::string& theExpression, st
     // Currently there is no way to get parent document, so we get PartSet for all.
     DocumentPtr aDocument = document();
     if (data()->name() == aVariableName) {
-      if (aDocument = ModelAPI_Session::get()->moduleDocument())
+      if (aDocument == ModelAPI_Session::get()->moduleDocument())
         continue;
       aDocument = ModelAPI_Session::get()->moduleDocument();
     }
index bff72d5554cf241cd24f43ca1f723abda2efbc94..79fb2b4cb905889df6cfa9597f82da01aa0405aa 100644 (file)
 :Parameter_ExpressionEditor    {container=':SALOME*.Parameter_XGUI_PropertyPanel' type='ExpressionEditor' unnamed='1' visible='1'}
 :Parameter_QFrame      {container=':SALOME*.Parameter_XGUI_PropertyPanel' type='QFrame' unnamed='1' visible='1'}
 :Parameter_QLineEdit   {container=':SALOME*.Parameter_XGUI_PropertyPanel' type='QLineEdit' unnamed='1' visible='1'}
+:Parameters (1).a = 32_QModelIndex     {column='0' container=':Part_1.Parameters (1)_QModelIndex' text='a = 32' type='QModelIndex'}
 :Parameters.E = _QModelIndex   {column='0' container=':Part_1.Parameters_QModelIndex' text?='E = *' type='QModelIndex'}
 :Parameters.L = _QModelIndex   {column='0' container=':Part_1.Parameters_QModelIndex' text?='L = *' type='QModelIndex'}
 :Parameters.P = _QModelIndex   {column='0' container=':Part_1.Parameters_QModelIndex' text?='P = *' type='QModelIndex'}
+:Part_1.Parameters (1)_QModelIndex     {column='0' container=':Part_1_QModelIndex' text='Parameters (1)' type='QModelIndex'}
 :Part_1.Parameters_QModelIndex {column='0' container=':Part_1_QModelIndex' text?='Parameters*' type='QModelIndex'}
 :Part_1_QModelIndex    {column='0' container=':Object browser_XGUI_DataTree' text='Part_1' type='QModelIndex'}
 :Part_QMenu    {title='Part' type='QMenu' unnamed='1' visible='1'}
diff --git a/test.squish/suite_FEATURE_PARAMETERS/shared/scripts/bdd_hooks.py b/test.squish/suite_FEATURE_PARAMETERS/shared/scripts/bdd_hooks.py
new file mode 100644 (file)
index 0000000..6a71199
--- /dev/null
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+
+# This file contains hook functions to run as the .feature file is executed.
+#
+# A common use-case is to use the OnScenarioStart/OnScenarioEnd hooks to
+# start and stop an AUT, e.g.
+#
+# @OnScenarioStart
+# def hook(context):
+#     startApplication("addressbook")
+#
+# @OnScenarioEnd
+# def hook(context):
+#     currentApplicationContext().detach()
+#
+# See the section 'Performing Actions During Test Execution Via Hooks' in the Squish
+# manual for a complete reference of the available API.
+
+import __builtin__
+
+# Detach (i.e. potentially terminate) all AUTs at the end of a scenario
+@OnScenarioEnd
+def hook(context):
+    source(findFile("scripts", "common.py"))
+    close_application()
+
+    for ctx in applicationContextList():
+        ctx.detach()
+
diff --git a/test.squish/suite_FEATURE_PARAMETERS/shared/steps/steps.py b/test.squish/suite_FEATURE_PARAMETERS/shared/steps/steps.py
new file mode 100644 (file)
index 0000000..ad69b63
--- /dev/null
@@ -0,0 +1,69 @@
+# -*- coding: utf-8 -*-
+
+# A quick introduction to implementing scripts for BDD tests:
+#
+# This file contains snippets of script code to be executed as the .feature
+# file is processed. See the section 'Behaviour Driven Testing' in the 'API
+# Reference Manual' chapter of the Squish manual for a comprehensive reference.
+#
+# The decorators Given/When/Then/Step can be used to associate a script snippet
+# with a pattern which is matched against the steps being executed. Optional
+# table/multi-line string arguments of the step are passed via a mandatory
+# 'context' parameter:
+#
+#   @When("I enter the text")
+#   def whenTextEntered(context):
+#      <code here>
+#
+# The pattern is a plain string without the leading keyword, but a couple of
+# placeholders including |any|, |word| and |integer| are supported which can be
+# used to extract arbitrary, alphanumeric and integer values resp. from the
+# pattern; the extracted values are passed as additional arguments:
+#
+#   @Then("I get |integer| different names")
+#   def namesReceived(context, numNames):
+#      <code here>
+#
+# Instead of using a string with placeholders, a regular expression can be
+# specified. In that case, make sure to set the (optional) 'regexp' argument
+# to True.
+
+import __builtin__
+
+@Given("Launch application in salome mode")
+def step(context):
+    startApplication("salome_run.sh")
+    clickButton(waitForObject(":SALOME*.NewGeom_QToolButton"))
+    clickButton(waitForObject(":Activate module.New_QPushButton"))
+
+@When("Create parameter a=30")
+def step(context):
+    activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
+    activateItem(waitForObjectItem(":Part_QMenu", "Parameter"))
+    mouseClick(waitForObject(":Parameter_QLineEdit"), 10, 10, 0, Qt.LeftButton)
+    type(waitForObject(":Parameter_QLineEdit"), "a")
+    mouseClick(waitForObject(":Parameter_ExpressionEditor"), 10, 10, 0, Qt.LeftButton)
+    type(waitForObject(":Parameter_ExpressionEditor"), "30")
+    clickButton(waitForObject(":Boolean.property_panel_ok_QToolButton"))
+
+@When("Create part")
+def step(context):
+    activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
+    activateItem(waitForObjectItem(":Part_QMenu", "New part"))
+
+@When("Create parameter a=a+2")
+def step(context):
+    activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
+    activateItem(waitForObjectItem(":Part_QMenu", "Parameter"))
+    mouseClick(waitForObject(":Parameter_QLineEdit"), 10, 10, 0, Qt.LeftButton)
+    type(waitForObject(":Parameter_QLineEdit"), "a")
+    mouseClick(waitForObject(":Parameter_ExpressionEditor"), 10, 10, 0, Qt.LeftButton)
+    type(waitForObject(":Parameter_ExpressionEditor"), "a+2")
+    clickButton(waitForObject(":Boolean.property_panel_ok_QToolButton"))
+
+@Then("the parameter in the part should exist")
+def step(context):
+    waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1.Parameters (1)")
+    clickItem(":Object browser_XGUI_DataTree", "Part\\_1.Parameters (1)", -10, 10, 0, Qt.LeftButton)
+    waitFor("object.exists(':Parameters (1).a = 32_QModelIndex')", 20000)
+    test.compare(findObject(":Parameters (1).a = 32_QModelIndex").text, "a = 32")
index bae54b56b7333cfd7dd085035d398735f02a3428..739cb8424d00020ef79af8174a5e9cd1f9a6a084 100644 (file)
@@ -5,6 +5,6 @@ HOOK_SUB_PROCESSES=true
 IMPLICITAUTSTART=0
 LANGUAGE=Python
 OBJECTMAP=../objects_salome.map
-TEST_CASES=tst_BASE
+TEST_CASES=tst_BASE tst_1127
 VERSION=3
 WRAPPERS=Qt
diff --git a/test.squish/suite_FEATURE_PARAMETERS/tst_1127/test.feature b/test.squish/suite_FEATURE_PARAMETERS/tst_1127/test.feature
new file mode 100644 (file)
index 0000000..48633ee
--- /dev/null
@@ -0,0 +1,11 @@
+Feature: Two parameters with the same name could exist in PartSet and Part
+
+    Each part can have its local parameter with any value.
+
+    Scenario: Parameter in part should be created
+
+        Given Launch application in salome mode
+         When Create parameter a=30
+          And Create part
+          And Create parameter a=a+2
+         Then the parameter in the part should exist
diff --git a/test.squish/suite_FEATURE_PARAMETERS/tst_1127/test.py b/test.squish/suite_FEATURE_PARAMETERS/tst_1127/test.py
new file mode 100644 (file)
index 0000000..75e47d0
--- /dev/null
@@ -0,0 +1,8 @@
+source(findFile('scripts', 'python/bdd.py'))
+
+setupHooks('../shared/scripts/bdd_hooks.py')
+collectStepDefinitions('./steps', '../shared/steps')
+
+def main():
+    testSettings.throwOnFailure = True
+    runFeatureFile('test.feature')