| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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.h" | 5 #include "chrome/browser/task_manager.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
| 9 #include "chrome/browser/browser_window.h" | 9 #include "chrome/browser/browser_window.h" |
| 10 #include "chrome/browser/extensions/extension_browsertest.h" | 10 #include "chrome/browser/extensions/extension_browsertest.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 ASSERT_TRUE(LoadExtension( | 111 ASSERT_TRUE(LoadExtension( |
| 112 test_data_dir_.AppendASCII("common").AppendASCII("one_in_shelf"))); | 112 test_data_dir_.AppendASCII("common").AppendASCII("one_in_shelf"))); |
| 113 WaitForResourceChange(3); | 113 WaitForResourceChange(3); |
| 114 | 114 |
| 115 // Make sure we also recognize extensions with just background pages. | 115 // Make sure we also recognize extensions with just background pages. |
| 116 ASSERT_TRUE(LoadExtension( | 116 ASSERT_TRUE(LoadExtension( |
| 117 test_data_dir_.AppendASCII("common").AppendASCII("background_page"))); | 117 test_data_dir_.AppendASCII("common").AppendASCII("background_page"))); |
| 118 WaitForResourceChange(4); | 118 WaitForResourceChange(4); |
| 119 } | 119 } |
| 120 | 120 |
| 121 // Regression test for http://crbug.com/18693. |
| 122 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, ReloadExtension) { |
| 123 // Show the task manager. This populates the model, and helps with debugging |
| 124 // (you see the task manager). |
| 125 browser()->window()->ShowTaskManager(); |
| 126 |
| 127 ASSERT_TRUE(LoadExtension( |
| 128 test_data_dir_.AppendASCII("common").AppendASCII("background_page"))); |
| 129 |
| 130 // Wait until we see the loaded extension in the task manager (the three |
| 131 // resources are: the browser process, New Tab Page, and the extension). |
| 132 WaitForResourceChange(3); |
| 133 |
| 134 EXPECT_TRUE(model()->GetResourceExtension(0) == NULL); |
| 135 EXPECT_TRUE(model()->GetResourceExtension(1) == NULL); |
| 136 ASSERT_TRUE(model()->GetResourceExtension(2) != NULL); |
| 137 |
| 138 const Extension* extension = model()->GetResourceExtension(2); |
| 139 |
| 140 // Reload the extension a few times and make sure our resource count |
| 141 // doesn't increase. |
| 142 ReloadExtension(extension->id()); |
| 143 EXPECT_EQ(3, model()->ResourceCount()); |
| 144 extension = model()->GetResourceExtension(2); |
| 145 |
| 146 ReloadExtension(extension->id()); |
| 147 EXPECT_EQ(3, model()->ResourceCount()); |
| 148 extension = model()->GetResourceExtension(2); |
| 149 |
| 150 ReloadExtension(extension->id()); |
| 151 EXPECT_EQ(3, model()->ResourceCount()); |
| 152 } |
| 153 |
| 121 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, PopulateWebCacheFields) { | 154 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, PopulateWebCacheFields) { |
| 122 EXPECT_EQ(0, model()->ResourceCount()); | 155 EXPECT_EQ(0, model()->ResourceCount()); |
| 123 | 156 |
| 124 // Show the task manager. This populates the model, and helps with debugging | 157 // Show the task manager. This populates the model, and helps with debugging |
| 125 // (you see the task manager). | 158 // (you see the task manager). |
| 126 browser()->window()->ShowTaskManager(); | 159 browser()->window()->ShowTaskManager(); |
| 127 | 160 |
| 128 // Browser and the New Tab Page. | 161 // Browser and the New Tab Page. |
| 129 EXPECT_EQ(2, model()->ResourceCount()); | 162 EXPECT_EQ(2, model()->ResourceCount()); |
| 130 | 163 |
| 131 // Open a new tab and make sure we notice that. | 164 // Open a new tab and make sure we notice that. |
| 132 GURL url(ui_test_utils::GetTestUrl(L".", L"title1.html")); | 165 GURL url(ui_test_utils::GetTestUrl(L".", L"title1.html")); |
| 133 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, | 166 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, |
| 134 true, 0, false, NULL); | 167 true, 0, false, NULL); |
| 135 WaitForResourceChange(3); | 168 WaitForResourceChange(3); |
| 136 | 169 |
| 137 // Check that we get some value for the cache columns. | 170 // Check that we get some value for the cache columns. |
| 138 DCHECK_NE(model()->GetResourceWebCoreImageCacheSize(2), | 171 DCHECK_NE(model()->GetResourceWebCoreImageCacheSize(2), |
| 139 l10n_util::GetString(IDS_TASK_MANAGER_NA_CELL_TEXT)); | 172 l10n_util::GetString(IDS_TASK_MANAGER_NA_CELL_TEXT)); |
| 140 DCHECK_NE(model()->GetResourceWebCoreScriptsCacheSize(2), | 173 DCHECK_NE(model()->GetResourceWebCoreScriptsCacheSize(2), |
| 141 l10n_util::GetString(IDS_TASK_MANAGER_NA_CELL_TEXT)); | 174 l10n_util::GetString(IDS_TASK_MANAGER_NA_CELL_TEXT)); |
| 142 DCHECK_NE(model()->GetResourceWebCoreCSSCacheSize(2), | 175 DCHECK_NE(model()->GetResourceWebCoreCSSCacheSize(2), |
| 143 l10n_util::GetString(IDS_TASK_MANAGER_NA_CELL_TEXT)); | 176 l10n_util::GetString(IDS_TASK_MANAGER_NA_CELL_TEXT)); |
| 144 } | 177 } |
| OLD | NEW |