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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/table/table_view.h" 5 #include "ui/views/controls/table/table_view.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 ui::ListSelectionModel new_selection; 1016 ui::ListSelectionModel new_selection;
1017 new_selection.AddIndexToSelection(0); 1017 new_selection.AddIndexToSelection(0);
1018 new_selection.AddIndexToSelection(1); 1018 new_selection.AddIndexToSelection(1);
1019 new_selection.set_active(0); 1019 new_selection.set_active(0);
1020 new_selection.set_anchor(0); 1020 new_selection.set_anchor(0);
1021 helper_->SetSelectionModel(new_selection); 1021 helper_->SetSelectionModel(new_selection);
1022 model_->RemoveRow(0); 1022 model_->RemoveRow(0);
1023 helper_->OnFocus(); 1023 helper_->OnFocus();
1024 } 1024 }
1025 1025
1026 // Tests that focusing the table will activate the first row, but only if
1027 // there's no active row.
1028 TEST_F(TableViewTest, InitialFocusActivatesFirstRow) {
1029 EXPECT_EQ(-1, table_->selection_model().active());
1030 helper_->OnFocus();
1031 EXPECT_EQ(0, table_->selection_model().active());
1032
1033 ui::ListSelectionModel new_selection;
1034 new_selection.set_active(1);
1035 helper_->SetSelectionModel(new_selection);
1036 EXPECT_EQ(1, table_->selection_model().active());
1037 helper_->OnFocus();
1038 EXPECT_EQ(1, table_->selection_model().active());
1039
1040 // Remove all rows; focusing should not activate a non existent first row.
1041 while (model_->RowCount())
1042 model_->RemoveRow(0);
1043
1044 new_selection.set_active(-1);
1045 helper_->SetSelectionModel(new_selection);
1046 helper_->OnFocus();
1047 EXPECT_EQ(-1, table_->selection_model().active());
1048 }
1049
1026 } // namespace views 1050 } // namespace views
OLDNEW
« 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