OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 using WebCore::HitTestRequest; | 98 using WebCore::HitTestRequest; |
99 using WebCore::Range; | 99 using WebCore::Range; |
100 using blink::URLTestHelpers::toKURL; | 100 using blink::URLTestHelpers::toKURL; |
101 using blink::FrameTestHelpers::runPendingTasks; | 101 using blink::FrameTestHelpers::runPendingTasks; |
102 | 102 |
103 namespace { | 103 namespace { |
104 | 104 |
105 const int touchPointPadding = 32; | 105 const int touchPointPadding = 32; |
106 | 106 |
107 #define EXPECT_EQ_RECT(a, b) \ | 107 #define EXPECT_EQ_RECT(a, b) \ |
108 EXPECT_EQ(a.x(), b.x()); \ | 108 do { \ |
109 EXPECT_EQ(a.y(), b.y()); \ | 109 EXPECT_EQ(a.x(), b.x()); \ |
110 EXPECT_EQ(a.width(), b.width()); \ | 110 EXPECT_EQ(a.y(), b.y()); \ |
111 EXPECT_EQ(a.height(), b.height()); | 111 EXPECT_EQ(a.width(), b.width()); \ |
| 112 EXPECT_EQ(a.height(), b.height()); \ |
| 113 } while (false) |
112 | 114 |
113 class FakeCompositingWebViewClient : public WebViewClient { | 115 class FakeCompositingWebViewClient : public WebViewClient { |
114 public: | 116 public: |
115 virtual ~FakeCompositingWebViewClient() | 117 virtual ~FakeCompositingWebViewClient() |
116 { | 118 { |
117 } | 119 } |
118 | 120 |
119 virtual void initializeLayerTreeView() OVERRIDE | 121 virtual void initializeLayerTreeView() OVERRIDE |
120 { | 122 { |
121 m_layerTreeView = adoptPtr(Platform::current()->unitTestSupport()->creat
eLayerTreeViewForTesting(WebUnitTestSupport::TestViewTypeUnitTest)); | 123 m_layerTreeView = adoptPtr(Platform::current()->unitTestSupport()->creat
eLayerTreeViewForTesting(WebUnitTestSupport::TestViewTypeUnitTest)); |
(...skipping 5065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5187 TEST_F(WebFrameTest, CreateChildFrameFailure) | 5189 TEST_F(WebFrameTest, CreateChildFrameFailure) |
5188 { | 5190 { |
5189 registerMockedHttpURLLoad("create_child_frame_fail.html"); | 5191 registerMockedHttpURLLoad("create_child_frame_fail.html"); |
5190 FailCreateChildFrame client; | 5192 FailCreateChildFrame client; |
5191 FrameTestHelpers::WebViewHelper webViewHelper; | 5193 FrameTestHelpers::WebViewHelper webViewHelper; |
5192 webViewHelper.initializeAndLoad(m_baseURL + "create_child_frame_fail.html",
true, &client); | 5194 webViewHelper.initializeAndLoad(m_baseURL + "create_child_frame_fail.html",
true, &client); |
5193 | 5195 |
5194 EXPECT_EQ(1, client.callCount()); | 5196 EXPECT_EQ(1, client.callCount()); |
5195 } | 5197 } |
5196 | 5198 |
| 5199 TEST_F(WebFrameTest, heightChangeRepaint) |
| 5200 { |
| 5201 const char* kTests[] = { |
| 5202 "repaint/height-change-no-full-repaint1.html", |
| 5203 "repaint/height-change-no-full-repaint2.html", |
| 5204 |
| 5205 // The following tests need full repaint on height change for now, |
| 5206 // but may be optimized not to need full repaint in the future and need |
| 5207 // to be updated. |
| 5208 "repaint/height-change-repaint1.html", // vertical writing mode |
| 5209 "repaint/height-change-repaint2.html", // frameset |
| 5210 "repaint/height-change-repaint3.html", // percentage height |
| 5211 "repaint/height-change-repaint4.html", // positioned percentage height |
| 5212 "repaint/height-change-repaint5.html", // percentage top |
| 5213 "repaint/height-change-repaint6.html", // bottom |
| 5214 "repaint/height-change-repaint7.html", // viewport related media query |
| 5215 "repaint/height-change-repaint8.html", // viewport percentage length |
| 5216 }; |
| 5217 |
| 5218 UseMockScrollbarSettings mockScrollbarSettings; |
| 5219 |
| 5220 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5221 WebViewImpl* webView = webViewHelper.initialize(true); |
| 5222 |
| 5223 for (size_t i = 0; i < arraysize(kTests); ++i) { |
| 5224 SCOPED_TRACE(kTests[i]); |
| 5225 registerMockedHttpURLLoad(kTests[i]); |
| 5226 FrameTestHelpers::loadFrame(webView->mainFrame(), m_baseURL + kTests[i])
; |
| 5227 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(
); |
| 5228 |
| 5229 webView->resize(WebSize(200, 200)); |
| 5230 webView->layout(); |
| 5231 |
| 5232 // Change height. |
| 5233 WebCore::FrameView* frameView = webView->mainFrameImpl()->frameView(); |
| 5234 frameView->setTracksRepaints(true); |
| 5235 webView->resize(WebSize(200, 300)); |
| 5236 webView->layout(); |
| 5237 if (strstr(kTests[i], "no-full-repaint")) |
| 5238 EXPECT_EQ_RECT(WebCore::IntRect(0, 200, 200, 100), WebCore::unionRec
t(frameView->trackedRepaintRects())); |
| 5239 else |
| 5240 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 300), WebCore::unionRect(
frameView->trackedRepaintRects())); |
| 5241 frameView->setTracksRepaints(false); |
| 5242 |
| 5243 // Change width, ensure optimized logic for height change doesn't break
repaint on width change. |
| 5244 frameView->setTracksRepaints(true); |
| 5245 webView->resize(WebSize(300, 300)); |
| 5246 webView->layout(); |
| 5247 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 300, 300), WebCore::unionRect(fram
eView->trackedRepaintRects())); |
| 5248 frameView->setTracksRepaints(false); |
| 5249 } |
| 5250 } |
| 5251 |
| 5252 TEST_F(WebFrameTest, heightChangeNoFullRepaintOverflowChange) |
| 5253 { |
| 5254 UseMockScrollbarSettings mockScrollbarSettings; |
| 5255 |
| 5256 registerMockedHttpURLLoad("repaint/height-change-no-full-repaint-overflow-ch
ange.html"); |
| 5257 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5258 webViewHelper.initializeAndLoad(m_baseURL + "repaint/height-change-no-full-r
epaint-overflow-change.html"); |
| 5259 WebView* webView = webViewHelper.webView(); |
| 5260 webView->resize(WebSize(200, 200)); |
| 5261 webView->layout(); |
| 5262 |
| 5263 WebCore::FrameView* frameView = toWebFrameImpl(webView->mainFrame())->frameV
iew(); |
| 5264 WebCore::RenderView* renderView = frameView->renderView(); |
| 5265 EXPECT_TRUE(renderView->hasRenderOverflow()); |
| 5266 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 200), WebCore::enclosingIntRect(r
enderView->visualOverflowRect())); |
| 5267 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 250), WebCore::enclosingIntRect(r
enderView->layoutOverflowRect())); |
| 5268 |
| 5269 frameView->setTracksRepaints(true); |
| 5270 webView->resize(WebSize(200, 300)); |
| 5271 webView->layout(); |
| 5272 EXPECT_EQ_RECT(WebCore::IntRect(0, 200, 200, 100), WebCore::unionRect(frameV
iew->trackedRepaintRects())); |
| 5273 frameView->setTracksRepaints(false); |
| 5274 |
| 5275 EXPECT_FALSE(renderView->hasRenderOverflow()); |
| 5276 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 300), WebCore::enclosingIntRect(r
enderView->visualOverflowRect())); |
| 5277 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 300), WebCore::enclosingIntRect(r
enderView->layoutOverflowRect())); |
| 5278 |
| 5279 webView->resize(WebSize(200, 200)); |
| 5280 webView->layout(); |
| 5281 EXPECT_TRUE(renderView->hasRenderOverflow()); |
| 5282 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 200), WebCore::enclosingIntRect(r
enderView->visualOverflowRect())); |
| 5283 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 250), WebCore::enclosingIntRect(r
enderView->layoutOverflowRect())); |
| 5284 } |
| 5285 |
5197 TEST_F(WebFrameTest, fixedPositionInFixedViewport) | 5286 TEST_F(WebFrameTest, fixedPositionInFixedViewport) |
5198 { | 5287 { |
5199 UseMockScrollbarSettings mockScrollbarSettings; | 5288 UseMockScrollbarSettings mockScrollbarSettings; |
5200 registerMockedHttpURLLoad("fixed-position-in-fixed-viewport.html"); | 5289 registerMockedHttpURLLoad("fixed-position-in-fixed-viewport.html"); |
5201 FrameTestHelpers::WebViewHelper webViewHelper; | 5290 FrameTestHelpers::WebViewHelper webViewHelper; |
5202 webViewHelper.initializeAndLoad(m_baseURL + "fixed-position-in-fixed-viewpor
t.html", true, 0, 0, enableViewportSettings); | 5291 webViewHelper.initializeAndLoad(m_baseURL + "fixed-position-in-fixed-viewpor
t.html", true, 0, 0, enableViewportSettings); |
5203 | 5292 |
5204 WebView* webView = webViewHelper.webView(); | 5293 WebView* webView = webViewHelper.webView(); |
5205 webView->resize(WebSize(100, 100)); | 5294 webView->resize(WebSize(100, 100)); |
5206 webView->layout(); | 5295 webView->layout(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5238 webViewHelper.initializeAndLoad("about:blank"); | 5327 webViewHelper.initializeAndLoad("about:blank"); |
5239 | 5328 |
5240 WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()
->frameView(); | 5329 WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()
->frameView(); |
5241 frameView->setFrameRect(WebCore::IntRect(0, 0, 200, 200)); | 5330 frameView->setFrameRect(WebCore::IntRect(0, 0, 200, 200)); |
5242 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 200), frameView->frameRect()); | 5331 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 200), frameView->frameRect()); |
5243 frameView->setFrameRect(WebCore::IntRect(100, 100, 200, 200)); | 5332 frameView->setFrameRect(WebCore::IntRect(100, 100, 200, 200)); |
5244 EXPECT_EQ_RECT(WebCore::IntRect(100, 100, 200, 200), frameView->frameRect())
; | 5333 EXPECT_EQ_RECT(WebCore::IntRect(100, 100, 200, 200), frameView->frameRect())
; |
5245 } | 5334 } |
5246 | 5335 |
5247 } // namespace | 5336 } // namespace |
OLD | NEW |