Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / test.squish / suite_PYTHONAPI_SALOME / tst_Platine / test.py
1 ## Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 ##
3 ## This library is free software; you can redistribute it and/or
4 ## modify it under the terms of the GNU Lesser General Public
5 ## License as published by the Free Software Foundation; either
6 ## version 2.1 of the License, or (at your option) any later version.
7 ##
8 ## This library is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 ## Lesser General Public License for more details.
12 ##
13 ## You should have received a copy of the GNU Lesser General Public
14 ## License along with this library; if not, write to the Free Software
15 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 ##
17 ## See http:##www.salome-platform.org/ or
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 ##
20
21 def set_parameter_value(name, value):
22     openContextMenu(waitForObject(":Parameters.%s = _QModelIndex" % name), 10, 10, 0)
23     activateItem(waitForObjectItem(":_QMenu", "Edit..."))
24     mouseClick(waitForObject(":Parameter_ExpressionEditor"), 10, 10, 0, Qt.LeftButton)
25     type(waitForObject(":Parameter_ExpressionEditor"), "<Ctrl+A>")
26     type(waitForObject(":Parameter_ExpressionEditor"), value)
27     type(waitForObject(":Parameter_ExpressionEditor"), "<Return>")
28     clickButton(waitForObject(":Boolean.property_panel_ok_QToolButton"))
29
30 def main():
31     # [project] SHAPER
32     # [Scenario] 'Platine' model created by PythonAPI
33     # [Topic] PythonAPI functionality
34     # [Tested functionality]
35     # [Summary description]
36     # [Expected results]
37     # [General comments]
38
39     source(findFile("scripts", "common.py"))
40
41     # [section] Application start
42     # [step] Launch SALOME
43     startApplication("salome_run.sh")
44
45     set_defaults()
46
47     # [step] Activate Shaper module and create new file
48     activate_SHAPER()
49
50     # [step] In Python console type: import examples.Platine
51     type(waitForObject(":Python Console_PyConsole_EnhEditor"), "import examples.Platine")
52     type(waitForObject(":Python Console_PyConsole_EnhEditor"), "<Return>")
53
54     # [step] Check that the model is correct [vp VP_PLATINE]
55     clickButton(waitForObject(":SALOME*.Fit All_QToolButton"))
56     test.vp("VP_PLATINE")
57
58     # [step] Check that the object browser contains all objects from the model [vp VP_TREE]
59     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1.Parameters (3)")
60     clickItem(":Object browser_XGUI_DataTree", "Part\\_1.Parameters (3)", -10, 10, 0, Qt.LeftButton)
61     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1.Constructions (3)")
62     clickItem(":Object browser_XGUI_DataTree", "Part\\_1.Constructions (3)", -10, 10, 0, Qt.LeftButton)
63     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1.Bodies (1)")
64     clickItem(":Object browser_XGUI_DataTree", "Part\\_1.Bodies (1)", -10, 10, 0, Qt.LeftButton)
65     # Tree is under modification, so it can not be checked by a picture
66     # Moreover a mask for a text should be provided to check it on different platforms
67     #test.vp("VP_TREE")
68
69     # [step] Change parameter values: L = 64, E = 5, P = 80
70     set_parameter_value("L", 64)
71     set_parameter_value("E", 5)
72     set_parameter_value("P", 80)
73     clickButton(waitForObject(":SALOME*.Fit All_QToolButton"))
74     mouseMove(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 320, 240)
75     test.vp("VP_PLATINE_E")
76
77     # [step] Change parameter values: L = 90, E = 20, P = 80
78     set_parameter_value("L", 90)
79     set_parameter_value("E", 20)
80     set_parameter_value("P", 80)
81     clickButton(waitForObject(":SALOME*.Fit All_QToolButton"))
82     mouseMove(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 320, 240)
83     test.vp("VP_PLATINE_L")
84
85     # [step] Change parameter values: L = 64, E = 20, P = 120
86     set_parameter_value("L", 64)
87     set_parameter_value("E", 20)
88     set_parameter_value("P", 120)
89     clickButton(waitForObject(":SALOME*.Fit All_QToolButton"))
90     mouseMove(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 320, 240)
91     test.vp("VP_PLATINE_P")
92
93     # [step] Close application
94     close_application()