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

Unified Diff: chrome/common/extensions/extension_unittest.cc

Issue 12213093: Remove ImageLoadingTracker class (Closed) Base URL: https://git.chromium.org/chromium/src.git@Issue_163929
Patch Set: Fix merge conflict Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/extension_resource.h ('k') | ui/gfx/image/image_skia.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/extension_unittest.cc
diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc
index c701f1d4e5c6a691ea9c4acebe609695684994a8..909e9bf0836541a60b890187c92e7046a4653090 100644
--- a/chrome/common/extensions/extension_unittest.cc
+++ b/chrome/common/extensions/extension_unittest.cc
@@ -496,91 +496,6 @@ TEST_F(ExtensionTest, SocketPermissions) {
"239.255.255.250", 1900));
}
-// Returns a copy of |source| resized to |size| x |size|.
-static SkBitmap ResizedCopy(const SkBitmap& source, int size) {
- return skia::ImageOperations::Resize(source,
- skia::ImageOperations::RESIZE_LANCZOS3,
- size,
- size);
-}
-
-static bool SizeEquals(const SkBitmap& bitmap, const gfx::Size& size) {
- return bitmap.width() == size.width() && bitmap.height() == size.height();
-}
-
-TEST_F(ExtensionTest, ImageCaching) {
- base::FilePath path;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path));
- path = path.AppendASCII("extensions");
-
- // Initialize the Extension.
- std::string errors;
- DictionaryValue values;
- values.SetString(keys::kName, "test");
- values.SetString(keys::kVersion, "0.1");
- scoped_refptr<Extension> extension(Extension::Create(
- path, Manifest::INVALID_LOCATION, values, Extension::NO_FLAGS, &errors));
- ASSERT_TRUE(extension.get());
-
- // Create an ExtensionResource pointing at an icon.
- base::FilePath icon_relative_path(FILE_PATH_LITERAL("icon3.png"));
- ExtensionResource resource(extension->id(),
- extension->path(),
- icon_relative_path);
-
- // Read in the icon file.
- base::FilePath icon_absolute_path =
- extension->path().Append(icon_relative_path);
- std::string raw_png;
- ASSERT_TRUE(file_util::ReadFileToString(icon_absolute_path, &raw_png));
- SkBitmap image;
- ASSERT_TRUE(gfx::PNGCodec::Decode(
- reinterpret_cast<const unsigned char*>(raw_png.data()),
- raw_png.length(),
- &image));
-
- // Make sure the icon file is the size we expect.
- gfx::Size original_size(66, 66);
- ASSERT_EQ(image.width(), original_size.width());
- ASSERT_EQ(image.height(), original_size.height());
-
- // Create two resized versions at size 16x16 and 24x24.
- SkBitmap image16 = ResizedCopy(image, 16);
- SkBitmap image24 = ResizedCopy(image, 24);
-
- gfx::Size size16(16, 16);
- gfx::Size size24(24, 24);
-
- // Cache the 16x16 copy.
- EXPECT_FALSE(extension->HasCachedImage(resource, size16));
- extension->SetCachedImage(resource, image16, original_size);
- EXPECT_TRUE(extension->HasCachedImage(resource, size16));
- EXPECT_TRUE(SizeEquals(extension->GetCachedImage(resource, size16), size16));
- EXPECT_FALSE(extension->HasCachedImage(resource, size24));
- EXPECT_FALSE(extension->HasCachedImage(resource, original_size));
-
- // Cache the 24x24 copy.
- extension->SetCachedImage(resource, image24, original_size);
- EXPECT_TRUE(extension->HasCachedImage(resource, size24));
- EXPECT_TRUE(SizeEquals(extension->GetCachedImage(resource, size24), size24));
- EXPECT_FALSE(extension->HasCachedImage(resource, original_size));
-
- // Cache the original, and verify that it gets returned when we ask for a
- // max_size that is larger than the original.
- gfx::Size size128(128, 128);
- EXPECT_TRUE(image.width() < size128.width() &&
- image.height() < size128.height());
- extension->SetCachedImage(resource, image, original_size);
- EXPECT_TRUE(extension->HasCachedImage(resource, original_size));
- EXPECT_TRUE(extension->HasCachedImage(resource, size128));
- EXPECT_TRUE(SizeEquals(extension->GetCachedImage(resource, original_size),
- original_size));
- EXPECT_TRUE(SizeEquals(extension->GetCachedImage(resource, size128),
- original_size));
- EXPECT_EQ(extension->GetCachedImage(resource, original_size).getPixels(),
- extension->GetCachedImage(resource, size128).getPixels());
-}
-
// This tests the API permissions with an empty manifest (one that just
// specifies a name and a version and nothing else).
TEST_F(ExtensionTest, ApiPermissions) {
« no previous file with comments | « chrome/common/extensions/extension_resource.h ('k') | ui/gfx/image/image_skia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698