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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "core/dom/DocumentMarkerController.h" | 42 #include "core/dom/DocumentMarkerController.h" |
43 #include "core/dom/Fullscreen.h" | 43 #include "core/dom/Fullscreen.h" |
44 #include "core/dom/NodeRenderStyle.h" | 44 #include "core/dom/NodeRenderStyle.h" |
45 #include "core/dom/Range.h" | 45 #include "core/dom/Range.h" |
46 #include "core/editing/Editor.h" | 46 #include "core/editing/Editor.h" |
47 #include "core/editing/FrameSelection.h" | 47 #include "core/editing/FrameSelection.h" |
48 #include "core/editing/SpellChecker.h" | 48 #include "core/editing/SpellChecker.h" |
49 #include "core/editing/VisiblePosition.h" | 49 #include "core/editing/VisiblePosition.h" |
50 #include "core/events/MouseEvent.h" | 50 #include "core/events/MouseEvent.h" |
51 #include "core/fetch/MemoryCache.h" | 51 #include "core/fetch/MemoryCache.h" |
| 52 #include "core/frame/FrameHost.h" |
52 #include "core/frame/FrameView.h" | 53 #include "core/frame/FrameView.h" |
53 #include "core/frame/LocalFrame.h" | 54 #include "core/frame/LocalFrame.h" |
| 55 #include "core/frame/PinchViewport.h" |
54 #include "core/frame/Settings.h" | 56 #include "core/frame/Settings.h" |
55 #include "core/html/HTMLDocument.h" | 57 #include "core/html/HTMLDocument.h" |
56 #include "core/html/HTMLFormElement.h" | 58 #include "core/html/HTMLFormElement.h" |
57 #include "core/loader/DocumentThreadableLoader.h" | 59 #include "core/loader/DocumentThreadableLoader.h" |
58 #include "core/loader/DocumentThreadableLoaderClient.h" | 60 #include "core/loader/DocumentThreadableLoaderClient.h" |
59 #include "core/loader/FrameLoadRequest.h" | 61 #include "core/loader/FrameLoadRequest.h" |
60 #include "core/loader/ThreadableLoader.h" | 62 #include "core/loader/ThreadableLoader.h" |
61 #include "core/page/EventHandler.h" | 63 #include "core/page/EventHandler.h" |
62 #include "core/page/Page.h" | 64 #include "core/page/Page.h" |
63 #include "core/rendering/HitTestResult.h" | 65 #include "core/rendering/HitTestResult.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 #include <v8.h> | 111 #include <v8.h> |
110 | 112 |
111 namespace { | 113 namespace { |
112 | 114 |
113 using blink::URLTestHelpers::toKURL; | 115 using blink::URLTestHelpers::toKURL; |
114 using blink::FrameTestHelpers::runPendingTasks; | 116 using blink::FrameTestHelpers::runPendingTasks; |
115 using namespace blink; | 117 using namespace blink; |
116 | 118 |
117 const int touchPointPadding = 32; | 119 const int touchPointPadding = 32; |
118 | 120 |
119 #define EXPECT_EQ_RECT(a, b) \ | 121 #define EXPECT_RECT_EQ(a, b) \ |
120 EXPECT_EQ(a.x(), b.x()); \ | 122 do { \ |
121 EXPECT_EQ(a.y(), b.y()); \ | 123 EXPECT_EQ(a.x(), b.x()); \ |
122 EXPECT_EQ(a.width(), b.width()); \ | 124 EXPECT_EQ(a.y(), b.y()); \ |
123 EXPECT_EQ(a.height(), b.height()); | 125 EXPECT_EQ(a.width(), b.width()); \ |
| 126 EXPECT_EQ(a.height(), b.height()); \ |
| 127 } while (false) |
| 128 |
| 129 #define EXPECT_POINT_EQ(expected, actual) \ |
| 130 do { \ |
| 131 EXPECT_EQ((expected).x(), (actual).x()); \ |
| 132 EXPECT_EQ((expected).y(), (actual).y()); \ |
| 133 } while (false) |
| 134 |
| 135 #define EXPECT_FLOAT_POINT_EQ(expected, actual) \ |
| 136 do { \ |
| 137 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \ |
| 138 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \ |
| 139 } while (false) |
124 | 140 |
125 class FakeCompositingWebViewClient : public FrameTestHelpers::TestWebViewClient
{ | 141 class FakeCompositingWebViewClient : public FrameTestHelpers::TestWebViewClient
{ |
126 public: | 142 public: |
127 virtual bool enterFullScreen() OVERRIDE { return true; } | 143 virtual bool enterFullScreen() OVERRIDE { return true; } |
128 }; | 144 }; |
129 | 145 |
130 class WebFrameTest : public testing::Test { | 146 class WebFrameTest : public testing::Test { |
131 protected: | 147 protected: |
132 WebFrameTest() | 148 WebFrameTest() |
133 : m_baseURL("http://www.test.com/") | 149 : m_baseURL("http://www.test.com/") |
(...skipping 2056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2190 webViewHelper.webView()->setPageScaleFactor(0.5); | 2206 webViewHelper.webView()->setPageScaleFactor(0.5); |
2191 | 2207 |
2192 SkBitmap bitmap; | 2208 SkBitmap bitmap; |
2193 bitmap.allocN32Pixels(200, 200); | 2209 bitmap.allocN32Pixels(200, 200); |
2194 bitmap.eraseColor(0); | 2210 bitmap.eraseColor(0); |
2195 SkCanvas canvas(bitmap); | 2211 SkCanvas canvas(bitmap); |
2196 | 2212 |
2197 GraphicsContext context(&canvas); | 2213 GraphicsContext context(&canvas); |
2198 context.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque); | 2214 context.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque); |
2199 | 2215 |
2200 EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), context.opaqueRegion().asRect()); | 2216 EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), context.opaqueRegion().asRect()); |
2201 | 2217 |
2202 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); | 2218 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); |
2203 IntRect paintRect(0, 0, 200, 200); | 2219 IntRect paintRect(0, 0, 200, 200); |
2204 view->paint(&context, paintRect); | 2220 view->paint(&context, paintRect); |
2205 | 2221 |
2206 // FIXME: This test broke in release builds when changing the FixedLayoutTes
tWebViewClient | 2222 // FIXME: This test broke in release builds when changing the FixedLayoutTes
tWebViewClient |
2207 // to return a non-null layerTreeView, which is what all our shipping config
urations do, | 2223 // to return a non-null layerTreeView, which is what all our shipping config
urations do, |
2208 // so this is just exposing an existing bug. | 2224 // so this is just exposing an existing bug. |
2209 // crbug.com/365812 | 2225 // crbug.com/365812 |
2210 #ifndef NDEBUG | 2226 #ifndef NDEBUG |
2211 int viewportWidthMinusScrollbar = 50 - (view->verticalScrollbar()->isOverlay
Scrollbar() ? 0 : 15); | 2227 int viewportWidthMinusScrollbar = 50 - (view->verticalScrollbar()->isOverlay
Scrollbar() ? 0 : 15); |
2212 int viewportHeightMinusScrollbar = 50 - (view->horizontalScrollbar()->isOver
layScrollbar() ? 0 : 15); | 2228 int viewportHeightMinusScrollbar = 50 - (view->horizontalScrollbar()->isOver
layScrollbar() ? 0 : 15); |
2213 IntRect clippedRect(0, 0, viewportWidthMinusScrollbar * 2, viewportHeightMin
usScrollbar * 2); | 2229 IntRect clippedRect(0, 0, viewportWidthMinusScrollbar * 2, viewportHeightMin
usScrollbar * 2); |
2214 EXPECT_EQ_RECT(clippedRect, context.opaqueRegion().asRect()); | 2230 EXPECT_RECT_EQ(clippedRect, context.opaqueRegion().asRect()); |
2215 #endif | 2231 #endif |
2216 } | 2232 } |
2217 | 2233 |
2218 TEST_F(WebFrameTest, pageScaleFactorUpdatesScrollbars) | 2234 TEST_F(WebFrameTest, pageScaleFactorUpdatesScrollbars) |
2219 { | 2235 { |
2220 UseMockScrollbarSettings mockScrollbarSettings; | 2236 UseMockScrollbarSettings mockScrollbarSettings; |
2221 registerMockedHttpURLLoad("fixed_layout.html"); | 2237 registerMockedHttpURLLoad("fixed_layout.html"); |
2222 | 2238 |
2223 FixedLayoutTestWebViewClient client; | 2239 FixedLayoutTestWebViewClient client; |
2224 client.m_screenInfo.deviceScaleFactor = 1; | 2240 client.m_screenInfo.deviceScaleFactor = 1; |
(...skipping 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4124 | 4140 |
4125 frame = webViewHelper.webView()->mainFrame(); | 4141 frame = webViewHelper.webView()->mainFrame(); |
4126 frame->executeCommand(WebString::fromUTF8("Unselect")); | 4142 frame->executeCommand(WebString::fromUTF8("Unselect")); |
4127 webViewHelper.webView()->layout(); | 4143 webViewHelper.webView()->layout(); |
4128 ASSERT_FALSE(frame->hasSelection()); | 4144 ASSERT_FALSE(frame->hasSelection()); |
4129 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); | 4145 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); |
4130 } | 4146 } |
4131 | 4147 |
4132 class DisambiguationPopupTestWebViewClient : public FrameTestHelpers::TestWebVie
wClient { | 4148 class DisambiguationPopupTestWebViewClient : public FrameTestHelpers::TestWebVie
wClient { |
4133 public: | 4149 public: |
4134 virtual bool didTapMultipleTargets(const WebGestureEvent&, const WebVector<W
ebRect>& targetRects) OVERRIDE | 4150 virtual bool didTapMultipleTargets(const WebSize&, const WebRect&, const Web
Vector<WebRect>& targetRects) OVERRIDE |
4135 { | 4151 { |
4136 EXPECT_GE(targetRects.size(), 2u); | 4152 EXPECT_GE(targetRects.size(), 2u); |
4137 m_triggered = true; | 4153 m_triggered = true; |
4138 return true; | 4154 return true; |
4139 } | 4155 } |
4140 | 4156 |
4141 bool triggered() const { return m_triggered; } | 4157 bool triggered() const { return m_triggered; } |
4142 void resetTriggered() { m_triggered = false; } | 4158 void resetTriggered() { m_triggered = false; } |
4143 bool m_triggered; | 4159 bool m_triggered; |
4144 }; | 4160 }; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4282 EXPECT_FALSE(client.triggered()); | 4298 EXPECT_FALSE(client.triggered()); |
4283 } | 4299 } |
4284 | 4300 |
4285 for (int i = 0; i <= 46; i++) { | 4301 for (int i = 0; i <= 46; i++) { |
4286 client.resetTriggered(); | 4302 client.resetTriggered(); |
4287 webViewHelper.webView()->handleInputEvent(fatTap(10 + i * 5, 590)); | 4303 webViewHelper.webView()->handleInputEvent(fatTap(10 + i * 5, 590)); |
4288 EXPECT_FALSE(client.triggered()); | 4304 EXPECT_FALSE(client.triggered()); |
4289 } | 4305 } |
4290 } | 4306 } |
4291 | 4307 |
| 4308 static void enableVirtualViewport(WebSettings* settings) |
| 4309 { |
| 4310 settings->setPinchVirtualViewportEnabled(true); |
| 4311 settings->setViewportEnabled(true); |
| 4312 settings->setViewportMetaEnabled(true); |
| 4313 settings->setShrinksViewportContentToFit(true); |
| 4314 } |
| 4315 |
| 4316 TEST_F(WebFrameTest, DisambiguationPopupPinchViewport) |
| 4317 { |
| 4318 const std::string htmlFile = "disambiguation_popup_200_by_800.html"; |
| 4319 registerMockedHttpURLLoad(htmlFile); |
| 4320 |
| 4321 DisambiguationPopupTestWebViewClient client; |
| 4322 |
| 4323 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4324 webViewHelper.initializeAndLoad(m_baseURL + htmlFile, true, 0, &client, enab
leVirtualViewport); |
| 4325 |
| 4326 WebViewImpl* webViewImpl = webViewHelper.webViewImpl(); |
| 4327 ASSERT_TRUE(webViewImpl); |
| 4328 LocalFrame* frame = webViewImpl->mainFrameImpl()->frame(); |
| 4329 ASSERT_TRUE(frame); |
| 4330 |
| 4331 webViewHelper.webView()->resize(WebSize(200, 400)); |
| 4332 |
| 4333 // Scroll main frame to the bottom of the document |
| 4334 webViewImpl->setMainFrameScrollOffset(WebPoint(0, 400)); |
| 4335 EXPECT_POINT_EQ(IntPoint(0, 400), frame->view()->scrollPosition()); |
| 4336 |
| 4337 webViewImpl->setPageScaleFactor(2.0); |
| 4338 |
| 4339 // Scroll pinch viewport to the top of the main frame. |
| 4340 PinchViewport& pinchViewport = frame->page()->frameHost().pinchViewport(); |
| 4341 pinchViewport.setLocation(FloatPoint(0, 0)); |
| 4342 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), pinchViewport.location()); |
| 4343 |
| 4344 // Tap at the top: there is nothing there. |
| 4345 client.resetTriggered(); |
| 4346 webViewHelper.webView()->handleInputEvent(fatTap(10, 60)); |
| 4347 EXPECT_FALSE(client.triggered()); |
| 4348 |
| 4349 // Scroll pinch viewport to the bottom of the main frame. |
| 4350 pinchViewport.setLocation(FloatPoint(0, 200)); |
| 4351 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 200), pinchViewport.location()); |
| 4352 |
| 4353 // Now the tap with the same coordinates should hit two elements. |
| 4354 client.resetTriggered(); |
| 4355 webViewHelper.webView()->handleInputEvent(fatTap(10, 60)); |
| 4356 EXPECT_TRUE(client.triggered()); |
| 4357 } |
| 4358 |
4292 TEST_F(WebFrameTest, DisambiguationPopupBlacklist) | 4359 TEST_F(WebFrameTest, DisambiguationPopupBlacklist) |
4293 { | 4360 { |
4294 const unsigned viewportWidth = 500; | 4361 const unsigned viewportWidth = 500; |
4295 const unsigned viewportHeight = 1000; | 4362 const unsigned viewportHeight = 1000; |
4296 const unsigned divHeight = 100; | 4363 const unsigned divHeight = 100; |
4297 const std::string htmlFile = "disambiguation_popup_blacklist.html"; | 4364 const std::string htmlFile = "disambiguation_popup_blacklist.html"; |
4298 registerMockedHttpURLLoad(htmlFile); | 4365 registerMockedHttpURLLoad(htmlFile); |
4299 | 4366 |
4300 DisambiguationPopupTestWebViewClient client; | 4367 DisambiguationPopupTestWebViewClient client; |
4301 | 4368 |
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5714 EXPECT_EQ(200, leftRightFixed->offsetWidth()); | 5781 EXPECT_EQ(200, leftRightFixed->offsetWidth()); |
5715 } | 5782 } |
5716 | 5783 |
5717 TEST_F(WebFrameTest, FrameViewSetFrameRect) | 5784 TEST_F(WebFrameTest, FrameViewSetFrameRect) |
5718 { | 5785 { |
5719 FrameTestHelpers::WebViewHelper webViewHelper; | 5786 FrameTestHelpers::WebViewHelper webViewHelper; |
5720 webViewHelper.initializeAndLoad("about:blank"); | 5787 webViewHelper.initializeAndLoad("about:blank"); |
5721 | 5788 |
5722 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); | 5789 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); |
5723 frameView->setFrameRect(IntRect(0, 0, 200, 200)); | 5790 frameView->setFrameRect(IntRect(0, 0, 200, 200)); |
5724 EXPECT_EQ_RECT(IntRect(0, 0, 200, 200), frameView->frameRect()); | 5791 EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), frameView->frameRect()); |
5725 frameView->setFrameRect(IntRect(100, 100, 200, 200)); | 5792 frameView->setFrameRect(IntRect(100, 100, 200, 200)); |
5726 EXPECT_EQ_RECT(IntRect(100, 100, 200, 200), frameView->frameRect()); | 5793 EXPECT_RECT_EQ(IntRect(100, 100, 200, 200), frameView->frameRect()); |
5727 } | 5794 } |
5728 | 5795 |
5729 TEST_F(WebFrameTest, FullscreenLayerNonScrollable) | 5796 TEST_F(WebFrameTest, FullscreenLayerNonScrollable) |
5730 { | 5797 { |
5731 FakeCompositingWebViewClient client; | 5798 FakeCompositingWebViewClient client; |
5732 registerMockedHttpURLLoad("fullscreen_div.html"); | 5799 registerMockedHttpURLLoad("fullscreen_div.html"); |
5733 FrameTestHelpers::WebViewHelper webViewHelper; | 5800 FrameTestHelpers::WebViewHelper webViewHelper; |
5734 int viewportWidth = 640; | 5801 int viewportWidth = 640; |
5735 int viewportHeight = 480; | 5802 int viewportHeight = 480; |
5736 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, 0, &client, &configueCompositingWebView); | 5803 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, 0, &client, &configueCompositingWebView); |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6268 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6335 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6269 | 6336 |
6270 // Neither should a page reload. | 6337 // Neither should a page reload. |
6271 localFrame->reload(); | 6338 localFrame->reload(); |
6272 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | 6339 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); |
6273 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 6340 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
6274 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6341 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6275 } | 6342 } |
6276 | 6343 |
6277 } // namespace | 6344 } // namespace |
OLD | NEW |