diff options
author | dgozman@chromium.org <dgozman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-23 11:58:10 +0000 |
---|---|---|
committer | dgozman@chromium.org <dgozman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-23 11:58:10 +0000 |
commit | 48c684eb3633e62aafa595a56d54edb94ef6c510 (patch) | |
tree | a228999328fe8c40680428f9b9310af975bbfdbc /chrome/browser/extensions/image_loading_tracker_unittest.cc | |
parent | 64b0c76178a548b6e711dbfe2ed90b540d43743c (diff) | |
download | chromium_src-48c684eb3633e62aafa595a56d54edb94ef6c510.zip chromium_src-48c684eb3633e62aafa595a56d54edb94ef6c510.tar.gz chromium_src-48c684eb3633e62aafa595a56d54edb94ef6c510.tar.bz2 |
Attempt to load component extension favicon from the resources first.
Special handling of CWS icon.
Also correctly handle URL rewrites in favicon requests.
BUG=chromium-os:28314,chromium:120471
TEST=Observe the right favicon for CWS and FileManager component extension. Bookmark them and see the right favicon.
Review URL: https://chromiumcodereview.appspot.com/9979001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133427 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/image_loading_tracker_unittest.cc')
-rw-r--r-- | chrome/browser/extensions/image_loading_tracker_unittest.cc | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/chrome/browser/extensions/image_loading_tracker_unittest.cc b/chrome/browser/extensions/image_loading_tracker_unittest.cc index 67be34f..d07109e 100644 --- a/chrome/browser/extensions/image_loading_tracker_unittest.cc +++ b/chrome/browser/extensions/image_loading_tracker_unittest.cc @@ -13,6 +13,7 @@ #include "chrome/common/extensions/extension_resource.h" #include "content/public/browser/notification_service.h" #include "content/test/test_browser_thread.h" +#include "grit/component_extension_resources.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/image/image.h" @@ -52,7 +53,8 @@ class ImageLoadingTrackerTest : public testing::Test, return result; } - scoped_refptr<Extension> CreateExtension() { + scoped_refptr<Extension> CreateExtension(const char* name, + Extension::Location location) { // Create and load an extension. FilePath test_file; if (!PathService::Get(chrome::DIR_TEST_DATA, &test_file)) { @@ -60,7 +62,7 @@ class ImageLoadingTrackerTest : public testing::Test, return NULL; } test_file = test_file.AppendASCII("extensions") - .AppendASCII("image_loading_tracker"); + .AppendASCII(name); int error_code = 0; std::string error; JSONFileValueSerializer serializer(test_file.AppendASCII("app.json")); @@ -75,7 +77,7 @@ class ImageLoadingTrackerTest : public testing::Test, if (!valid_value.get()) return NULL; - return Extension::Create(test_file, Extension::INVALID, *valid_value, + return Extension::Create(test_file, location, *valid_value, Extension::STRICT_ERROR_CHECKS, &error); } @@ -97,7 +99,8 @@ class ImageLoadingTrackerTest : public testing::Test, // Tests asking ImageLoadingTracker to cache pushes the result to the Extension. TEST_F(ImageLoadingTrackerTest, Cache) { - scoped_refptr<Extension> extension(CreateExtension()); + scoped_refptr<Extension> extension(CreateExtension( + "image_loading_tracker", Extension::INVALID)); ASSERT_TRUE(extension.get() != NULL); ExtensionResource image_resource = @@ -146,7 +149,8 @@ TEST_F(ImageLoadingTrackerTest, Cache) { // Tests deleting an extension while waiting for the image to load doesn't cause // problems. TEST_F(ImageLoadingTrackerTest, DeleteExtensionWhileWaitingForCache) { - scoped_refptr<Extension> extension(CreateExtension()); + scoped_refptr<Extension> extension(CreateExtension( + "image_loading_tracker", Extension::INVALID)); ASSERT_TRUE(extension.get() != NULL); ExtensionResource image_resource = @@ -187,7 +191,8 @@ TEST_F(ImageLoadingTrackerTest, DeleteExtensionWhileWaitingForCache) { // Tests loading multiple dimensions of the same image. TEST_F(ImageLoadingTrackerTest, MultipleImages) { - scoped_refptr<Extension> extension(CreateExtension()); + scoped_refptr<Extension> extension(CreateExtension( + "image_loading_tracker", Extension::INVALID)); ASSERT_TRUE(extension.get() != NULL); std::vector<ImageLoadingTracker::ImageInfo> info_list; @@ -221,3 +226,24 @@ TEST_F(ImageLoadingTrackerTest, MultipleImages) { EXPECT_EQ(ExtensionIconSet::EXTENSION_ICON_BITTY, bmp1->width()); EXPECT_EQ(ExtensionIconSet::EXTENSION_ICON_SMALLISH, bmp2->width()); } + +// Tests IsComponentExtensionResource function. +TEST_F(ImageLoadingTrackerTest, IsComponentExtensionResource) { + scoped_refptr<Extension> extension(CreateExtension( + "file_manager", Extension::COMPONENT)); + ASSERT_TRUE(extension.get() != NULL); + + ExtensionResource resource = + extension->GetIconResource(ExtensionIconSet::EXTENSION_ICON_BITTY, + ExtensionIconSet::MATCH_EXACTLY); + +#if defined(FILE_MANAGER_EXTENSION) + ImageLoadingTracker loader(this); + int resource_id; + ASSERT_EQ(true, + loader.IsComponentExtensionResource(extension.get(), + resource, + resource_id)); + ASSERT_EQ(IDR_FILE_MANAGER_ICON_16, resource_id); +#endif +} |