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" | |
53 #include "core/frame/FrameView.h" | 52 #include "core/frame/FrameView.h" |
54 #include "core/frame/LocalFrame.h" | 53 #include "core/frame/LocalFrame.h" |
55 #include "core/frame/PinchViewport.h" | |
56 #include "core/frame/Settings.h" | 54 #include "core/frame/Settings.h" |
57 #include "core/html/HTMLDocument.h" | 55 #include "core/html/HTMLDocument.h" |
58 #include "core/html/HTMLFormElement.h" | 56 #include "core/html/HTMLFormElement.h" |
59 #include "core/loader/DocumentThreadableLoader.h" | 57 #include "core/loader/DocumentThreadableLoader.h" |
60 #include "core/loader/DocumentThreadableLoaderClient.h" | 58 #include "core/loader/DocumentThreadableLoaderClient.h" |
61 #include "core/loader/FrameLoadRequest.h" | 59 #include "core/loader/FrameLoadRequest.h" |
62 #include "core/loader/ThreadableLoader.h" | 60 #include "core/loader/ThreadableLoader.h" |
63 #include "core/page/EventHandler.h" | 61 #include "core/page/EventHandler.h" |
64 #include "core/page/Page.h" | 62 #include "core/page/Page.h" |
65 #include "core/rendering/HitTestResult.h" | 63 #include "core/rendering/HitTestResult.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 #include <v8.h> | 109 #include <v8.h> |
112 | 110 |
113 namespace { | 111 namespace { |
114 | 112 |
115 using blink::URLTestHelpers::toKURL; | 113 using blink::URLTestHelpers::toKURL; |
116 using blink::FrameTestHelpers::runPendingTasks; | 114 using blink::FrameTestHelpers::runPendingTasks; |
117 using namespace blink; | 115 using namespace blink; |
118 | 116 |
119 const int touchPointPadding = 32; | 117 const int touchPointPadding = 32; |
120 | 118 |
121 #define EXPECT_RECT_EQ(a, b) \ | 119 #define EXPECT_EQ_RECT(a, b) \ |
122 do { \ | 120 EXPECT_EQ(a.x(), b.x()); \ |
123 EXPECT_EQ(a.x(), b.x()); \ | 121 EXPECT_EQ(a.y(), b.y()); \ |
124 EXPECT_EQ(a.y(), b.y()); \ | 122 EXPECT_EQ(a.width(), b.width()); \ |
125 EXPECT_EQ(a.width(), b.width()); \ | 123 EXPECT_EQ(a.height(), b.height()); |
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) | |
140 | 124 |
141 class FakeCompositingWebViewClient : public FrameTestHelpers::TestWebViewClient
{ | 125 class FakeCompositingWebViewClient : public FrameTestHelpers::TestWebViewClient
{ |
142 public: | 126 public: |
143 virtual bool enterFullScreen() OVERRIDE { return true; } | 127 virtual bool enterFullScreen() OVERRIDE { return true; } |
144 }; | 128 }; |
145 | 129 |
146 class WebFrameTest : public testing::Test { | 130 class WebFrameTest : public testing::Test { |
147 protected: | 131 protected: |
148 WebFrameTest() | 132 WebFrameTest() |
149 : m_baseURL("http://www.test.com/") | 133 : m_baseURL("http://www.test.com/") |
(...skipping 2056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2206 webViewHelper.webView()->setPageScaleFactor(0.5); | 2190 webViewHelper.webView()->setPageScaleFactor(0.5); |
2207 | 2191 |
2208 SkBitmap bitmap; | 2192 SkBitmap bitmap; |
2209 bitmap.allocN32Pixels(200, 200); | 2193 bitmap.allocN32Pixels(200, 200); |
2210 bitmap.eraseColor(0); | 2194 bitmap.eraseColor(0); |
2211 SkCanvas canvas(bitmap); | 2195 SkCanvas canvas(bitmap); |
2212 | 2196 |
2213 GraphicsContext context(&canvas); | 2197 GraphicsContext context(&canvas); |
2214 context.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque); | 2198 context.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque); |
2215 | 2199 |
2216 EXPECT_RECT_EQ(IntRect(0, 0, 0, 0), context.opaqueRegion().asRect()); | 2200 EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), context.opaqueRegion().asRect()); |
2217 | 2201 |
2218 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); | 2202 FrameView* view = webViewHelper.webViewImpl()->mainFrameImpl()->frameView(); |
2219 IntRect paintRect(0, 0, 200, 200); | 2203 IntRect paintRect(0, 0, 200, 200); |
2220 view->paint(&context, paintRect); | 2204 view->paint(&context, paintRect); |
2221 | 2205 |
2222 // FIXME: This test broke in release builds when changing the FixedLayoutTes
tWebViewClient | 2206 // FIXME: This test broke in release builds when changing the FixedLayoutTes
tWebViewClient |
2223 // to return a non-null layerTreeView, which is what all our shipping config
urations do, | 2207 // to return a non-null layerTreeView, which is what all our shipping config
urations do, |
2224 // so this is just exposing an existing bug. | 2208 // so this is just exposing an existing bug. |
2225 // crbug.com/365812 | 2209 // crbug.com/365812 |
2226 #ifndef NDEBUG | 2210 #ifndef NDEBUG |
2227 int viewportWidthMinusScrollbar = 50 - (view->verticalScrollbar()->isOverlay
Scrollbar() ? 0 : 15); | 2211 int viewportWidthMinusScrollbar = 50 - (view->verticalScrollbar()->isOverlay
Scrollbar() ? 0 : 15); |
2228 int viewportHeightMinusScrollbar = 50 - (view->horizontalScrollbar()->isOver
layScrollbar() ? 0 : 15); | 2212 int viewportHeightMinusScrollbar = 50 - (view->horizontalScrollbar()->isOver
layScrollbar() ? 0 : 15); |
2229 IntRect clippedRect(0, 0, viewportWidthMinusScrollbar * 2, viewportHeightMin
usScrollbar * 2); | 2213 IntRect clippedRect(0, 0, viewportWidthMinusScrollbar * 2, viewportHeightMin
usScrollbar * 2); |
2230 EXPECT_RECT_EQ(clippedRect, context.opaqueRegion().asRect()); | 2214 EXPECT_EQ_RECT(clippedRect, context.opaqueRegion().asRect()); |
2231 #endif | 2215 #endif |
2232 } | 2216 } |
2233 | 2217 |
2234 TEST_F(WebFrameTest, pageScaleFactorUpdatesScrollbars) | 2218 TEST_F(WebFrameTest, pageScaleFactorUpdatesScrollbars) |
2235 { | 2219 { |
2236 UseMockScrollbarSettings mockScrollbarSettings; | 2220 UseMockScrollbarSettings mockScrollbarSettings; |
2237 registerMockedHttpURLLoad("fixed_layout.html"); | 2221 registerMockedHttpURLLoad("fixed_layout.html"); |
2238 | 2222 |
2239 FixedLayoutTestWebViewClient client; | 2223 FixedLayoutTestWebViewClient client; |
2240 client.m_screenInfo.deviceScaleFactor = 1; | 2224 client.m_screenInfo.deviceScaleFactor = 1; |
(...skipping 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4140 | 4124 |
4141 frame = webViewHelper.webView()->mainFrame(); | 4125 frame = webViewHelper.webView()->mainFrame(); |
4142 frame->executeCommand(WebString::fromUTF8("Unselect")); | 4126 frame->executeCommand(WebString::fromUTF8("Unselect")); |
4143 webViewHelper.webView()->layout(); | 4127 webViewHelper.webView()->layout(); |
4144 ASSERT_FALSE(frame->hasSelection()); | 4128 ASSERT_FALSE(frame->hasSelection()); |
4145 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); | 4129 EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared()); |
4146 } | 4130 } |
4147 | 4131 |
4148 class DisambiguationPopupTestWebViewClient : public FrameTestHelpers::TestWebVie
wClient { | 4132 class DisambiguationPopupTestWebViewClient : public FrameTestHelpers::TestWebVie
wClient { |
4149 public: | 4133 public: |
4150 virtual bool didTapMultipleTargets(const WebSize&, const WebRect&, const Web
Vector<WebRect>& targetRects) OVERRIDE | 4134 virtual bool didTapMultipleTargets(const WebGestureEvent&, const WebVector<W
ebRect>& targetRects) OVERRIDE |
4151 { | 4135 { |
4152 EXPECT_GE(targetRects.size(), 2u); | 4136 EXPECT_GE(targetRects.size(), 2u); |
4153 m_triggered = true; | 4137 m_triggered = true; |
4154 return true; | 4138 return true; |
4155 } | 4139 } |
4156 | 4140 |
4157 bool triggered() const { return m_triggered; } | 4141 bool triggered() const { return m_triggered; } |
4158 void resetTriggered() { m_triggered = false; } | 4142 void resetTriggered() { m_triggered = false; } |
4159 bool m_triggered; | 4143 bool m_triggered; |
4160 }; | 4144 }; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4298 EXPECT_FALSE(client.triggered()); | 4282 EXPECT_FALSE(client.triggered()); |
4299 } | 4283 } |
4300 | 4284 |
4301 for (int i = 0; i <= 46; i++) { | 4285 for (int i = 0; i <= 46; i++) { |
4302 client.resetTriggered(); | 4286 client.resetTriggered(); |
4303 webViewHelper.webView()->handleInputEvent(fatTap(10 + i * 5, 590)); | 4287 webViewHelper.webView()->handleInputEvent(fatTap(10 + i * 5, 590)); |
4304 EXPECT_FALSE(client.triggered()); | 4288 EXPECT_FALSE(client.triggered()); |
4305 } | 4289 } |
4306 } | 4290 } |
4307 | 4291 |
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 | |
4359 TEST_F(WebFrameTest, DisambiguationPopupBlacklist) | 4292 TEST_F(WebFrameTest, DisambiguationPopupBlacklist) |
4360 { | 4293 { |
4361 const unsigned viewportWidth = 500; | 4294 const unsigned viewportWidth = 500; |
4362 const unsigned viewportHeight = 1000; | 4295 const unsigned viewportHeight = 1000; |
4363 const unsigned divHeight = 100; | 4296 const unsigned divHeight = 100; |
4364 const std::string htmlFile = "disambiguation_popup_blacklist.html"; | 4297 const std::string htmlFile = "disambiguation_popup_blacklist.html"; |
4365 registerMockedHttpURLLoad(htmlFile); | 4298 registerMockedHttpURLLoad(htmlFile); |
4366 | 4299 |
4367 DisambiguationPopupTestWebViewClient client; | 4300 DisambiguationPopupTestWebViewClient client; |
4368 | 4301 |
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5781 EXPECT_EQ(200, leftRightFixed->offsetWidth()); | 5714 EXPECT_EQ(200, leftRightFixed->offsetWidth()); |
5782 } | 5715 } |
5783 | 5716 |
5784 TEST_F(WebFrameTest, FrameViewSetFrameRect) | 5717 TEST_F(WebFrameTest, FrameViewSetFrameRect) |
5785 { | 5718 { |
5786 FrameTestHelpers::WebViewHelper webViewHelper; | 5719 FrameTestHelpers::WebViewHelper webViewHelper; |
5787 webViewHelper.initializeAndLoad("about:blank"); | 5720 webViewHelper.initializeAndLoad("about:blank"); |
5788 | 5721 |
5789 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); | 5722 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); |
5790 frameView->setFrameRect(IntRect(0, 0, 200, 200)); | 5723 frameView->setFrameRect(IntRect(0, 0, 200, 200)); |
5791 EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), frameView->frameRect()); | 5724 EXPECT_EQ_RECT(IntRect(0, 0, 200, 200), frameView->frameRect()); |
5792 frameView->setFrameRect(IntRect(100, 100, 200, 200)); | 5725 frameView->setFrameRect(IntRect(100, 100, 200, 200)); |
5793 EXPECT_RECT_EQ(IntRect(100, 100, 200, 200), frameView->frameRect()); | 5726 EXPECT_EQ_RECT(IntRect(100, 100, 200, 200), frameView->frameRect()); |
5794 } | 5727 } |
5795 | 5728 |
5796 TEST_F(WebFrameTest, FullscreenLayerNonScrollable) | 5729 TEST_F(WebFrameTest, FullscreenLayerNonScrollable) |
5797 { | 5730 { |
5798 FakeCompositingWebViewClient client; | 5731 FakeCompositingWebViewClient client; |
5799 registerMockedHttpURLLoad("fullscreen_div.html"); | 5732 registerMockedHttpURLLoad("fullscreen_div.html"); |
5800 FrameTestHelpers::WebViewHelper webViewHelper; | 5733 FrameTestHelpers::WebViewHelper webViewHelper; |
5801 int viewportWidth = 640; | 5734 int viewportWidth = 640; |
5802 int viewportHeight = 480; | 5735 int viewportHeight = 480; |
5803 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, 0, &client, &configueCompositingWebView); | 5736 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... |
6335 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6268 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6336 | 6269 |
6337 // Neither should a page reload. | 6270 // Neither should a page reload. |
6338 localFrame->reload(); | 6271 localFrame->reload(); |
6339 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | 6272 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); |
6340 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 6273 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
6341 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6274 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6342 } | 6275 } |
6343 | 6276 |
6344 } // namespace | 6277 } // namespace |
OLD | NEW |