| 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
|
|
|