2 This test case corresponds to HYDRO-003 (Immersible zone creation/edition and operations with it) scenario
12 TEST_FILES_DIR = os.getenv("TEST_FILES_DIR")
15 APPSETTINGS = os.path.join(TEST_FILES_DIR, "SalomeApp.xml")
17 source(os.path.join(os.getenv("COMMON_SCRIPT_DIR"), "common_hydro.py"))
20 os.system("killSalome.py") #@MZN
24 os.system("killSalome.py")
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
39 # Title 1: Creating a new study
41 # 1. Start the application
42 startApplication("runSalome.py --modules=HYDRO,GEOM,SMESH -r %s" % APPSETTINGS)
43 waitFor("object.exists(':SALOME_STD_TabDesktop')", 100000)
46 activateMenuItem("File", "New")
48 # 3. New study window appears including Object Browser and Python console
52 # 4. Select HYDRO in the list of modules, located in the toolbar
53 # 5. Graphics scene and OCC scene appear
56 showTrihedron(False) # Hide trihedron
60 Create immersible zone.
64 # Title 2: Create immersible zone
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")
71 importBathymetry(bath_file_path)
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")
78 # 6. Click "Fit All" button to observe imported bathymetry
81 # Check the bathymetry presentation in OCC viewer
84 # Hide bathymetry presentation
85 activateOBContextMenuItem("HYDRO.BATHYMETRIES", "IGN_pts_utiles_L2e_1", "Hide")
88 # 7. HYDRO - Create polyline
89 activateMenuItem("HYDRO", "Create polyline")
91 # 8. Create the polyline as follows:
92 addSplineSection(True)
94 addPolylinePoints([(621, 298), (571, 347), (620, 399), (721, 439), (812, 413), (839, 284), (699, 151)])
96 clickButton(waitForObject(":Create polyline.Apply_QPushButton"))
98 # 9. HYDRO - Create immersible zone
99 activateMenuItem("HYDRO", "Create immersible zone")
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")
107 # Check that default name is "Immersible zone_1"
108 test.compare(str(waitForObject(":Zone name.Name_QLineEdit").displayText), "Immersible zone_1")
110 # 11. As polyline select created in step 8 polyline
111 selectComboBoxItem(waitForObject(":Parameters.Polyline_QComboBox"), "Polyline_1")
113 # 12. As bathymetry select imported in step 3 bathymetry
114 selectComboBoxItem(waitForObject(":Bathymetry_QComboBox"), "IGN_pts_utiles_L2e_1")
117 clickButton(waitForObject(":Create immersible zone.Apply_QPushButton"))
119 # 14. Check the result
120 activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_1", "Show only")
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)
127 # 16. Create the polyline as follows:
130 activateMenuItem("HYDRO", "Create polyline")
132 addSplineSection(True)
133 addPolylinePoints([(827, 188), (650, 191), (495, 283), (441, 397), (515, 528), (755, 442), (769, 367)])
135 addSplineSection(True)
136 addPolylinePoints([(543, 380), (508, 431), (514, 489), (569, 469), (598, 413), (619, 388)])
138 addSplineSection(True)
139 addPolylinePoints([(696, 222), (762, 214), (798, 233), (773, 293), (693, 322)])
141 clickButton(waitForObject(":Create polyline.Apply_QPushButton"))
143 # 17. Create any open polyline. It has name "Polyline_3"
144 activateMenuItem("HYDRO", "Create polyline")
146 addPolylineSection(False)
147 addPolylinePoints([(368, 504), (525, 348), (830, 375), (954, 299)])
149 waitFor("object.exists(':Create polyline.Name_QLineEdit')", 20000)
150 test.compare(str(findObject(":Create polyline.Name_QLineEdit").displayText), "Polyline_3")
152 clickButton(waitForObject(":Create polyline.Apply_QPushButton"))
156 # 18. In Object browser select "NATURAL OBJECTS" item, call its context menu - Create immersible zone
157 activateOBContextMenuItem("HYDRO", "NATURAL OBJECTS", "Create immersible zone")
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")
164 # Check that the name is "Immersible zone_2" now
165 test.compare(str(waitForObject(":Zone name.Name_QLineEdit").displayText), "Immersible zone_2")
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"])
171 # As polyline select created in step 16 polyline.
172 selectComboBoxItem(poly_combo, "Polyline_2")
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"])
178 # As bathymetry select imported in step 3 bathymetry.
179 selectComboBoxItem(bath_combo, "IGN_pts_utiles_L2e_1")
181 # 22. Check the preview:
185 # 23. Click "Cancel" button
186 clickButton(waitForObject(":Create immersible zone.Cancel_QPushButton"))
188 # 24. No object has been created
189 checkOBItemNotExists("HYDRO", "NATURAL OBJECTS", "Immersible zone_2")
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")
197 clickButton(waitForObject(":Create immersible zone.Apply_QPushButton"))
199 # 27. Check the result
203 # 28. Create polyline, containing from polyline section and from spline section:
204 # 29. End points of sectors should have identical coordinates
207 activateMenuItem("HYDRO", "Create polyline")
209 start_point = (570, 130)
210 end_point = (880, 310)
212 addPolylineSection(False)
213 addPolylinePoints([start_point, end_point])
215 addSplineSection(False)
216 addPolylinePoints([start_point, (510, 220), (600, 260), (600, 410), end_point])
218 clickButton(waitForObject(":Create polyline.Apply_QPushButton"))
220 # 30. HYDRO - Create immersible zone
221 activateMenuItem("HYDRO", "Create immersible zone")
223 # 31. Select just created "Polyline_4" in "Polyline" combo box
224 selectComboBoxItem(waitForObject(":Parameters.Polyline_QComboBox"), "Polyline_4")
226 # 32. Select any bathymetry
227 selectComboBoxItem(waitForObject(":Bathymetry_QComboBox"), "inverted_IGN_pts_utiles_L2e_1")
230 clickButton(waitForObject(":Create immersible zone.Apply_QPushButton"))
232 # 34. Check the result
233 activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_3", "Show only")
239 Show/hide immersible zone.
243 # Title 3: Show/hide immersible zone.
245 # 1. Activate OCC 3D view
247 # Already active: do nothing
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")
256 # 5. Only "Immersible zone_1" is shown in OCC view
259 # 6. Call context menu - Hide
260 activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_1", "Hide")
262 # 7. "Immersible zone_1" is hidden in OCC view
263 test.vp("vp_empty_occ_view")
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")
273 # 11. Both immersible zones are shown in OCC 3D view
276 # 12. Call context menu - Hide all
277 activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_1", "Hide all")
279 # 13. Both immersible zones are hidden in OCC 3D view
280 test.vp("vp_empty_occ_view")
282 # 14. Window - New window - Graphics view
283 activateMenuItem("Window", "New Window", "Graphics view")
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)
290 # 16. Show Immersible zone_1
291 activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_1", "Show")
293 # 17. Nothing is shown
296 # 18. Window - New window - VTK 3D view
297 activateMenuItem("Window", "New Window", "VTK 3D view")
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")
304 # 20. Show Immersible zone_2
305 activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_2", "Show")
310 # 22. Check the result:
315 Color of immersible zone.
319 # Title 4: Color of immersible zone.
321 # 1. Activate OCC 3D view
322 clickTab(waitForObject(":SALOME *_QtxWorkstackTabBar"), "OCC scene:1 - viewer:1")
324 # 2. Show Immersible zone_1
325 activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_1", "Show")
327 # 3. Call its context menu - Color:
328 activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_1", "Color")
330 # 4. Click the button to select filling color
331 doubleClick(waitForObject(":Set color.Color_HYDROGUI_ColorWidget"), 43, 7, 0, Qt.LeftButton)
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")
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"))
342 # 7. Selected color appears in "Filling color" field
345 # 8. Check Border check box
346 mouseClick(waitForObject(":Set color.Border_QGroupBox"), 17, 11, 0, Qt.LeftButton)
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)
352 # 10. Click the button to select border color
353 doubleClick(waitForObject(":Border.Color_HYDROGUI_ColorWidget"), 76, 9, 0, Qt.LeftButton)
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")
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"))
364 # 13. Selected color appears in Border field
367 # 14. Click Cancel button
368 clickButton(waitForObject(":Set color.Cancel_QPushButton"))
370 # 15. No changes with Immersible zone_1 appear
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"))
384 # 17. Click OK in "set color" dialog
385 clickButton(waitForObject(":Set color.OK_QPushButton"))
387 # 18. Check the result:
393 Delete immersible zone.
397 # Title 5: Delete immersible zone.
399 # 1. Select "Immersible zone_1"
400 # 2. Call context menu - Delete
401 activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_1", "Delete")
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")
410 clickButton(waitForObject(":Delete objects.No_QPushButton"))
412 # 5. Nothing happens (Immersible zone_1 is still displayed in the view and presented in Object browser)
415 checkOBItem("HYDRO", "NATURAL OBJECTS", "Immersible zone_1")
417 # 6. Select Immersible zone_1
418 # 7. Call context menu - Delete
419 activateOBContextMenuItem("HYDRO.NATURAL OBJECTS", "Immersible zone_1", "Delete")
421 # 8. Delete objects" dialog appear
422 waitForObject(":Delete objects_HYDROGUI_DeleteDlg")
425 clickButton(waitForObject(":Delete objects.Yes_QPushButton"))
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")
431 # 11. Click Undo button
432 clickButton(waitForObject(":SALOME *.Undo_QToolButton"))
436 checkOBItem("HYDRO", "NATURAL OBJECTS", "Immersible zone_1")
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>")
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")
450 clickButton(waitForObject(":Delete objects.Yes_QPushButton"))
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")