Salome HOME
trying to fix selection mecanism in OCC Viewer: Selection is OK, but broken after...
[modules/hydro.git] / squish.suite / suite_immersible_zones.suite / tst_case1 / test.py
1 """
2 This test case corresponds to HYDRO-003 (Immersible zone creation/edition and operations with it) scenario
3 """
4
5 import os
6 import tempfile
7 import shutil
8
9 def main():
10     # Prepare test data
11     global TEST_FILES_DIR
12     TEST_FILES_DIR = os.getenv("TEST_FILES_DIR")
13
14     global APPSETTINGS
15     APPSETTINGS = os.path.join(TEST_FILES_DIR, "SalomeApp.xml")
16
17     source(os.path.join(os.getenv("COMMON_SCRIPT_DIR"), "common_hydro.py"))
18
19     # Run test
20     os.system("killSalome.py") #@MZN
21     runCase()
22     
23     # Kill SALOME
24     os.system("killSalome.py")
25
26 def runCase():
27     S1() # Creating a new study
28     S2() # Creating immersible zone
29     S3() # Show/hide immersible zone
30     S4() # Color of immersible zone
31     S5() # Delete immersible zone
32
33
34 """
35 Creating a new study.
36 """
37 def S1():
38
39     # Title 1: Creating a new study
40     
41     # 1. Start the application
42     startApplication("runSalome.py --modules=HYDRO,GEOM,SMESH -r %s" % APPSETTINGS)
43     waitFor("object.exists(':SALOME_STD_TabDesktop')", 100000)
44       
45     # 2. File - New
46     activateMenuItem("File", "New")
47     
48     # 3. New study window appears including Object Browser and Python console
49     checkObjectBrowser()
50     checkPythonConsole()
51    
52     # 4. Select HYDRO in the list of modules, located in the toolbar
53     # 5. Graphics scene and OCC scene appear
54     activateHYDRO()
55
56     showTrihedron(False) # Hide trihedron
57
58
59 """
60 Create immersible zone.
61 """
62 def S2():
63     
64     # Title 2: Create immersible zone
65     
66     # 1. Click Ctrl+B
67     # 2. "Import bathymetry" panel appears
68     # 3. Import "IGN_pts_utiles_L2e_1.xyz" bathymetry file
69     bath_file_path = os.path.join(TEST_FILES_DIR, "IGN_pts_utiles_L2e_1.xyz")
70       
71     importBathymetry(bath_file_path)
72    
73     # 4. Select IGN_pts_utiles_L2e_1 in Object Browser
74     # 5. Call context menu - Show only
75     checkOBItem("HYDRO", "BATHYMETRIES", "IGN_pts_utiles_L2e_1")
76     activateOBContextMenuItem("HYDRO.BATHYMETRIES", "IGN_pts_utiles_L2e_1", "Show only")
77     
78     # 6. Click "Fit All" button to observe imported bathymetry
79     fitAll(True)
80        
81     # Check the bathymetry presentation in OCC viewer
82     test.vp("VP1")
83     
84     # Hide bathymetry presentation
85     activateOBContextMenuItem("HYDRO.BATHYMETRIES", "IGN_pts_utiles_L2e_1", "Hide")
86     resetOCCViewer()
87     
88     # 7. HYDRO - Create polyline
89     activateMenuItem("HYDRO", "Create polyline")
90     
91     # 8. Create the polyline as follows:
92     addSplineSection(True)
93     
94     addPolylinePoints([(621, 298), (571, 347), (620, 399), (721, 439), (812, 413), (839, 284), (699, 151)])
95   
96     clickButton(waitForObject(":Create polyline.Apply_QPushButton"))
97
98     # 9. HYDRO - Create immersible zone
99     activateMenuItem("HYDRO", "Create immersible zone")
100     
101     # 10. "Create immersible zone" panel appears
102     waitFor("object.exists(':SALOME *.Create immersible zone_HYDROGUI_ImmersibleZoneDlg')", 20000)
103     zone_panel = findObject(":SALOME *.Create immersible zone_HYDROGUI_ImmersibleZoneDlg")
104     test.compare(zone_panel.visible, True)
105     test.compare(zone_panel.windowTitle, "Create immersible zone")
106     
107     # Check that default name is "Immersible zone_1"    
108     test.compare(str(waitForObject(":Zone name.Name_QLineEdit").displayText), "Immersible zone_1")
109     
110     # 11. As polyline select created in step 8 polyline
111     selectComboBoxItem(waitForObject(":Parameters.Polyline_QComboBox"), "Polyline_1")
112     
113     # 12. As bathymetry select imported in step 3 bathymetry
114     selectComboBoxItem(waitForObject(":Bathymetry_QComboBox"), "IGN_pts_utiles_L2e_1")
115
116     # 13. Click "Apply"
117     clickButton(waitForObject(":Create immersible zone.Apply_QPushButton"))
118
119     # 14. Check the result
120     activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_1", "Show only")
121     fitAll(True)
122     test.vp("VP2") 
123     
124     # 15. Import once more bathymetry, for example, inverted_IGN_pts_utiles_L2e_1
125     importBathymetry(bath_file_path, "inverted_IGN_pts_utiles_L2e_1", True)
126     
127     # 16. Create the polyline as follows:
128     hideAll()
129     
130     activateMenuItem("HYDRO", "Create polyline")
131     
132     addSplineSection(True)
133     addPolylinePoints([(827, 188), (650, 191), (495, 283), (441, 397), (515, 528), (755, 442), (769, 367)])
134    
135     addSplineSection(True)
136     addPolylinePoints([(543, 380), (508, 431), (514, 489), (569, 469), (598, 413), (619, 388)])
137     
138     addSplineSection(True)
139     addPolylinePoints([(696, 222), (762, 214), (798, 233), (773, 293), (693, 322)])
140
141     clickButton(waitForObject(":Create polyline.Apply_QPushButton"))
142
143     # 17. Create any open polyline. It has name "Polyline_3"
144     activateMenuItem("HYDRO", "Create polyline")
145     
146     addPolylineSection(False)
147     addPolylinePoints([(368, 504), (525, 348), (830, 375), (954, 299)])
148
149     waitFor("object.exists(':Create polyline.Name_QLineEdit')", 20000)
150     test.compare(str(findObject(":Create polyline.Name_QLineEdit").displayText), "Polyline_3")
151     
152     clickButton(waitForObject(":Create polyline.Apply_QPushButton"))
153     
154     hideAll()
155    
156     # 18. In Object browser select "NATURAL OBJECTS" item, call its context menu - Create immersible zone
157     activateOBContextMenuItem("HYDRO", "NATURAL OBJECTS", "Create immersible zone")
158    
159     # 19. "Create immersible zone" panel appears
160     zone_panel = waitForObject(":SALOME *.Create immersible zone_HYDROGUI_ImmersibleZoneDlg")
161     test.compare(zone_panel.visible, True)
162     test.compare(zone_panel.windowTitle, "Create immersible zone")
163     
164     # Check that the name is "Immersible zone_2" now    
165     test.compare(str(waitForObject(":Zone name.Name_QLineEdit").displayText), "Immersible zone_2")
166
167     # 20. Check that only "Polyline_1" and "Polyline_2" are shown in the combo box.
168     poly_combo = waitForObject(":Parameters.Polyline_QComboBox")
169     checkComboBoxContent(poly_combo, ["Polyline_1", "Polyline_2"])  
170     
171     # As polyline select created in step 16 polyline. 
172     selectComboBoxItem(poly_combo, "Polyline_2")
173     
174     # 21. Check that both bathymetries are shown in the combo box.
175     bath_combo = waitForObject(":Bathymetry_QComboBox")
176     checkComboBoxContent(bath_combo, ["IGN_pts_utiles_L2e_1", "inverted_IGN_pts_utiles_L2e_1"])
177         
178     # As bathymetry select imported in step 3 bathymetry.
179     selectComboBoxItem(bath_combo, "IGN_pts_utiles_L2e_1")
180    
181     # 22. Check the preview:
182     fitAll()
183     test.vp("VP3")   
184     
185     # 23. Click "Cancel" button
186     clickButton(waitForObject(":Create immersible zone.Cancel_QPushButton"))
187     
188     # 24. No object has been created
189     checkOBItemNotExists("HYDRO", "NATURAL OBJECTS", "Immersible zone_2")
190     
191     # 25. Repeat steps 18-21
192     activateOBContextMenuItem("HYDRO", "NATURAL OBJECTS", "Create immersible zone")
193     selectComboBoxItem(waitForObject(":Parameters.Polyline_QComboBox"), "Polyline_2")
194     selectComboBoxItem(waitForObject(":Bathymetry_QComboBox"), "IGN_pts_utiles_L2e_1")
195     
196     # 26. Click "Apply"
197     clickButton(waitForObject(":Create immersible zone.Apply_QPushButton"))
198     
199     # 27. Check the result
200     fitAll(True)
201     test.vp("VP4")
202     
203     # 28. Create polyline, containing from polyline section and from spline section:
204     # 29. End points of sectors should have identical coordinates
205     hideAll()
206     
207     activateMenuItem("HYDRO", "Create polyline")
208     
209     start_point = (570, 130)
210     end_point = (880, 310)
211     
212     addPolylineSection(False)
213     addPolylinePoints([start_point, end_point])
214    
215     addSplineSection(False)
216     addPolylinePoints([start_point, (510, 220), (600, 260), (600, 410), end_point])
217         
218     clickButton(waitForObject(":Create polyline.Apply_QPushButton"))
219     
220     # 30. HYDRO - Create immersible zone
221     activateMenuItem("HYDRO", "Create immersible zone")
222     
223     # 31. Select just created "Polyline_4" in "Polyline" combo box 
224     selectComboBoxItem(waitForObject(":Parameters.Polyline_QComboBox"), "Polyline_4")
225     
226     # 32. Select any bathymetry
227     selectComboBoxItem(waitForObject(":Bathymetry_QComboBox"), "inverted_IGN_pts_utiles_L2e_1")
228
229     # 33. Click "Apply"
230     clickButton(waitForObject(":Create immersible zone.Apply_QPushButton"))
231     
232     # 34. Check the result
233     activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_3", "Show only")
234     fitAll(True)
235     test.vp("VP5")
236
237    
238 """
239 Show/hide immersible zone.
240 """
241 def S3():
242     
243     # Title 3: Show/hide immersible zone.
244     
245     # 1. Activate OCC 3D view
246     
247     # Already active: do nothing
248     
249     # 2. Select "Immersible zone_1" in Object Browser
250     # 3. Call context menu - Show Only
251     activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_1", "Show only")
252     
253     # 4. Fit all
254     fitAll(True)
255     
256     # 5. Only "Immersible zone_1" is shown in OCC view
257     test.vp("VP2")
258     
259     # 6. Call context menu - Hide
260     activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_1", "Hide")
261     
262     # 7. "Immersible zone_1" is hidden in OCC view
263     test.vp("vp_empty_occ_view")
264     
265     # 8. Select "Immersible zone_1" and "Immersible zone_2" in Object Browser
266     # 9. Call context menu - Show
267     zones = ["Immersible zone_1", "Immersible zone_2"]
268     activateOBContextMenuItems("HYDRO.NATURAL OBJECTS", zones, "Show")
269       
270     # 10. Fit all
271     fitAll()
272     
273     # 11. Both immersible zones are shown in OCC 3D view
274     test.vp("VP9")
275     
276     # 12. Call context menu - Hide all
277     activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_1", "Hide all")
278     
279     # 13. Both immersible zones are hidden in OCC 3D view
280     test.vp("vp_empty_occ_view")
281     
282     # 14. Window - New window - Graphics view
283     activateMenuItem("Window", "New Window", "Graphics view")
284     
285     # 15. New Graphics view appears
286     waitFor("object.exists(':Graphics scene:2 - viewer:1_TabItem')", 20000)
287     test.compare(findObject(":Graphics scene:2 - viewer:1_TabItem").text, "Graphics scene:2 - viewer:1")
288     test.compare(findObject(":Graphics scene:2 - viewer:1_TabItem").enabled, True)
289     
290     # 16. Show Immersible zone_1
291     activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_1", "Show")
292       
293     # 17. Nothing is shown
294     test.vp("VP7")
295     
296     # 18. Window - New window - VTK 3D view
297     activateMenuItem("Window", "New Window", "VTK 3D view")
298
299     # 19. New VTK view appears
300     waitFor("object.exists(':VTK scene:1 - viewer:1_TabItem')", 20000)
301     test.compare(findObject(":VTK scene:1 - viewer:1_TabItem").enabled, True)
302     test.compare(findObject(":VTK scene:1 - viewer:1_TabItem").text, "VTK scene:1 - viewer:1")
303
304     # 20. Show Immersible zone_2
305     activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_2", "Show")
306
307     # 21. Fit all
308     fitAll()
309
310     # 22. Check the result:
311     test.vp("VP8")
312
313
314 """
315 Color of immersible zone.
316 """
317 def S4():
318     
319     # Title 4: Color of immersible zone.
320     
321     # 1. Activate OCC 3D view
322     clickTab(waitForObject(":SALOME *_QtxWorkstackTabBar"), "OCC scene:1 - viewer:1")
323        
324     # 2. Show Immersible zone_1
325     activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_1", "Show")
326     
327     # 3. Call its context menu - Color:
328     activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_1", "Color")
329         
330     # 4. Click the button to select filling color
331     doubleClick(waitForObject(":Set color.Color_HYDROGUI_ColorWidget"), 43, 7, 0, Qt.LeftButton)
332      
333     # 5. "Select color" dialog appears:
334     color_dlg1 = waitForObject(":Select Color_QColorDialog")
335     test.compare(color_dlg1.visible, True)
336     test.compare(color_dlg1.windowTitle, "Select Color")
337     
338     # 6. Select green color and click OK
339     mouseClick(waitForObject(":Basic colors_QWellArray"), 184, 11, 0, Qt.LeftButton)
340     clickButton(waitForObject(":Select Color.OK_QPushButton"))
341     
342     # 7. Selected color appears in "Filling color" field
343     test.vp("VP10")
344     
345     # 8. Check Border check box
346     mouseClick(waitForObject(":Set color.Border_QGroupBox"), 17, 11, 0, Qt.LeftButton)
347     
348     # 9. Color button to select Border color becomes enabled
349     waitFor("object.exists(':Border.Color_HYDROGUI_ColorWidget')", 20000)
350     test.compare(findObject(":Border.Color_HYDROGUI_ColorWidget").enabled, True)
351         
352     # 10. Click the button to select border color
353     doubleClick(waitForObject(":Border.Color_HYDROGUI_ColorWidget"), 76, 9, 0, Qt.LeftButton)
354     
355     # 11. "Select color" dialog appears
356     color_dlg2 = waitForObject(":Select Color_QColorDialog")
357     test.compare(color_dlg2.visible, True)
358     test.compare(color_dlg2.windowTitle, "Select Color")
359     
360     # 12. Select yellow color and click OK
361     mouseClick(waitForObject(":Basic colors_QWellArray"), 214, 89, 0, Qt.LeftButton)
362     clickButton(waitForObject(":Select Color.OK_QPushButton"))
363     
364     # 13. Selected color appears in Border field
365     test.vp("VP11")
366     
367     # 14. Click Cancel button
368     clickButton(waitForObject(":Set color.Cancel_QPushButton"))
369     
370     # 15. No changes with Immersible zone_1 appear
371     deselectAll()
372     test.vp("VP2") 
373     
374     # 16. Repeat steps 3-13
375     activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_1", "Color")
376     doubleClick(waitForObject(":Set color.Color_HYDROGUI_ColorWidget"), 43, 7, 0, Qt.LeftButton)
377     mouseClick(waitForObject(":Basic colors_QWellArray"), 184, 11, 0, Qt.LeftButton)
378     clickButton(waitForObject(":Select Color.OK_QPushButton"))
379     mouseClick(waitForObject(":Set color.Border_QGroupBox"), 17, 11, 0, Qt.LeftButton)
380     doubleClick(waitForObject(":Border.Color_HYDROGUI_ColorWidget"), 76, 9, 0, Qt.LeftButton)
381     mouseClick(waitForObject(":Basic colors_QWellArray"), 214, 89, 0, Qt.LeftButton)
382     clickButton(waitForObject(":Select Color.OK_QPushButton"))
383   
384     # 17. Click OK in "set color" dialog
385     clickButton(waitForObject(":Set color.OK_QPushButton"))
386     
387     # 18. Check the result:
388     deselectAll()
389     test.vp("VP12")
390
391
392 """
393 Delete immersible zone.
394 """
395 def S5():
396     
397     # Title 5: Delete immersible zone.
398     
399     # 1. Select "Immersible zone_1"
400     # 2. Call context menu - Delete
401     activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_1", "Delete")
402   
403     # 3. Delete objects" dialog appear
404     delete_dlg = waitForObject(":Delete objects_HYDROGUI_DeleteDlg")
405     test.compare(str(delete_dlg.windowTitle), "Delete objects")
406     objects_list_text = waitForObject(":Delete objects_QTextEdit")
407     test.compare(objects_list_text.plainText, "- Immersible zone_1")
408     
409     # 4. Click No
410     clickButton(waitForObject(":Delete objects.No_QPushButton"))
411     
412     # 5. Nothing happens (Immersible zone_1 is still displayed in the view and presented in Object browser)
413     deselectAll()
414     test.vp("VP12")
415     checkOBItem("HYDRO", "NATURAL OBJECTS", "Immersible zone_1")
416         
417     # 6. Select Immersible zone_1
418     # 7. Call context menu - Delete
419     activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_1", "Delete")
420     
421     # 8. Delete objects" dialog appear
422     waitForObject(":Delete objects_HYDROGUI_DeleteDlg")
423     
424     # 9. Click Yes
425     clickButton(waitForObject(":Delete objects.Yes_QPushButton"))
426     
427     # 10. Immersible zone_1 disappear as from OCC view as far from Object browser
428     checkOBItemNotExists("HYDRO", "NATURAL OBJECTS", "Immersible zone_1")
429     test.vp("vp_empty_occ_view")
430         
431     # 11. Click Undo button
432     clickButton(waitForObject(":SALOME *.Undo_QToolButton"))
433     deselectAll()
434     
435     test.vp("VP12")
436     checkOBItem("HYDRO", "NATURAL OBJECTS", "Immersible zone_1")
437         
438     # 12. Select Immersible zone_1 and Immersible zone_2
439     # 13. Click Delete button
440     selectObjectBrowserItem("Immersible zone_1", "HYDRO.NATURAL OBJECTS")
441     selectObjectBrowserItem("Immersible zone_2", "HYDRO.NATURAL OBJECTS", modifier=Qt.ControlModifier)
442     type(waitForObject(":SALOME_STD_TabDesktop"), "<Del>")
443     
444     # 14. Delete objects dialog appears:
445     waitForObject(":Delete objects_HYDROGUI_DeleteDlg")
446     objects_list_text = waitForObject(":Delete objects_QTextEdit")
447     test.compare(objects_list_text.plainText, "- Immersible zone_1\n- Immersible zone_2")
448     
449     # 15. Click Yes
450     clickButton(waitForObject(":Delete objects.Yes_QPushButton"))
451     
452     # 16. Both immersible zones disappear from OCC view and Object browser
453     checkOBItemNotExists("HYDRO", "NATURAL OBJECTS", "Immersible zone_1")
454     checkOBItemNotExists("HYDRO", "NATURAL OBJECTS", "Immersible zone_2")
455     test.vp("vp_empty_occ_view")
456     
457