| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 ASSERT_TRUE(highlightLayer); | 162 ASSERT_TRUE(highlightLayer); |
| 163 EXPECT_TRUE(highlightLayer->linkHighlight(0)); | 163 EXPECT_TRUE(highlightLayer->linkHighlight(0)); |
| 164 | 164 |
| 165 touchNode->remove(IGNORE_EXCEPTION); | 165 touchNode->remove(IGNORE_EXCEPTION); |
| 166 webViewImpl->updateAllLifecyclePhases(); | 166 webViewImpl->updateAllLifecyclePhases(); |
| 167 ASSERT_EQ(0U, highlightLayer->numLinkHighlights()); | 167 ASSERT_EQ(0U, highlightLayer->numLinkHighlights()); |
| 168 | 168 |
| 169 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 169 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
| 170 } | 170 } |
| 171 | 171 |
| 172 TEST(LinkHighlightImplTest, resetLayerTreeView) |
| 173 { |
| 174 OwnPtr<FakeCompositingWebViewClient> webViewClient = adoptPtr(new FakeCompos
itingWebViewClient()); |
| 175 webViewClient->setUseCompositorAnimationTimelines(true); |
| 176 |
| 177 const std::string baseURL("http://www.test.com/"); |
| 178 const std::string fileName("test_touch_link_highlight.html"); |
| 179 |
| 180 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("test_touch_link_highlight.html")); |
| 181 FrameTestHelpers::WebViewHelper webViewHelper; |
| 182 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true, 0, webViewClient.get()); |
| 183 |
| 184 int pageWidth = 640; |
| 185 int pageHeight = 480; |
| 186 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
| 187 webViewImpl->updateAllLifecyclePhases(); |
| 188 |
| 189 WebGestureEvent touchEvent; |
| 190 touchEvent.type = WebInputEvent::GestureShowPress; |
| 191 touchEvent.sourceDevice = WebGestureDeviceTouchscreen; |
| 192 touchEvent.x = 20; |
| 193 touchEvent.y = 20; |
| 194 |
| 195 GestureEventWithHitTestResults targetedEvent = getTargetedEvent(webViewImpl,
touchEvent); |
| 196 Node* touchNode = webViewImpl->bestTapNode(targetedEvent); |
| 197 ASSERT_TRUE(touchNode); |
| 198 |
| 199 webViewImpl->enableTapHighlightAtPoint(targetedEvent); |
| 200 ASSERT_TRUE(webViewImpl->linkHighlight(0)); |
| 201 |
| 202 GraphicsLayer* highlightLayer = webViewImpl->linkHighlight(0)->currentGraphi
csLayerForTesting(); |
| 203 ASSERT_TRUE(highlightLayer); |
| 204 EXPECT_TRUE(highlightLayer->linkHighlight(0)); |
| 205 |
| 206 // Mimic the logic from RenderWidget::Close: |
| 207 webViewImpl->willCloseLayerTreeView(); |
| 208 webViewClient.clear(); |
| 209 webViewHelper.reset(); |
| 210 |
| 211 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
| 212 } |
| 213 |
| 172 TEST(LinkHighlightImplTest, multipleHighlights) | 214 TEST(LinkHighlightImplTest, multipleHighlights) |
| 173 { | 215 { |
| 174 FrameTestHelpers::UseMockScrollbarSettings m_mockScrollbarSettings; | 216 FrameTestHelpers::UseMockScrollbarSettings m_mockScrollbarSettings; |
| 175 | 217 |
| 176 const std::string baseURL("http://www.test.com/"); | 218 const std::string baseURL("http://www.test.com/"); |
| 177 const std::string fileName("test_touch_link_highlight.html"); | 219 const std::string fileName("test_touch_link_highlight.html"); |
| 178 | 220 |
| 179 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("test_touch_link_highlight.html")); | 221 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("test_touch_link_highlight.html")); |
| 180 FrameTestHelpers::WebViewHelper webViewHelper; | 222 FrameTestHelpers::WebViewHelper webViewHelper; |
| 181 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true, 0, compositingWebViewClient()); | 223 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true, 0, compositingWebViewClient()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 196 IntRect boundingBox(touchEvent.x - touchEvent.data.tap.width / 2, touchEvent
.y - touchEvent.data.tap.height / 2, touchEvent.data.tap.width, touchEvent.data.
tap.height); | 238 IntRect boundingBox(touchEvent.x - touchEvent.data.tap.width / 2, touchEvent
.y - touchEvent.data.tap.height / 2, touchEvent.data.tap.width, touchEvent.data.
tap.height); |
| 197 findGoodTouchTargets(boundingBox, webViewImpl->mainFrameImpl()->frame(), goo
dTargets, highlightNodes); | 239 findGoodTouchTargets(boundingBox, webViewImpl->mainFrameImpl()->frame(), goo
dTargets, highlightNodes); |
| 198 | 240 |
| 199 webViewImpl->enableTapHighlights(highlightNodes); | 241 webViewImpl->enableTapHighlights(highlightNodes); |
| 200 EXPECT_EQ(2U, webViewImpl->numLinkHighlights()); | 242 EXPECT_EQ(2U, webViewImpl->numLinkHighlights()); |
| 201 | 243 |
| 202 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 244 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
| 203 } | 245 } |
| 204 | 246 |
| 205 } // namespace blink | 247 } // namespace blink |
| OLD | NEW |