OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/task_manager/task_manager.h" | 5 #include "chrome/browser/task_manager/task_manager.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/devtools/devtools_window.h" | 11 #include "chrome/browser/devtools/devtools_window.h" |
12 #include "chrome/browser/extensions/extension_browsertest.h" | 12 #include "chrome/browser/extensions/extension_browsertest.h" |
13 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
14 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 14 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
15 #include "chrome/browser/infobars/infobar.h" | 15 #include "chrome/browser/infobars/infobar.h" |
16 #include "chrome/browser/infobars/infobar_service.h" | 16 #include "chrome/browser/infobars/infobar_service.h" |
17 #include "chrome/browser/notifications/desktop_notification_service.h" | 17 #include "chrome/browser/notifications/desktop_notification_service.h" |
18 #include "chrome/browser/notifications/notification.h" | 18 #include "chrome/browser/notifications/notification.h" |
19 #include "chrome/browser/notifications/notification_test_util.h" | 19 #include "chrome/browser/notifications/notification_test_util.h" |
20 #include "chrome/browser/notifications/notification_ui_manager.h" | 20 #include "chrome/browser/notifications/notification_ui_manager.h" |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/task_manager/resource_provider.h" | 22 #include "chrome/browser/task_manager/resource_provider.h" |
23 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" | 23 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" |
24 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
| 25 #include "chrome/browser/ui/browser_commands.h" |
25 #include "chrome/browser/ui/browser_dialogs.h" | 26 #include "chrome/browser/ui/browser_dialogs.h" |
26 #include "chrome/browser/ui/browser_navigator.h" | 27 #include "chrome/browser/ui/browser_navigator.h" |
27 #include "chrome/browser/ui/browser_window.h" | 28 #include "chrome/browser/ui/browser_window.h" |
28 #include "chrome/browser/ui/panels/panel.h" | 29 #include "chrome/browser/ui/panels/panel.h" |
29 #include "chrome/browser/ui/panels/panel_manager.h" | 30 #include "chrome/browser/ui/panels/panel_manager.h" |
30 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
31 #include "chrome/browser/web_applications/web_app.h" | 32 #include "chrome/browser/web_applications/web_app.h" |
32 #include "chrome/common/chrome_switches.h" | 33 #include "chrome/common/chrome_switches.h" |
33 #include "chrome/test/base/in_process_browser_test.h" | 34 #include "chrome/test/base/in_process_browser_test.h" |
34 #include "chrome/test/base/ui_test_utils.h" | 35 #include "chrome/test/base/ui_test_utils.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("title1.html"))); | 135 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("title1.html"))); |
135 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); | 136 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); |
136 | 137 |
137 // Close the tab and verify that we notice. | 138 // Close the tab and verify that we notice. |
138 browser()->tab_strip_model()->CloseWebContentsAt(0, | 139 browser()->tab_strip_model()->CloseWebContentsAt(0, |
139 TabStripModel::CLOSE_NONE); | 140 TabStripModel::CLOSE_NONE); |
140 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchTab("title1.html"))); | 141 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchTab("title1.html"))); |
141 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | 142 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
142 } | 143 } |
143 | 144 |
| 145 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, KillTab) { |
| 146 ShowTaskManager(); |
| 147 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); |
| 148 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
| 149 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchTab("title1.html"))); |
| 150 |
| 151 // Open a new tab and make sure the task manager notices it. |
| 152 AddTabAtIndex(0, GetTestURL(), content::PAGE_TRANSITION_TYPED); |
| 153 |
| 154 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("title1.html"))); |
| 155 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); |
| 156 |
| 157 // Killing the tab via task manager should remove the row. |
| 158 int tab = FindResourceIndex(MatchTab("title1.html")); |
| 159 ASSERT_NE(-1, tab); |
| 160 ASSERT_TRUE(model()->GetResourceWebContents(tab) != NULL); |
| 161 ASSERT_TRUE(model()->CanActivate(tab)); |
| 162 TaskManager::GetInstance()->KillProcess(tab); |
| 163 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchTab("title1.html"))); |
| 164 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
| 165 |
| 166 // Tab should reappear in task manager upon reload. |
| 167 chrome::Reload(browser(), CURRENT_TAB); |
| 168 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("title1.html"))); |
| 169 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); |
| 170 } |
| 171 |
144 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticePanel) { | 172 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticePanel) { |
145 ASSERT_TRUE(LoadExtension( | 173 ASSERT_TRUE(LoadExtension( |
146 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") | 174 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") |
147 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 175 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
148 .AppendASCII("1.0.0.0"))); | 176 .AppendASCII("1.0.0.0"))); |
149 | 177 |
150 // Open a new panel to an extension url. | 178 // Open a new panel to an extension url. |
151 GURL url( | 179 GURL url( |
152 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html"); | 180 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html"); |
153 Panel* panel = PanelManager::GetInstance()->CreatePanel( | 181 Panel* panel = PanelManager::GetInstance()->CreatePanel( |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 } | 759 } |
732 | 760 |
733 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, DevToolsOldUnockedWindow) { | 761 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, DevToolsOldUnockedWindow) { |
734 DevToolsWindow::OpenDevToolsWindowForTest( | 762 DevToolsWindow::OpenDevToolsWindowForTest( |
735 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(), | 763 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(), |
736 false); | 764 false); |
737 ShowTaskManager(); // Task manager shown AFTER dev tools window. | 765 ShowTaskManager(); // Task manager shown AFTER dev tools window. |
738 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); | 766 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); |
739 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); | 767 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); |
740 } | 768 } |
OLD | NEW |