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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 using namespace WebCore; | 52 using namespace WebCore; |
53 | 53 |
54 namespace { | 54 namespace { |
55 | 55 |
56 TEST(LinkHighlightTest, verifyWebViewImplIntegration) | 56 TEST(LinkHighlightTest, verifyWebViewImplIntegration) |
57 { | 57 { |
58 const std::string baseURL("http://www.test.com/"); | 58 const std::string baseURL("http://www.test.com/"); |
59 const std::string fileName("test_touch_link_highlight.html"); | 59 const std::string fileName("test_touch_link_highlight.html"); |
60 | 60 |
61 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("test_touch_link_highlight.html")); | 61 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("test_touch_link_highlight.html")); |
62 WebViewImpl* webViewImpl = toWebViewImpl(FrameTestHelpers::createWebViewAndL
oad(baseURL + fileName, true)); | 62 FrameTestHelpers::WebViewHelper webViewHelper; |
| 63 WebViewImpl* webViewImpl = toWebViewImpl(webViewHelper.initializeAndLoad(bas
eURL + fileName, true)); |
63 int pageWidth = 640; | 64 int pageWidth = 640; |
64 int pageHeight = 480; | 65 int pageHeight = 480; |
65 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 66 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
66 webViewImpl->layout(); | 67 webViewImpl->layout(); |
67 | 68 |
68 WebGestureEvent touchEvent; | 69 WebGestureEvent touchEvent; |
69 touchEvent.type = WebInputEvent::GestureTapDown; | 70 touchEvent.type = WebInputEvent::GestureTapDown; |
70 | 71 |
71 // The coordinates below are linked to absolute positions in the referenced
.html file. | 72 // The coordinates below are linked to absolute positions in the referenced
.html file. |
72 touchEvent.x = 20; | 73 touchEvent.x = 20; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 115 } |
115 ASSERT_FALSE(webViewImpl->linkHighlight()); | 116 ASSERT_FALSE(webViewImpl->linkHighlight()); |
116 | 117 |
117 touchEvent.y = 260; // A text input box. | 118 touchEvent.y = 260; // A text input box. |
118 { | 119 { |
119 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->
frameView(), touchEvent); | 120 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->
frameView(), touchEvent); |
120 webViewImpl->enableTapHighlight(platformEvent); | 121 webViewImpl->enableTapHighlight(platformEvent); |
121 } | 122 } |
122 ASSERT_FALSE(webViewImpl->linkHighlight()); | 123 ASSERT_FALSE(webViewImpl->linkHighlight()); |
123 | 124 |
124 webViewImpl->close(); | |
125 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 125 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
126 } | 126 } |
127 | 127 |
128 class FakeWebFrameClient : public WebFrameClient { | 128 class FakeWebFrameClient : public WebFrameClient { |
129 // To make the destructor public. | 129 // To make the destructor public. |
130 }; | 130 }; |
131 | 131 |
132 class FakeCompositingWebViewClient : public WebViewClient { | 132 class FakeCompositingWebViewClient : public WebViewClient { |
133 public: | 133 public: |
134 virtual ~FakeCompositingWebViewClient() | 134 virtual ~FakeCompositingWebViewClient() |
(...skipping 22 matching lines...) Expand all Loading... |
157 DEFINE_STATIC_LOCAL(FakeCompositingWebViewClient, client, ()); | 157 DEFINE_STATIC_LOCAL(FakeCompositingWebViewClient, client, ()); |
158 return &client; | 158 return &client; |
159 } | 159 } |
160 | 160 |
161 TEST(LinkHighlightTest, resetDuringNodeRemoval) | 161 TEST(LinkHighlightTest, resetDuringNodeRemoval) |
162 { | 162 { |
163 const std::string baseURL("http://www.test.com/"); | 163 const std::string baseURL("http://www.test.com/"); |
164 const std::string fileName("test_touch_link_highlight.html"); | 164 const std::string fileName("test_touch_link_highlight.html"); |
165 | 165 |
166 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("test_touch_link_highlight.html")); | 166 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("test_touch_link_highlight.html")); |
167 WebViewImpl* webViewImpl = toWebViewImpl(FrameTestHelpers::createWebViewAndL
oad(baseURL + fileName, true, 0, compositingWebViewClient())); | 167 FrameTestHelpers::WebViewHelper webViewHelper; |
| 168 WebViewImpl* webViewImpl = toWebViewImpl(webViewHelper.initializeAndLoad(bas
eURL + fileName, true, 0, compositingWebViewClient())); |
168 | 169 |
169 int pageWidth = 640; | 170 int pageWidth = 640; |
170 int pageHeight = 480; | 171 int pageHeight = 480; |
171 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 172 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
172 webViewImpl->layout(); | 173 webViewImpl->layout(); |
173 | 174 |
174 WebGestureEvent touchEvent; | 175 WebGestureEvent touchEvent; |
175 touchEvent.type = WebInputEvent::GestureTapDown; | 176 touchEvent.type = WebInputEvent::GestureTapDown; |
176 touchEvent.x = 20; | 177 touchEvent.x = 20; |
177 touchEvent.y = 20; | 178 touchEvent.y = 20; |
178 | 179 |
179 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->fram
eView(), touchEvent); | 180 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->fram
eView(), touchEvent); |
180 Node* touchNode = webViewImpl->bestTapNode(platformEvent); | 181 Node* touchNode = webViewImpl->bestTapNode(platformEvent); |
181 ASSERT_TRUE(touchNode); | 182 ASSERT_TRUE(touchNode); |
182 | 183 |
183 webViewImpl->enableTapHighlight(platformEvent); | 184 webViewImpl->enableTapHighlight(platformEvent); |
184 ASSERT_TRUE(webViewImpl->linkHighlight()); | 185 ASSERT_TRUE(webViewImpl->linkHighlight()); |
185 | 186 |
186 GraphicsLayer* highlightLayer = webViewImpl->linkHighlight()->currentGraphic
sLayerForTesting(); | 187 GraphicsLayer* highlightLayer = webViewImpl->linkHighlight()->currentGraphic
sLayerForTesting(); |
187 ASSERT_TRUE(highlightLayer); | 188 ASSERT_TRUE(highlightLayer); |
188 EXPECT_TRUE(highlightLayer->linkHighlight()); | 189 EXPECT_TRUE(highlightLayer->linkHighlight()); |
189 | 190 |
190 touchNode->remove(IGNORE_EXCEPTION); | 191 touchNode->remove(IGNORE_EXCEPTION); |
191 webViewImpl->layout(); | 192 webViewImpl->layout(); |
192 EXPECT_FALSE(highlightLayer->linkHighlight()); | 193 EXPECT_FALSE(highlightLayer->linkHighlight()); |
193 | 194 |
194 webViewImpl->close(); | |
195 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 195 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
196 } | 196 } |
197 | 197 |
198 } // namespace | 198 } // namespace |
OLD | NEW |