OLD | NEW |
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/extensions/browser_action_test_util.h" | 5 #include "chrome/browser/extensions/browser_action_test_util.h" |
6 #include "chrome/browser/extensions/extension_browsertest.h" | 6 #include "chrome/browser/extensions/extension_browsertest.h" |
7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/views/browser_actions_container.h" | 10 #include "chrome/browser/ui/views/browser_actions_container.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 | 235 |
236 ReloadExtension(idA); | 236 ReloadExtension(idA); |
237 | 237 |
238 // The browser action should become visible again. | 238 // The browser action should become visible again. |
239 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions()); | 239 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions()); |
240 } | 240 } |
241 | 241 |
242 IN_PROC_BROWSER_TEST_F(BrowserActionsContainerTest, TestCrash57536) { | 242 IN_PROC_BROWSER_TEST_F(BrowserActionsContainerTest, TestCrash57536) { |
243 LOG(INFO) << "Test starting\n" << std::flush; | 243 LOG(INFO) << "Test starting\n" << std::flush; |
244 | 244 |
| 245 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 246 const size_t size_before = service->extensions()->size(); |
| 247 |
245 LOG(INFO) << "Loading extension\n" << std::flush; | 248 LOG(INFO) << "Loading extension\n" << std::flush; |
246 | 249 |
247 // Load extension A (contains browser action). | 250 // Load extension A (contains browser action). |
248 const Extension* extension = LoadExtension( | 251 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("api_test") |
249 test_data_dir_.AppendASCII("api_test") | 252 .AppendASCII("browser_action") |
250 .AppendASCII("browser_action") | 253 .AppendASCII("crash_57536"))); |
251 .AppendASCII("crash_57536")); | 254 |
252 ASSERT_TRUE(extension); | 255 const Extension* extension = service->extensions()->at(size_before); |
253 | 256 |
254 LOG(INFO) << "Creating bitmap\n" << std::flush; | 257 LOG(INFO) << "Creating bitmap\n" << std::flush; |
255 | 258 |
256 // Create and cache and empty bitmap. | 259 // Create and cache and empty bitmap. |
257 SkBitmap bitmap; | 260 SkBitmap bitmap; |
258 bitmap.setConfig(SkBitmap::kARGB_8888_Config, | 261 bitmap.setConfig(SkBitmap::kARGB_8888_Config, |
259 Extension::kBrowserActionIconMaxSize, | 262 Extension::kBrowserActionIconMaxSize, |
260 Extension::kBrowserActionIconMaxSize); | 263 Extension::kBrowserActionIconMaxSize); |
261 bitmap.allocPixels(); | 264 bitmap.allocPixels(); |
262 | 265 |
263 LOG(INFO) << "Set as cached image\n" << std::flush; | 266 LOG(INFO) << "Set as cached image\n" << std::flush; |
264 | 267 |
265 gfx::Size size(Extension::kBrowserActionIconMaxSize, | 268 gfx::Size size(Extension::kBrowserActionIconMaxSize, |
266 Extension::kBrowserActionIconMaxSize); | 269 Extension::kBrowserActionIconMaxSize); |
267 extension->SetCachedImage( | 270 extension->SetCachedImage( |
268 extension->GetResource(extension->browser_action()->default_icon_path()), | 271 extension->GetResource(extension->browser_action()->default_icon_path()), |
269 bitmap, | 272 bitmap, |
270 size); | 273 size); |
271 | 274 |
272 LOG(INFO) << "Disabling extension\n" << std::flush; | 275 LOG(INFO) << "Disabling extension\n" << std::flush; |
273 DisableExtension(extension->id()); | 276 DisableExtension(extension->id()); |
274 LOG(INFO) << "Enabling extension\n" << std::flush; | 277 LOG(INFO) << "Enabling extension\n" << std::flush; |
275 EnableExtension(extension->id()); | 278 EnableExtension(extension->id()); |
276 LOG(INFO) << "Test ending\n" << std::flush; | 279 LOG(INFO) << "Test ending\n" << std::flush; |
277 } | 280 } |
OLD | NEW |