@@ -97,6 +97,9 @@ def test_with_live_preview(self):
9797 dlg .line_tool .canvasReleaseEvent (self .map_release (0 , 0 , Qt .LeftButton ))
9898 # click on canvas at [5, 5]
9999 dlg .line_tool .canvasReleaseEvent (self .map_release (5 , 5 , Qt .LeftButton ))
100+ dlg .line_tool .canvasReleaseEvent (self .map_release (5 , 0 , Qt .LeftButton ))
101+ dlg .line_tool .canvasReleaseEvent (self .map_release (0 , 5 , Qt .LeftButton ))
102+ dlg .line_tool .canvasReleaseEvent (self .map_release (10 , 0 , Qt .LeftButton ))
100103
101104 self .assertEqual (
102105 dlg .routing_fromline_list .item (0 ).text (), "Point 0: -123.384059, 48.448463"
@@ -111,22 +114,39 @@ def test_with_live_preview(self):
111114 dlg .line_tool .canvasReleaseEvent (self .map_release (0 , 5 , Qt .RightButton ))
112115 self .assertTrue (dlg .isVisible ())
113116 # Test that right click doesn't create a point
114- self .assertEqual (dlg .routing_fromline_list .count (), 2 )
117+ self .assertEqual (dlg .routing_fromline_list .count (), 5 )
115118
116119 # click on canvas at [10, 10]
117120 # Check that the click with an open dlg doesn't create an entry
118121 dlg .line_tool .canvasReleaseEvent (self .map_release (10 , 10 , Qt .LeftButton ))
119- self .assertEqual (dlg .routing_fromline_list .count (), 2 )
122+ self .assertEqual (dlg .routing_fromline_list .count (), 5 )
123+
124+ # test whether point order remains valid when selected points are deleted from QListWidget
125+ dlg .routing_fromline_list .setCurrentRow (1 )
126+ dlg .routing_fromline_clear .clicked .emit ()
127+
128+ # click again after deletion
129+ QTest .mouseClick (dlg .routing_fromline_map , Qt .LeftButton )
130+ self .assertFalse (dlg .isVisible ())
131+ dlg .line_tool .canvasReleaseEvent (self .map_release (10 , 10 , Qt .LeftButton ))
132+
133+ # Right click and thus show dlg
134+ dlg .line_tool .canvasReleaseEvent (self .map_release (0 , 5 , Qt .RightButton ))
135+ self .assertTrue (dlg .isVisible ())
136+
137+ self .assertEqual (dlg .routing_fromline_list .count (), 5 )
138+ numbers = [int (i .document ().toPlainText ()) for i in dlg .annotations ]
139+ self .assertTrue (numbers == list (range (numbers [0 ], numbers [0 ] + len (numbers ))))
120140
121141 # Disable live preview
122142 dlg .toggle_preview .toggle ()
123143 self .assertFalse (dlg .toggle_preview .isChecked ())
124144
125- # Check rubber band has only 2 vertices
126- self .assertEqual (dlg .routing_fromline_list .count (), 2 )
145+ # Check rubber band has only 5 vertices
146+ self .assertEqual (dlg .routing_fromline_list .count (), 5 )
127147 self .assertEqual (type (dlg .rubber_band ), QgsRubberBand )
128148 len_rubber_band = len (dlg .rubber_band .asGeometry ().asPolyline ())
129- self .assertEqual (len_rubber_band , 2 )
149+ self .assertEqual (len_rubber_band , 5 )
130150
131151 # Click Add Vertices again
132152 QTest .mouseClick (dlg .routing_fromline_map , Qt .LeftButton )
@@ -135,7 +155,7 @@ def test_with_live_preview(self):
135155 # continue digitization
136156 # click on canvas at [10, 5]
137157 dlg .line_tool .canvasReleaseEvent (self .map_release (10 , 5 , Qt .LeftButton ))
138- self .assertEqual (dlg .routing_fromline_list .count (), 3 )
158+ self .assertEqual (dlg .routing_fromline_list .count (), 6 )
139159
140160 # Double click and thus show dlg
141161 dlg .line_tool .canvasDoubleClickEvent (self .map_dclick (0 , 5 , Qt .LeftButton ))
0 commit comments