Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Unified Diff: ui/views/controls/table/table_view_unittest.cc

Issue 1129233006: Fixes possible crash in TableView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/table/table_view.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ui/views/controls/table/table_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698