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

Side by Side Diff: third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp

Issue 1898813002: Allow throttling in painting microbenchmark (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/dom/Document.h" 5 #include "core/dom/Document.h"
6 #include "core/dom/Element.h" 6 #include "core/dom/Element.h"
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/html/HTMLIFrameElement.h" 8 #include "core/html/HTMLIFrameElement.h"
9 #include "core/page/FocusController.h" 9 #include "core/page/FocusController.h"
10 #include "core/page/Page.h" 10 #include "core/page/Page.h"
11 #include "core/paint/PaintLayer.h" 11 #include "core/paint/PaintLayer.h"
12 #include "platform/testing/URLTestHelpers.h" 12 #include "platform/testing/URLTestHelpers.h"
13 #include "platform/testing/UnitTestHelpers.h" 13 #include "platform/testing/UnitTestHelpers.h"
14 #include "public/platform/WebDisplayItemList.h"
14 #include "public/platform/WebLayer.h" 15 #include "public/platform/WebLayer.h"
15 #include "public/web/WebHitTestResult.h" 16 #include "public/web/WebHitTestResult.h"
16 #include "public/web/WebSettings.h" 17 #include "public/web/WebSettings.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "web/WebLocalFrameImpl.h" 19 #include "web/WebLocalFrameImpl.h"
19 #include "web/WebRemoteFrameImpl.h" 20 #include "web/WebRemoteFrameImpl.h"
20 #include "web/tests/sim/SimCompositor.h" 21 #include "web/tests/sim/SimCompositor.h"
21 #include "web/tests/sim/SimDisplayItemList.h" 22 #include "web/tests/sim/SimDisplayItemList.h"
22 #include "web/tests/sim/SimRequest.h" 23 #include "web/tests/sim/SimRequest.h"
23 #include "web/tests/sim/SimTest.h" 24 #include "web/tests/sim/SimTest.h"
24 25
26 using testing::_;
27
25 namespace blink { 28 namespace blink {
26 29
27 using namespace HTMLNames; 30 using namespace HTMLNames;
28 31
29 // NOTE: This test uses <iframe sandbox> to create cross origin iframes. 32 // NOTE: This test uses <iframe sandbox> to create cross origin iframes.
30 33
34 namespace {
35
36 class MockWebDisplayItemList : public WebDisplayItemList {
37 public:
38 ~MockWebDisplayItemList() override {}
39
40 MOCK_METHOD2(appendDrawingItem, void(const WebRect&, sk_sp<const SkPicture>) );
41 };
42
43 void paintRecursively(GraphicsLayer* layer, WebDisplayItemList* displayItems)
44 {
45 if (layer->drawsContent()) {
46 layer->setNeedsDisplay();
47 layer->contentLayerDelegateForTesting()->paintContents(displayItems, Con tentLayerDelegate::PaintDefaultBehaviorForTest);
48 }
49 for (const auto& child : layer->children())
50 paintRecursively(child, displayItems);
51 }
52
53 } // namespace
54
31 class FrameThrottlingTest : public SimTest { 55 class FrameThrottlingTest : public SimTest {
32 protected: 56 protected:
33 FrameThrottlingTest() 57 FrameThrottlingTest()
34 { 58 {
35 webView().resize(WebSize(640, 480)); 59 webView().resize(WebSize(640, 480));
36 } 60 }
37 61
38 SimDisplayItemList compositeFrame() 62 SimDisplayItemList compositeFrame()
39 { 63 {
40 SimDisplayItemList displayItems = compositor().beginFrame(); 64 SimDisplayItemList displayItems = compositor().beginFrame();
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 // The touch handler in the throttled frame should have been ignored. 638 // The touch handler in the throttled frame should have been ignored.
615 EXPECT_EQ(0u, touchHandlerRegionSize()); 639 EXPECT_EQ(0u, touchHandlerRegionSize());
616 640
617 // Unthrottling the frame makes the touch handler active again. 641 // Unthrottling the frame makes the touch handler active again.
618 frameElement->setAttribute(styleAttr, "transform: translateY(0px)"); 642 frameElement->setAttribute(styleAttr, "transform: translateY(0px)");
619 compositeFrame(); // Unthrottle the frame. 643 compositeFrame(); // Unthrottle the frame.
620 compositeFrame(); // Update touch handler regions. 644 compositeFrame(); // Update touch handler regions.
621 EXPECT_EQ(1u, touchHandlerRegionSize()); 645 EXPECT_EQ(1u, touchHandlerRegionSize());
622 } 646 }
623 647
648 TEST_F(FrameThrottlingTest, PaintingViaContentLayerDelegateIsThrottled)
649 {
650 webView().settings()->setAcceleratedCompositingEnabled(true);
651 webView().settings()->setPreferCompositingToLCDTextEnabled(true);
652
653 // Create a hidden frame which is throttled.
654 SimRequest mainResource("https://example.com/", "text/html");
655 SimRequest frameResource("https://example.com/iframe.html", "text/html");
656
657 loadURL("https://example.com/");
658 mainResource.complete("<iframe id=frame sandbox src=iframe.html></iframe>");
659 frameResource.complete("throttled");
660 compositeFrame();
661
662 // Move the frame offscreen to throttle it and make sure it is backed by a
663 // graphics layer.
664 auto* frameElement = toHTMLIFrameElement(document().getElementById("frame")) ;
665 frameElement->setAttribute(styleAttr, "transform: translateY(480px) translat eZ(0px)");
666 EXPECT_FALSE(frameElement->contentDocument()->view()->canThrottleRendering() );
667 compositeFrame();
668 EXPECT_TRUE(frameElement->contentDocument()->view()->canThrottleRendering()) ;
669
670 // If painting of the iframe is throttled, we should only receive two
671 // drawing items.
672 MockWebDisplayItemList displayItems;
673 EXPECT_CALL(displayItems, appendDrawingItem(_, _))
674 .Times(2);
675
676 GraphicsLayer* layer = webView().rootGraphicsLayer();
677 paintRecursively(layer, &displayItems);
ojan 2016/04/28 21:47:27 Specifically, this is not a thing that can happen
Xianzhu 2016/04/28 21:56:32 Right. However, I think this is why we call raste
678 }
679
624 } // namespace blink 680 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698