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

Side by Side Diff: chrome/browser/ui/cocoa/task_manager_mac_browsertest.mm

Issue 2197483003: Move the Mac Task Manager to the new backend code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 4 years, 4 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 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 #import <Cocoa/Cocoa.h>
5 #include <stddef.h> 6 #include <stddef.h>
6 7
7 #include "base/macros.h" 8 #include "base/macros.h"
8 #include "base/strings/pattern.h" 9 #include "base/strings/pattern.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/sessions/session_tab_helper.h" 11 #include "chrome/browser/sessions/session_tab_helper.h"
12 #include "chrome/browser/task_management/task_manager_browsertest_util.h" 12 #include "chrome/browser/task_management/task_manager_browsertest_util.h"
13 #include "chrome/browser/task_management/task_manager_tester.h" 13 #include "chrome/browser/task_management/task_manager_tester.h"
14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_commands.h" 14 #include "chrome/browser/ui/browser_commands.h"
16 #include "chrome/browser/ui/browser_dialogs.h" 15 #include "chrome/browser/ui/browser_dialogs.h"
17 #include "chrome/browser/ui/browser_tabstrip.h" 16 #include "chrome/browser/ui/browser_tabstrip.h"
17 #include "chrome/browser/ui/cocoa/task_manager_mac.h"
18 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" 18 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "chrome/browser/ui/task_manager/task_manager_columns.h" 19 #include "chrome/browser/ui/task_manager/task_manager_columns.h"
21 #include "chrome/browser/ui/task_manager/task_manager_table_model.h" 20 #include "chrome/browser/ui/task_manager/task_manager_table_model.h"
22 #include "chrome/browser/ui/views/new_task_manager_view.h"
23 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
24 #include "chrome/test/base/in_process_browser_test.h" 22 #include "chrome/test/base/in_process_browser_test.h"
25 #include "chrome/test/base/ui_test_utils.h" 23 #include "chrome/test/base/ui_test_utils.h"
26 #include "components/prefs/pref_service.h" 24 #include "components/prefs/pref_service.h"
27 #include "components/prefs/scoped_user_pref_update.h" 25 #include "components/prefs/scoped_user_pref_update.h"
28 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
29 #include "content/public/browser/web_contents_delegate.h" 27 #include "content/public/browser/web_contents_delegate.h"
30 #include "content/public/test/browser_test_utils.h" 28 #include "content/public/test/browser_test_utils.h"
31 #include "content/public/test/test_utils.h" 29 #include "content/public/test/test_utils.h"
32 #include "net/dns/mock_host_resolver.h" 30 #include "net/dns/mock_host_resolver.h"
33 #include "net/test/embedded_test_server/embedded_test_server.h" 31 #include "net/test/embedded_test_server/embedded_test_server.h"
34 #include "ui/views/controls/table/table_view.h" 32 #include "testing/gtest_mac.h"
35 33
36 namespace task_management { 34 namespace task_management {
37 35
38 using browsertest_util::WaitForTaskManagerRows; 36 using browsertest_util::WaitForTaskManagerRows;
39 37
40 class NewTaskManagerViewTest : public InProcessBrowserTest { 38 class TaskManagerMacTest : public InProcessBrowserTest {
41 public: 39 public:
42 NewTaskManagerViewTest() {} 40 TaskManagerMacTest() {}
43 ~NewTaskManagerViewTest() override {} 41 ~TaskManagerMacTest() override {}
44 42
45 void SetUpOnMainThread() override { 43 void SetUpOnMainThread() override {
Mark Mentovai 2016/08/02 20:45:49 Make sure that GetTaskManagerMac() is false when s
Avi (use Gerrit) 2016/08/02 20:52:50 Done.
46 host_resolver()->AddRule("*", "127.0.0.1"); 44 host_resolver()->AddRule("*", "127.0.0.1");
47 ASSERT_TRUE(embedded_test_server()->Start()); 45 ASSERT_TRUE(embedded_test_server()->Start());
48 } 46 }
49 47
50 void TearDownOnMainThread() override { 48 void TearDownOnMainThread() override {
51 // Make sure the task manager is closed (if any). 49 // Make sure the task manager is closed (if any).
52 chrome::HideTaskManager(); 50 chrome::HideTaskManager();
53 content::RunAllPendingInMessageLoop(); 51 ASSERT_FALSE(GetTaskManagerMac());
54 ASSERT_FALSE(GetView());
55 52
56 InProcessBrowserTest::TearDownOnMainThread(); 53 InProcessBrowserTest::TearDownOnMainThread();
57 } 54 }
58 55
59 NewTaskManagerView* GetView() const { 56 TaskManagerMac* GetTaskManagerMac() const {
60 return NewTaskManagerView::GetInstanceForTests(); 57 return TaskManagerMac::GetInstanceForTests();
61 } 58 }
62 59
63 views::TableView* GetTable() const { 60 NSTableView* GetTable() const {
64 return GetView() ? GetView()->tab_table_ : nullptr; 61 return GetTaskManagerMac() ? [GetTaskManagerMac()->CocoaControllerForTests()
62 tableViewForTesting]
63 : nullptr;
65 } 64 }
66 65
67 void PressKillButton() { GetView()->Accept(); } 66 int TableFirstSelectedRow() const {
67 return [[GetTable() selectedRowIndexes] firstIndex];
68 }
69
70 void PressKillButton() {
71 [[GetTaskManagerMac()->CocoaControllerForTests() endProcessButtonForTesting]
72 performClick:nil];
73 }
68 74
69 void ClearStoredColumnSettings() const { 75 void ClearStoredColumnSettings() const {
70 PrefService* local_state = g_browser_process->local_state(); 76 PrefService* local_state = g_browser_process->local_state();
71 if (!local_state) 77 if (!local_state)
72 FAIL(); 78 FAIL();
73 79
74 DictionaryPrefUpdate dict_update(local_state, 80 DictionaryPrefUpdate dict_update(local_state,
75 prefs::kTaskManagerColumnVisibility); 81 prefs::kTaskManagerColumnVisibility);
76 dict_update->Clear(); 82 dict_update->Clear();
77 } 83 }
78 84
79 void ToggleColumnVisibility(NewTaskManagerView* view, int col_id) { 85 void ToggleColumnVisibility(TaskManagerMac* task_manager, int col_id) {
80 DCHECK(view); 86 DCHECK(task_manager);
81 view->table_model_->ToggleColumnVisibility(col_id); 87 task_manager->GetTableModelForTests()->ToggleColumnVisibility(col_id);
82 } 88 }
83 89
84 // Looks up a tab based on its tab ID. 90 // Looks up a tab based on its tab ID.
85 content::WebContents* FindWebContentsByTabId(SessionID::id_type tab_id) { 91 content::WebContents* FindWebContentsByTabId(SessionID::id_type tab_id) {
86 for (TabContentsIterator it; !it.done(); it.Next()) { 92 for (TabContentsIterator it; !it.done(); it.Next()) {
87 if (SessionTabHelper::IdForTab(*it) == tab_id) 93 if (SessionTabHelper::IdForTab(*it) == tab_id)
88 return *it; 94 return *it;
89 } 95 }
90 return nullptr; 96 return nullptr;
91 } 97 }
92 98
93 // Returns the current TaskManagerTableModel index for a particular tab. Don't 99 // Returns the current TaskManagerTableModel index for a particular tab. Don't
94 // cache this value, since it can change whenever the message loop runs. 100 // cache this value, since it can change whenever the message loop runs.
95 int FindRowForTab(content::WebContents* tab) { 101 int FindRowForTab(content::WebContents* tab) {
96 int32_t tab_id = SessionTabHelper::IdForTab(tab); 102 int32_t tab_id = SessionTabHelper::IdForTab(tab);
97 std::unique_ptr<TaskManagerTester> tester = 103 std::unique_ptr<TaskManagerTester> tester =
98 TaskManagerTester::Create(base::Closure()); 104 TaskManagerTester::Create(base::Closure());
99 for (int i = 0; i < tester->GetRowCount(); ++i) { 105 for (int i = 0; i < tester->GetRowCount(); ++i) {
100 if (tester->GetTabId(i) == tab_id) 106 if (tester->GetTabId(i) == tab_id)
101 return i; 107 return i;
102 } 108 }
103 return -1; 109 return -1;
104 } 110 }
105 111
106 private: 112 private:
107 DISALLOW_COPY_AND_ASSIGN(NewTaskManagerViewTest); 113 DISALLOW_COPY_AND_ASSIGN(TaskManagerMacTest);
108 }; 114 };
109 115
110 // Tests that all defined columns have a corresponding string IDs for keying 116 // Tests that all defined columns have a corresponding string IDs for keying
111 // into the user preferences dictionary. 117 // into the user preferences dictionary.
112 IN_PROC_BROWSER_TEST_F(NewTaskManagerViewTest, AllColumnsHaveStringIds) { 118 IN_PROC_BROWSER_TEST_F(TaskManagerMacTest, AllColumnsHaveStringIds) {
113 for (size_t i = 0; i < kColumnsSize; ++i) 119 for (size_t i = 0; i < kColumnsSize; ++i)
114 EXPECT_NE("", GetColumnIdAsString(kColumns[i].id)); 120 EXPECT_NE("", GetColumnIdAsString(kColumns[i].id));
115 } 121 }
116 122
117 // In the case of no settings stored in the user preferences local store, test 123 // In the case of no settings stored in the user preferences local store, test
118 // that the task manager table starts with the default columns visibility as 124 // that the task manager table starts with the default columns visibility as
119 // stored in |kColumns|. 125 // stored in |kColumns|.
120 IN_PROC_BROWSER_TEST_F(NewTaskManagerViewTest, TableStartsWithDefaultColumns) { 126 IN_PROC_BROWSER_TEST_F(TaskManagerMacTest, TableStartsWithDefaultColumns) {
121 ASSERT_NO_FATAL_FAILURE(ClearStoredColumnSettings()); 127 ASSERT_NO_FATAL_FAILURE(ClearStoredColumnSettings());
122 128
123 chrome::ShowTaskManager(browser()); 129 chrome::ShowTaskManager(browser());
124 views::TableView* table = GetTable(); 130 NSTableView* table = GetTable();
125 ASSERT_TRUE(table); 131 ASSERT_TRUE(table);
126 132
127 EXPECT_FALSE(table->is_sorted()); 133 EXPECT_EQ(0u, [[table sortDescriptors] count]);
134 NSArray* tableColumns = [table tableColumns];
128 for (size_t i = 0; i < kColumnsSize; ++i) { 135 for (size_t i = 0; i < kColumnsSize; ++i) {
136 EXPECT_EQ(kColumns[i].id,
137 [[[tableColumns objectAtIndex:i] identifier] intValue]);
129 EXPECT_EQ(kColumns[i].default_visibility, 138 EXPECT_EQ(kColumns[i].default_visibility,
130 table->IsColumnVisible(kColumns[i].id)); 139 ![[tableColumns objectAtIndex:i] isHidden]);
131 } 140 }
132 } 141 }
133 142
134 // Tests that changing columns visibility and sort order will be stored upon 143 // Tests that changing columns visibility and sort order will be stored upon
135 // closing the task manager view and restored when re-opened. 144 // closing the task manager view and restored when re-opened.
136 IN_PROC_BROWSER_TEST_F(NewTaskManagerViewTest, ColumnsSettingsAreRestored) { 145 IN_PROC_BROWSER_TEST_F(TaskManagerMacTest, ColumnsSettingsAreRestored) {
137 ASSERT_NO_FATAL_FAILURE(ClearStoredColumnSettings()); 146 ASSERT_NO_FATAL_FAILURE(ClearStoredColumnSettings());
138 147
139 chrome::ShowTaskManager(browser()); 148 chrome::ShowTaskManager(browser());
140 NewTaskManagerView* view = GetView(); 149 TaskManagerMac* task_manager = GetTaskManagerMac();
141 ASSERT_TRUE(view); 150 ASSERT_TRUE(task_manager);
142 views::TableView* table = GetTable(); 151 NSTableView* table = GetTable();
143 ASSERT_TRUE(table); 152 ASSERT_TRUE(table);
144 153
145 // Toggle the visibility of all columns. 154 // Toggle the visibility of all columns.
146 EXPECT_FALSE(table->is_sorted()); 155 EXPECT_EQ(0u, [[table sortDescriptors] count]);
156 NSArray* tableColumns = [table tableColumns];
147 for (size_t i = 0; i < kColumnsSize; ++i) { 157 for (size_t i = 0; i < kColumnsSize; ++i) {
158 EXPECT_EQ(kColumns[i].id,
159 [[[tableColumns objectAtIndex:i] identifier] intValue]);
148 EXPECT_EQ(kColumns[i].default_visibility, 160 EXPECT_EQ(kColumns[i].default_visibility,
149 table->IsColumnVisible(kColumns[i].id)); 161 ![[tableColumns objectAtIndex:i] isHidden]);
150 ToggleColumnVisibility(view, kColumns[i].id); 162 ToggleColumnVisibility(task_manager, kColumns[i].id);
151 } 163 }
152 164
153 // Sort by the first visible and initially ascending sortable column. 165 // Sort by the first visible and initially ascending sortable column. It would
166 // be nice to fake a click with -performClick: but that doesn't work (see
167 // http://www.cocoabuilder.com/archive/cocoa/177610-programmatically-click-col umn-header-in-nstableview.html).
154 bool is_sorted = false; 168 bool is_sorted = false;
155 int sorted_col_id = -1; 169 int sorted_col_id = -1;
156 for (size_t i = 0; i < table->visible_columns().size(); ++i) { 170 for (NSTableColumn* column in tableColumns) {
157 const ui::TableColumn& column = table->visible_columns()[i].column; 171 if ([column isHidden])
158 if (column.sortable && column.initial_sort_is_ascending) { 172 continue;
159 // Toggle the sort twice for a descending sort. 173 if ([column sortDescriptorPrototype].ascending) {
160 table->ToggleSortOrder(static_cast<int>(i)); 174 // Toggle the sort for a descending sort.
161 table->ToggleSortOrder(static_cast<int>(i)); 175 NSSortDescriptor* newSortDescriptor =
176 [[column sortDescriptorPrototype] reversedSortDescriptor];
177 [table setSortDescriptors:@[ newSortDescriptor ]];
162 is_sorted = true; 178 is_sorted = true;
163 sorted_col_id = column.id; 179 sorted_col_id = [[column identifier] intValue];
164 break; 180 break;
165 } 181 }
166 } 182 }
167 183
168 if (is_sorted) { 184 NSArray* expectedSortDescriptors = [table sortDescriptors];
169 EXPECT_TRUE(table->is_sorted()); 185 EXPECT_EQ(is_sorted, [expectedSortDescriptors count] > 0);
170 EXPECT_FALSE(table->sort_descriptors().front().ascending);
171 EXPECT_EQ(table->sort_descriptors().front().column_id, sorted_col_id);
172 }
173 186
174 // Close the task manager view and re-open. Expect the inverse of the default 187 // Close the task manager view and re-open. Expect the inverse of the default
175 // visibility, and the last sort order. 188 // visibility, and the last sort order.
176 chrome::HideTaskManager(); 189 chrome::HideTaskManager();
177 content::RunAllPendingInMessageLoop(); 190 ASSERT_FALSE(GetTaskManagerMac());
178 ASSERT_FALSE(GetView());
179 chrome::ShowTaskManager(browser()); 191 chrome::ShowTaskManager(browser());
180 view = GetView(); 192 task_manager = GetTaskManagerMac();
181 ASSERT_TRUE(view); 193 ASSERT_TRUE(task_manager);
182 table = GetTable(); 194 table = GetTable();
183 ASSERT_TRUE(table); 195 ASSERT_TRUE(table);
184 196
185 if (is_sorted) { 197 if (is_sorted) {
186 EXPECT_TRUE(table->is_sorted()); 198 EXPECT_NSEQ(expectedSortDescriptors, [table sortDescriptors]);
187 EXPECT_FALSE(table->sort_descriptors().front().ascending);
188 EXPECT_EQ(table->sort_descriptors().front().column_id, sorted_col_id);
189 }
190 for (size_t i = 0; i < kColumnsSize; ++i) {
191 EXPECT_EQ(!kColumns[i].default_visibility,
192 table->IsColumnVisible(kColumns[i].id));
193 } 199 }
194 } 200 }
195 201
196 IN_PROC_BROWSER_TEST_F(NewTaskManagerViewTest, InitialSelection) { 202 IN_PROC_BROWSER_TEST_F(TaskManagerMacTest, SelectionConsistency) {
197 // Navigate the first tab. 203 ASSERT_NO_FATAL_FAILURE(ClearStoredColumnSettings());
198 ui_test_utils::NavigateToURL(
199 browser(), embedded_test_server()->GetURL("a.com", "/title2.html"));
200 204
201 ui_test_utils::NavigateToURLWithDisposition(
202 browser(), embedded_test_server()->GetURL("b.com", "/title3.html"),
203 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
204
205 // When the task manager is initially shown, the row for the active tab should
206 // be selected.
207 chrome::ShowTaskManager(browser());
208
209 EXPECT_EQ(1, GetTable()->SelectedRowCount());
210 EXPECT_EQ(GetTable()->FirstSelectedRow(),
211 FindRowForTab(browser()->tab_strip_model()->GetWebContentsAt(1)));
212
213 // Activate tab 0. The selection should not change.
214 browser()->tab_strip_model()->ActivateTabAt(0, true);
215 EXPECT_EQ(1, GetTable()->SelectedRowCount());
216 EXPECT_EQ(GetTable()->FirstSelectedRow(),
217 FindRowForTab(browser()->tab_strip_model()->GetWebContentsAt(1)));
218
219 // If the user re-triggers chrome::ShowTaskManager (e.g. via shift-esc), this
220 // should set the TaskManager selection to the active tab.
221 chrome::ShowTaskManager(browser());
222
223 EXPECT_EQ(1, GetTable()->SelectedRowCount());
224 EXPECT_EQ(GetTable()->FirstSelectedRow(),
225 FindRowForTab(browser()->tab_strip_model()->GetWebContentsAt(0)));
226 }
227
228 IN_PROC_BROWSER_TEST_F(NewTaskManagerViewTest, SelectionConsistency) {
229 chrome::ShowTaskManager(browser()); 205 chrome::ShowTaskManager(browser());
230 206
231 // Set up a total of three tabs in different processes. 207 // Set up a total of three tabs in different processes.
232 ui_test_utils::NavigateToURL( 208 ui_test_utils::NavigateToURL(
233 browser(), embedded_test_server()->GetURL("a.com", "/title2.html")); 209 browser(), embedded_test_server()->GetURL("a.com", "/title2.html"));
234 ui_test_utils::NavigateToURLWithDisposition( 210 ui_test_utils::NavigateToURLWithDisposition(
235 browser(), embedded_test_server()->GetURL("b.com", "/title2.html"), 211 browser(), embedded_test_server()->GetURL("b.com", "/title2.html"),
236 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 212 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
237 ui_test_utils::NavigateToURLWithDisposition( 213 ui_test_utils::NavigateToURLWithDisposition(
238 browser(), embedded_test_server()->GetURL("c.com", "/title2.html"), 214 browser(), embedded_test_server()->GetURL("c.com", "/title2.html"),
(...skipping 14 matching lines...) Expand all
253 // Filter based on our title. 229 // Filter based on our title.
254 if (!base::MatchPattern(tester->GetRowTitle(i), pattern)) 230 if (!base::MatchPattern(tester->GetRowTitle(i), pattern))
255 continue; 231 continue;
256 content::WebContents* tab = FindWebContentsByTabId(tester->GetTabId(i)); 232 content::WebContents* tab = FindWebContentsByTabId(tester->GetTabId(i));
257 EXPECT_NE(nullptr, tab); 233 EXPECT_NE(nullptr, tab);
258 tabs.push_back(tab); 234 tabs.push_back(tab);
259 } 235 }
260 EXPECT_EQ(3U, tabs.size()); 236 EXPECT_EQ(3U, tabs.size());
261 237
262 // Select the middle row, and store its tab id. 238 // Select the middle row, and store its tab id.
263 GetTable()->Select(FindRowForTab(tabs[1])); 239 [GetTable()
264 EXPECT_EQ(GetTable()->FirstSelectedRow(), FindRowForTab(tabs[1])); 240 selectRowIndexes:[NSIndexSet indexSetWithIndex:FindRowForTab(tabs[1])]
241 byExtendingSelection:NO];
242 EXPECT_EQ(TableFirstSelectedRow(), FindRowForTab(tabs[1]));
243 EXPECT_EQ(1, [GetTable() numberOfSelectedRows]);
265 244
266 // Add 3 rows above the selection. The selected tab should not change. 245 // Add 3 rows above the selection. The selected tab should not change.
267 for (int i = 0; i < 3; ++i) { 246 for (int i = 0; i < 3; ++i) {
268 ASSERT_TRUE(content::ExecuteScript(tabs[0], "window.open('title3.html');")); 247 ASSERT_TRUE(content::ExecuteScript(tabs[0], "window.open('title3.html');"));
269 EXPECT_EQ(GetTable()->FirstSelectedRow(), FindRowForTab(tabs[1])); 248 EXPECT_EQ(TableFirstSelectedRow(), FindRowForTab(tabs[1]));
270 } 249 }
271 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows((rows += 3), pattern)); 250 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows((rows += 3), pattern));
272 EXPECT_EQ(GetTable()->FirstSelectedRow(), FindRowForTab(tabs[1])); 251 EXPECT_EQ(TableFirstSelectedRow(), FindRowForTab(tabs[1]));
252 EXPECT_EQ(1, [GetTable() numberOfSelectedRows]);
273 253
274 // Add 2 rows below the selection. The selected tab should not change. 254 // Add 2 rows below the selection. The selected tab should not change.
275 for (int i = 0; i < 2; ++i) { 255 for (int i = 0; i < 2; ++i) {
276 ASSERT_TRUE(content::ExecuteScript(tabs[2], "window.open('title3.html');")); 256 ASSERT_TRUE(content::ExecuteScript(tabs[2], "window.open('title3.html');"));
277 EXPECT_EQ(GetTable()->FirstSelectedRow(), FindRowForTab(tabs[1])); 257 EXPECT_EQ(TableFirstSelectedRow(), FindRowForTab(tabs[1]));
278 } 258 }
279 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows((rows += 2), pattern)); 259 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows((rows += 2), pattern));
280 EXPECT_EQ(GetTable()->FirstSelectedRow(), FindRowForTab(tabs[1])); 260 EXPECT_EQ(TableFirstSelectedRow(), FindRowForTab(tabs[1]));
261 EXPECT_EQ(1, [GetTable() numberOfSelectedRows]);
281 262
282 // Add a new row in the same process as the selection. The selected tab should 263 // Add a new row in the same process as the selection. The selected tab should
283 // not change. 264 // not change.
284 ASSERT_TRUE(content::ExecuteScript(tabs[1], "window.open('title3.html');")); 265 ASSERT_TRUE(content::ExecuteScript(tabs[1], "window.open('title3.html');"));
285 EXPECT_EQ(GetTable()->FirstSelectedRow(), FindRowForTab(tabs[1])); 266 EXPECT_EQ(TableFirstSelectedRow(), FindRowForTab(tabs[1]));
286 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows((rows += 1), pattern)); 267 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows((rows += 1), pattern));
287 EXPECT_EQ(GetTable()->FirstSelectedRow(), FindRowForTab(tabs[1])); 268 EXPECT_EQ(TableFirstSelectedRow(), FindRowForTab(tabs[1]));
288 EXPECT_EQ(1, GetTable()->SelectedRowCount()); 269 EXPECT_EQ(2, [GetTable() numberOfSelectedRows]);
289 270
290 // Press the button, which kills the process of the selected row. 271 // Press the button, which kills the process of the selected row.
291 PressKillButton(); 272 PressKillButton();
292 273
293 // Two rows should disappear. 274 // Two rows should disappear.
294 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows((rows -= 2), pattern)); 275 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows((rows -= 2), pattern));
295 276
296 // A later row should now be selected. The selection should be after the 4 277 // No row should now be selected.
297 // rows sharing the tabs[0] process, and it should be at or before 278 ASSERT_EQ(-1, TableFirstSelectedRow());
298 // the tabs[2] row.
299 ASSERT_LT(FindRowForTab(tabs[0]) + 3, GetTable()->FirstSelectedRow());
300 ASSERT_LE(GetTable()->FirstSelectedRow(), FindRowForTab(tabs[2]));
301 279
302 // Now select tabs[2]. 280 // Now select tabs[2].
303 GetTable()->Select(FindRowForTab(tabs[2])); 281 [GetTable()
282 selectRowIndexes:[NSIndexSet indexSetWithIndex:FindRowForTab(tabs[2])]
283 byExtendingSelection:NO];
304 284
305 // Focus and reload one of the sad tabs. It should reappear in the TM. The 285 // Focus and reload one of the sad tabs. It should reappear in the TM. The
306 // other sad tab should not reappear. 286 // other sad tab should not reappear.
307 tabs[1]->GetDelegate()->ActivateContents(tabs[1]); 287 tabs[1]->GetDelegate()->ActivateContents(tabs[1]);
308 chrome::Reload(browser(), CURRENT_TAB); 288 chrome::Reload(browser(), CURRENT_TAB);
309 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows((rows += 1), pattern)); 289 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows((rows += 1), pattern));
310 290
311 // tabs[2] should still be selected. 291 // tabs[2] should still be selected.
312 EXPECT_EQ(GetTable()->FirstSelectedRow(), FindRowForTab(tabs[2])); 292 EXPECT_EQ(TableFirstSelectedRow(), FindRowForTab(tabs[2]));
313 293
314 // Close tabs[0]. The selection should not change. 294 // Close tabs[0]. The selection should not change.
315 chrome::CloseWebContents(browser(), tabs[0], false); 295 chrome::CloseWebContents(browser(), tabs[0], false);
316 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows((rows -= 1), pattern)); 296 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows((rows -= 1), pattern));
317 EXPECT_EQ(GetTable()->FirstSelectedRow(), FindRowForTab(tabs[2])); 297 EXPECT_EQ(TableFirstSelectedRow(), FindRowForTab(tabs[2]));
318 } 298 }
319 299
320 } // namespace task_management 300 } // namespace task_management
321
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698