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

Unified Diff: ui/base/resource/resource_bundle_unittest.cc

Issue 12939015: Fix sizing when auto-scaling a missing resource at a non-integer scale factor. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Make rounding test Windows only. Created 7 years, 8 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 | « ui/base/resource/resource_bundle.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/resource/resource_bundle_unittest.cc
diff --git a/ui/base/resource/resource_bundle_unittest.cc b/ui/base/resource/resource_bundle_unittest.cc
index ab1c20944bd1c97ddc6483e21405494f2fe20536..94e03bc2be0b348cb3f8d9d4f944b8574bd4be4c 100644
--- a/ui/base/resource/resource_bundle_unittest.cc
+++ b/ui/base/resource/resource_bundle_unittest.cc
@@ -498,6 +498,39 @@ TEST_F(ResourceBundleImageTest, GetImageNamedFallback1x) {
EXPECT_EQ(20, image_rep.pixel_height());
}
+#if defined(OS_WIN)
+// Tests GetImageNamed() behaves properly when the size of a scaled image
+// requires rounding as a result of using a non-integer scale factor.
+// Scale factors of 140 and 1805 are Windows specific.
+TEST_F(ResourceBundleImageTest, GetImageNamedFallback1xRounding) {
+ base::FilePath data_path = dir_path().AppendASCII("sample.pak");
+ base::FilePath data_140P_path = dir_path().AppendASCII("sample_140P.pak");
+ base::FilePath data_180P_path = dir_path().AppendASCII("sample_180P.pak");
+
+ CreateDataPackWithSingleBitmap(data_path, 8, base::StringPiece());
+ // Mark 140% and 180% images as requiring 1x fallback.
+ CreateDataPackWithSingleBitmap(data_140P_path, 8, base::StringPiece(
+ reinterpret_cast<const char*>(kPngScaleChunk),
+ arraysize(kPngScaleChunk)));
+ CreateDataPackWithSingleBitmap(data_180P_path, 8, base::StringPiece(
+ reinterpret_cast<const char*>(kPngScaleChunk),
+ arraysize(kPngScaleChunk)));
+
+ ResourceBundle* resource_bundle = CreateResourceBundleWithEmptyLocalePak();
+ resource_bundle->AddDataPackFromPath(data_path, SCALE_FACTOR_100P);
+ resource_bundle->AddDataPackFromPath(data_140P_path, SCALE_FACTOR_140P);
+ resource_bundle->AddDataPackFromPath(data_180P_path, SCALE_FACTOR_180P);
+
+ // Non-integer dimensions should be rounded up.
+ gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3);
+ gfx::ImageSkiaRep image_rep =
+ image_skia->GetRepresentation(ui::SCALE_FACTOR_140P);
+ EXPECT_EQ(12, image_rep.pixel_width());
+ image_rep = image_skia->GetRepresentation(ui::SCALE_FACTOR_180P);
+ EXPECT_EQ(15, image_rep.pixel_width());
+}
+#endif
+
TEST_F(ResourceBundleImageTest, FallbackToNone) {
base::FilePath data_default_path = dir_path().AppendASCII("sample.pak");
« no previous file with comments | « ui/base/resource/resource_bundle.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698