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

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') | 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 eadfd9e530032f9ffa506da688e0ef7d6b382948..2c170604531fd24cd681d57ab15f30a43c2f3189 100644
--- a/ui/base/resource/resource_bundle_unittest.cc
+++ b/ui/base/resource/resource_bundle_unittest.cc
@@ -335,23 +335,30 @@ TEST(ResourceBundle, GetImageNamed) {
ASSERT_TRUE(dir.CreateUniqueTempDir());
FilePath locale_path = dir.path().Append(FILE_PATH_LITERAL("empty.pak"));
- FilePath data_path = dir.path().Append(FILE_PATH_LITERAL("sample.pak"));
+ FilePath data_default_path =
+ dir.path().Append(FILE_PATH_LITERAL("sample.pak"));
+ FilePath data_1x_path = dir.path().Append(FILE_PATH_LITERAL("sample_1x.pak"));
FilePath data_2x_path = dir.path().Append(FILE_PATH_LITERAL("sample_2x.pak"));
{
// Create the pak files.
ASSERT_EQ(file_util::WriteFile(locale_path, kEmptyPakContents,
kEmptyPakSize), static_cast<int>(kEmptyPakSize));
- CreateDataPackWithSingleBitmap(data_path, 10);
+ CreateDataPackWithSingleBitmap(data_default_path, 10);
+ CreateDataPackWithSingleBitmap(data_1x_path, 10);
CreateDataPackWithSingleBitmap(data_2x_path, 20);
// Load the regular and 2x pak files.
ResourceBundle resource_bundle(NULL);
- resource_bundle.LoadTestResources(data_path, locale_path);
+ resource_bundle.LoadTestResources(data_default_path, locale_path);
+ 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);
+ EXPECT_EQ(ui::GetMaxScaleFactor(),
+ image_skia->image_reps()[0].scale_factor());
+
// 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 =
@@ -368,4 +375,31 @@ TEST(ResourceBundle, GetImageNamed) {
}
}
+TEST(ResourceBundle, FallbackToNone) {
+ // On Windows, the default data is compiled into the binary so this does
+ // nothing.
+ ScopedTempDir dir;
+ ASSERT_TRUE(dir.CreateUniqueTempDir());
+
+ FilePath locale_path = dir.path().Append(FILE_PATH_LITERAL("empty.pak"));
sail 2012/11/05 23:46:39 use AppendASCII instead of FILE_PATH_LITERAL? same
oshima 2012/11/06 00:36:51 Done. changed all instance of this.
+ FilePath data_default_path =
+ dir.path().Append(FILE_PATH_LITERAL("sample.pak"));
+
+ {
sail 2012/11/05 23:46:39 do you really need this?
oshima 2012/11/06 00:36:51 removed here and above.
+ // Create the pak files.
+ ASSERT_EQ(file_util::WriteFile(locale_path, kEmptyPakContents,
+ kEmptyPakSize), static_cast<int>(kEmptyPakSize));
+ CreateDataPackWithSingleBitmap(data_default_path, 10);
+
+ // Load the regular and 2x pak files.
sail 2012/11/05 23:46:39 I can't tell how this code loads both regular and
oshima 2012/11/06 00:36:51 fixed the comment.
+ ResourceBundle resource_bundle(NULL);
+ resource_bundle.LoadTestResources(data_default_path, locale_path);
+
+ gfx::ImageSkia* image_skia = resource_bundle.GetImageSkiaNamed(3);
+ EXPECT_EQ(1ui, 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') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698