OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/svg/graphics/SVGImage.h" | 5 #include "core/svg/graphics/SVGImage.h" |
6 | 6 |
7 #include "core/svg/graphics/SVGImageChromeClient.h" | 7 #include "core/svg/graphics/SVGImageChromeClient.h" |
8 #include "platform/SharedBuffer.h" | 8 #include "platform/SharedBuffer.h" |
9 #include "platform/Timer.h" | 9 #include "platform/Timer.h" |
10 #include "platform/geometry/FloatRect.h" | 10 #include "platform/geometry/FloatRect.h" |
| 11 #include "platform/graphics/paint/PaintCanvas.h" |
| 12 #include "platform/graphics/paint/PaintFlags.h" |
11 #include "platform/testing/UnitTestHelpers.h" | 13 #include "platform/testing/UnitTestHelpers.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "third_party/skia/include/core/SkCanvas.h" | 15 #include "third_party/skia/include/core/SkCanvas.h" |
14 #include "third_party/skia/include/utils/SkNullCanvas.h" | 16 #include "third_party/skia/include/utils/SkNullCanvas.h" |
15 #include "wtf/PtrUtil.h" | 17 #include "wtf/PtrUtil.h" |
16 | 18 |
17 namespace blink { | 19 namespace blink { |
18 class SVGImageTest : public ::testing::Test { | 20 class SVGImageTest : public ::testing::Test { |
19 public: | 21 public: |
20 SVGImage& image() { return *m_image; } | 22 SVGImage& image() { return *m_image; } |
21 | 23 |
22 void load(const char* data, bool shouldPause) { | 24 void load(const char* data, bool shouldPause) { |
23 m_observer = new PauseControlImageObserver(shouldPause); | 25 m_observer = new PauseControlImageObserver(shouldPause); |
24 m_image = SVGImage::create(m_observer); | 26 m_image = SVGImage::create(m_observer); |
25 m_image->setData(SharedBuffer::create(data, strlen(data)), true); | 27 m_image->setData(SharedBuffer::create(data, strlen(data)), true); |
26 } | 28 } |
27 | 29 |
28 void pumpFrame() { | 30 void pumpFrame() { |
29 Image* image = m_image.get(); | 31 Image* image = m_image.get(); |
30 std::unique_ptr<SkCanvas> nullCanvas = SkMakeNullCanvas(); | 32 std::unique_ptr<SkCanvas> nullCanvas = SkMakeNullCanvas(); |
31 SkPaint paint; | 33 PaintCanvasPassThrough canvas(nullCanvas.get()); |
| 34 PaintFlags paint; |
32 FloatRect dummyRect(0, 0, 100, 100); | 35 FloatRect dummyRect(0, 0, 100, 100); |
33 image->draw(nullCanvas.get(), paint, dummyRect, dummyRect, | 36 image->draw(&canvas, paint, dummyRect, dummyRect, |
34 DoNotRespectImageOrientation, | 37 DoNotRespectImageOrientation, |
35 Image::DoNotClampImageToSourceRect, | 38 Image::DoNotClampImageToSourceRect, |
36 ColorBehavior::transformToGlobalTarget()); | 39 ColorBehavior::transformToGlobalTarget()); |
37 } | 40 } |
38 | 41 |
39 private: | 42 private: |
40 class PauseControlImageObserver | 43 class PauseControlImageObserver |
41 : public GarbageCollectedFinalized<PauseControlImageObserver>, | 44 : public GarbageCollectedFinalized<PauseControlImageObserver>, |
42 public ImageObserver { | 45 public ImageObserver { |
43 USING_GARBAGE_COLLECTED_MIXIN(PauseControlImageObserver); | 46 USING_GARBAGE_COLLECTED_MIXIN(PauseControlImageObserver); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 EXPECT_TRUE(chromeClient.isSuspended()); | 137 EXPECT_TRUE(chromeClient.isSuspended()); |
135 EXPECT_FALSE(timer->isActive()); | 138 EXPECT_FALSE(timer->isActive()); |
136 | 139 |
137 // Simulate a draw. This should resume the animation again. | 140 // Simulate a draw. This should resume the animation again. |
138 pumpFrame(); | 141 pumpFrame(); |
139 EXPECT_FALSE(chromeClient.isSuspended()); | 142 EXPECT_FALSE(chromeClient.isSuspended()); |
140 EXPECT_TRUE(timer->isActive()); | 143 EXPECT_TRUE(timer->isActive()); |
141 } | 144 } |
142 | 145 |
143 } // namespace blink | 146 } // namespace blink |
OLD | NEW |