Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DUsageTrackingTest.cpp

Issue 2197953002: Remove unnecessary uses of HTMLDocument (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: simplify Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "modules/canvas2d/CanvasRenderingContext2D.h" 5 #include "modules/canvas2d/CanvasRenderingContext2D.h"
6 6
7 #include "core/dom/Document.h"
7 #include "core/fetch/MemoryCache.h" 8 #include "core/fetch/MemoryCache.h"
8 #include "core/frame/FrameView.h" 9 #include "core/frame/FrameView.h"
9 #include "core/frame/Settings.h" 10 #include "core/frame/Settings.h"
10 #include "core/html/HTMLCanvasElement.h" 11 #include "core/html/HTMLCanvasElement.h"
11 #include "core/html/HTMLDocument.h"
12 #include "core/html/ImageData.h" 12 #include "core/html/ImageData.h"
13 #include "core/loader/EmptyClients.h" 13 #include "core/loader/EmptyClients.h"
14 #include "core/testing/DummyPageHolder.h" 14 #include "core/testing/DummyPageHolder.h"
15 #include "modules/accessibility/AXObject.h" 15 #include "modules/accessibility/AXObject.h"
16 #include "modules/accessibility/AXObjectCacheImpl.h" 16 #include "modules/accessibility/AXObjectCacheImpl.h"
17 #include "modules/canvas2d/CanvasGradient.h" 17 #include "modules/canvas2d/CanvasGradient.h"
18 #include "modules/canvas2d/CanvasPattern.h" 18 #include "modules/canvas2d/CanvasPattern.h"
19 #include "modules/canvas2d/HitRegionOptions.h" 19 #include "modules/canvas2d/HitRegionOptions.h"
20 #include "modules/webgl/WebGLRenderingContext.h" 20 #include "modules/webgl/WebGLRenderingContext.h"
21 #include "platform/graphics/StaticBitmapImage.h" 21 #include "platform/graphics/StaticBitmapImage.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 *status = NormalSourceImageStatus; 69 *status = NormalSourceImageStatus;
70 return m_image; 70 return m_image;
71 } 71 }
72 72
73 class CanvasRenderingContextUsageTrackingTest : public ::testing::Test { 73 class CanvasRenderingContextUsageTrackingTest : public ::testing::Test {
74 protected: 74 protected:
75 CanvasRenderingContextUsageTrackingTest(); 75 CanvasRenderingContextUsageTrackingTest();
76 void SetUp() override; 76 void SetUp() override;
77 77
78 DummyPageHolder& page() const { return *m_dummyPageHolder; } 78 DummyPageHolder& page() const { return *m_dummyPageHolder; }
79 HTMLDocument& document() const { return *m_document; } 79 Document& document() const { return *m_document; }
80 HTMLCanvasElement& canvasElement() const { return *m_canvasElement; } 80 HTMLCanvasElement& canvasElement() const { return *m_canvasElement; }
81 CanvasRenderingContext2D* context2d() const; 81 CanvasRenderingContext2D* context2d() const;
82 82
83 void createContext(OpacityMode); 83 void createContext(OpacityMode);
84 84
85 FakeImageSource m_opaqueBitmap; 85 FakeImageSource m_opaqueBitmap;
86 FakeImageSource m_alphaBitmap; 86 FakeImageSource m_alphaBitmap;
87 Persistent<ImageData> m_fullImageData; 87 Persistent<ImageData> m_fullImageData;
88 void TearDown(); 88 void TearDown();
89 private: 89 private:
90 std::shared_ptr<DummyPageHolder> m_dummyPageHolder; 90 std::shared_ptr<DummyPageHolder> m_dummyPageHolder;
91 Persistent<HTMLDocument> m_document; 91 Persistent<Document> m_document;
92 Persistent<HTMLCanvasElement> m_canvasElement; 92 Persistent<HTMLCanvasElement> m_canvasElement;
93 Persistent<MemoryCache> m_globalMemoryCache; 93 Persistent<MemoryCache> m_globalMemoryCache;
94 }; 94 };
95 95
96 CanvasRenderingContextUsageTrackingTest::CanvasRenderingContextUsageTrackingTest () 96 CanvasRenderingContextUsageTrackingTest::CanvasRenderingContextUsageTrackingTest ()
97 : m_opaqueBitmap(IntSize(10, 10), OpaqueBitmap) 97 : m_opaqueBitmap(IntSize(10, 10), OpaqueBitmap)
98 , m_alphaBitmap(IntSize(10, 10), TransparentBitmap) 98 , m_alphaBitmap(IntSize(10, 10), TransparentBitmap)
99 { } 99 { }
100 100
101 void CanvasRenderingContextUsageTrackingTest::TearDown() 101 void CanvasRenderingContextUsageTrackingTest::TearDown()
(...skipping 18 matching lines...) Expand all
120 attributes.setAlpha(opacityMode == NonOpaque); 120 attributes.setAlpha(opacityMode == NonOpaque);
121 m_canvasElement->getCanvasRenderingContext(canvasType, attributes); 121 m_canvasElement->getCanvasRenderingContext(canvasType, attributes);
122 context2d(); // Calling this for the checks 122 context2d(); // Calling this for the checks
123 } 123 }
124 124
125 void CanvasRenderingContextUsageTrackingTest::SetUp() 125 void CanvasRenderingContextUsageTrackingTest::SetUp()
126 { 126 {
127 Page::PageClients pageClients; 127 Page::PageClients pageClients;
128 fillWithEmptyClients(pageClients); 128 fillWithEmptyClients(pageClients);
129 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients) ; 129 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients) ;
130 m_document = toHTMLDocument(&m_dummyPageHolder->document()); 130 m_document = &m_dummyPageHolder->document();
131 m_document->documentElement()->setInnerHTML("<body><canvas id='c'></canvas>< /body>", ASSERT_NO_EXCEPTION); 131 m_document->documentElement()->setInnerHTML("<body><canvas id='c'></canvas>< /body>", ASSERT_NO_EXCEPTION);
132 m_document->view()->updateAllLifecyclePhases(); 132 m_document->view()->updateAllLifecyclePhases();
133 m_canvasElement = toHTMLCanvasElement(m_document->getElementById("c")); 133 m_canvasElement = toHTMLCanvasElement(m_document->getElementById("c"));
134 m_fullImageData = ImageData::create(IntSize(10, 10)); 134 m_fullImageData = ImageData::create(IntSize(10, 10));
135 135
136 m_globalMemoryCache = replaceMemoryCacheForTesting(MemoryCache::create()); 136 m_globalMemoryCache = replaceMemoryCacheForTesting(MemoryCache::create());
137 } 137 }
138 138
139 TEST_F(CanvasRenderingContextUsageTrackingTest, FillTracking) 139 TEST_F(CanvasRenderingContextUsageTrackingTest, FillTracking)
140 { 140 {
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 EXPECT_EQ(0, context2d()->getUsage().numDrawCalls[BaseRenderingContext2D::Fi llRect]); 485 EXPECT_EQ(0, context2d()->getUsage().numDrawCalls[BaseRenderingContext2D::Fi llRect]);
486 486
487 for (int i = 0; i < numReps; i++) { 487 for (int i = 0; i < numReps; i++) {
488 context2d()->fillRect(10, 10, 100, 100); 488 context2d()->fillRect(10, 10, 100, 100);
489 } 489 }
490 EXPECT_EQ(numReps, context2d()->getUsage().numDrawCalls[BaseRenderingContext 2D::FillRect]); 490 EXPECT_EQ(numReps, context2d()->getUsage().numDrawCalls[BaseRenderingContext 2D::FillRect]);
491 } 491 }
492 492
493 } // namespace UsageTrackingTests 493 } // namespace UsageTrackingTests
494 } // namespace blink 494 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698