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/testing/UnitTestHelpers.h" | 11 #include "platform/testing/UnitTestHelpers.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "third_party/skia/include/core/SkCanvas.h" | 13 #include "third_party/skia/include/core/SkCanvas.h" |
14 #include "third_party/skia/include/utils/SkNullCanvas.h" | 14 #include "third_party/skia/include/utils/SkNullCanvas.h" |
15 #include "wtf/PtrUtil.h" | 15 #include "wtf/PtrUtil.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 class SVGImageTest : public ::testing::Test { | 18 class SVGImageTest : public ::testing::Test { |
19 public: | 19 public: |
20 SVGImage& image() { return *m_image; } | 20 SVGImage& image() { return *m_image; } |
21 | 21 |
22 void load(const char* data, bool shouldPause) { | 22 void load(const char* data, bool shouldPause) { |
23 m_observer = new PauseControlImageObserver(shouldPause); | 23 m_observer = new PauseControlImageObserver(shouldPause); |
24 m_image = SVGImage::create(m_observer); | 24 m_image = SVGImage::create(m_observer); |
25 m_image->setData(SharedBuffer::create(data, strlen(data)), true); | 25 m_image->setData(SharedBuffer::create(data, strlen(data)), true); |
26 } | 26 } |
27 | 27 |
28 void pumpFrame() { | 28 void pumpFrame() { |
29 Image* image = m_image.get(); | 29 Image* image = m_image.get(); |
30 std::unique_ptr<SkCanvas> nullCanvas = SkMakeNullCanvas(); | 30 sk_sp<SkCanvas> nullCanvas(SkCreateNullCanvas()); |
31 SkPaint paint; | 31 SkPaint paint; |
32 FloatRect dummyRect(0, 0, 100, 100); | 32 FloatRect dummyRect(0, 0, 100, 100); |
33 image->draw(nullCanvas.get(), paint, dummyRect, dummyRect, | 33 image->draw(nullCanvas.get(), paint, dummyRect, dummyRect, |
34 DoNotRespectImageOrientation, | 34 DoNotRespectImageOrientation, |
35 Image::DoNotClampImageToSourceRect); | 35 Image::DoNotClampImageToSourceRect); |
36 } | 36 } |
37 | 37 |
38 private: | 38 private: |
39 class PauseControlImageObserver | 39 class PauseControlImageObserver |
40 : public GarbageCollectedFinalized<PauseControlImageObserver>, | 40 : public GarbageCollectedFinalized<PauseControlImageObserver>, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 EXPECT_TRUE(chromeClient.isSuspended()); | 134 EXPECT_TRUE(chromeClient.isSuspended()); |
135 EXPECT_FALSE(timer->isActive()); | 135 EXPECT_FALSE(timer->isActive()); |
136 | 136 |
137 // Simulate a draw. This should resume the animation again. | 137 // Simulate a draw. This should resume the animation again. |
138 pumpFrame(); | 138 pumpFrame(); |
139 EXPECT_FALSE(chromeClient.isSuspended()); | 139 EXPECT_FALSE(chromeClient.isSuspended()); |
140 EXPECT_TRUE(timer->isActive()); | 140 EXPECT_TRUE(timer->isActive()); |
141 } | 141 } |
142 | 142 |
143 } // namespace blink | 143 } // namespace blink |
OLD | NEW |