Salome HOME
updated copyright message
[modules/shaper.git] / test.squish / suite_FEATURE_EXCHANGE / tst_XAO-export / test.py
1 # Copyright (C) 2014-2023  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 main():
21     # [project] NewGEOM
22     # [Scenario] XAO-export
23     # [Topic] 'Exchange' functionality
24     # [Tested functionality]
25     # [Summary description]
26     # [Expected results]
27     # [General comments]
28
29     source(findFile("scripts", "common.py"))
30
31     # [step] Launch SALOME
32     startApplication("salome_run.sh")
33
34     set_defaults()
35
36     # [step] Activate NewGeom
37     activate_newgeom()
38
39     # [step] Create new Part
40     activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
41     activateItem(waitForObjectItem(":Part_QMenu", "New part"))
42
43     # [step] Import file 'exchange/xao/Box_1.brep'
44     export_file_path = os.path.join(DATA_PATH, 'exchange', 'xao', 'Box_1.brep');
45
46     activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
47     activateItem(waitForObjectItem(":Part_QMenu", "Import"))
48     mouseClick(waitForObject(":property_panel_dock...._QPushButton"), 10, 10, 0, Qt.LeftButton)
49     mouseClick(waitForObjectItem(":property_panel_dock.fileTypeCombo_QComboBox", "BREP files (*\\.BREP *\\.BRP)"), 10, 10, 0, Qt.LeftButton)
50     type(waitForObject(":fileNameEdit_QLineEdit_3"), export_file_path)
51     type(waitForObject(":fileNameEdit_QLineEdit_3"), "<Return>")
52     clickButton(waitForObject(":Boolean.property_panel_ok_QToolButton"))
53
54     # [step] Check that the body is visible in the view [vp BODY]
55     fit_all()
56     test.vp("BODY")
57
58     # [step] Create Group feature
59     activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Features"))
60     activateItem(waitForObjectItem(":_QMenu", "Group"))
61
62     # [step] Select type: Solids
63     mouseClick(waitForObjectItem(":property_panel_dock.Type_QComboBox", "Solids"), 10, 10, 0, Qt.LeftButton)
64
65     # [step] Select the imported box [vp SELECTED_SOLIDS]
66     mouseClick(waitForObject(":property_panel_dock.Selected objects:_QListWidget"), 10, 10, 0, Qt.LeftButton)
67     mouseClick(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 310, 147, 0, Qt.LeftButton)
68     test.vp("SELECTED_SOLIDS")
69
70     # [step] Apply the feature
71     clickButton(waitForObject(":Boolean.property_panel_ok_QToolButton"))
72
73     # [step] Rename the Group_1 result to: boite_1
74     # rename feature
75 #     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1.Group\\_1")
76 #     clickItem(":Object browser_XGUI_DataTree", "Part\\_1.Group\\_1", 10, 10, 0, Qt.LeftButton)
77 #     openItemContextMenu(waitForObject(":Object browser_XGUI_DataTree"), "Part\\_1.Group\\_1", 49, 7, 0)
78 #     activateItem(waitForObjectItem(":_QMenu", "Rename"))
79 #     type(waitForObject(":_QExpandingLineEdit_2"), "boite_1")
80 #     type(waitForObject(":_QExpandingLineEdit_2"), "<Return>")
81     # rename result
82     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1.Groups (1)")
83     clickItem(":Object browser_XGUI_DataTree", "Part\\_1.Groups (1)", -10, 10, 0, Qt.LeftButton)
84     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1.Groups (1).Group\\_1")
85     openItemContextMenu(waitForObject(":Object browser_XGUI_DataTree"), "Part\\_1.Groups (1).Group\\_1", 10, 10, 0)
86     activateItem(waitForObjectItem(":_QMenu", "Rename"))
87     type(waitForObject(":_QExpandingLineEdit"), "boite_1")
88     type(waitForObject(":_QExpandingLineEdit"), "<Return>")
89
90     # [step] Create Group feature
91     activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Features"))
92     activateItem(waitForObjectItem(":_QMenu", "Group"))
93
94     # [step] Select type: Faces
95     mouseClick(waitForObjectItem(":property_panel_dock.Type_QComboBox", "Faces"), 10, 10, 0, Qt.LeftButton)
96
97     # [step] Select the two faces [vp SELECTED_FACES]
98     mouseClick(waitForObject(":property_panel_dock.Selected objects:_QListWidget"), 10, 10, 0, Qt.LeftButton)
99     mouseClick(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 469, 292, 0, Qt.LeftButton)
100     type(waitForObject(":property_panel_dock.Selected objects:_QListWidget"), "<Shift>")
101     mouseClick(waitForObject(":SALOME*.3D View Operations_OCCViewer_ViewPort3d"), 306, 296, 33554432, Qt.LeftButton)
102     test.vp("SELECTED_FACES")
103
104     # [step] Apply the feature
105     clickButton(waitForObject(":Boolean.property_panel_ok_QToolButton"))
106
107     # [step] Check that the new Group result name is: Group_2
108     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1.Groups (2).Group\\_2")
109
110     # [step] Create Export feature
111     activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
112     activateItem(waitForObjectItem(":Part_QMenu", "Export"))
113
114     # [step] Select export type: XAO
115     mouseClick(waitForObjectItem(":property_panel_dock_QComboBox", "XAO"), 10, 10, 0, Qt.LeftButton)
116
117     # [step] Set the file name 'Box-export.xao'
118     export_file_path = os.path.join(TMP_DIR, 'Box-export.xao')
119     clickButton(waitForObject(":property_panel_dock...._QPushButton"))
120     mouseClick(waitForObject(":fileNameEdit_QLineEdit_3"), 64, 7, 0, Qt.LeftButton)
121     type(waitForObject(":fileNameEdit_QLineEdit_3"), export_file_path)
122     clickButton(waitForObject(":property_panel_dock.Save_QPushButton"))
123
124     # [step] Set author: me
125     type(waitForObject(":property_panel_dock.Author_QLineEdit"), "me")
126
127     # [step] Set geometry name: mygeom
128     type(waitForObject(":property_panel_dock.Geometry name_QLineEdit"), "mygeom")
129     type(waitForObject(":property_panel_dock.Geometry name_QLineEdit"), "<Return>")
130
131     # [step] Apply the feature
132     clickButton(waitForObject(":Boolean.property_panel_ok_QToolButton"))
133     snooze(1)
134
135     # [step] Check that the exported file exists: 'exchange/xao/results/Box-export.xao'
136     example_file_path = os.path.join(DATA_PATH, 'exchange', 'xao-examples', 'Box-export.xao')
137     files = (export_file_path, example_file_path)
138     if filecmp.cmp(*files):
139         test.passes("File comparison of '%s' and '%s' passed" % files)
140     else:
141         test.fail("Files '%s' and '%s' are not equal" % files)
142
143     # [section] Import
144
145     # [step] Delete Part_1
146     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1")
147     clickItem(":Object browser_XGUI_DataTree", "Part\\_1", 10, 10, 0, Qt.LeftButton)
148     activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
149     activateItem(waitForObjectItem(":Part_QMenu", "Remove part"))
150
151     # [step] Create new Part
152     activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
153     activateItem(waitForObjectItem(":Part_QMenu", "New part"))
154
155     # [step] Create Import feature
156     activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
157     activateItem(waitForObjectItem(":Part_QMenu", "Import"))
158
159     # [step] Select the exported file
160     mouseClick(waitForObject(":property_panel_dock...._QPushButton"), 10, 10, 0, Qt.LeftButton)
161     mouseClick(waitForObjectItem(":property_panel_dock.fileTypeCombo_QComboBox", "XAO files (*\\.XAO)"), 10, 10, 0, Qt.LeftButton)
162     type(waitForObject(":fileNameEdit_QLineEdit_3"), export_file_path)
163     type(waitForObject(":fileNameEdit_QLineEdit_3"), "<Return>")
164
165     # [step] Apply the feature
166     clickButton(waitForObject(":Boolean.property_panel_ok_QToolButton"))
167
168     # [step] Check that the body is visible in the view [vp BODY]
169     openItemContextMenu(waitForObject(":Object browser_XGUI_DataTree"), "Part\\_1.Bodies (1).mygeom\\_1", 10, 10, 0)
170     activateItem(waitForObjectItem(":_QMenu", "Show only"))
171     fit_all()
172     test.vp("BODY_IMPORT")
173
174     # [step] In Object Browser check that the Import feature name is "mygeom"
175     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1.mygeom")
176
177     # [step] In Object Browser check new body: mygeom_1
178     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1.Bodies (1).mygeom\\_1")
179     # [step] In Object Browser check new groups: boite_1, Group_2
180     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1.Groups (2).boite\\_1")
181     waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1.Groups (2).Group\\_2")
182
183     # [step] Check the group boite_1 is a solid [vp GROUP_1]
184     openItemContextMenu(waitForObject(":Object browser_XGUI_DataTree"), "Part\\_1.Groups (2).boite\\_1", 10, 10, 0)
185     activateItem(waitForObjectItem(":_QMenu", "Show only"))
186     fit_all()
187     test.vp("GROUP_1")
188
189     # [step] Check the group Group_2 is a list of 2 faces [vp GROUP_2]
190     openItemContextMenu(waitForObject(":Object browser_XGUI_DataTree"), "Part\\_1.Groups (2).Group\\_2", 10, 10, 0)
191     activateItem(waitForObjectItem(":_QMenu", "Show only"))
192     fit_all()
193     test.vp("GROUP_2")
194
195     # [step] Close application without saving
196     close_application()