OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/html/canvas/CanvasFontCache.h" | 5 #include "core/html/canvas/CanvasFontCache.h" |
6 | 6 |
7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
8 #include "core/html/HTMLDocument.h" | 8 #include "core/html/HTMLDocument.h" |
9 #include "core/html/canvas/CanvasContextCreationAttributes.h" | 9 #include "core/html/canvas/CanvasContextCreationAttributes.h" |
10 #include "core/html/canvas/CanvasRenderingContext.h" | 10 #include "core/html/canvas/CanvasRenderingContext.h" |
11 #include "core/loader/EmptyClients.h" | 11 #include "core/loader/EmptyClients.h" |
12 #include "core/testing/DummyPageHolder.h" | 12 #include "core/testing/DummyPageHolder.h" |
13 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 13 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include <memory> |
16 | 17 |
17 using ::testing::Mock; | 18 using ::testing::Mock; |
18 | 19 |
19 namespace blink { | 20 namespace blink { |
20 | 21 |
21 class CanvasFontCacheTest : public ::testing::Test { | 22 class CanvasFontCacheTest : public ::testing::Test { |
22 protected: | 23 protected: |
23 CanvasFontCacheTest(); | 24 CanvasFontCacheTest(); |
24 void SetUp() override; | 25 void SetUp() override; |
25 | 26 |
26 DummyPageHolder& page() const { return *m_dummyPageHolder; } | 27 DummyPageHolder& page() const { return *m_dummyPageHolder; } |
27 HTMLDocument& document() const { return *m_document; } | 28 HTMLDocument& document() const { return *m_document; } |
28 HTMLCanvasElement& canvasElement() const { return *m_canvasElement; } | 29 HTMLCanvasElement& canvasElement() const { return *m_canvasElement; } |
29 CanvasRenderingContext* context2d() const; | 30 CanvasRenderingContext* context2d() const; |
30 CanvasFontCache* cache() { return m_document->canvasFontCache(); } | 31 CanvasFontCache* cache() { return m_document->canvasFontCache(); } |
31 | 32 |
32 private: | 33 private: |
33 OwnPtr<DummyPageHolder> m_dummyPageHolder; | 34 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; |
34 Persistent<HTMLDocument> m_document; | 35 Persistent<HTMLDocument> m_document; |
35 Persistent<HTMLCanvasElement> m_canvasElement; | 36 Persistent<HTMLCanvasElement> m_canvasElement; |
36 }; | 37 }; |
37 | 38 |
38 CanvasFontCacheTest::CanvasFontCacheTest() | 39 CanvasFontCacheTest::CanvasFontCacheTest() |
39 { } | 40 { } |
40 | 41 |
41 CanvasRenderingContext* CanvasFontCacheTest::context2d() const | 42 CanvasRenderingContext* CanvasFontCacheTest::context2d() const |
42 { | 43 { |
43 // If the following check fails, perhaps you forgot to call createContext | 44 // If the following check fails, perhaps you forgot to call createContext |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 EXPECT_FALSE(cache()->isInCache("15px sans-serif")); | 96 EXPECT_FALSE(cache()->isInCache("15px sans-serif")); |
96 | 97 |
97 page().page().setVisibilityState(PageVisibilityStateVisible, false); | 98 page().page().setVisibilityState(PageVisibilityStateVisible, false); |
98 context2d()->setFont("15px sans-serif"); | 99 context2d()->setFont("15px sans-serif"); |
99 context2d()->setFont("10px sans-serif"); | 100 context2d()->setFont("10px sans-serif"); |
100 EXPECT_TRUE(cache()->isInCache("10px sans-serif")); | 101 EXPECT_TRUE(cache()->isInCache("10px sans-serif")); |
101 EXPECT_TRUE(cache()->isInCache("15px sans-serif")); | 102 EXPECT_TRUE(cache()->isInCache("15px sans-serif")); |
102 } | 103 } |
103 | 104 |
104 } // namespace blink | 105 } // namespace blink |
OLD | NEW |