summaryrefslogtreecommitdiff
path: root/chromium/ui/base/resource/resource_bundle_unittest.cc
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2014-03-18 13:16:26 +0100
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-03-20 15:55:39 +0100
commit3f0f86b0caed75241fa71c95a5d73bc0164348c5 (patch)
tree92b9fb00f2e9e90b0be2262093876d4f43b6cd13 /chromium/ui/base/resource/resource_bundle_unittest.cc
parente90d7c4b152c56919d963987e2503f9909a666d2 (diff)
downloadqtwebengine-chromium-3f0f86b0caed75241fa71c95a5d73bc0164348c5.tar.gz
Update to new stable branch 1750
This also includes an updated ninja and chromium dependencies needed on Windows. Change-Id: Icd597d80ed3fa4425933c9f1334c3c2e31291c42 Reviewed-by: Zoltan Arvai <zarvai@inf.u-szeged.hu> Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Diffstat (limited to 'chromium/ui/base/resource/resource_bundle_unittest.cc')
-rw-r--r--chromium/ui/base/resource/resource_bundle_unittest.cc59
1 files changed, 43 insertions, 16 deletions
diff --git a/chromium/ui/base/resource/resource_bundle_unittest.cc b/chromium/ui/base/resource/resource_bundle_unittest.cc
index 6a7b2b7db9c..f6ab49dfbb9 100644
--- a/chromium/ui/base/resource/resource_bundle_unittest.cc
+++ b/chromium/ui/base/resource/resource_bundle_unittest.cc
@@ -308,7 +308,13 @@ TEST_F(ResourceBundleTest, DelegateGetLocalizedString) {
EXPECT_EQ(data, result);
}
-TEST_F(ResourceBundleTest, DelegateGetFontList) {
+#if defined(USE_OZONE) && !defined(USE_PANGO)
+#define MAYBE_DelegateGetFontList DISABLED_DelegateGetFontList
+#else
+#define MAYBE_DelegateGetFontList DelegateGetFontList
+#endif
+
+TEST_F(ResourceBundleTest, MAYBE_DelegateGetFontList) {
MockResourceBundleDelegate delegate;
ResourceBundle* resource_bundle = CreateResourceBundle(&delegate);
@@ -433,6 +439,10 @@ TEST_F(ResourceBundleImageTest, GetRawDataResource) {
// Test requesting image reps at various scale factors from the image returned
// via ResourceBundle::GetImageNamed().
TEST_F(ResourceBundleImageTest, GetImageNamed) {
+ std::vector<ScaleFactor> supported_factors;
+ supported_factors.push_back(SCALE_FACTOR_100P);
+ supported_factors.push_back(SCALE_FACTOR_200P);
+ test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors);
base::FilePath data_1x_path = dir_path().AppendASCII("sample_1x.pak");
base::FilePath data_2x_path = dir_path().AppendASCII("sample_2x.pak");
@@ -445,35 +455,44 @@ TEST_F(ResourceBundleImageTest, GetImageNamed) {
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());
+ EXPECT_EQ(SCALE_FACTOR_200P, resource_bundle->GetMaxScaleFactor());
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());
+ EXPECT_EQ(ui::SCALE_FACTOR_200P,
+ GetSupportedScaleFactor(image_skia->image_reps()[0].scale()));
#else
- EXPECT_EQ(ui::SCALE_FACTOR_100P, image_skia->image_reps()[0].scale_factor());
+ EXPECT_EQ(ui::SCALE_FACTOR_100P,
+ GetSupportedScaleFactor(image_skia->image_reps()[0].scale()));
#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 =
- image_skia->GetRepresentation(ui::SCALE_FACTOR_100P);
- EXPECT_EQ(ui::SCALE_FACTOR_100P, image_rep.scale_factor());
- image_rep = image_skia->GetRepresentation(ui::SCALE_FACTOR_200P);
- EXPECT_EQ(ui::SCALE_FACTOR_200P, image_rep.scale_factor());
+ image_skia->GetRepresentation(GetImageScale(ui::SCALE_FACTOR_100P));
+ EXPECT_EQ(ui::SCALE_FACTOR_100P, GetSupportedScaleFactor(image_rep.scale()));
+ image_rep =
+ image_skia->GetRepresentation(GetImageScale(ui::SCALE_FACTOR_200P));
+ EXPECT_EQ(ui::SCALE_FACTOR_200P, GetSupportedScaleFactor(image_rep.scale()));
// The 1.4x pack was not loaded. Requesting the 1.4x resource should return
// either the 1x or the 2x resource.
- image_rep = image_skia->GetRepresentation(ui::SCALE_FACTOR_140P);
- EXPECT_TRUE(image_rep.scale_factor() == ui::SCALE_FACTOR_100P ||
- image_rep.scale_factor() == ui::SCALE_FACTOR_200P);
+ image_rep = image_skia->GetRepresentation(
+ ui::GetImageScale(ui::SCALE_FACTOR_140P));
+ ui::ScaleFactor scale_factor = GetSupportedScaleFactor(image_rep.scale());
+ EXPECT_TRUE(scale_factor == ui::SCALE_FACTOR_100P ||
+ scale_factor == ui::SCALE_FACTOR_200P);
}
// Test that GetImageNamed() behaves properly for images which GRIT has
// annotated as having fallen back to 1x.
TEST_F(ResourceBundleImageTest, GetImageNamedFallback1x) {
+ std::vector<ScaleFactor> supported_factors;
+ supported_factors.push_back(SCALE_FACTOR_100P);
+ supported_factors.push_back(SCALE_FACTOR_200P);
+ test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors);
base::FilePath data_path = dir_path().AppendASCII("sample.pak");
base::FilePath data_2x_path = dir_path().AppendASCII("sample_2x.pak");
@@ -495,8 +514,8 @@ TEST_F(ResourceBundleImageTest, GetImageNamedFallback1x) {
// The image rep for 2x should be available. It should be resized to the
// proper 2x size.
gfx::ImageSkiaRep image_rep =
- image_skia->GetRepresentation(ui::SCALE_FACTOR_200P);
- EXPECT_EQ(ui::SCALE_FACTOR_200P, image_rep.scale_factor());
+ image_skia->GetRepresentation(GetImageScale(ui::SCALE_FACTOR_200P));
+ EXPECT_EQ(ui::SCALE_FACTOR_200P, GetSupportedScaleFactor(image_rep.scale()));
EXPECT_EQ(20, image_rep.pixel_width());
EXPECT_EQ(20, image_rep.pixel_height());
}
@@ -506,6 +525,12 @@ TEST_F(ResourceBundleImageTest, GetImageNamedFallback1x) {
// requires rounding as a result of using a non-integer scale factor.
// Scale factors of 140 and 1805 are Windows specific.
TEST_F(ResourceBundleImageTest, GetImageNamedFallback1xRounding) {
+ std::vector<ScaleFactor> supported_factors;
+ supported_factors.push_back(SCALE_FACTOR_100P);
+ supported_factors.push_back(SCALE_FACTOR_140P);
+ supported_factors.push_back(SCALE_FACTOR_180P);
+ test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors);
+
base::FilePath data_path = dir_path().AppendASCII("sample.pak");
base::FilePath data_140P_path = dir_path().AppendASCII("sample_140P.pak");
base::FilePath data_180P_path = dir_path().AppendASCII("sample_180P.pak");
@@ -527,9 +552,11 @@ TEST_F(ResourceBundleImageTest, GetImageNamedFallback1xRounding) {
// Non-integer dimensions should be rounded up.
gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3);
gfx::ImageSkiaRep image_rep =
- image_skia->GetRepresentation(ui::SCALE_FACTOR_140P);
+ image_skia->GetRepresentation(
+ GetImageScale(ui::SCALE_FACTOR_140P));
EXPECT_EQ(12, image_rep.pixel_width());
- image_rep = image_skia->GetRepresentation(ui::SCALE_FACTOR_180P);
+ image_rep = image_skia->GetRepresentation(
+ GetImageScale(ui::SCALE_FACTOR_180P));
EXPECT_EQ(15, image_rep.pixel_width());
}
#endif
@@ -547,7 +574,7 @@ TEST_F(ResourceBundleImageTest, FallbackToNone) {
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());
+ GetSupportedScaleFactor(image_skia->image_reps()[0].scale()));
}
} // namespace ui