2 This test case corresponds to HYDRO-002 (Polyline 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() # Create polyline using Addition and Detection modes
30 S4() # Show/hide polyline
31 S5() # Delete polyline
32 S6() # Change local CS
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 polyline using Addition and Detection modes.
64 # Title 2: Create polyline using Addition and Detection modes
66 # 1. HYDRO - Create polyline
67 activateMenuItem("HYDRO", "Create polyline")
70 # 2. "Create polyline" panel appears. Check that default name is "Polyline_1"
71 panel = waitForObject(":SALOME *.Create polyline_HYDROGUI_PolylineDlg")
72 test.compare(str(panel.windowTitle), "Create polyline")
74 name_edit = waitForObject(":Create polyline.Name_QLineEdit")
75 test.compare(str(name_edit.text), "Polyline_1")
77 # 3. Type name "MyPolyline" in the "Name" section
78 setInputFieldValue(name_edit, "MyPolyline")
80 # 4. Click "Insert new section" button
81 new_section_btn = waitForObject(":Sections.New section_QToolButton")
82 clickButton(new_section_btn)
84 # 5. "Add element" panel appears. Check that default name is "Section_1":
85 add_panel = waitForObject(":Create polyline.Add element_QGroupBox")
86 test.compare(str(add_panel.title), "Add element")
88 section_name_edit = waitForObject(":Add element.Name_QLineEdit")
89 test.compare(str(section_name_edit.text), "Section_1")
91 # Click Cancel button - no changes in Sections list
92 sections_list_name = ":Sections.Sections_CurveCreator_TreeView"
93 waitFor("object.exists(':Sections.Sections_CurveCreator_TreeView')", 20000)
94 sections_list = findObject(sections_list_name)
96 test.compare(getTreeNames(sections_list), [])
97 clickButton(waitForObject(":Create polyline.Cancel_QPushButton"))
98 test.compare(getTreeNames(sections_list), [])
100 # 7. Click "Insert new section" button
101 clickButton(new_section_btn)
103 # 8. Click Add button
104 clickButton(waitForObject(":Add element.Add_QPushButton"))
106 # 9. Click "Insert new section" button
107 clickButton(new_section_btn)
109 # 10. Remove the tick in "Closed" checkbox
110 setButtonChecked(waitForObject(":Add element.Closed_QCheckBox"), False)
112 # 11. Type name "Open_polyline"
113 setInputFieldValue(waitForObject(":Add element.Name_QLineEdit"), "Open_polyline")
115 # 12. Click "Add" button
116 clickButton(waitForObject(":Add element.Add_QPushButton"))
118 # 13. Click "Insert new section" button
119 clickButton(new_section_btn)
121 # 14. As Type select Spline
122 selectComboBoxItem(waitForObject(":Add element.Type_QComboBox"), "Spline")
124 # 15. Type name "Closed_spline"
125 setInputFieldValue(waitForObject(":Add element.Name_QLineEdit"), "Closed_spline")
127 # 16. Click "Add" button
128 clickButton(waitForObject(":Add element.Add_QPushButton"))
130 # 17. Click "Insert new section" button
131 clickButton(new_section_btn)
133 # 18. As Type select Spline
134 selectComboBoxItem(waitForObject(":Add element.Type_QComboBox"), "Spline")
136 # 19. Remove the tick in "Closed" checkbox
137 setButtonChecked(waitForObject(":Add element.Closed_QCheckBox"), False)
139 # 20. Type name "Open_spline"
140 setInputFieldValue(waitForObject(":Add element.Name_QLineEdit"), "Open_spline")
142 # 21. Click "Add" button
143 clickButton(waitForObject(":Add element.Add_QPushButton"))
145 # 22. Double click on "Section_1" object
146 doubleClickObjectItem(sections_list_name, "Section_1")
148 # 23. "Edit element" panel appears:
149 edit_element_panel = waitForObject(":Create polyline.Edit element_QGroupBox")
150 test.compare(str(edit_element_panel.title), "Edit element")
152 # 24. Type new name "Closed_polyline" and click OK button
153 setInputFieldValue(waitForObject(":Edit element.Name_QLineEdit"), "Closed_polyline")
154 clickButton(waitForObject(":Edit element.Ok_QPushButton"))
156 # 25. Check the list of sections, located inside "Create polyline" panel. each type of sections has own label:
157 sections_list.clearSelection()
160 # 26. Select "Closed_polyline" and click "Addition mode" button
161 clickObjectItem(sections_list_name, "Closed_polyline")
162 clickButton(waitForObject(":Sections.Addition mode_QToolButton"))
164 # 27. Create polyline consisting of 5 points
165 five_points = [(452, 134), (617, 71), (853, 100), (829, 193), (579, 172)]
166 addPolylinePoints(five_points)
168 # 28. Select "Open_polyline" and create polyline in OCC viewer consisting form 3 points
169 clickObjectItem(sections_list_name, "Open_polyline")
171 three_points = [(421, 280), (642, 243), (806, 295)]
172 addPolylinePoints(three_points)
174 # 29. Select "Closed_spline" and create spline in OCC viewer consisting form 4 points
175 clickObjectItem(sections_list_name, "Closed_spline")
177 four_points = [(422, 409), (537, 382), (770, 390), (751, 474)]
178 addPolylinePoints(four_points)
180 # 30. Select "Open_spline" and create spline in OCC viewer consisting form 6 points
181 clickObjectItem(sections_list_name, "Open_spline")
183 six_points = [(377, 598), (436, 567), (535, 599), (622, 578), (679, 606), (772, 581)]
184 addPolylinePoints(six_points)
186 # 31. Check the result:
187 test.vp("VP2") # OCC viewer
189 sections_list.clearSelection()
190 test.vp("VP3") # Sections list widget
192 # 31. Click Undo button 10 times
193 for i in range(1, 11):
194 clickButton(waitForObject(":Sections.Undo_QToolButton"))
196 # 33. Check that "Closed_spline" and "Open_spline" don't contain points now
198 #waitFor("object.exists(':Sections.0_QModelIndex')", 20000)
199 #test.compare(findObject(":Sections.0_QModelIndex").text, "0")
200 #waitFor("object.exists(':Sections.Open_spline_QModelIndex')", 20000)
201 #test.compare(findObject(":Sections.Open_spline_QModelIndex").text, "Open_spline")
202 #waitFor("object.exists(':Sections.0_QModelIndex_2')", 20000)
203 #test.compare(findObject(":Sections.0_QModelIndex_2").row, 3)
204 #Test.compare(findObject(":Sections.0_QModelIndex_2").column, 1)
205 #test.compare(findObject(":Sections.0_QModelIndex_2").text, "0")
207 # 34. Click Redo button 10 times
208 for i in range(1, 11):
209 clickButton(waitForObject(":Sections.Redo_QToolButton"))
211 # 35. Click Apply button
212 clickButton(waitForObject(":Create polyline.Apply_QPushButton"))
214 # 36. "MyPolyline" object appears in Object Browser as a child of "POLYLINES" branch
215 checkOBItem("HYDRO", "POLYLINES", "MyPolyline")
217 # CREATION OF POLYLINE WITH HELP OF DETECTION MODE: TO BE DONE
225 # Title 3: Edit polyline
227 # 1. Select "MyPolyline" in Object browser
228 # 2. Call its context menu - Edit polyline
229 activateOBContextMenuItem("HYDRO.POLYLINES", "MyPolyline", "Edit polyline")
231 # 3. "Edit" polyline panel appears:
232 panel = waitForObject(":SALOME *.Edit polyline_HYDROGUI_PolylineDlg")
233 test.compare(str(panel.windowTitle), "Edit polyline")
235 sections_list_name = ":Sections.Sections_CurveCreator_TreeView_2"
236 sections_list = waitForObject(sections_list_name)
238 # 4. Type new name "Polyline_1"
239 setInputFieldValue(waitForObject(":Edit polyline.Name_QLineEdit"), "Polyline_1")
241 # 5. Select "Open_polyline" section
242 clickObjectItem(sections_list, "Open_polyline")
244 # 6. Click "Remove" button
245 mouseDrag(waitForObject(":SALOME_STD_TabDesktop"), 1649, 420, -64, 1, 1, Qt.LeftButton) #TODO: resize the panel in another way
246 clickButton(waitForObject(":Sections.Remove_QToolButton"))
248 # 7. "Open_polyline" object disappears from the list of sections
249 #TODO: check list of sections context
251 # 8. Select "Closed_spline" and "Open_spline" objects in Sections panel
252 clickObjectItem(sections_list, "Closed_spline")
253 clickObjectItem(sections_list, "Open_spline", Qt.ControlModifier)
255 # 9. Click "Join selected sections" button
256 clickButton(waitForObject(":Sections.Join_QToolButton"))
258 # 10. New section, consisting from 10 points appears in the list of sections
259 #TODO: check than "Closed_spline" appears and consists of 10 points
261 # 11. Click Undo button 2 times
262 clickButton(waitForObject(":Sections.Undo_QToolButton_2"))
263 clickButton(waitForObject(":Sections.Undo_QToolButton_2"))
265 # 12. Check that all 4 sections are in the list like in step 3.3
266 sections_list.clearSelection()
267 test.vp("VP7") # Sections list widget
269 # 13. Activate Modification mode by clicking corresponding button
270 clickButton(waitForObject(":Sections.Modification mode_QToolButton"))
272 # 14. Select some point in OCC view and drag it to another position
273 occMouseClick(452, 137)
274 occMouseDrag(452, 137, 77, -115)
276 # 15. Repeat previous step with each section
277 occMouseClick(642, 244)
278 occMouseDrag(642, 244, -180, 86)
279 occMouseClick(754, 477)
280 occMouseDrag(752, 477, 119, 37)
281 occMouseClick(619, 577)
282 occMouseDrag(621, 581, -15, 74)
284 # 16. Click on the segment of the sector - new points have been created and appeared on the place, where you click
285 occMouseClick(10, 10) # clear point selection
287 # Add 3 points to "Closed_polyline"
288 occMouseClick(723, 87)
289 occMouseClick(649, 180)
290 occMouseClick(841, 148)
292 occMouseClick(10, 10) # clear point selection
295 # 17. Check that the number of points, located in the modified sector increases after each point addition
296 #TODO: Check number of pointsin "Closed_polyline" increases from 5 to 8
298 # 18. Add some points to each sector. Check the result - as old representations of sectors are shown as far as new representations:
299 occMouseClick(619, 315) # Add point to "Open_polyline"
300 occMouseClick(563, 503) # Add point to "Closed_spline"
301 occMouseClicks([(567, 629), (652, 631)]) # Add 2 points to "Open_spline"
303 occMouseClick(10, 10) # clear point selection
306 # 19. Click Apply button
307 clickButton(waitForObject(":Edit polyline.Apply_QPushButton"))
309 # 20. Modified object "Polyline_1" has appeared in Object browser and in OCC view
310 checkOBItemNotExists("HYDRO", "POLYLINES", "MyPolyline")
311 checkOBItem("HYDRO", "POLYLINES", "Polyline_1")
314 test.vp("VP6") # OCC view
316 # 21. Select "MyPolyline" in Object browser
317 # 22. Call its context menu - Edit polyline
318 activateOBContextMenuItem("HYDRO.POLYLINES", "Polyline_1", "Edit polyline")
320 # 23. "Edit" polyline panel appears:
321 panel = waitForObject(":SALOME *.Edit polyline_HYDROGUI_PolylineDlg")
323 waitFor("object.exists(':Sections.Sections_CurveCreator_TreeView')", 20000)
324 sections_list = findObject(sections_list_name)
326 # 24. Activate Modification mode
327 clickButton(waitForObject(":Sections.Modification mode_QToolButton"))
329 # 25. Select all points from "Closed_polyline" except 4 points on the right with the help of rectangle
330 occMouseDrag(513, 0, 195, 205)
331 # occMouseDrag(511, 11, 204, 196) #MZN
333 # 26. Click Remove button
334 clickButton(waitForObject(":Sections.Remove_QToolButton"))
336 # 27. Select remaining 4 points
337 occMouseDrag(730, 45, 240, 190)
338 #occMouseDrag(690, 63, 176, 152) #MZN
340 # 28. Table with coordinates appears. Input following coordinates:
341 table_name = ":Sections_CurveCreator_TableView"
342 waitFor("object.exists(':Sections_CurveCreator_TableView')", 20000)
343 test.compare(findObject(table_name).visible, True)
345 doubleClickObjectItem(table_name, "0/2")
346 setInputFieldValue(waitForObject(":_QtxDoubleSpinBox"), "155")
348 doubleClickObjectItem(table_name, "0/3")
349 setInputFieldValue(waitForObject(":_QtxDoubleSpinBox_2"), "704")
351 doubleClickObjectItem(table_name, "1/2")
352 setInputFieldValue(waitForObject(":_QtxDoubleSpinBox_3"), "340")
354 doubleClickObjectItem(table_name, "1/3")
355 setInputFieldValue(waitForObject(":_QtxDoubleSpinBox_4"), "704")
357 doubleClickObjectItem(table_name, "2/2")
358 setInputFieldValue(waitForObject(":_QtxDoubleSpinBox_5"), "340")
360 doubleClickObjectItem(table_name, "2/3")
361 setInputFieldValue(waitForObject(":_QtxDoubleSpinBox_6"), "530")
363 doubleClickObjectItem(table_name, "3/2")
364 setInputFieldValue(waitForObject(":_QtxDoubleSpinBox_7"), "155")
366 doubleClickObjectItem(table_name, "3/3")
367 setInputFieldValue(waitForObject(":_QtxDoubleSpinBox_8"), "530")
369 type(waitForObject(":_QtxDoubleSpinBox_8"), "<Tab>")
371 # 29. Check the result:
372 occMouseClick(10, 10) # clear point selection
377 # 30. Select "Closed_spline" in Sections table, call context menu - Set open
378 openItemContextMenu(waitForObject(sections_list_name), "Closed\\_spline", 73, 12, 0)
379 activateItem(waitForObjectItem(":SALOME *_QMenu", "Set open"))
381 # 31. Section has became open as in OCC viewer as far in Sections table
382 activateOBContextMenuItem("HYDRO.POLYLINES", "Polyline_1", "Hide") # hide the edited polyline
384 test.vp("VP9") # OCC view
386 sections_list.clearSelection()
387 test.vp("VP10") # Sections list
389 # 32. Activate Modification mode
390 clickButton(waitForObject(":Sections.Modification mode_QToolButton"))
392 # 33. Select "Closed_spline" section and call its context menu
394 openItemContextMenu(waitForObject(sections_list_name), "Closed\\_spline", 73, 12, 0)
395 activateItem(waitForObjectItem(":SALOME *_QMenu", "Set polyline"))
397 # 35. Section has become polyline:
398 test.vp("VP11") # OCC view
400 sections_list.clearSelection()
401 test.vp("VP12") # Sections list
403 # 36. Click Cancel button in "Edit polyline" panel
404 clickButton(waitForObject(":Edit polyline.Cancel_QPushButton"))
406 # 37. Select Polyline_1 in Object browser
407 # 38. Call context menu - Edit polyline
408 activateOBContextMenuItem("HYDRO.POLYLINES", "Polyline_1", "Edit polyline")
414 clickButton(waitForObject(":Edit polyline.Cancel_QPushButton"))
421 # Title 4: Show/hide polyline
423 # 1. Select "POLYLINES" in Object browser, call context menu - "Create polyline"
424 activateOBContextMenuItem("HYDRO", "POLYLINES", "Create polyline")
426 # 2. Create polyline, consisting from 1 closed polyline section, click Apply:
427 addPolylineSection(True)
428 addPolylinePoints([(515, 203), (661, 119), (759, 200), (814, 375), (630, 435), (449, 416)])
430 clickButton(waitForObject(":Create polyline.Apply_QPushButton"))
432 # 3. Select Polyline_1 in Object browser
433 # 4. Call context menu - Show only
434 activateOBContextMenuItem("HYDRO.POLYLINES", "Polyline_1", "Show only")
439 # 6. Only Polyline_1 is shown in OCC viewer
443 # 7. Select Polyline_2 in Object browser
444 # 8. Call context menu - Show
445 activateOBContextMenuItem("HYDRO.POLYLINES", "Polyline_2", "Show")
450 # 10. Both polylines are shown in OCC view
454 # 11. Call context menu in OCC viewer - Hide all
457 # 12. Nothing is shown in OCC view
458 test.vp("vp_empty_occ_view")
460 # 13. Call context menu in OCC viewer - Show all
463 # 14. Both polylines are shown in OCC view
467 # type(waitForObject(":SALOME_STD_TabDesktop"), "<Alt+K>") #TODO: <Alt+K> doesn't work
468 activateMenuItem("Window", "New Window", "VTK 3D view")
470 # 16. New VTK scene appears
471 waitFor("object.exists(':SALOME *.SVTK_RenderWindowInteractor_SVTK_RenderWindowInteractor')", 20000)
472 test.compare(findObject(":SALOME *.SVTK_RenderWindowInteractor_SVTK_RenderWindowInteractor").visible, True)
473 showTrihedron(False) # Hide trihedron
475 # 17. Select Polyline_1 in Object browser
476 # 18. Call context menu - Show only
477 activateOBContextMenuItem("HYDRO.POLYLINES", "Polyline_1", "Show only")
482 # 20. Only Polyline_1 is shown in VTK viewer
485 # 21. Select Polyline_2 in Object browser
486 # 22. Call context menu - Show
487 activateOBContextMenuItem("HYDRO.POLYLINES", "Polyline_2", "Show")
492 # 24. Both polylines are shown in VTK view
495 # 25. Call context menu in VTK viewer - Hide all
498 # 26. Nothing is shown in VTK view
499 test.vp("vp_empty_vtk_view")
501 # 27. Call context menu in VTK viewer - Show all
504 # 28. Both of polylines are shown in VTK view
513 # Title 5: Delete polyline
515 # 0. Activate OCC 3D view
516 clickTab(waitForObject(":SALOME *_QtxWorkstackTabBar"), "OCC scene:1 - viewer:1")
518 # 1. Select Polyline_1
519 # 2. Call context menu - Delete
520 activateOBContextMenuItem("HYDRO.POLYLINES", "Polyline_1", "Delete")
522 # 3. Delete objects" dialog appear
523 delete_dlg = waitForObject(":Delete objects_HYDROGUI_DeleteDlg")
524 test.compare(str(delete_dlg.windowTitle), "Delete objects")
525 objects_list_text = waitForObject(":Delete objects_QTextEdit")
526 test.compare(objects_list_text.plainText, "- Polyline_1")
529 clickButton(waitForObject(":Delete objects.No_QPushButton"))
535 checkOBItem("HYDRO", "POLYLINES", "Polyline_1")
537 # 6. Select Polyline_1
538 # 7. Call context menu - Delete
539 activateOBContextMenuItem("HYDRO.POLYLINES", "Polyline_1", "Delete")
541 # 8. Delete objects" dialog appear
542 waitForObject(":Delete objects_HYDROGUI_DeleteDlg")
545 clickButton(waitForObject(":Delete objects.Yes_QPushButton"))
547 # 10. Polyline_1 disappears as from OCC view as far from Object browser
548 checkOBItemNotExists("HYDRO", "POLYLINES", "Polyline_1")
551 # 11. Click Undo button
552 clickButton(waitForObject(":SALOME *.Undo_QToolButton"))
554 # 12. Polyline_1 appears in OCC view and Object browser
556 checkOBItem("HYDRO", "POLYLINES", "Polyline_1")
558 # 13. Select Polyline_1 and Polyline_2
559 selectObjectBrowserItem("Polyline_1", "HYDRO.POLYLINES")
560 selectObjectBrowserItem("Polyline_2", "HYDRO.POLYLINES", modifier=Qt.ControlModifier)
562 # 14. Click Delete button
563 type(waitForObject(":SALOME_STD_TabDesktop"), "<Del>")
565 # 15. Delete objects dialog appears:
566 waitForObject(":Delete objects_HYDROGUI_DeleteDlg")
567 objects_list_text = waitForObject(":Delete objects_QTextEdit")
568 test.compare(objects_list_text.plainText, "- Polyline_1\n- Polyline_2")
571 clickButton(waitForObject(":Delete objects.Yes_QPushButton"))
573 # 17. Both polylines disappear from OCC view and Object browser
574 checkOBItemNotExists("HYDRO", "POLYLINES", "Polyline_1")
575 checkOBItemNotExists("HYDRO", "POLYLINES", "Polyline_2")
576 test.vp("vp_empty_occ_view")
578 # 18. Click Undo button
579 clickButton(waitForObject(":SALOME *.Undo_QToolButton"))
581 # 19. Polyline_1 and Polyline_2 appear in OCC view and Object browser
583 checkOBItem("HYDRO", "POLYLINES", "Polyline_1")
584 checkOBItem("HYDRO", "POLYLINES", "Polyline_2")
592 # Title 6: Change local CS
594 # 1. Select Polyline_2
595 # 2. Call context menu - Show only
596 activateOBContextMenuItem("HYDRO.POLYLINES", "Polyline_2", "Show only")
598 # 3. Check local and global coordinates of bottom vertex of polyline
599 occMouseClick(798, 438)
601 lc1 = getLocalCoordinates()
602 gc1 = getGlobalCoordinates()
604 test.verify(lc1 == gc1)
606 # 4. HYDRO - Change local CS
607 activateMenuItem("HYDRO", "Change local CS")
609 # 5. Local CS transformation panel appears. Check that default LX=0, LY=0
610 cs_panel = waitForObject(":SALOME *.Local CS transformation_HYDROGUI_LocalCSDlg")
611 test.compare(str(cs_panel.windowTitle), "Local CS transformation")
613 lx_edit = waitForObject(":Local CS transformation.qt_spinbox_lineedit_QLineEdit")
614 test.compare(str(lx_edit.text), "0")
616 ly_edit = waitForObject(":Local CS transformation.qt_spinbox_lineedit_QLineEdit_2")
617 test.compare(str(ly_edit.text), "0")
619 # 6. Set LX=20000, LY=400
623 setInputFieldValue(lx_edit, lx)
624 setInputFieldValue(lx_edit, ly)
626 # 7. Check local and global coordinates of bottom vertex of polyline. Difference between values
627 # of local CS and global CS is equal to LX and LY
628 occMouseClick(798, 438)
630 lc2 = getLocalCoordinates()
631 gc2 = getGlobalCoordinates()
633 test.compare(gc2[0] - lc2[0], lx)
634 test.compare(gc2[1] - lc2[1], ly)