Index: ui/views/controls/table/table_view_unittest.cc |
diff --git a/ui/views/controls/table/table_view_unittest.cc b/ui/views/controls/table/table_view_unittest.cc |
index 2b991b0007943964fe44b33a2415d317e19d004f..e7d9f87fef474510b63479b66da42f4a8c5e27a6 100644 |
--- a/ui/views/controls/table/table_view_unittest.cc |
+++ b/ui/views/controls/table/table_view_unittest.cc |
@@ -34,6 +34,14 @@ class TableViewTestHelper { |
TableHeader* header() { return table_->header_; } |
+ void SetSelectionModel(const ui::ListSelectionModel& new_selection) { |
+ table_->SetSelectionModel(new_selection); |
+ } |
+ |
+ void OnFocus() { |
+ table_->OnFocus(); |
+ } |
+ |
private: |
TableView* table_; |
@@ -844,4 +852,19 @@ TEST_F(TableViewTest, MultiselectionWithSort) { |
table_->SetObserver(NULL); |
} |
+// Verifies we don't crash after removing the selected row when there is |
+// sorting and the anchor/active index also match the selected row. |
+TEST_F(TableViewTest, FocusAfterRemovingAnchor) { |
+ table_->ToggleSortOrder(0); |
+ |
+ ui::ListSelectionModel new_selection; |
+ new_selection.AddIndexToSelection(0); |
+ new_selection.AddIndexToSelection(1); |
+ new_selection.set_active(0); |
+ new_selection.set_anchor(0); |
+ helper_->SetSelectionModel(new_selection); |
+ model_->RemoveRow(0); |
+ helper_->OnFocus(); |
+} |
+ |
} // namespace views |