OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/prefs/pref_service.h" | 5 #include "base/prefs/pref_service.h" |
6 #include "base/prefs/scoped_user_pref_update.h" | 6 #include "base/prefs/scoped_user_pref_update.h" |
7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/ui/browser_dialogs.h" | 8 #include "chrome/browser/ui/browser_dialogs.h" |
| 9 #include "chrome/browser/ui/task_manager/task_manager_columns.h" |
| 10 #include "chrome/browser/ui/task_manager/task_manager_table_model.h" |
9 #include "chrome/browser/ui/views/new_task_manager_view.h" | 11 #include "chrome/browser/ui/views/new_task_manager_view.h" |
10 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
11 #include "chrome/test/base/in_process_browser_test.h" | 13 #include "chrome/test/base/in_process_browser_test.h" |
12 #include "content/public/test/test_utils.h" | 14 #include "content/public/test/test_utils.h" |
13 #include "ui/views/controls/table/table_view.h" | 15 #include "ui/views/controls/table/table_view.h" |
14 | 16 |
15 namespace task_management { | 17 namespace task_management { |
16 | 18 |
17 class NewTaskManagerViewTest : public InProcessBrowserTest { | 19 class NewTaskManagerViewTest : public InProcessBrowserTest { |
18 public: | 20 public: |
(...skipping 22 matching lines...) Expand all Loading... |
41 if (!local_state) | 43 if (!local_state) |
42 FAIL(); | 44 FAIL(); |
43 | 45 |
44 DictionaryPrefUpdate dict_update(local_state, | 46 DictionaryPrefUpdate dict_update(local_state, |
45 prefs::kTaskManagerColumnVisibility); | 47 prefs::kTaskManagerColumnVisibility); |
46 dict_update->Clear(); | 48 dict_update->Clear(); |
47 } | 49 } |
48 | 50 |
49 void ToggleColumnVisibility(NewTaskManagerView* view, int col_id) { | 51 void ToggleColumnVisibility(NewTaskManagerView* view, int col_id) { |
50 DCHECK(view); | 52 DCHECK(view); |
51 view->ToggleColumnVisibility(col_id); | 53 view->table_model_->ToggleColumnVisibility(col_id); |
52 } | 54 } |
53 | 55 |
54 private: | 56 private: |
55 DISALLOW_COPY_AND_ASSIGN(NewTaskManagerViewTest); | 57 DISALLOW_COPY_AND_ASSIGN(NewTaskManagerViewTest); |
56 }; | 58 }; |
57 | 59 |
58 // Tests that all defined columns have a corresponding string IDs for keying | 60 // Tests that all defined columns have a corresponding string IDs for keying |
59 // into the user preferences dictionary. | 61 // into the user preferences dictionary. |
60 IN_PROC_BROWSER_TEST_F(NewTaskManagerViewTest, AllColumnsHaveStringIds) { | 62 IN_PROC_BROWSER_TEST_F(NewTaskManagerViewTest, AllColumnsHaveStringIds) { |
61 for (size_t i = 0; i < kColumnsSize; ++i) | 63 for (size_t i = 0; i < kColumnsSize; ++i) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // Sort by the first visible and initially ascending sortable column. | 103 // Sort by the first visible and initially ascending sortable column. |
102 bool is_sorted = false; | 104 bool is_sorted = false; |
103 int sorted_col_id = -1; | 105 int sorted_col_id = -1; |
104 for (size_t i = 0; i < table->visible_columns().size(); ++i) { | 106 for (size_t i = 0; i < table->visible_columns().size(); ++i) { |
105 const ui::TableColumn& column = table->visible_columns()[i].column; | 107 const ui::TableColumn& column = table->visible_columns()[i].column; |
106 if (column.sortable && column.initial_sort_is_ascending) { | 108 if (column.sortable && column.initial_sort_is_ascending) { |
107 // Toggle the sort twice for a descending sort. | 109 // Toggle the sort twice for a descending sort. |
108 table->ToggleSortOrder(static_cast<int>(i)); | 110 table->ToggleSortOrder(static_cast<int>(i)); |
109 table->ToggleSortOrder(static_cast<int>(i)); | 111 table->ToggleSortOrder(static_cast<int>(i)); |
110 is_sorted = true; | 112 is_sorted = true; |
111 return; | 113 sorted_col_id = column.id; |
| 114 break; |
112 } | 115 } |
113 } | 116 } |
114 | 117 |
115 if (is_sorted) { | 118 if (is_sorted) { |
116 EXPECT_TRUE(table->is_sorted()); | 119 EXPECT_TRUE(table->is_sorted()); |
117 EXPECT_FALSE(table->sort_descriptors().front().ascending); | 120 EXPECT_FALSE(table->sort_descriptors().front().ascending); |
118 EXPECT_EQ(table->sort_descriptors().front().column_id, sorted_col_id); | 121 EXPECT_EQ(table->sort_descriptors().front().column_id, sorted_col_id); |
119 } | 122 } |
120 | 123 |
121 // Close the task manager view and re-open. Expect the inverse of the default | 124 // Close the task manager view and re-open. Expect the inverse of the default |
(...skipping 13 matching lines...) Expand all Loading... |
135 EXPECT_EQ(table->sort_descriptors().front().column_id, sorted_col_id); | 138 EXPECT_EQ(table->sort_descriptors().front().column_id, sorted_col_id); |
136 } | 139 } |
137 for (size_t i = 0; i < kColumnsSize; ++i) { | 140 for (size_t i = 0; i < kColumnsSize; ++i) { |
138 EXPECT_EQ(!kColumns[i].default_visibility, | 141 EXPECT_EQ(!kColumns[i].default_visibility, |
139 table->IsColumnVisible(kColumns[i].id)); | 142 table->IsColumnVisible(kColumns[i].id)); |
140 } | 143 } |
141 } | 144 } |
142 | 145 |
143 } // namespace task_management | 146 } // namespace task_management |
144 | 147 |
OLD | NEW |