OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions | |
6 * are met: | |
7 * | |
8 * 1. Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * 2. Redistributions in binary form must reproduce the above copyright | |
11 * notice, this list of conditions and the following disclaimer in the | |
12 * documentation and/or other materials provided with the distribution. | |
13 * | |
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | |
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | |
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
24 */ | |
25 | |
26 #include "config.h" | |
27 | |
28 #include "core/rendering/compositing/CompositedLayerMapping.h" | |
29 | |
30 #include "core/dom/Document.h" | |
31 #include "core/frame/FrameView.h" | |
32 #include "public/platform/Platform.h" | |
33 #include "public/platform/WebUnitTestSupport.h" | |
34 #include "public/web/WebDocument.h" | |
35 #include "public/web/WebElement.h" | |
36 #include "public/web/WebFrameClient.h" | |
37 #include "public/web/WebSettings.h" | |
38 #include "public/web/WebViewClient.h" | |
39 #include "web/WebLocalFrameImpl.h" | |
40 #include "web/WebViewImpl.h" | |
41 #include "web/tests/FrameTestHelpers.h" | |
42 #include "web/tests/URLTestHelpers.h" | |
43 | |
44 #include <gtest/gtest.h> | |
45 | |
46 using namespace blink; | |
47 | |
48 namespace WebCore { | |
49 | |
50 namespace { | |
51 | |
52 class MockWebFrameClient : public WebFrameClient { | |
53 }; | |
54 | |
55 class CompositedLayerMappingTest : public testing::Test { | |
56 public: | |
57 CompositedLayerMappingTest() | |
58 : m_baseURL("http://www.test.com/") | |
59 { | |
60 // We cannot reuse FrameTestHelpers::createWebViewAndLoad here because t
he compositing | |
61 // settings need to be set before the page is loaded. | |
62 m_mainFrame = WebLocalFrame::create(&m_mockWebFrameClient); | |
63 m_webViewImpl = toWebViewImpl(WebView::create(&m_mockWebViewClient)); | |
64 m_webViewImpl->settings()->setAcceleratedCompositingEnabled(true); | |
65 m_webViewImpl->settings()->setAcceleratedCompositingForFixedPositionEnab
led(true); | |
66 m_webViewImpl->settings()->setAcceleratedCompositingForOverflowScrollEna
bled(true); | |
67 m_webViewImpl->settings()->setCompositedScrollingForFramesEnabled(true); | |
68 m_webViewImpl->setMainFrame(m_mainFrame); | |
69 m_webViewImpl->resize(IntSize(320, 240)); | |
70 } | |
71 | |
72 virtual void TearDown() | |
73 { | |
74 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | |
75 m_webViewImpl->close(); | |
76 m_mainFrame->close(); | |
77 } | |
78 | |
79 void navigateTo(const std::string& url) | |
80 { | |
81 FrameTestHelpers::loadFrame(m_webViewImpl->mainFrame(), url); | |
82 } | |
83 | |
84 void registerMockedHttpURLLoad(const std::string& fileName) | |
85 { | |
86 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str())); | |
87 } | |
88 | |
89 protected: | |
90 std::string m_baseURL; | |
91 MockWebFrameClient m_mockWebFrameClient; | |
92 FrameTestHelpers::TestWebViewClient m_mockWebViewClient; | |
93 WebViewImpl* m_webViewImpl; | |
94 WebFrame* m_mainFrame; | |
95 }; | |
96 | |
97 TEST_F(CompositedLayerMappingTest, DISABLED_GraphicsLayerBackgroundColor) | |
98 { | |
99 registerMockedHttpURLLoad("layer_background_color.html"); | |
100 navigateTo(m_baseURL + "layer_background_color.html"); | |
101 m_webViewImpl->layout(); | |
102 | |
103 Document* document = m_webViewImpl->mainFrameImpl()->frame()->document(); | |
104 Element* layerElement = document->getElementById("layer"); | |
105 RenderLayerModelObject* renderer = toRenderLayerModelObject(layerElement->re
nderer()); | |
106 EXPECT_EQ(renderer->style()->visitedDependentColor(CSSPropertyBackgroundColo
r), | |
107 renderer->layer()->compositedLayerMapping()->mainGraphicsLayer()->backgr
oundColor()); | |
108 | |
109 layerElement = document->getElementById("layer-solid-color"); | |
110 renderer = toRenderLayerModelObject(layerElement->renderer()); | |
111 // CompositedLayerMapping::graphicsLayer's background color is unset if Soli
dColorLayer is created. | |
112 EXPECT_EQ(Color(), renderer->layer()->compositedLayerMapping()->mainGraphics
Layer()->backgroundColor()); | |
113 } | |
114 | |
115 } | |
116 | |
117 } // namespace WebCore | |
OLD | NEW |