Chromium Code Reviews| 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 |