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 16 matching lines...) Expand all Loading... |
27 | 27 |
28 #include <memory> | 28 #include <memory> |
29 #include "bindings/core/v8/ExceptionState.h" | 29 #include "bindings/core/v8/ExceptionState.h" |
30 #include "core/dom/Node.h" | 30 #include "core/dom/Node.h" |
31 #include "core/exported/WebViewBase.h" | 31 #include "core/exported/WebViewBase.h" |
32 #include "core/frame/FrameView.h" | 32 #include "core/frame/FrameView.h" |
33 #include "core/input/EventHandler.h" | 33 #include "core/input/EventHandler.h" |
34 #include "core/page/Page.h" | 34 #include "core/page/Page.h" |
35 #include "core/page/TouchDisambiguation.h" | 35 #include "core/page/TouchDisambiguation.h" |
36 #include "platform/geometry/IntRect.h" | 36 #include "platform/geometry/IntRect.h" |
| 37 #include "platform/graphics/GraphicsLayer.h" |
37 #include "platform/testing/URLTestHelpers.h" | 38 #include "platform/testing/URLTestHelpers.h" |
38 #include "platform/testing/UnitTestHelpers.h" | 39 #include "platform/testing/UnitTestHelpers.h" |
39 #include "platform/wtf/PtrUtil.h" | 40 #include "platform/wtf/PtrUtil.h" |
40 #include "public/platform/Platform.h" | 41 #include "public/platform/Platform.h" |
41 #include "public/platform/WebContentLayer.h" | 42 #include "public/platform/WebContentLayer.h" |
42 #include "public/platform/WebFloatPoint.h" | 43 #include "public/platform/WebFloatPoint.h" |
43 #include "public/platform/WebInputEvent.h" | 44 #include "public/platform/WebInputEvent.h" |
44 #include "public/platform/WebSize.h" | 45 #include "public/platform/WebSize.h" |
45 #include "public/platform/WebURLLoaderMockFactory.h" | 46 #include "public/platform/WebURLLoaderMockFactory.h" |
46 #include "public/web/WebFrame.h" | 47 #include "public/web/WebFrame.h" |
47 #include "public/web/WebFrameClient.h" | 48 #include "public/web/WebFrameClient.h" |
48 #include "public/web/WebViewClient.h" | 49 #include "public/web/WebViewClient.h" |
49 #include "testing/gtest/include/gtest/gtest.h" | 50 #include "testing/gtest/include/gtest/gtest.h" |
50 #include "web/WebInputEventConversion.h" | 51 #include "web/WebInputEventConversion.h" |
51 #include "web/WebLocalFrameImpl.h" | 52 #include "web/WebLocalFrameImpl.h" |
52 #include "web/tests/FrameTestHelpers.h" | 53 #include "web/tests/FrameTestHelpers.h" |
53 | 54 |
54 namespace blink { | 55 namespace blink { |
55 | 56 |
56 namespace { | 57 namespace { |
57 | 58 |
58 GestureEventWithHitTestResults GetTargetedEvent(WebViewImpl* web_view_impl, | 59 GestureEventWithHitTestResults GetTargetedEvent(WebViewBase* web_view_impl, |
59 WebGestureEvent& touch_event) { | 60 WebGestureEvent& touch_event) { |
60 WebGestureEvent scaled_event = TransformWebGestureEvent( | 61 WebGestureEvent scaled_event = TransformWebGestureEvent( |
61 web_view_impl->MainFrameImpl()->GetFrameView(), touch_event); | 62 web_view_impl->MainFrameImpl()->GetFrameView(), touch_event); |
62 return web_view_impl->GetPage() | 63 return web_view_impl->GetPage() |
63 ->DeprecatedLocalMainFrame() | 64 ->DeprecatedLocalMainFrame() |
64 ->GetEventHandler() | 65 ->GetEventHandler() |
65 .TargetGestureEvent(scaled_event, true); | 66 .TargetGestureEvent(scaled_event, true); |
66 } | 67 } |
67 | 68 |
68 std::string RegisterMockedURLLoad() { | 69 std::string RegisterMockedURLLoad() { |
69 WebURL url = URLTestHelpers::RegisterMockedURLLoadFromBase( | 70 WebURL url = URLTestHelpers::RegisterMockedURLLoadFromBase( |
70 WebString::FromUTF8("http://www.test.com/"), testing::WebTestDataPath(), | 71 WebString::FromUTF8("http://www.test.com/"), testing::WebTestDataPath(), |
71 WebString::FromUTF8("test_touch_link_highlight.html")); | 72 WebString::FromUTF8("test_touch_link_highlight.html")); |
72 return url.GetString().Utf8(); | 73 return url.GetString().Utf8(); |
73 } | 74 } |
74 | 75 |
75 } // namespace | 76 } // namespace |
76 | 77 |
77 TEST(LinkHighlightImplTest, verifyWebViewImplIntegration) { | 78 TEST(LinkHighlightImplTest, verifyWebViewImplIntegration) { |
78 const std::string url = RegisterMockedURLLoad(); | 79 const std::string url = RegisterMockedURLLoad(); |
79 FrameTestHelpers::WebViewHelper web_view_helper; | 80 FrameTestHelpers::WebViewHelper web_view_helper; |
80 WebViewImpl* web_view_impl = web_view_helper.InitializeAndLoad(url, true); | 81 WebViewBase* web_view_impl = web_view_helper.InitializeAndLoad(url, true); |
81 int page_width = 640; | 82 int page_width = 640; |
82 int page_height = 480; | 83 int page_height = 480; |
83 web_view_impl->Resize(WebSize(page_width, page_height)); | 84 web_view_impl->Resize(WebSize(page_width, page_height)); |
84 web_view_impl->UpdateAllLifecyclePhases(); | 85 web_view_impl->UpdateAllLifecyclePhases(); |
85 | 86 |
86 WebGestureEvent touch_event(WebInputEvent::kGestureShowPress, | 87 WebGestureEvent touch_event(WebInputEvent::kGestureShowPress, |
87 WebInputEvent::kNoModifiers, | 88 WebInputEvent::kNoModifiers, |
88 WebInputEvent::kTimeStampForTesting); | 89 WebInputEvent::kTimeStampForTesting); |
89 touch_event.source_device = kWebGestureDeviceTouchscreen; | 90 touch_event.source_device = kWebGestureDeviceTouchscreen; |
90 | 91 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 FakeCompositingWebViewClient* CompositingWebViewClient() { | 143 FakeCompositingWebViewClient* CompositingWebViewClient() { |
143 DEFINE_STATIC_LOCAL(FakeCompositingWebViewClient, client, ()); | 144 DEFINE_STATIC_LOCAL(FakeCompositingWebViewClient, client, ()); |
144 return &client; | 145 return &client; |
145 } | 146 } |
146 | 147 |
147 } // anonymous namespace | 148 } // anonymous namespace |
148 | 149 |
149 TEST(LinkHighlightImplTest, resetDuringNodeRemoval) { | 150 TEST(LinkHighlightImplTest, resetDuringNodeRemoval) { |
150 const std::string url = RegisterMockedURLLoad(); | 151 const std::string url = RegisterMockedURLLoad(); |
151 FrameTestHelpers::WebViewHelper web_view_helper; | 152 FrameTestHelpers::WebViewHelper web_view_helper; |
152 WebViewImpl* web_view_impl = web_view_helper.InitializeAndLoad( | 153 WebViewBase* web_view_impl = web_view_helper.InitializeAndLoad( |
153 url, true, 0, CompositingWebViewClient()); | 154 url, true, 0, CompositingWebViewClient()); |
154 | 155 |
155 int page_width = 640; | 156 int page_width = 640; |
156 int page_height = 480; | 157 int page_height = 480; |
157 web_view_impl->Resize(WebSize(page_width, page_height)); | 158 web_view_impl->Resize(WebSize(page_width, page_height)); |
158 web_view_impl->UpdateAllLifecyclePhases(); | 159 web_view_impl->UpdateAllLifecyclePhases(); |
159 | 160 |
160 WebGestureEvent touch_event(WebInputEvent::kGestureShowPress, | 161 WebGestureEvent touch_event(WebInputEvent::kGestureShowPress, |
161 WebInputEvent::kNoModifiers, | 162 WebInputEvent::kNoModifiers, |
162 WebInputEvent::kTimeStampForTesting); | 163 WebInputEvent::kTimeStampForTesting); |
(...skipping 23 matching lines...) Expand all Loading... |
186 ->UnregisterAllURLsAndClearMemoryCache(); | 187 ->UnregisterAllURLsAndClearMemoryCache(); |
187 } | 188 } |
188 | 189 |
189 // A lifetime test: delete LayerTreeView while running LinkHighlights. | 190 // A lifetime test: delete LayerTreeView while running LinkHighlights. |
190 TEST(LinkHighlightImplTest, resetLayerTreeView) { | 191 TEST(LinkHighlightImplTest, resetLayerTreeView) { |
191 std::unique_ptr<FakeCompositingWebViewClient> web_view_client = | 192 std::unique_ptr<FakeCompositingWebViewClient> web_view_client = |
192 WTF::MakeUnique<FakeCompositingWebViewClient>(); | 193 WTF::MakeUnique<FakeCompositingWebViewClient>(); |
193 | 194 |
194 const std::string url = RegisterMockedURLLoad(); | 195 const std::string url = RegisterMockedURLLoad(); |
195 FrameTestHelpers::WebViewHelper web_view_helper; | 196 FrameTestHelpers::WebViewHelper web_view_helper; |
196 WebViewImpl* web_view_impl = | 197 WebViewBase* web_view_impl = |
197 web_view_helper.InitializeAndLoad(url, true, 0, web_view_client.get()); | 198 web_view_helper.InitializeAndLoad(url, true, 0, web_view_client.get()); |
198 | 199 |
199 int page_width = 640; | 200 int page_width = 640; |
200 int page_height = 480; | 201 int page_height = 480; |
201 web_view_impl->Resize(WebSize(page_width, page_height)); | 202 web_view_impl->Resize(WebSize(page_width, page_height)); |
202 web_view_impl->UpdateAllLifecyclePhases(); | 203 web_view_impl->UpdateAllLifecyclePhases(); |
203 | 204 |
204 WebGestureEvent touch_event(WebInputEvent::kGestureShowPress, | 205 WebGestureEvent touch_event(WebInputEvent::kGestureShowPress, |
205 WebInputEvent::kNoModifiers, | 206 WebInputEvent::kNoModifiers, |
206 WebInputEvent::kTimeStampForTesting); | 207 WebInputEvent::kTimeStampForTesting); |
(...skipping 19 matching lines...) Expand all Loading... |
226 web_view_helper.Reset(); | 227 web_view_helper.Reset(); |
227 | 228 |
228 Platform::Current() | 229 Platform::Current() |
229 ->GetURLLoaderMockFactory() | 230 ->GetURLLoaderMockFactory() |
230 ->UnregisterAllURLsAndClearMemoryCache(); | 231 ->UnregisterAllURLsAndClearMemoryCache(); |
231 } | 232 } |
232 | 233 |
233 TEST(LinkHighlightImplTest, multipleHighlights) { | 234 TEST(LinkHighlightImplTest, multipleHighlights) { |
234 const std::string url = RegisterMockedURLLoad(); | 235 const std::string url = RegisterMockedURLLoad(); |
235 FrameTestHelpers::WebViewHelper web_view_helper; | 236 FrameTestHelpers::WebViewHelper web_view_helper; |
236 WebViewImpl* web_view_impl = web_view_helper.InitializeAndLoad( | 237 WebViewBase* web_view_impl = web_view_helper.InitializeAndLoad( |
237 url, true, 0, CompositingWebViewClient()); | 238 url, true, 0, CompositingWebViewClient()); |
238 | 239 |
239 int page_width = 640; | 240 int page_width = 640; |
240 int page_height = 480; | 241 int page_height = 480; |
241 web_view_impl->Resize(WebSize(page_width, page_height)); | 242 web_view_impl->Resize(WebSize(page_width, page_height)); |
242 web_view_impl->UpdateAllLifecyclePhases(); | 243 web_view_impl->UpdateAllLifecyclePhases(); |
243 | 244 |
244 WebGestureEvent touch_event; | 245 WebGestureEvent touch_event; |
245 touch_event.x = 50; | 246 touch_event.x = 50; |
246 touch_event.y = 310; | 247 touch_event.y = 310; |
(...skipping 10 matching lines...) Expand all Loading... |
257 | 258 |
258 web_view_impl->EnableTapHighlights(highlight_nodes); | 259 web_view_impl->EnableTapHighlights(highlight_nodes); |
259 EXPECT_EQ(2U, web_view_impl->NumLinkHighlights()); | 260 EXPECT_EQ(2U, web_view_impl->NumLinkHighlights()); |
260 | 261 |
261 Platform::Current() | 262 Platform::Current() |
262 ->GetURLLoaderMockFactory() | 263 ->GetURLLoaderMockFactory() |
263 ->UnregisterAllURLsAndClearMemoryCache(); | 264 ->UnregisterAllURLsAndClearMemoryCache(); |
264 } | 265 } |
265 | 266 |
266 } // namespace blink | 267 } // namespace blink |
OLD | NEW |