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

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

Issue 2769243002: Adjust initial activation/focus Task Manager/Views TableView. (Closed)
Patch Set: sky review Created 3 years, 9 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
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 d72345c69be3b05b8091f9cbc9739b6697405dda..5c71032e61d3a05b052ff3180785be4c1ebe685b 100644
--- a/ui/views/controls/table/table_view_unittest.cc
+++ b/ui/views/controls/table/table_view_unittest.cc
@@ -1023,4 +1023,28 @@ TEST_F(TableViewTest, FocusAfterRemovingAnchor) {
helper_->OnFocus();
}
+// Tests that focusing the table will activate the first row, but only if
+// there's no active row.
+TEST_F(TableViewTest, InitialFocusActivatesFirstRow) {
+ EXPECT_EQ(-1, table_->selection_model().active());
+ helper_->OnFocus();
+ EXPECT_EQ(0, table_->selection_model().active());
+
+ ui::ListSelectionModel new_selection;
+ new_selection.set_active(1);
+ helper_->SetSelectionModel(new_selection);
+ EXPECT_EQ(1, table_->selection_model().active());
+ helper_->OnFocus();
+ EXPECT_EQ(1, table_->selection_model().active());
+
+ // Remove all rows; focusing should not activate a non existent first row.
+ while (model_->RowCount())
+ model_->RemoveRow(0);
+
+ new_selection.set_active(-1);
+ helper_->SetSelectionModel(new_selection);
+ helper_->OnFocus();
+ EXPECT_EQ(-1, table_->selection_model().active());
+}
+
} // namespace views
« chrome/browser/ui/views/task_manager_view.h ('K') | « 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