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

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: do this only for chromeos for now 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
« ui/base/layout.h ('K') | « ui/base/resource/resource_bundle_mac.mm ('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 25e1748b599f2d9dfe43d97d46bec21aa71e2867..1e3c9edfba57f3c3006d76d3a9c1f5874bafe4e3 100644
--- a/ui/base/resource/resource_bundle_unittest.cc
+++ b/ui/base/resource/resource_bundle_unittest.cc
@@ -379,20 +379,31 @@ 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"));
+ std::vector<ScaleFactor> supported_factors;
+ supported_factors.push_back(SCALE_FACTOR_100P);
+ supported_factors.push_back(SCALE_FACTOR_200P);
+ test::SetSupportedScaleFactors(supported_factors);
+ EXPECT_EQ(SCALE_FACTOR_200P, ui::GetMaxScaleFactor());
+
+ 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);
+ CreateDataPackWithSingleBitmap(data_1x_path, 10);
CreateDataPackWithSingleBitmap(data_2x_path, 20);
// 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);
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());
+#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 =
@@ -408,4 +419,20 @@ TEST_F(ResourceBundleImageTest, GetImageNamed) {
image_rep.scale_factor() == ui::SCALE_FACTOR_200P);
}
+TEST_F(ResourceBundleImageTest, FallbackToNone) {
+ FilePath data_default_path = dir_path().AppendASCII("sample.pak");
+
+ // Create the pak files.
+ CreateDataPackWithSingleBitmap(data_default_path, 10);
+
+ // 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
« ui/base/layout.h ('K') | « ui/base/resource/resource_bundle_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698