diff options
Diffstat (limited to 'third_party/WebKit/Source/web/PageOverlayTest.cpp')
-rw-r--r-- | third_party/WebKit/Source/web/PageOverlayTest.cpp | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/third_party/WebKit/Source/web/PageOverlayTest.cpp b/third_party/WebKit/Source/web/PageOverlayTest.cpp index 935ae39..bf2036c 100644 --- a/third_party/WebKit/Source/web/PageOverlayTest.cpp +++ b/third_party/WebKit/Source/web/PageOverlayTest.cpp @@ -46,6 +46,24 @@ void disableAcceleratedCompositing(WebSettings* settings) settings->setAcceleratedCompositingEnabled(false); } +// PageOverlay that paints a solid color. +class SolidColorOverlay : public PageOverlay::Delegate { +public: + SolidColorOverlay(Color color) : m_color(color) { } + + void paintPageOverlay(const PageOverlay& pageOverlay, GraphicsContext& graphicsContext, const WebSize& size) const override + { + if (DrawingRecorder::useCachedDrawingIfPossible(graphicsContext, pageOverlay, DisplayItem::PageOverlay)) + return; + FloatRect rect(0, 0, size.width, size.height); + DrawingRecorder drawingRecorder(graphicsContext, pageOverlay, DisplayItem::PageOverlay, rect); + graphicsContext.fillRect(rect, m_color); + } + +private: + Color m_color; +}; + class PageOverlayTest : public ::testing::Test { protected: enum CompositingMode { AcceleratedCompositing, UnacceleratedCompositing }; @@ -62,6 +80,11 @@ protected: WebViewImpl* webViewImpl() const { return m_helper.webViewImpl(); } + PassOwnPtr<PageOverlay> createSolidYellowOverlay() + { + return PageOverlay::create(webViewImpl(), new SolidColorOverlay(SK_ColorYELLOW)); + } + template <typename OverlayType> void runPageOverlayTestWithAcceleratedCompositing(); @@ -69,24 +92,6 @@ private: FrameTestHelpers::WebViewHelper m_helper; }; -// PageOverlay that paints a solid color. -class SolidColorOverlay : public PageOverlay::Delegate { -public: - SolidColorOverlay(Color color) : m_color(color) { } - - void paintPageOverlay(const PageOverlay& pageOverlay, GraphicsContext& graphicsContext, const WebSize& size) const override - { - if (DrawingRecorder::useCachedDrawingIfPossible(graphicsContext, pageOverlay, DisplayItem::PageOverlay)) - return; - FloatRect rect(0, 0, size.width, size.height); - DrawingRecorder drawingRecorder(graphicsContext, pageOverlay, DisplayItem::PageOverlay, rect); - graphicsContext.fillRect(rect, m_color); - } - -private: - Color m_color; -}; - template <bool(*getter)(), void(*setter)(bool)> class RuntimeFeatureChange { public: @@ -107,7 +112,7 @@ TEST_F(PageOverlayTest, PageOverlay_AcceleratedCompositing) initialize(AcceleratedCompositing); webViewImpl()->layerTreeView()->setViewportSize(WebSize(viewportWidth, viewportHeight)); - OwnPtr<PageOverlay> pageOverlay = PageOverlay::create(webViewImpl(), new SolidColorOverlay(SK_ColorYELLOW)); + OwnPtr<PageOverlay> pageOverlay = createSolidYellowOverlay(); pageOverlay->update(); webViewImpl()->updateAllLifecyclePhases(); @@ -134,5 +139,14 @@ TEST_F(PageOverlayTest, PageOverlay_AcceleratedCompositing) graphicsContext.endRecording()->playback(&canvas); } +TEST_F(PageOverlayTest, PageOverlay_VisualRect) +{ + initialize(AcceleratedCompositing); + OwnPtr<PageOverlay> pageOverlay = createSolidYellowOverlay(); + pageOverlay->update(); + webViewImpl()->updateAllLifecyclePhases(); + EXPECT_EQ(LayoutRect(0, 0, viewportWidth, viewportHeight), pageOverlay->visualRect()); +} + } // namespace } // namespace blink |