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