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