Skip to content

Commit 932bb81

Browse files
committed
feat: test for annotation order after selective deletion and readding of vertices
1 parent c5d41fc commit 932bb81

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

tests/test_gui.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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,41 @@ 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+
print("laokdndfla" + str(numbers))
140+
ordered = numbers == list(range(numbers[0], numbers[0] + len(numbers)))
141+
self.assertTrue(ordered)
120142

121143
# Disable live preview
122144
dlg.toggle_preview.toggle()
123145
self.assertFalse(dlg.toggle_preview.isChecked())
124146

125147
# Check rubber band has only 2 vertices
126-
self.assertEqual(dlg.routing_fromline_list.count(), 2)
148+
self.assertEqual(dlg.routing_fromline_list.count(), 5)
127149
self.assertEqual(type(dlg.rubber_band), QgsRubberBand)
128150
len_rubber_band = len(dlg.rubber_band.asGeometry().asPolyline())
129-
self.assertEqual(len_rubber_band, 2)
151+
self.assertEqual(len_rubber_band, 5)
130152

131153
# Click Add Vertices again
132154
QTest.mouseClick(dlg.routing_fromline_map, Qt.LeftButton)
@@ -135,7 +157,7 @@ def test_with_live_preview(self):
135157
# continue digitization
136158
# click on canvas at [10, 5]
137159
dlg.line_tool.canvasReleaseEvent(self.map_release(10, 5, Qt.LeftButton))
138-
self.assertEqual(dlg.routing_fromline_list.count(), 3)
160+
self.assertEqual(dlg.routing_fromline_list.count(), 6)
139161

140162
# Double click and thus show dlg
141163
dlg.line_tool.canvasDoubleClickEvent(self.map_dclick(0, 5, Qt.LeftButton))

0 commit comments

Comments
 (0)