Index: ui/gfx/image/image_skia_unittest.cc |
diff --git a/ui/gfx/image/image_skia_unittest.cc b/ui/gfx/image/image_skia_unittest.cc |
index fd17453f8f9e3553d158b969b6746148fee3ecdf..0047822122bb67ee954d7e21f940dd7c149ff275 100644 |
--- a/ui/gfx/image/image_skia_unittest.cc |
+++ b/ui/gfx/image/image_skia_unittest.cc |
@@ -8,7 +8,6 @@ |
#include "base/threading/simple_thread.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "third_party/skia/include/core/SkBitmap.h" |
-#include "ui/base/layout.h" |
#include "ui/gfx/image/image_skia_rep.h" |
#include "ui/gfx/image/image_skia_source.h" |
#include "ui/gfx/size.h" |
@@ -32,7 +31,7 @@ class FixedSource : public ImageSkiaSource { |
virtual ~FixedSource() { |
} |
- virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE { |
+ virtual ImageSkiaRep GetImageForScale(float scale) OVERRIDE { |
return image_; |
} |
@@ -49,8 +48,8 @@ class DynamicSource : public ImageSkiaSource { |
virtual ~DynamicSource() { |
} |
- virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE { |
- return gfx::ImageSkiaRep(size_, scale_factor); |
+ virtual ImageSkiaRep GetImageForScale(float scale) OVERRIDE { |
+ return gfx::ImageSkiaRep(size_, scale); |
} |
private: |
@@ -67,7 +66,7 @@ class NullSource: public ImageSkiaSource { |
virtual ~NullSource() { |
} |
- virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE { |
+ virtual ImageSkiaRep GetImageForScale(float scale) OVERRIDE { |
return gfx::ImageSkiaRep(); |
} |
@@ -115,58 +114,55 @@ class TestOnThread : public base::SimpleThread { |
} // namespace test |
TEST(ImageSkiaTest, FixedSource) { |
- ImageSkiaRep image(Size(100, 200), ui::SCALE_FACTOR_100P); |
+ ImageSkiaRep image(Size(100, 200), 1.0f); |
ImageSkia image_skia(new FixedSource(image), Size(100, 200)); |
EXPECT_EQ(0U, image_skia.image_reps().size()); |
- const ImageSkiaRep& result_100p = |
- image_skia.GetRepresentation(ui::SCALE_FACTOR_100P); |
+ const ImageSkiaRep& result_100p = image_skia.GetRepresentation(1.0f); |
EXPECT_EQ(100, result_100p.GetWidth()); |
EXPECT_EQ(200, result_100p.GetHeight()); |
- EXPECT_EQ(ui::SCALE_FACTOR_100P, result_100p.scale_factor()); |
+ EXPECT_EQ(1.0f, result_100p.scale()); |
EXPECT_EQ(1U, image_skia.image_reps().size()); |
- const ImageSkiaRep& result_200p = |
- image_skia.GetRepresentation(ui::SCALE_FACTOR_200P); |
+ const ImageSkiaRep& result_200p = image_skia.GetRepresentation(2.0f); |
EXPECT_EQ(100, result_200p.GetWidth()); |
EXPECT_EQ(200, result_200p.GetHeight()); |
EXPECT_EQ(100, result_200p.pixel_width()); |
EXPECT_EQ(200, result_200p.pixel_height()); |
- EXPECT_EQ(ui::SCALE_FACTOR_100P, result_200p.scale_factor()); |
+ EXPECT_EQ(1.0f, result_200p.scale()); |
EXPECT_EQ(1U, image_skia.image_reps().size()); |
// Get the representation again and make sure it doesn't |
// generate new image skia rep. |
- image_skia.GetRepresentation(ui::SCALE_FACTOR_100P); |
- image_skia.GetRepresentation(ui::SCALE_FACTOR_200P); |
+ image_skia.GetRepresentation(1.0f); |
+ image_skia.GetRepresentation(2.0f); |
EXPECT_EQ(1U, image_skia.image_reps().size()); |
} |
TEST(ImageSkiaTest, DynamicSource) { |
ImageSkia image_skia(new DynamicSource(Size(100, 200)), Size(100, 200)); |
EXPECT_EQ(0U, image_skia.image_reps().size()); |
- const ImageSkiaRep& result_100p = |
- image_skia.GetRepresentation(ui::SCALE_FACTOR_100P); |
+ const ImageSkiaRep& result_100p = image_skia.GetRepresentation(1.0f); |
EXPECT_EQ(100, result_100p.GetWidth()); |
EXPECT_EQ(200, result_100p.GetHeight()); |
- EXPECT_EQ(ui::SCALE_FACTOR_100P, result_100p.scale_factor()); |
+ EXPECT_EQ(1.0f, result_100p.scale()); |
EXPECT_EQ(1U, image_skia.image_reps().size()); |
const ImageSkiaRep& result_200p = |
- image_skia.GetRepresentation(ui::SCALE_FACTOR_200P); |
+ image_skia.GetRepresentation(2.0f); |
EXPECT_EQ(100, result_200p.GetWidth()); |
EXPECT_EQ(200, result_200p.GetHeight()); |
EXPECT_EQ(200, result_200p.pixel_width()); |
EXPECT_EQ(400, result_200p.pixel_height()); |
- EXPECT_EQ(ui::SCALE_FACTOR_200P, result_200p.scale_factor()); |
+ EXPECT_EQ(2.0f, result_200p.scale()); |
EXPECT_EQ(2U, image_skia.image_reps().size()); |
// Get the representation again and make sure it doesn't |
// generate new image skia rep. |
- image_skia.GetRepresentation(ui::SCALE_FACTOR_100P); |
+ image_skia.GetRepresentation(1.0f); |
EXPECT_EQ(2U, image_skia.image_reps().size()); |
- image_skia.GetRepresentation(ui::SCALE_FACTOR_200P); |
+ image_skia.GetRepresentation(2.0f); |
EXPECT_EQ(2U, image_skia.image_reps().size()); |
} |
@@ -182,16 +178,16 @@ TEST(ImageSkiaTest, ManyRepsPerScaleFactor) { |
// Simulate a source which loads images on a delay. Upon |
// GetImageForScaleFactor, it immediately returns null and starts loading |
// image reps slowly. |
- image.GetRepresentation(ui::SCALE_FACTOR_100P); |
- image.GetRepresentation(ui::SCALE_FACTOR_200P); |
+ image.GetRepresentation(1.0f); |
+ image.GetRepresentation(2.0f); |
// After a lengthy amount of simulated time, finally loaded image reps. |
image.AddRepresentation(ImageSkiaRep( |
- gfx::Size(kSmallIcon1x, kSmallIcon1x), ui::SCALE_FACTOR_100P)); |
+ gfx::Size(kSmallIcon1x, kSmallIcon1x), 1.0f)); |
image.AddRepresentation(ImageSkiaRep( |
- gfx::Size(kSmallIcon2x, kSmallIcon2x), ui::SCALE_FACTOR_200P)); |
+ gfx::Size(kSmallIcon2x, kSmallIcon2x), 2.0f)); |
image.AddRepresentation(ImageSkiaRep( |
- gfx::Size(kLargeIcon1x, kLargeIcon1x), ui::SCALE_FACTOR_100P)); |
+ gfx::Size(kLargeIcon1x, kLargeIcon1x), 1.0f)); |
std::vector<ImageSkiaRep> image_reps = image.image_reps(); |
EXPECT_EQ(3u, image_reps.size()); |
@@ -199,9 +195,9 @@ TEST(ImageSkiaTest, ManyRepsPerScaleFactor) { |
int num_1x = 0; |
int num_2x = 0; |
for (size_t i = 0; i < image_reps.size(); ++i) { |
- if (image_reps[i].scale_factor() == ui::SCALE_FACTOR_100P) |
+ if (image_reps[i].scale() == 1.0f) |
num_1x++; |
- else if (image_reps[i].scale_factor() == ui::SCALE_FACTOR_200P) |
+ else if (image_reps[i].scale() == 2.0f) |
num_2x++; |
} |
EXPECT_EQ(2, num_1x); |
@@ -218,9 +214,9 @@ TEST(ImageSkiaTest, GetBitmap) { |
TEST(ImageSkiaTest, GetBitmapFromEmpty) { |
// Create an image with 1 representation and remove it so the ImageSkiaStorage |
// is left with no representations. |
- ImageSkia empty_image(ImageSkiaRep(Size(100, 200), ui::SCALE_FACTOR_100P)); |
+ ImageSkia empty_image(ImageSkiaRep(Size(100, 200), 1.0f)); |
ImageSkia empty_image_copy(empty_image); |
- empty_image.RemoveRepresentation(ui::SCALE_FACTOR_100P); |
+ empty_image.RemoveRepresentation(1.0f); |
// Check that ImageSkia::bitmap() still returns a valid SkBitmap pointer for |
// the image and all its copies. |
@@ -237,12 +233,12 @@ TEST(ImageSkiaTest, BackedBySameObjectAs) { |
EXPECT_TRUE(image.BackedBySameObjectAs(unrelated)); |
image.AddRepresentation(gfx::ImageSkiaRep(gfx::Size(10, 10), |
- ui::SCALE_FACTOR_100P)); |
+ 1.0f)); |
ImageSkia copy = image; |
copy.AddRepresentation(gfx::ImageSkiaRep(gfx::Size(10, 10), |
- ui::SCALE_FACTOR_200P)); |
+ 2.0f)); |
unrelated.AddRepresentation(gfx::ImageSkiaRep(gfx::Size(10, 10), |
- ui::SCALE_FACTOR_100P)); |
+ 1.0f)); |
EXPECT_TRUE(image.BackedBySameObjectAs(copy)); |
EXPECT_FALSE(image.BackedBySameObjectAs(unrelated)); |
EXPECT_FALSE(copy.BackedBySameObjectAs(unrelated)); |
@@ -259,7 +255,7 @@ TEST(ImageSkiaTest, EmptyOnThreadTest) { |
} |
TEST(ImageSkiaTest, StaticOnThreadTest) { |
- ImageSkia image(ImageSkiaRep(Size(100, 200), ui::SCALE_FACTOR_100P)); |
+ ImageSkia image(ImageSkiaRep(Size(100, 200), 1.0f)); |
EXPECT_FALSE(image.IsThreadSafe()); |
test::TestOnThread image_on_thread(&image); |
@@ -365,8 +361,8 @@ TEST(ImageSkiaTest, SourceOnThreadTest) { |
image.MakeThreadSafe(); |
EXPECT_TRUE(image.IsThreadSafe()); |
// Check if image reps are generated for supported scale factors. |
- EXPECT_EQ(ui::GetSupportedScaleFactors().size(), |
- image.image_reps().size()); |
+ EXPECT_EQ(ImageSkia::GetSupportedScales().size(), |
+ image.image_reps().size()); |
test::TestOnThread threadsafe_on_thread(&image); |
threadsafe_on_thread.StartAndJoin(); |
EXPECT_TRUE(threadsafe_on_thread.can_read()); |