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

Side by Side Diff: chrome/browser/ui/views/new_task_manager_view_browsertest.cc

Issue 2146273002: TaskManager: when shown or activated, select the last active tab. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@triple_click_tm
Patch Set: Fix compile. 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
« no previous file with comments | « chrome/browser/ui/views/new_task_manager_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/sessions/session_tab_helper.h" 11 #include "chrome/browser/sessions/session_tab_helper.h"
11 #include "chrome/browser/task_management/task_manager_browsertest_util.h" 12 #include "chrome/browser/task_management/task_manager_browsertest_util.h"
12 #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"
13 #include "chrome/browser/ui/browser_commands.h" 15 #include "chrome/browser/ui/browser_commands.h"
14 #include "chrome/browser/ui/browser_dialogs.h" 16 #include "chrome/browser/ui/browser_dialogs.h"
15 #include "chrome/browser/ui/browser_tabstrip.h" 17 #include "chrome/browser/ui/browser_tabstrip.h"
16 #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"
17 #include "chrome/browser/ui/task_manager/task_manager_columns.h" 20 #include "chrome/browser/ui/task_manager/task_manager_columns.h"
18 #include "chrome/browser/ui/task_manager/task_manager_table_model.h" 21 #include "chrome/browser/ui/task_manager/task_manager_table_model.h"
19 #include "chrome/browser/ui/views/new_task_manager_view.h" 22 #include "chrome/browser/ui/views/new_task_manager_view.h"
20 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
21 #include "chrome/test/base/in_process_browser_test.h" 24 #include "chrome/test/base/in_process_browser_test.h"
22 #include "chrome/test/base/ui_test_utils.h" 25 #include "chrome/test/base/ui_test_utils.h"
23 #include "components/prefs/pref_service.h" 26 #include "components/prefs/pref_service.h"
24 #include "components/prefs/scoped_user_pref_update.h" 27 #include "components/prefs/scoped_user_pref_update.h"
25 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
26 #include "content/public/browser/web_contents_delegate.h" 29 #include "content/public/browser/web_contents_delegate.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 EXPECT_TRUE(table->is_sorted()); 186 EXPECT_TRUE(table->is_sorted());
184 EXPECT_FALSE(table->sort_descriptors().front().ascending); 187 EXPECT_FALSE(table->sort_descriptors().front().ascending);
185 EXPECT_EQ(table->sort_descriptors().front().column_id, sorted_col_id); 188 EXPECT_EQ(table->sort_descriptors().front().column_id, sorted_col_id);
186 } 189 }
187 for (size_t i = 0; i < kColumnsSize; ++i) { 190 for (size_t i = 0; i < kColumnsSize; ++i) {
188 EXPECT_EQ(!kColumns[i].default_visibility, 191 EXPECT_EQ(!kColumns[i].default_visibility,
189 table->IsColumnVisible(kColumns[i].id)); 192 table->IsColumnVisible(kColumns[i].id));
190 } 193 }
191 } 194 }
192 195
196 IN_PROC_BROWSER_TEST_F(NewTaskManagerViewTest, InitialSelection) {
197 // Navigate the first tab.
198 ui_test_utils::NavigateToURL(
199 browser(), embedded_test_server()->GetURL("a.com", "/title2.html"));
200
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
193 IN_PROC_BROWSER_TEST_F(NewTaskManagerViewTest, SelectionConsistency) { 228 IN_PROC_BROWSER_TEST_F(NewTaskManagerViewTest, SelectionConsistency) {
194 chrome::ShowTaskManager(browser()); 229 chrome::ShowTaskManager(browser());
195 230
196 // Set up a total of three tabs in different processes. 231 // Set up a total of three tabs in different processes.
197 ui_test_utils::NavigateToURL( 232 ui_test_utils::NavigateToURL(
198 browser(), embedded_test_server()->GetURL("a.com", "/title2.html")); 233 browser(), embedded_test_server()->GetURL("a.com", "/title2.html"));
199 ui_test_utils::NavigateToURLWithDisposition( 234 ui_test_utils::NavigateToURLWithDisposition(
200 browser(), embedded_test_server()->GetURL("b.com", "/title2.html"), 235 browser(), embedded_test_server()->GetURL("b.com", "/title2.html"),
201 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 236 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
202 ui_test_utils::NavigateToURLWithDisposition( 237 ui_test_utils::NavigateToURLWithDisposition(
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 EXPECT_EQ(GetTable()->FirstSelectedRow(), FindRowForTab(tabs[2])); 312 EXPECT_EQ(GetTable()->FirstSelectedRow(), FindRowForTab(tabs[2]));
278 313
279 // Close tabs[0]. The selection should not change. 314 // Close tabs[0]. The selection should not change.
280 chrome::CloseWebContents(browser(), tabs[0], false); 315 chrome::CloseWebContents(browser(), tabs[0], false);
281 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows((rows -= 1), pattern)); 316 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows((rows -= 1), pattern));
282 EXPECT_EQ(GetTable()->FirstSelectedRow(), FindRowForTab(tabs[2])); 317 EXPECT_EQ(GetTable()->FirstSelectedRow(), FindRowForTab(tabs[2]));
283 } 318 }
284 319
285 } // namespace task_management 320 } // namespace task_management
286 321
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/new_task_manager_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698