| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 using namespace WebCore; | 53 using namespace WebCore; |
| 54 | 54 |
| 55 namespace { | 55 namespace { |
| 56 | 56 |
| 57 TEST(LinkHighlightTest, verifyWebViewImplIntegration) | 57 TEST(LinkHighlightTest, verifyWebViewImplIntegration) |
| 58 { | 58 { |
| 59 const std::string baseURL("http://www.test.com/"); | 59 const std::string baseURL("http://www.test.com/"); |
| 60 const std::string fileName("test_touch_link_highlight.html"); | 60 const std::string fileName("test_touch_link_highlight.html"); |
| 61 | 61 |
| 62 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("test_touch_link_highlight.html")); | 62 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("test_touch_link_highlight.html")); |
| 63 WebViewImpl* webViewImpl = toWebViewImpl(FrameTestHelpers::createWebViewAndL
oad(baseURL + fileName, true)); | 63 FrameTestHelpers::WebViewHelper webViewHelper; |
| 64 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true); |
| 64 int pageWidth = 640; | 65 int pageWidth = 640; |
| 65 int pageHeight = 480; | 66 int pageHeight = 480; |
| 66 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 67 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
| 67 webViewImpl->layout(); | 68 webViewImpl->layout(); |
| 68 | 69 |
| 69 WebGestureEvent touchEvent; | 70 WebGestureEvent touchEvent; |
| 70 touchEvent.type = WebInputEvent::GestureTapDown; | 71 touchEvent.type = WebInputEvent::GestureTapDown; |
| 71 | 72 |
| 72 // The coordinates below are linked to absolute positions in the referenced
.html file. | 73 // The coordinates below are linked to absolute positions in the referenced
.html file. |
| 73 touchEvent.x = 20; | 74 touchEvent.x = 20; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 116 } |
| 116 ASSERT_EQ(0U, webViewImpl->numLinkHighlights()); | 117 ASSERT_EQ(0U, webViewImpl->numLinkHighlights()); |
| 117 | 118 |
| 118 touchEvent.y = 260; // A text input box. | 119 touchEvent.y = 260; // A text input box. |
| 119 { | 120 { |
| 120 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->
frameView(), touchEvent); | 121 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->
frameView(), touchEvent); |
| 121 webViewImpl->enableTapHighlightAtPoint(platformEvent); | 122 webViewImpl->enableTapHighlightAtPoint(platformEvent); |
| 122 } | 123 } |
| 123 ASSERT_EQ(0U, webViewImpl->numLinkHighlights()); | 124 ASSERT_EQ(0U, webViewImpl->numLinkHighlights()); |
| 124 | 125 |
| 125 webViewImpl->close(); | |
| 126 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 126 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 class FakeWebFrameClient : public WebFrameClient { | 129 class FakeWebFrameClient : public WebFrameClient { |
| 130 // To make the destructor public. | 130 // To make the destructor public. |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 class FakeCompositingWebViewClient : public WebViewClient { | 133 class FakeCompositingWebViewClient : public WebViewClient { |
| 134 public: | 134 public: |
| 135 virtual ~FakeCompositingWebViewClient() | 135 virtual ~FakeCompositingWebViewClient() |
| (...skipping 22 matching lines...) Expand all Loading... |
| 158 DEFINE_STATIC_LOCAL(FakeCompositingWebViewClient, client, ()); | 158 DEFINE_STATIC_LOCAL(FakeCompositingWebViewClient, client, ()); |
| 159 return &client; | 159 return &client; |
| 160 } | 160 } |
| 161 | 161 |
| 162 TEST(LinkHighlightTest, resetDuringNodeRemoval) | 162 TEST(LinkHighlightTest, resetDuringNodeRemoval) |
| 163 { | 163 { |
| 164 const std::string baseURL("http://www.test.com/"); | 164 const std::string baseURL("http://www.test.com/"); |
| 165 const std::string fileName("test_touch_link_highlight.html"); | 165 const std::string fileName("test_touch_link_highlight.html"); |
| 166 | 166 |
| 167 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("test_touch_link_highlight.html")); | 167 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("test_touch_link_highlight.html")); |
| 168 WebViewImpl* webViewImpl = toWebViewImpl(FrameTestHelpers::createWebViewAndL
oad(baseURL + fileName, true, 0, compositingWebViewClient())); | 168 FrameTestHelpers::WebViewHelper webViewHelper; |
| 169 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true, 0, compositingWebViewClient()); |
| 169 | 170 |
| 170 int pageWidth = 640; | 171 int pageWidth = 640; |
| 171 int pageHeight = 480; | 172 int pageHeight = 480; |
| 172 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 173 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
| 173 webViewImpl->layout(); | 174 webViewImpl->layout(); |
| 174 | 175 |
| 175 WebGestureEvent touchEvent; | 176 WebGestureEvent touchEvent; |
| 176 touchEvent.type = WebInputEvent::GestureTapDown; | 177 touchEvent.type = WebInputEvent::GestureTapDown; |
| 177 touchEvent.x = 20; | 178 touchEvent.x = 20; |
| 178 touchEvent.y = 20; | 179 touchEvent.y = 20; |
| 179 | 180 |
| 180 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->fram
eView(), touchEvent); | 181 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->fram
eView(), touchEvent); |
| 181 Node* touchNode = webViewImpl->bestTapNode(platformEvent); | 182 Node* touchNode = webViewImpl->bestTapNode(platformEvent); |
| 182 ASSERT_TRUE(touchNode); | 183 ASSERT_TRUE(touchNode); |
| 183 | 184 |
| 184 webViewImpl->enableTapHighlightAtPoint(platformEvent); | 185 webViewImpl->enableTapHighlightAtPoint(platformEvent); |
| 185 ASSERT_TRUE(webViewImpl->linkHighlight(0)); | 186 ASSERT_TRUE(webViewImpl->linkHighlight(0)); |
| 186 | 187 |
| 187 GraphicsLayer* highlightLayer = webViewImpl->linkHighlight(0)->currentGraphi
csLayerForTesting(); | 188 GraphicsLayer* highlightLayer = webViewImpl->linkHighlight(0)->currentGraphi
csLayerForTesting(); |
| 188 ASSERT_TRUE(highlightLayer); | 189 ASSERT_TRUE(highlightLayer); |
| 189 EXPECT_TRUE(highlightLayer->linkHighlight(0)); | 190 EXPECT_TRUE(highlightLayer->linkHighlight(0)); |
| 190 | 191 |
| 191 touchNode->remove(IGNORE_EXCEPTION); | 192 touchNode->remove(IGNORE_EXCEPTION); |
| 192 webViewImpl->layout(); | 193 webViewImpl->layout(); |
| 193 ASSERT_EQ(0U, highlightLayer->numLinkHighlights()); | 194 ASSERT_EQ(0U, highlightLayer->numLinkHighlights()); |
| 194 | 195 |
| 195 webViewImpl->close(); | |
| 196 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 196 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
| 197 } | 197 } |
| 198 | 198 |
| 199 TEST(LinkHighlightTest, multipleHighlights) | 199 TEST(LinkHighlightTest, multipleHighlights) |
| 200 { | 200 { |
| 201 const std::string baseURL("http://www.test.com/"); | 201 const std::string baseURL("http://www.test.com/"); |
| 202 const std::string fileName("test_touch_link_highlight.html"); | 202 const std::string fileName("test_touch_link_highlight.html"); |
| 203 | 203 |
| 204 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("test_touch_link_highlight.html")); | 204 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("test_touch_link_highlight.html")); |
| 205 WebViewImpl* webViewImpl = toWebViewImpl(FrameTestHelpers::createWebViewAndL
oad(baseURL + fileName, true, 0, compositingWebViewClient())); | 205 FrameTestHelpers::WebViewHelper webViewHelper; |
| 206 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true, 0, compositingWebViewClient()); |
| 206 | 207 |
| 207 int pageWidth = 640; | 208 int pageWidth = 640; |
| 208 int pageHeight = 480; | 209 int pageHeight = 480; |
| 209 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 210 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
| 210 webViewImpl->layout(); | 211 webViewImpl->layout(); |
| 211 | 212 |
| 212 WebGestureEvent touchEvent; | 213 WebGestureEvent touchEvent; |
| 213 touchEvent.x = 50; | 214 touchEvent.x = 50; |
| 214 touchEvent.y = 310; | 215 touchEvent.y = 310; |
| 215 touchEvent.data.tap.width = 30; | 216 touchEvent.data.tap.width = 30; |
| 216 touchEvent.data.tap.height = 30; | 217 touchEvent.data.tap.height = 30; |
| 217 | 218 |
| 218 Vector<IntRect> goodTargets; | 219 Vector<IntRect> goodTargets; |
| 219 Vector<Node*> highlightNodes; | 220 Vector<Node*> highlightNodes; |
| 220 IntRect boundingBox(touchEvent.x - touchEvent.data.tap.width / 2, touchEvent
.y - touchEvent.data.tap.height / 2, touchEvent.data.tap.width, touchEvent.data.
tap.height); | 221 IntRect boundingBox(touchEvent.x - touchEvent.data.tap.width / 2, touchEvent
.y - touchEvent.data.tap.height / 2, touchEvent.data.tap.width, touchEvent.data.
tap.height); |
| 221 findGoodTouchTargets(boundingBox, webViewImpl->mainFrameImpl()->frame(), goo
dTargets, highlightNodes); | 222 findGoodTouchTargets(boundingBox, webViewImpl->mainFrameImpl()->frame(), goo
dTargets, highlightNodes); |
| 222 | 223 |
| 223 webViewImpl->enableTapHighlights(highlightNodes); | 224 webViewImpl->enableTapHighlights(highlightNodes); |
| 224 EXPECT_EQ(2U, webViewImpl->numLinkHighlights()); | 225 EXPECT_EQ(2U, webViewImpl->numLinkHighlights()); |
| 225 | 226 |
| 226 webViewImpl->close(); | |
| 227 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 227 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
| 228 } | 228 } |
| 229 | 229 |
| 230 } // namespace | 230 } // namespace |
| OLD | NEW |