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 "config.h" | 5 #include "config.h" |
6 #include "core/html/canvas/CanvasFontCache.h" | 6 #include "core/html/canvas/CanvasFontCache.h" |
7 | 7 |
8 | 8 |
9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
10 #include "core/html/HTMLDocument.h" | 10 #include "core/html/HTMLDocument.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 Page::PageClients pageClients; | 54 Page::PageClients pageClients; |
55 fillWithEmptyClients(pageClients); | 55 fillWithEmptyClients(pageClients); |
56 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients) ; | 56 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients) ; |
57 m_document = toHTMLDocument(&m_dummyPageHolder->document()); | 57 m_document = toHTMLDocument(&m_dummyPageHolder->document()); |
58 m_document->documentElement()->setInnerHTML("<body><canvas id='c'></canvas>< /body>", ASSERT_NO_EXCEPTION); | 58 m_document->documentElement()->setInnerHTML("<body><canvas id='c'></canvas>< /body>", ASSERT_NO_EXCEPTION); |
59 m_document->view()->updateAllLifecyclePhases(); | 59 m_document->view()->updateAllLifecyclePhases(); |
60 m_canvasElement = toHTMLCanvasElement(m_document->getElementById("c")); | 60 m_canvasElement = toHTMLCanvasElement(m_document->getElementById("c")); |
61 String canvasType("2d"); | 61 String canvasType("2d"); |
62 CanvasContextCreationAttributes attributes; | 62 CanvasContextCreationAttributes attributes; |
63 attributes.setAlpha(true); | 63 attributes.setAlpha(true); |
64 m_canvasElement->getCanvasRenderingContext(canvasType, attributes); | 64 m_canvasElement->getCanvasRenderingContext(nullptr, canvasType, attributes); |
haraken
2015/10/13 02:02:04
Consider using V8TestingScope.
| |
65 context2d(); // Calling this for the checks | 65 context2d(); // Calling this for the checks |
66 } | 66 } |
67 | 67 |
68 TEST_F(CanvasFontCacheTest, CacheHardLimit) | 68 TEST_F(CanvasFontCacheTest, CacheHardLimit) |
69 { | 69 { |
70 String fontString; | 70 String fontString; |
71 unsigned i; | 71 unsigned i; |
72 for (i = 0; i < cache()->hardMaxFonts() + 1; i++) { | 72 for (i = 0; i < cache()->hardMaxFonts() + 1; i++) { |
73 fontString = String::number(i + 1) + "px sans-serif"; | 73 fontString = String::number(i + 1) + "px sans-serif"; |
74 context2d()->setFont(fontString); | 74 context2d()->setFont(fontString); |
(...skipping 22 matching lines...) Expand all Loading... | |
97 EXPECT_FALSE(cache()->isInCache("15px sans-serif")); | 97 EXPECT_FALSE(cache()->isInCache("15px sans-serif")); |
98 | 98 |
99 page().page().setVisibilityState(PageVisibilityStateVisible, false); | 99 page().page().setVisibilityState(PageVisibilityStateVisible, false); |
100 context2d()->setFont("15px sans-serif"); | 100 context2d()->setFont("15px sans-serif"); |
101 context2d()->setFont("10px sans-serif"); | 101 context2d()->setFont("10px sans-serif"); |
102 EXPECT_TRUE(cache()->isInCache("10px sans-serif")); | 102 EXPECT_TRUE(cache()->isInCache("10px sans-serif")); |
103 EXPECT_TRUE(cache()->isInCache("15px sans-serif")); | 103 EXPECT_TRUE(cache()->isInCache("15px sans-serif")); |
104 } | 104 } |
105 | 105 |
106 } // namespace blink | 106 } // namespace blink |
OLD | NEW |