| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/pattern.h" | 8 #include "base/strings/pattern.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } | 193 } |
| 194 } | 194 } |
| 195 | 195 |
| 196 IN_PROC_BROWSER_TEST_F(TaskManagerViewTest, InitialSelection) { | 196 IN_PROC_BROWSER_TEST_F(TaskManagerViewTest, InitialSelection) { |
| 197 // Navigate the first tab. | 197 // Navigate the first tab. |
| 198 ui_test_utils::NavigateToURL( | 198 ui_test_utils::NavigateToURL( |
| 199 browser(), embedded_test_server()->GetURL("a.com", "/title2.html")); | 199 browser(), embedded_test_server()->GetURL("a.com", "/title2.html")); |
| 200 | 200 |
| 201 ui_test_utils::NavigateToURLWithDisposition( | 201 ui_test_utils::NavigateToURLWithDisposition( |
| 202 browser(), embedded_test_server()->GetURL("b.com", "/title3.html"), | 202 browser(), embedded_test_server()->GetURL("b.com", "/title3.html"), |
| 203 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 203 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 204 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 204 | 205 |
| 205 // When the task manager is initially shown, the row for the active tab should | 206 // When the task manager is initially shown, the row for the active tab should |
| 206 // be selected. | 207 // be selected. |
| 207 chrome::ShowTaskManager(browser()); | 208 chrome::ShowTaskManager(browser()); |
| 208 | 209 |
| 209 EXPECT_EQ(1, GetTable()->SelectedRowCount()); | 210 EXPECT_EQ(1, GetTable()->SelectedRowCount()); |
| 210 EXPECT_EQ(GetTable()->FirstSelectedRow(), | 211 EXPECT_EQ(GetTable()->FirstSelectedRow(), |
| 211 FindRowForTab(browser()->tab_strip_model()->GetWebContentsAt(1))); | 212 FindRowForTab(browser()->tab_strip_model()->GetWebContentsAt(1))); |
| 212 | 213 |
| 213 // Activate tab 0. The selection should not change. | 214 // Activate tab 0. The selection should not change. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 228 IN_PROC_BROWSER_TEST_F(TaskManagerViewTest, SelectionConsistency) { | 229 IN_PROC_BROWSER_TEST_F(TaskManagerViewTest, SelectionConsistency) { |
| 229 ASSERT_NO_FATAL_FAILURE(ClearStoredColumnSettings()); | 230 ASSERT_NO_FATAL_FAILURE(ClearStoredColumnSettings()); |
| 230 | 231 |
| 231 chrome::ShowTaskManager(browser()); | 232 chrome::ShowTaskManager(browser()); |
| 232 | 233 |
| 233 // Set up a total of three tabs in different processes. | 234 // Set up a total of three tabs in different processes. |
| 234 ui_test_utils::NavigateToURL( | 235 ui_test_utils::NavigateToURL( |
| 235 browser(), embedded_test_server()->GetURL("a.com", "/title2.html")); | 236 browser(), embedded_test_server()->GetURL("a.com", "/title2.html")); |
| 236 ui_test_utils::NavigateToURLWithDisposition( | 237 ui_test_utils::NavigateToURLWithDisposition( |
| 237 browser(), embedded_test_server()->GetURL("b.com", "/title2.html"), | 238 browser(), embedded_test_server()->GetURL("b.com", "/title2.html"), |
| 238 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 239 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 240 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 239 ui_test_utils::NavigateToURLWithDisposition( | 241 ui_test_utils::NavigateToURLWithDisposition( |
| 240 browser(), embedded_test_server()->GetURL("c.com", "/title2.html"), | 242 browser(), embedded_test_server()->GetURL("c.com", "/title2.html"), |
| 241 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 243 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 244 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 242 | 245 |
| 243 // Wait for their titles to appear in the TaskManager. There should be three | 246 // Wait for their titles to appear in the TaskManager. There should be three |
| 244 // rows. | 247 // rows. |
| 245 auto pattern = browsertest_util::MatchTab("Title *"); | 248 auto pattern = browsertest_util::MatchTab("Title *"); |
| 246 int rows = 3; | 249 int rows = 3; |
| 247 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(rows, pattern)); | 250 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(rows, pattern)); |
| 248 | 251 |
| 249 // Find the three tabs we set up, in TaskManager model order. Because we have | 252 // Find the three tabs we set up, in TaskManager model order. Because we have |
| 250 // not sorted the table yet, this should also be their UI display order. | 253 // not sorted the table yet, this should also be their UI display order. |
| 251 std::unique_ptr<TaskManagerTester> tester = | 254 std::unique_ptr<TaskManagerTester> tester = |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 // the tabs[2] row. | 306 // the tabs[2] row. |
| 304 ASSERT_LT(FindRowForTab(tabs[0]) + 3, GetTable()->FirstSelectedRow()); | 307 ASSERT_LT(FindRowForTab(tabs[0]) + 3, GetTable()->FirstSelectedRow()); |
| 305 ASSERT_LE(GetTable()->FirstSelectedRow(), FindRowForTab(tabs[2])); | 308 ASSERT_LE(GetTable()->FirstSelectedRow(), FindRowForTab(tabs[2])); |
| 306 | 309 |
| 307 // Now select tabs[2]. | 310 // Now select tabs[2]. |
| 308 GetTable()->Select(FindRowForTab(tabs[2])); | 311 GetTable()->Select(FindRowForTab(tabs[2])); |
| 309 | 312 |
| 310 // Focus and reload one of the sad tabs. It should reappear in the TM. The | 313 // Focus and reload one of the sad tabs. It should reappear in the TM. The |
| 311 // other sad tab should not reappear. | 314 // other sad tab should not reappear. |
| 312 tabs[1]->GetDelegate()->ActivateContents(tabs[1]); | 315 tabs[1]->GetDelegate()->ActivateContents(tabs[1]); |
| 313 chrome::Reload(browser(), CURRENT_TAB); | 316 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB); |
| 314 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows((rows += 1), pattern)); | 317 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows((rows += 1), pattern)); |
| 315 | 318 |
| 316 // tabs[2] should still be selected. | 319 // tabs[2] should still be selected. |
| 317 EXPECT_EQ(GetTable()->FirstSelectedRow(), FindRowForTab(tabs[2])); | 320 EXPECT_EQ(GetTable()->FirstSelectedRow(), FindRowForTab(tabs[2])); |
| 318 | 321 |
| 319 // Close tabs[0]. The selection should not change. | 322 // Close tabs[0]. The selection should not change. |
| 320 chrome::CloseWebContents(browser(), tabs[0], false); | 323 chrome::CloseWebContents(browser(), tabs[0], false); |
| 321 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows((rows -= 1), pattern)); | 324 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows((rows -= 1), pattern)); |
| 322 EXPECT_EQ(GetTable()->FirstSelectedRow(), FindRowForTab(tabs[2])); | 325 EXPECT_EQ(GetTable()->FirstSelectedRow(), FindRowForTab(tabs[2])); |
| 323 } | 326 } |
| 324 | 327 |
| 325 } // namespace task_manager | 328 } // namespace task_manager |
| OLD | NEW |