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

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

Issue 2258523006: Convert Settings::rootLayerScrolls to RuntimeEnabledFeatures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add RAII-style helper to toggle REF. Rebase. Created 4 years, 3 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 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/frame/FrameView.h" 5 #include "core/frame/FrameView.h"
6 #include "core/layout/api/LayoutViewItem.h" 6 #include "core/layout/api/LayoutViewItem.h"
7 #include "core/layout/compositing/CompositedLayerMapping.h" 7 #include "core/layout/compositing/CompositedLayerMapping.h"
8 #include "core/layout/compositing/PaintLayerCompositor.h" 8 #include "core/layout/compositing/PaintLayerCompositor.h"
9 #include "core/page/Page.h" 9 #include "core/page/Page.h"
10 #include "platform/graphics/CompositorMutableProperties.h" 10 #include "platform/graphics/CompositorMutableProperties.h"
11 #include "platform/graphics/CompositorMutation.h" 11 #include "platform/graphics/CompositorMutation.h"
12 #include "platform/graphics/GraphicsLayer.h" 12 #include "platform/graphics/GraphicsLayer.h"
13 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
13 #include "platform/testing/URLTestHelpers.h" 14 #include "platform/testing/URLTestHelpers.h"
14 #include "public/platform/Platform.h" 15 #include "public/platform/Platform.h"
15 #include "public/platform/WebLayer.h" 16 #include "public/platform/WebLayer.h"
16 #include "public/platform/WebLayerTreeView.h" 17 #include "public/platform/WebLayerTreeView.h"
17 #include "public/platform/WebURLLoaderMockFactory.h" 18 #include "public/platform/WebURLLoaderMockFactory.h"
18 #include "public/web/WebCache.h" 19 #include "public/web/WebCache.h"
19 #include "public/web/WebSettings.h" 20 #include "public/web/WebSettings.h"
20 #include "public/web/WebViewClient.h" 21 #include "public/web/WebViewClient.h"
21 #include "web/WebLocalFrameImpl.h" 22 #include "web/WebLocalFrameImpl.h"
22 #include "web/WebViewImpl.h" 23 #include "web/WebViewImpl.h"
23 #include "web/tests/FrameTestHelpers.h" 24 #include "web/tests/FrameTestHelpers.h"
24 #include "wtf/PtrUtil.h" 25 #include "wtf/PtrUtil.h"
25 #include <gtest/gtest.h> 26 #include <gtest/gtest.h>
26 #include <memory> 27 #include <memory>
27 28
28 namespace blink { 29 namespace blink {
29 30
31 typedef bool TestParamRootLayerScrolling;
30 class CompositorWorkerTest 32 class CompositorWorkerTest
31 : public testing::Test 33 : public testing::WithParamInterface<TestParamRootLayerScrolling>
32 , public testing::WithParamInterface<FrameTestHelpers::SettingOverrideFuncti on> 34 , private ScopedRootLayerScrollingForTest
33 , public FrameTestHelpers::SettingOverrider { 35 , private ScopedCompositorWorkerForTest
36 , public testing::Test {
34 37
35 public: 38 public:
36 CompositorWorkerTest() 39 CompositorWorkerTest()
37 : m_baseURL("http://www.test.com/") 40 : ScopedRootLayerScrollingForTest(GetParam())
38 , m_helper(this) 41 , ScopedCompositorWorkerForTest(true)
39 { 42 , m_baseURL("http://www.test.com/") { }
40 }
41 43
42 void SetUp() override 44 void SetUp() override
43 { 45 {
44 RuntimeEnabledFeatures::setCompositorWorkerEnabled(true);
45 m_helper.initialize(true, nullptr, &m_mockWebViewClient, nullptr, &confi gureSettings); 46 m_helper.initialize(true, nullptr, &m_mockWebViewClient, nullptr, &confi gureSettings);
46 webViewImpl()->resize(IntSize(320, 240)); 47 webViewImpl()->resize(IntSize(320, 240));
47 } 48 }
48 49
49 ~CompositorWorkerTest() override 50 ~CompositorWorkerTest() override
50 { 51 {
51 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); 52 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs();
52 WebCache::clear(); 53 WebCache::clear();
53 } 54 }
54 55
55 void overrideSettings(WebSettings *settings) override
56 {
57 GetParam()(settings);
58 }
59
60 void navigateTo(const String& url) 56 void navigateTo(const String& url)
61 { 57 {
62 FrameTestHelpers::loadFrame(webViewImpl()->mainFrame(), url.utf8().data( )); 58 FrameTestHelpers::loadFrame(webViewImpl()->mainFrame(), url.utf8().data( ));
63 } 59 }
64 60
65 void forceFullCompositingUpdate() 61 void forceFullCompositingUpdate()
66 { 62 {
67 webViewImpl()->updateAllLifecyclePhases(); 63 webViewImpl()->updateAllLifecyclePhases();
68 } 64 }
69 65
70 void registerMockedHttpURLLoad(const std::string& fileName) 66 void registerMockedHttpURLLoad(const std::string& fileName)
71 { 67 {
72 URLTestHelpers::registerMockedURLFromBaseURL(m_baseURL, WebString::fromU TF8(fileName.c_str())); 68 URLTestHelpers::registerMockedURLFromBaseURL(m_baseURL, WebString::fromU TF8(fileName.c_str()));
73 } 69 }
74 70
75 WebLayer* getRootScrollLayer() 71 WebLayer* getRootScrollLayer()
76 { 72 {
77 Settings* settings = frame()->settings(); 73 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
78 bool rootLayerScrolls = settings && settings->rootLayerScrolls();
79 if (rootLayerScrolls) {
80 DCHECK(frame()); 74 DCHECK(frame());
81 DCHECK(frame()->view()); 75 DCHECK(frame()->view());
82 DCHECK(frame()->view()->layoutViewportScrollableArea()); 76 DCHECK(frame()->view()->layoutViewportScrollableArea());
83 DCHECK(frame()->view()->layoutViewportScrollableArea()->layerForScro lling()); 77 DCHECK(frame()->view()->layoutViewportScrollableArea()->layerForScro lling());
84 return frame()->view()->layoutViewportScrollableArea()->layerForScro lling()->platformLayer(); 78 return frame()->view()->layoutViewportScrollableArea()->layerForScro lling()->platformLayer();
85 } 79 }
86 PaintLayerCompositor* compositor = frame()->contentLayoutItem().composit or(); 80 PaintLayerCompositor* compositor = frame()->contentLayoutItem().composit or();
87 DCHECK(compositor); 81 DCHECK(compositor);
88 DCHECK(compositor->scrollLayer()); 82 DCHECK(compositor->scrollLayer());
89 83
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 135 }
142 136
143 static WebLayer* webLayerFromElement(Element* element) 137 static WebLayer* webLayerFromElement(Element* element)
144 { 138 {
145 CompositedLayerMapping* compositedLayerMapping = mappingFromElement(element) ; 139 CompositedLayerMapping* compositedLayerMapping = mappingFromElement(element) ;
146 if (!compositedLayerMapping) 140 if (!compositedLayerMapping)
147 return nullptr; 141 return nullptr;
148 return webLayerFromGraphicsLayer(compositedLayerMapping->mainGraphicsLayer() ); 142 return webLayerFromGraphicsLayer(compositedLayerMapping->mainGraphicsLayer() );
149 } 143 }
150 144
151 INSTANTIATE_TEST_CASE_P(All, CompositorWorkerTest, ::testing::Values( 145 INSTANTIATE_TEST_CASE_P(All, CompositorWorkerTest, ::testing::Bool());
152 FrameTestHelpers::DefaultSettingOverride,
153 FrameTestHelpers::RootLayerScrollsSettingOverride));
154 146
155 TEST_P(CompositorWorkerTest, plumbingElementIdAndMutableProperties) 147 TEST_P(CompositorWorkerTest, plumbingElementIdAndMutableProperties)
156 { 148 {
157 registerMockedHttpURLLoad("compositor-proxy-basic.html"); 149 registerMockedHttpURLLoad("compositor-proxy-basic.html");
158 navigateTo(m_baseURL + "compositor-proxy-basic.html"); 150 navigateTo(m_baseURL + "compositor-proxy-basic.html");
159 151
160 forceFullCompositingUpdate(); 152 forceFullCompositingUpdate();
161 153
162 Document* document = frame()->document(); 154 Document* document = frame()->document();
163 155
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 { 316 {
325 const String& transformValue = document->domWindow()->getComputedStyle( proxiedElement, String())->getPropertyValueInternal(CSSPropertyTransform); 317 const String& transformValue = document->domWindow()->getComputedStyle( proxiedElement, String())->getPropertyValueInternal(CSSPropertyTransform);
326 EXPECT_EQ("matrix3d(11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41, 42, 43, 44)", transformValue); 318 EXPECT_EQ("matrix3d(11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41, 42, 43, 44)", transformValue);
327 319
328 const String& opacityValue = document->domWindow()->getComputedStyle(pro xiedElement, String())->getPropertyValueInternal(CSSPropertyOpacity); 320 const String& opacityValue = document->domWindow()->getComputedStyle(pro xiedElement, String())->getPropertyValueInternal(CSSPropertyOpacity);
329 EXPECT_EQ("0.8", opacityValue); 321 EXPECT_EQ("0.8", opacityValue);
330 } 322 }
331 } 323 }
332 324
333 } // namespace blink 325 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebSettingsImpl.cpp ('k') | third_party/WebKit/Source/web/tests/FrameTestHelpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698