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

Side by Side Diff: chrome/browser/task_manager/task_manager_browsertest.cc

Issue 5526002: Show extension tabs in task manager and correctly label apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding NoticeAppTabs test. Created 10 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/background_contents_service.h" 10 #include "chrome/browser/background_contents_service.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 // Browser and the New Tab Page. 100 // Browser and the New Tab Page.
101 EXPECT_EQ(2, model()->ResourceCount()); 101 EXPECT_EQ(2, model()->ResourceCount());
102 102
103 // Open a new tab and make sure we notice that. 103 // Open a new tab and make sure we notice that.
104 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), 104 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
105 FilePath(kTitle1File))); 105 FilePath(kTitle1File)));
106 AddTabAtIndex(0, url, PageTransition::TYPED); 106 AddTabAtIndex(0, url, PageTransition::TYPED);
107 WaitForResourceChange(3); 107 WaitForResourceChange(3);
108 108
109 // Check that the third entry is a tab contents resource whose title starts
110 // starts with "Tab:".
111 ASSERT_TRUE(model()->GetResourceTabContents(2) != NULL);
112 string16 prefix = WideToUTF16Hack(l10n_util::GetStringF(
113 IDS_TASK_MANAGER_TAB_PREFIX, L""));
114 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), prefix, true));
115
109 // Close the tab and verify that we notice. 116 // Close the tab and verify that we notice.
110 TabContents* first_tab = browser()->GetTabContentsAt(0); 117 TabContents* first_tab = browser()->GetTabContentsAt(0);
111 ASSERT_TRUE(first_tab); 118 ASSERT_TRUE(first_tab);
112 browser()->CloseTabContents(first_tab); 119 browser()->CloseTabContents(first_tab);
113 WaitForResourceChange(2); 120 WaitForResourceChange(2);
114 } 121 }
115 122
116 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeBGContentsChanges) { 123 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeBGContentsChanges) {
117 EXPECT_EQ(0, model()->ResourceCount()); 124 EXPECT_EQ(0, model()->ResourceCount());
118 125
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // Browser and the New Tab Page. 166 // Browser and the New Tab Page.
160 EXPECT_EQ(2, model()->ResourceCount()); 167 EXPECT_EQ(2, model()->ResourceCount());
161 168
162 // Loading an extension with a background page should result in a new 169 // Loading an extension with a background page should result in a new
163 // resource being created for it. 170 // resource being created for it.
164 ASSERT_TRUE(LoadExtension( 171 ASSERT_TRUE(LoadExtension(
165 test_data_dir_.AppendASCII("common").AppendASCII("background_page"))); 172 test_data_dir_.AppendASCII("common").AppendASCII("background_page")));
166 WaitForResourceChange(3); 173 WaitForResourceChange(3);
167 } 174 }
168 175
176 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTabs) {
177 // Show the task manager. This populates the model, and helps with debugging
178 // (you see the task manager).
179 browser()->window()->ShowTaskManager();
180
181 ASSERT_TRUE(LoadExtension(
182 test_data_dir_.AppendASCII("good").AppendASCII("Extensions")
183 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
184 .AppendASCII("1.0.0.0")));
185
186 // Browser, Extension background page, and the New Tab Page.
187 EXPECT_EQ(3, model()->ResourceCount());
188
189 // Open a new tab to an extension URL and make sure we notice that.
190 GURL url("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html");
191 AddTabAtIndex(0, url, PageTransition::TYPED);
192 WaitForResourceChange(4);
193
194 // Check that the third entry (background) is an extension resource whose
195 // title starts with "Extension:".
196 ASSERT_TRUE(model()->GetResourceExtension(2) != NULL);
197 string16 prefix = WideToUTF16Hack(l10n_util::GetStringF(
198 IDS_TASK_MANAGER_EXTENSION_PREFIX, L""));
199 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), prefix, true));
200
201 // Check that the fourth entry (page.html) is a tab contents resource whose
202 // title starts with "Extension:".
203 ASSERT_TRUE(model()->GetResourceTabContents(3) != NULL);
204 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(3), prefix, true));
205 }
206
207 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeAppTabs) {
208 // Show the task manager. This populates the model, and helps with debugging
209 // (you see the task manager).
210 browser()->window()->ShowTaskManager();
211
212 ASSERT_TRUE(LoadExtension(
213 test_data_dir_.AppendASCII("packaged_app")));
214
215 // Browser and the New Tab Page.
216 EXPECT_EQ(2, model()->ResourceCount());
217
218 // Open a new tab to the app's launch URL and make sure we notice that.
219 GURL url("chrome-extension://pffmiogcfmficciligcchmiebhahbanm/main.html");
Charlie Reis 2010/12/02 02:14:23 I'm guessing this is fragile and won't have the sa
220 AddTabAtIndex(0, url, PageTransition::TYPED);
221 WaitForResourceChange(3);
222
223 // Check that the third entry (main.html) is a tab contents resource whose
224 // title starts with "App:".
225 ASSERT_TRUE(model()->GetResourceTabContents(2) != NULL);
226 string16 prefix = WideToUTF16Hack(l10n_util::GetStringF(
227 IDS_TASK_MANAGER_APP_PREFIX, L""));
228 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), prefix, true));
229 }
230
169 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeNotificationChanges) { 231 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeNotificationChanges) {
170 EXPECT_EQ(0, model()->ResourceCount()); 232 EXPECT_EQ(0, model()->ResourceCount());
171 233
172 // Show the task manager. 234 // Show the task manager.
173 browser()->window()->ShowTaskManager(); 235 browser()->window()->ShowTaskManager();
174 // Expect to see the browser and the New Tab Page renderer. 236 // Expect to see the browser and the New Tab Page renderer.
175 EXPECT_EQ(2, model()->ResourceCount()); 237 EXPECT_EQ(2, model()->ResourceCount());
176 238
177 // Show a notification. 239 // Show a notification.
178 NotificationUIManager* notifications = 240 NotificationUIManager* notifications =
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 WaitForResourceChange(3); 368 WaitForResourceChange(3);
307 369
308 // Check that we get some value for the cache columns. 370 // Check that we get some value for the cache columns.
309 DCHECK_NE(model()->GetResourceWebCoreImageCacheSize(2), 371 DCHECK_NE(model()->GetResourceWebCoreImageCacheSize(2),
310 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); 372 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT));
311 DCHECK_NE(model()->GetResourceWebCoreScriptsCacheSize(2), 373 DCHECK_NE(model()->GetResourceWebCoreScriptsCacheSize(2),
312 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); 374 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT));
313 DCHECK_NE(model()->GetResourceWebCoreCSSCacheSize(2), 375 DCHECK_NE(model()->GetResourceWebCoreCSSCacheSize(2),
314 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); 376 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT));
315 } 377 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.cc ('k') | chrome/browser/task_manager/task_manager_resource_providers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698