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

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

Issue 11301007: Load the resources for max scale factor first. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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_mac.mm ('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: 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 339e59c767309678df1bc0db63ff6f785355e016..9478d5ce8868404d6b2f178405c7fad6f0e8ae78 100644
--- a/ui/base/resource/resource_bundle_unittest.cc
+++ b/ui/base/resource/resource_bundle_unittest.cc
@@ -423,20 +423,29 @@ TEST_F(ResourceBundleImageTest, GetRawDataResource) {
// Test requesting image reps at various scale factors from the image returned
// via ResourceBundle::GetImageNamed().
TEST_F(ResourceBundleImageTest, GetImageNamed) {
- FilePath data_path = dir_path().Append(FILE_PATH_LITERAL("sample.pak"));
- FilePath data_2x_path = dir_path().Append(FILE_PATH_LITERAL("sample_2x.pak"));
+ FilePath data_1x_path = dir_path().AppendASCII("sample_1x.pak");
+ FilePath data_2x_path = dir_path().AppendASCII("sample_2x.pak");
// Create the pak files.
- CreateDataPackWithSingleBitmap(data_path, 10, base::StringPiece());
+ CreateDataPackWithSingleBitmap(data_1x_path, 10, base::StringPiece());
CreateDataPackWithSingleBitmap(data_2x_path, 20, base::StringPiece());
// Load the regular and 2x pak files.
ResourceBundle* resource_bundle = CreateResourceBundleWithEmptyLocalePak();
- resource_bundle->AddDataPackFromPath(data_path, SCALE_FACTOR_100P);
+ resource_bundle->AddDataPackFromPath(data_1x_path, SCALE_FACTOR_100P);
resource_bundle->AddDataPackFromPath(data_2x_path, SCALE_FACTOR_200P);
+ EXPECT_EQ(SCALE_FACTOR_200P, resource_bundle->max_scale_factor());
+
gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3);
+#if defined(OS_CHROMEOS)
+ // ChromeOS loads highest scale factor first.
+ EXPECT_EQ(ui::SCALE_FACTOR_200P, image_skia->image_reps()[0].scale_factor());
+#else
+ EXPECT_EQ(ui::SCALE_FACTOR_100P, image_skia->image_reps()[0].scale_factor());
+#endif
+
// Resource ID 3 exists in both 1x and 2x paks. Image reps should be
// available for both scale factors in |image_skia|.
gfx::ImageSkiaRep image_rep =
@@ -482,4 +491,20 @@ TEST_F(ResourceBundleImageTest, GetImageNamedFallback1x) {
EXPECT_EQ(20, image_rep.pixel_height());
}
+TEST_F(ResourceBundleImageTest, FallbackToNone) {
+ FilePath data_default_path = dir_path().AppendASCII("sample.pak");
+
+ // Create the pak files.
+ CreateDataPackWithSingleBitmap(data_default_path, 10, base::StringPiece());
+
+ // Load the regular pak files only.
+ ResourceBundle* resource_bundle = CreateResourceBundleWithEmptyLocalePak();
+ resource_bundle->AddDataPackFromPath(data_default_path, SCALE_FACTOR_NONE);
+
+ gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3);
+ EXPECT_EQ(1u, image_skia->image_reps().size());
+ EXPECT_EQ(ui::SCALE_FACTOR_100P,
+ image_skia->image_reps()[0].scale_factor());
+}
+
} // namespace ui
« no previous file with comments | « ui/base/resource/resource_bundle_mac.mm ('k') | ui/gfx/image/image_skia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698