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

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

Issue 7063015: Swap processes on reload if a hosted app has been installed/uninstalled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile on Windows Created 9 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/file_path.h" 7 #include "base/file_path.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/background_contents_service.h" 9 #include "chrome/browser/background_contents_service.h"
10 #include "chrome/browser/background_contents_service_factory.h" 10 #include "chrome/browser/background_contents_service_factory.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.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/notifications/desktop_notification_service.h" 14 #include "chrome/browser/notifications/desktop_notification_service.h"
15 #include "chrome/browser/notifications/notification.h" 15 #include "chrome/browser/notifications/notification.h"
16 #include "chrome/browser/notifications/notification_test_util.h" 16 #include "chrome/browser/notifications/notification_test_util.h"
17 #include "chrome/browser/notifications/notification_ui_manager.h" 17 #include "chrome/browser/notifications/notification_ui_manager.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 19 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
20 #include "chrome/browser/tabs/tab_strip_model.h" 20 #include "chrome/browser/tabs/tab_strip_model.h"
21 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
22 #include "chrome/browser/ui/browser_navigator.h" 22 #include "chrome/browser/ui/browser_navigator.h"
23 #include "chrome/browser/ui/browser_window.h" 23 #include "chrome/browser/ui/browser_window.h"
24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
25 #include "chrome/common/extensions/extension.h" 25 #include "chrome/common/extensions/extension.h"
26 #include "chrome/test/in_process_browser_test.h" 26 #include "chrome/test/in_process_browser_test.h"
27 #include "chrome/test/ui_test_utils.h" 27 #include "chrome/test/ui_test_utils.h"
28 #include "content/common/page_transition_types.h" 28 #include "content/common/page_transition_types.h"
29 #include "grit/generated_resources.h" 29 #include "grit/generated_resources.h"
30 #include "net/base/mock_host_resolver.h"
30 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
31 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
32 33
33 namespace { 34 namespace {
34 35
35 const FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html"); 36 const FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html");
36 37
37 class ResourceChangeObserver : public TaskManagerModelObserver { 38 class ResourceChangeObserver : public TaskManagerModelObserver {
38 public: 39 public:
39 ResourceChangeObserver(const TaskManagerModel* model, 40 ResourceChangeObserver(const TaskManagerModel* model,
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 298
298 // Open a new tab to the app's launch URL and make sure we notice that. 299 // Open a new tab to the app's launch URL and make sure we notice that.
299 GURL url(extension->GetResourceURL("main.html")); 300 GURL url(extension->GetResourceURL("main.html"));
300 AddTabAtIndex(0, url, PageTransition::TYPED); 301 AddTabAtIndex(0, url, PageTransition::TYPED);
301 WaitForResourceChange(3); 302 WaitForResourceChange(3);
302 303
303 // Check that the third entry (main.html) is of type extension and has both 304 // Check that the third entry (main.html) is of type extension and has both
304 // a tab contents and an extension. The title should start with "App:". 305 // a tab contents and an extension. The title should start with "App:".
305 ASSERT_EQ(TaskManager::Resource::EXTENSION, model()->GetResourceType(2)); 306 ASSERT_EQ(TaskManager::Resource::EXTENSION, model()->GetResourceType(2));
306 ASSERT_TRUE(model()->GetResourceTabContents(2) != NULL); 307 ASSERT_TRUE(model()->GetResourceTabContents(2) != NULL);
307 ASSERT_TRUE(model()->GetResourceExtension(2) != NULL); 308 ASSERT_TRUE(model()->GetResourceExtension(2) == extension);
308 string16 prefix = l10n_util::GetStringFUTF16( 309 string16 prefix = l10n_util::GetStringFUTF16(
309 IDS_TASK_MANAGER_APP_PREFIX, string16()); 310 IDS_TASK_MANAGER_APP_PREFIX, string16());
310 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), prefix, true)); 311 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), prefix, true));
311 312
312 // Unload extension to avoid crash on Windows. 313 // Unload extension to avoid crash on Windows.
313 UnloadExtension(last_loaded_extension_id_); 314 UnloadExtension(last_loaded_extension_id_);
314 WaitForResourceChange(2); 315 WaitForResourceChange(2);
315 } 316 }
316 317
318 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabs) {
319 // Show the task manager. This populates the model, and helps with debugging
320 // (you see the task manager).
321 browser()->window()->ShowTaskManager();
322
323 // Browser and the New Tab Page.
324 WaitForResourceChange(2);
325
326 // The app under test acts on URLs whose host is "localhost",
327 // so the URLs we navigate to must have host "localhost".
328 host_resolver()->AddRule("*", "127.0.0.1");
329 ASSERT_TRUE(test_server()->Start());
330 GURL::Replacements replace_host;
331 std::string host_str("localhost"); // must stay in scope with replace_host
332 replace_host.SetHostStr(host_str);
333 GURL base_url = test_server()->GetURL(
334 "files/extensions/api_test/app_process/");
335 base_url = base_url.ReplaceComponents(replace_host);
336
337 // Open a new tab to an app URL before the app is loaded.
338 GURL url(base_url.Resolve("path1/empty.html"));
339 AddTabAtIndex(0, url, PageTransition::TYPED);
340 ui_test_utils::WaitForNavigation(
341 &browser()->GetSelectedTabContents()->controller());
342
343 // Check that the third entry's title starts with "Tab:".
344 string16 tab_prefix = l10n_util::GetStringFUTF16(
345 IDS_TASK_MANAGER_TAB_PREFIX, string16());
346 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), tab_prefix, true));
347
348 // Load the hosted app and make sure it still starts with "Tab:",
349 // since it hasn't changed to an app process yet.
350 ASSERT_TRUE(LoadExtension(
351 test_data_dir_.AppendASCII("api_test").AppendASCII("app_process")));
352 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), tab_prefix, true));
353
354 // Now reload and check that the third entry's title now starts with "App:".
355 ui_test_utils::NavigateToURL(browser(), url);
356 string16 app_prefix = l10n_util::GetStringFUTF16(
357 IDS_TASK_MANAGER_APP_PREFIX, string16());
358 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), app_prefix, true));
359
360 // Disable extension and reload page.
361 DisableExtension(last_loaded_extension_id_);
362 ui_test_utils::NavigateToURL(browser(), url);
363
364 // The third entry's title should be back to a normal tab.
365 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), tab_prefix, true));
366 }
367
317 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeNotificationChanges) { 368 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeNotificationChanges) {
318 EXPECT_EQ(0, model()->ResourceCount()); 369 EXPECT_EQ(0, model()->ResourceCount());
319 370
320 // Show the task manager. 371 // Show the task manager.
321 browser()->window()->ShowTaskManager(); 372 browser()->window()->ShowTaskManager();
322 // Expect to see the browser and the New Tab Page renderer. 373 // Expect to see the browser and the New Tab Page renderer.
323 WaitForResourceChange(2); 374 WaitForResourceChange(2);
324 375
325 // Show a notification. 376 // Show a notification.
326 NotificationUIManager* notifications = 377 NotificationUIManager* notifications =
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 WaitForResourceChange(3); 518 WaitForResourceChange(3);
468 519
469 // Check that we get some value for the cache columns. 520 // Check that we get some value for the cache columns.
470 DCHECK_NE(model()->GetResourceWebCoreImageCacheSize(2), 521 DCHECK_NE(model()->GetResourceWebCoreImageCacheSize(2),
471 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); 522 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT));
472 DCHECK_NE(model()->GetResourceWebCoreScriptsCacheSize(2), 523 DCHECK_NE(model()->GetResourceWebCoreScriptsCacheSize(2),
473 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); 524 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT));
474 DCHECK_NE(model()->GetResourceWebCoreCSSCacheSize(2), 525 DCHECK_NE(model()->GetResourceWebCoreCSSCacheSize(2),
475 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); 526 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT));
476 } 527 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/app_process_apitest.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