Chromium Code Reviews| Index: ui/compositor/layer_unittest.cc |
| diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc |
| index dce618331d5ad48edc48736b9cfcb23fe7ba4ea1..009e5494ae2b76708b756b301ac75a3401904888 100644 |
| --- a/ui/compositor/layer_unittest.cc |
| +++ b/ui/compositor/layer_unittest.cc |
| @@ -92,24 +92,14 @@ class ColoredLayer : public Layer, public LayerDelegate { |
| SkColor color_; |
| }; |
| -// Layer delegate for painting text with effects on canvas. |
| -class DrawStringLayerDelegate : public LayerDelegate { |
| +// Layer delegate for painting text with fade effect on canvas. |
| +class DrawFadedStringLayerDelegateDelegate : public LayerDelegate { |
|
msw
2017/01/26 00:52:10
nit: DelegateDelegate?
Evan Stade
2017/03/22 22:59:56
Done.
|
| public: |
| - enum DrawFunction { |
| - STRING_WITH_HALO, |
| - STRING_FADED, |
| - }; |
| - |
| - DrawStringLayerDelegate( |
| - SkColor back_color, SkColor halo_color, |
| - DrawFunction func, const gfx::Size& layer_size) |
| - : background_color_(back_color), |
| - halo_color_(halo_color), |
| - func_(func), |
| - layer_size_(layer_size) { |
| - } |
| + DrawFadedStringLayerDelegateDelegate(SkColor back_color, |
| + const gfx::Size& layer_size) |
| + : background_color_(back_color), layer_size_(layer_size) {} |
| - ~DrawStringLayerDelegate() override {} |
| + ~DrawFadedStringLayerDelegateDelegate() override {} |
| // Overridden from LayerDelegate: |
| void OnPaintLayer(const ui::PaintContext& context) override { |
| @@ -117,18 +107,8 @@ class DrawStringLayerDelegate : public LayerDelegate { |
| gfx::Rect bounds(layer_size_); |
| recorder.canvas()->DrawColor(background_color_); |
| const base::string16 text = base::ASCIIToUTF16("Tests!"); |
| - switch (func_) { |
| - case STRING_WITH_HALO: |
| - recorder.canvas()->DrawStringRectWithHalo( |
| - text, font_list_, SK_ColorRED, halo_color_, bounds, 0); |
| - break; |
| - case STRING_FADED: |
| - recorder.canvas()->DrawFadedString( |
| - text, font_list_, SK_ColorRED, bounds, 0); |
| - break; |
| - default: |
| - NOTREACHED(); |
| - } |
| + recorder.canvas()->DrawFadedString(text, font_list_, SK_ColorRED, bounds, |
| + 0); |
| } |
| void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {} |
| @@ -137,12 +117,10 @@ class DrawStringLayerDelegate : public LayerDelegate { |
| private: |
| const SkColor background_color_; |
| - const SkColor halo_color_; |
| - const DrawFunction func_; |
| const gfx::FontList font_list_; |
| const gfx::Size layer_size_; |
| - DISALLOW_COPY_AND_ASSIGN(DrawStringLayerDelegate); |
| + DISALLOW_COPY_AND_ASSIGN(DrawFadedStringLayerDelegateDelegate); |
| }; |
| class LayerWithRealCompositorTest : public testing::Test { |
| @@ -198,8 +176,9 @@ class LayerWithRealCompositorTest : public testing::Test { |
| return layer; |
| } |
| - std::unique_ptr<Layer> CreateDrawStringLayer( |
| - const gfx::Rect& bounds, DrawStringLayerDelegate* delegate) { |
| + std::unique_ptr<Layer> CreateDrawFadedStringLayerDelegate( |
| + const gfx::Rect& bounds, |
| + DrawFadedStringLayerDelegateDelegate* delegate) { |
| std::unique_ptr<Layer> layer(new Layer(LAYER_TEXTURED)); |
| layer->SetBounds(bounds); |
| layer->set_delegate(delegate); |
| @@ -1450,48 +1429,13 @@ TEST_F(LayerWithRealCompositorTest, ModifyHierarchy) { |
| // So we choose to check result only on Windows. |
| // See https://codereview.chromium.org/1634103003/#msg41 |
| #if defined(OS_WIN) |
| -TEST_F(LayerWithRealCompositorTest, CanvasDrawStringRectWithHalo) { |
| - gfx::Size size(50, 50); |
| - GetCompositor()->SetScaleAndSize(1.0f, size); |
| - DrawStringLayerDelegate delegate(SK_ColorBLUE, SK_ColorWHITE, |
| - DrawStringLayerDelegate::STRING_WITH_HALO, |
| - size); |
| - std::unique_ptr<Layer> layer( |
| - CreateDrawStringLayer(gfx::Rect(size), &delegate)); |
| - DrawTree(layer.get()); |
| - |
| - SkBitmap bitmap; |
| - ReadPixels(&bitmap); |
| - ASSERT_FALSE(bitmap.empty()); |
| - |
| - base::FilePath ref_img = |
| - test_data_directory().AppendASCII("string_with_halo.png"); |
| - // WritePNGFile(bitmap, ref_img, true); |
| - |
| - float percentage_pixels_large_error = 1.0f; |
| - float percentage_pixels_small_error = 0.0f; |
| - float average_error_allowed_in_bad_pixels = 1.f; |
| - int large_error_allowed = 1; |
| - int small_error_allowed = 0; |
| - |
| - EXPECT_TRUE(MatchesPNGFile(bitmap, ref_img, |
| - cc::FuzzyPixelComparator( |
| - true, |
| - percentage_pixels_large_error, |
| - percentage_pixels_small_error, |
| - average_error_allowed_in_bad_pixels, |
| - large_error_allowed, |
| - small_error_allowed))); |
| -} |
| - |
| TEST_F(LayerWithRealCompositorTest, CanvasDrawFadedString) { |
| gfx::Size size(50, 50); |
| GetCompositor()->SetScaleAndSize(1.0f, size); |
| - DrawStringLayerDelegate delegate(SK_ColorBLUE, SK_ColorWHITE, |
| - DrawStringLayerDelegate::STRING_FADED, |
| - size); |
| + DrawFadedStringLayerDelegateDelegate delegate(SK_ColorBLUE, SK_ColorWHITE, |
| + size); |
| std::unique_ptr<Layer> layer( |
| - CreateDrawStringLayer(gfx::Rect(size), &delegate)); |
| + CreateDrawFadedStringLayerDelegate(gfx::Rect(size), &delegate)); |
| DrawTree(layer.get()); |
| SkBitmap bitmap; |