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

Side by Side Diff: extensions/browser/image_loader_unittest.cc

Issue 355223002: Add ExtensionsTestBrowserContext class for test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/image_loader.h" 5 #include "extensions/browser/image_loader.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/json/json_file_value_serializer.h" 8 #include "base/json/json_file_value_serializer.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/common/chrome_paths.h" 12 #include "chrome/common/chrome_paths.h"
14 #include "content/public/browser/notification_service.h" 13 #include "content/public/browser/notification_service.h"
15 #include "content/public/test/test_browser_thread.h" 14 #include "content/public/test/test_browser_thread.h"
16 #include "extensions/browser/component_extension_resource_manager.h" 15 #include "extensions/browser/component_extension_resource_manager.h"
16 #include "extensions/browser/extension_registry.h"
17 #include "extensions/browser/extensions_browser_client.h" 17 #include "extensions/browser/extensions_browser_client.h"
18 #include "extensions/common/constants.h" 18 #include "extensions/common/constants.h"
19 #include "extensions/common/extension.h" 19 #include "extensions/common/extension.h"
20 #include "extensions/common/extension_icon_set.h" 20 #include "extensions/common/extension_icon_set.h"
21 #include "extensions/common/extension_resource.h" 21 #include "extensions/common/extension_resource.h"
22 #include "extensions/common/extensions_test_browser_context.h"
22 #include "extensions/common/manifest.h" 23 #include "extensions/common/manifest.h"
23 #include "extensions/common/manifest_handlers/icons_handler.h" 24 #include "extensions/common/manifest_handlers/icons_handler.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
25 #include "third_party/skia/include/core/SkBitmap.h" 26 #include "third_party/skia/include/core/SkBitmap.h"
26 #include "ui/gfx/image/image.h" 27 #include "ui/gfx/image/image.h"
27 #include "ui/gfx/image/image_family.h" 28 #include "ui/gfx/image/image_family.h"
28 #include "ui/gfx/image/image_skia.h" 29 #include "ui/gfx/image/image_skia.h"
29 #include "ui/gfx/size.h" 30 #include "ui/gfx/size.h"
30 31
31 #if defined(OS_CHROMEOS) 32 #if defined(OS_CHROMEOS)
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 sizes.insert(extension_misc::EXTENSION_ICON_SMALLISH); 179 sizes.insert(extension_misc::EXTENSION_ICON_SMALLISH);
179 loader.LoadImageAsync(extension.get(), 180 loader.LoadImageAsync(extension.get(),
180 image_resource, 181 image_resource,
181 max_size, 182 max_size,
182 base::Bind(&ImageLoaderTest::OnImageLoaded, 183 base::Bind(&ImageLoaderTest::OnImageLoaded,
183 base::Unretained(this))); 184 base::Unretained(this)));
184 185
185 // The image isn't cached, so we should not have received notification. 186 // The image isn't cached, so we should not have received notification.
186 EXPECT_EQ(0, image_loaded_count()); 187 EXPECT_EQ(0, image_loaded_count());
187 188
189 extensions::ExtensionsTestBrowserContext browser_context;
188 // Send out notification the extension was uninstalled. 190 // Send out notification the extension was uninstalled.
189 UnloadedExtensionInfo details(extension.get(), 191 extensions::ExtensionRegistry::Get(&browser_context)->TriggerOnUnloaded(
190 UnloadedExtensionInfo::REASON_UNINSTALL); 192 extension.get(), UnloadedExtensionInfo::REASON_UNINSTALL);
191 content::NotificationService::current()->Notify(
192 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
193 content::NotificationService::AllSources(),
194 content::Details<UnloadedExtensionInfo>(&details));
195 193
196 // Chuck the extension, that way if anyone tries to access it we should crash 194 // Chuck the extension, that way if anyone tries to access it we should crash
197 // or get valgrind errors. 195 // or get valgrind errors.
198 extension = NULL; 196 extension = NULL;
199 197
200 WaitForImageLoad(); 198 WaitForImageLoad();
201 199
202 // Even though we deleted the extension, we should still get the image. 200 // Even though we deleted the extension, we should still get the image.
203 // We should still have gotten the image. 201 // We should still have gotten the image.
204 EXPECT_EQ(1, image_loaded_count()); 202 EXPECT_EQ(1, image_loaded_count());
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 340
343 #if defined(OS_CHROMEOS) 341 #if defined(OS_CHROMEOS)
344 int resource_id; 342 int resource_id;
345 ASSERT_TRUE(resource_manager->IsComponentExtensionResource( 343 ASSERT_TRUE(resource_manager->IsComponentExtensionResource(
346 extension->path(), 344 extension->path(),
347 resource.relative_path(), 345 resource.relative_path(),
348 &resource_id)); 346 &resource_id));
349 ASSERT_EQ(IDR_FILE_MANAGER_ICON_16, resource_id); 347 ASSERT_EQ(IDR_FILE_MANAGER_ICON_16, resource_id);
350 #endif 348 #endif
351 } 349 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698