OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 class MockWebFrameClient : public WebFrameClient { | 69 class MockWebFrameClient : public WebFrameClient { |
70 }; | 70 }; |
71 | 71 |
72 class ScrollingCoordinatorChromiumTest : public testing::Test { | 72 class ScrollingCoordinatorChromiumTest : public testing::Test { |
73 public: | 73 public: |
74 ScrollingCoordinatorChromiumTest() | 74 ScrollingCoordinatorChromiumTest() |
75 : m_baseURL("http://www.test.com/") | 75 : m_baseURL("http://www.test.com/") |
76 { | 76 { |
77 // We cannot reuse FrameTestHelpers::createWebViewAndLoad here because t
he compositing | 77 // We cannot reuse FrameTestHelpers::createWebViewAndLoad here because t
he compositing |
78 // settings need to be set before the page is loaded. | 78 // settings need to be set before the page is loaded. |
| 79 m_mainFrame = WebFrame::create(&m_mockWebFrameClient); |
79 m_webViewImpl = toWebViewImpl(WebView::create(&m_mockWebViewClient)); | 80 m_webViewImpl = toWebViewImpl(WebView::create(&m_mockWebViewClient)); |
80 m_webViewImpl->settings()->setJavaScriptEnabled(true); | 81 m_webViewImpl->settings()->setJavaScriptEnabled(true); |
81 m_webViewImpl->settings()->setForceCompositingMode(true); | 82 m_webViewImpl->settings()->setForceCompositingMode(true); |
82 m_webViewImpl->settings()->setAcceleratedCompositingEnabled(true); | 83 m_webViewImpl->settings()->setAcceleratedCompositingEnabled(true); |
83 m_webViewImpl->settings()->setAcceleratedCompositingForFixedPositionEnab
led(true); | 84 m_webViewImpl->settings()->setAcceleratedCompositingForFixedPositionEnab
led(true); |
84 m_webViewImpl->settings()->setAcceleratedCompositingForOverflowScrollEna
bled(true); | 85 m_webViewImpl->settings()->setAcceleratedCompositingForOverflowScrollEna
bled(true); |
85 m_webViewImpl->settings()->setAcceleratedCompositingForScrollableFramesE
nabled(true); | 86 m_webViewImpl->settings()->setAcceleratedCompositingForScrollableFramesE
nabled(true); |
86 m_webViewImpl->settings()->setCompositedScrollingForFramesEnabled(true); | 87 m_webViewImpl->settings()->setCompositedScrollingForFramesEnabled(true); |
87 m_webViewImpl->settings()->setFixedPositionCreatesStackingContext(true); | 88 m_webViewImpl->settings()->setFixedPositionCreatesStackingContext(true); |
88 m_webViewImpl->initializeMainFrame(&m_mockWebFrameClient); | 89 m_webViewImpl->setMainFrame(m_mainFrame); |
89 m_webViewImpl->resize(IntSize(320, 240)); | 90 m_webViewImpl->resize(IntSize(320, 240)); |
90 } | 91 } |
91 | 92 |
92 virtual ~ScrollingCoordinatorChromiumTest() | 93 virtual ~ScrollingCoordinatorChromiumTest() |
93 { | 94 { |
94 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 95 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
95 m_webViewImpl->close(); | 96 m_webViewImpl->close(); |
| 97 m_mainFrame->close(); |
96 } | 98 } |
97 | 99 |
98 void navigateTo(const std::string& url) | 100 void navigateTo(const std::string& url) |
99 { | 101 { |
100 FrameTestHelpers::loadFrame(m_webViewImpl->mainFrame(), url); | 102 FrameTestHelpers::loadFrame(m_webViewImpl->mainFrame(), url); |
101 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(
); | 103 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(
); |
102 } | 104 } |
103 | 105 |
104 void registerMockedHttpURLLoad(const std::string& fileName) | 106 void registerMockedHttpURLLoad(const std::string& fileName) |
105 { | 107 { |
106 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str())); | 108 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str())); |
107 } | 109 } |
108 | 110 |
109 WebLayer* getRootScrollLayer() | 111 WebLayer* getRootScrollLayer() |
110 { | 112 { |
111 RenderLayerCompositor* compositor = m_webViewImpl->mainFrameImpl()->fram
e()->contentRenderer()->compositor(); | 113 RenderLayerCompositor* compositor = m_webViewImpl->mainFrameImpl()->fram
e()->contentRenderer()->compositor(); |
112 ASSERT(compositor); | 114 ASSERT(compositor); |
113 ASSERT(compositor->scrollLayer()); | 115 ASSERT(compositor->scrollLayer()); |
114 | 116 |
115 WebLayer* webScrollLayer = compositor->scrollLayer()->platformLayer(); | 117 WebLayer* webScrollLayer = compositor->scrollLayer()->platformLayer(); |
116 return webScrollLayer; | 118 return webScrollLayer; |
117 } | 119 } |
118 | 120 |
119 protected: | 121 protected: |
120 std::string m_baseURL; | 122 std::string m_baseURL; |
121 MockWebFrameClient m_mockWebFrameClient; | 123 MockWebFrameClient m_mockWebFrameClient; |
122 FakeWebViewClient m_mockWebViewClient; | 124 FakeWebViewClient m_mockWebViewClient; |
123 WebViewImpl* m_webViewImpl; | 125 WebViewImpl* m_webViewImpl; |
| 126 WebFrame* m_mainFrame; |
124 }; | 127 }; |
125 | 128 |
126 TEST_F(ScrollingCoordinatorChromiumTest, fastScrollingByDefault) | 129 TEST_F(ScrollingCoordinatorChromiumTest, fastScrollingByDefault) |
127 { | 130 { |
128 navigateTo("about:blank"); | 131 navigateTo("about:blank"); |
129 | 132 |
130 // Make sure the scrolling coordinator is active. | 133 // Make sure the scrolling coordinator is active. |
131 FrameView* frameView = m_webViewImpl->mainFrameImpl()->frameView(); | 134 FrameView* frameView = m_webViewImpl->mainFrameImpl()->frameView(); |
132 Page* page = m_webViewImpl->mainFrameImpl()->frame()->page(); | 135 Page* page = m_webViewImpl->mainFrameImpl()->frame()->page(); |
133 ASSERT_TRUE(page->scrollingCoordinator()); | 136 ASSERT_TRUE(page->scrollingCoordinator()); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 | 397 |
395 TEST_F(ScrollingCoordinatorChromiumTest, setupScrollbarLayerShouldNotCrash) | 398 TEST_F(ScrollingCoordinatorChromiumTest, setupScrollbarLayerShouldNotCrash) |
396 { | 399 { |
397 registerMockedHttpURLLoad("setup_scrollbar_layer_crash.html"); | 400 registerMockedHttpURLLoad("setup_scrollbar_layer_crash.html"); |
398 navigateTo(m_baseURL + "setup_scrollbar_layer_crash.html"); | 401 navigateTo(m_baseURL + "setup_scrollbar_layer_crash.html"); |
399 // This test document setup an iframe with scrollbars, then switch to | 402 // This test document setup an iframe with scrollbars, then switch to |
400 // an empty document by javascript. | 403 // an empty document by javascript. |
401 } | 404 } |
402 | 405 |
403 } // namespace | 406 } // namespace |
OLD | NEW |