Salome HOME
Updated copyright comment
[modules/shaper.git] / test.squish / suite_PYTHONAPI_SALOME / tst_Platine / test.py
1 # Copyright (C) 2014-2024  CEA, EDF
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 email : webmaster.salome@opencascade.com
18 #
19
20 def set_parameter_value(name, value):
21     openContextMenu(waitForObject(":Parameters.%s = _QModelIndex" % name), 10, 10, 0)
22     activateItem(waitForObjectItem(":_QMenu", "Edit..."))
23     mouseClick(waitForObject(":Parameter_ExpressionEditor"), 10, 10, 0, Qt.LeftButton)
24     type(waitForObject(":Parameter_ExpressionEditor"), "<Ctrl+A>")
25     type(waitForObject(":Parameter_ExpressionEditor"), value)
26     type(waitForObject(":Parameter_ExpressionEditor"), "<Return>")
27     clickButton(waitForObject(":Boolean.property_panel_ok_QToolButton"))
28
29 def main():
30     # [project] SHAPER
31     # [Scenario] 'Platine' model created by PythonAPI
32     # [Topic] PythonAPI functionality
33     # [Tested functionality]
34     # [Summary description]
35     # [Expected results]
36     # [General comments]
37
38     source(findFile("scripts", "common.py"))
39
40     # [section] Application start
41     # [step] Launch SALOME
42     startApplication("salome_run.sh")
43
44     set_defaults()
45
46     # [step] Activate Shaper module and create new file
47     activate_SHAPER()
48
49     # [step] In Python console type: import examples.Platine
50     type(waitForObject(":Python Console_PyConsole_EnhEditor"), "import examples.Platine")
51     type(waitForObject(":Python Console_PyConsole_EnhEditor"), "<Return>")
52
53     # [step] Check that the model is correct [vp VP_PLATINE]
54     clickButton(waitForObject(":SALOME*.Fit All_QToolButton"))
55     test.vp("VP_PLATINE")
56
57     # [step] Check that the object browser contains all objects from the model [vp VP_TREE]
58     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1.Parameters (3)")
59     clickItem(":Object browser_XGUI_DataTree", "Part\\_1.Parameters (3)", -10, 10, 0, Qt.LeftButton)
60     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1.Constructions (3)")
61     clickItem(":Object browser_XGUI_DataTree", "Part\\_1.Constructions (3)", -10, 10, 0, Qt.LeftButton)
62     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1.Bodies (1)")
63     clickItem(":Object browser_XGUI_DataTree", "Part\\_1.Bodies (1)", -10, 10, 0, Qt.LeftButton)
64     # Tree is under modification, so it can not be checked by a picture
65     # Moreover a mask for a text should be provided to check it on different platforms
66     #test.vp("VP_TREE")
67
68     # [step] Change parameter values: L = 64, E = 5, P = 80
69     set_parameter_value("L", 64)
70     set_parameter_value("E", 5)
71     set_parameter_value("P", 80)
72     clickButton(waitForObject(":SALOME*.Fit All_QToolButton"))
73     mouseMove(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 320, 240)
74     test.vp("VP_PLATINE_E")
75
76     # [step] Change parameter values: L = 90, E = 20, P = 80
77     set_parameter_value("L", 90)
78     set_parameter_value("E", 20)
79     set_parameter_value("P", 80)
80     clickButton(waitForObject(":SALOME*.Fit All_QToolButton"))
81     mouseMove(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 320, 240)
82     test.vp("VP_PLATINE_L")
83
84     # [step] Change parameter values: L = 64, E = 20, P = 120
85     set_parameter_value("L", 64)
86     set_parameter_value("E", 20)
87     set_parameter_value("P", 120)
88     clickButton(waitForObject(":SALOME*.Fit All_QToolButton"))
89     mouseMove(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 320, 240)
90     test.vp("VP_PLATINE_P")
91
92     # [step] Close application
93     close_application()