1 # Copyright (C) 2014-2021 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # [Scenario] XAO-export
23 # [Topic] 'Exchange' functionality
24 # [Tested functionality]
25 # [Summary description]
29 source(findFile("scripts", "common.py"))
31 # [step] Launch SALOME
32 startApplication("salome_run.sh")
36 # [step] Activate NewGeom
39 # [step] Create new Part
40 activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
41 activateItem(waitForObjectItem(":Part_QMenu", "New part"))
43 # [step] Import file 'exchange/xao/Box_1.brep'
44 export_file_path = os.path.join(DATA_PATH, 'exchange', 'xao', 'Box_1.brep');
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"))
54 # [step] Check that the body is visible in the view [vp BODY]
58 # [step] Create Group feature
59 activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Features"))
60 activateItem(waitForObjectItem(":_QMenu", "Group"))
62 # [step] Select type: Solids
63 mouseClick(waitForObjectItem(":property_panel_dock.Type_QComboBox", "Solids"), 10, 10, 0, Qt.LeftButton)
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")
70 # [step] Apply the feature
71 clickButton(waitForObject(":Boolean.property_panel_ok_QToolButton"))
73 # [step] Rename the Group_1 result to: boite_1
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>")
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>")
90 # [step] Create Group feature
91 activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Features"))
92 activateItem(waitForObjectItem(":_QMenu", "Group"))
94 # [step] Select type: Faces
95 mouseClick(waitForObjectItem(":property_panel_dock.Type_QComboBox", "Faces"), 10, 10, 0, Qt.LeftButton)
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")
104 # [step] Apply the feature
105 clickButton(waitForObject(":Boolean.property_panel_ok_QToolButton"))
107 # [step] Check that the new Group result name is: Group_2
108 waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1.Groups (2).Group\\_2")
110 # [step] Create Export feature
111 activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
112 activateItem(waitForObjectItem(":Part_QMenu", "Export"))
114 # [step] Select export type: XAO
115 mouseClick(waitForObjectItem(":property_panel_dock_QComboBox", "XAO"), 10, 10, 0, Qt.LeftButton)
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"))
124 # [step] Set author: me
125 type(waitForObject(":property_panel_dock.Author_QLineEdit"), "me")
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>")
131 # [step] Apply the feature
132 clickButton(waitForObject(":Boolean.property_panel_ok_QToolButton"))
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)
141 test.fail("Files '%s' and '%s' are not equal" % files)
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"))
151 # [step] Create new Part
152 activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
153 activateItem(waitForObjectItem(":Part_QMenu", "New part"))
155 # [step] Create Import feature
156 activateItem(waitForObjectItem(":SALOME*_QMenuBar", "Part"))
157 activateItem(waitForObjectItem(":Part_QMenu", "Import"))
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>")
165 # [step] Apply the feature
166 clickButton(waitForObject(":Boolean.property_panel_ok_QToolButton"))
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"))
172 test.vp("BODY_IMPORT")
174 # [step] In Object Browser check that the Import feature name is "mygeom"
175 waitForObjectItem(":Object browser_XGUI_DataTree", "Part\\_1.mygeom")
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")
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"))
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"))
195 # [step] Close application without saving