| 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 18 matching lines...) Expand all Loading... |
| 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/frame/FrameView.h" | 31 #include "core/frame/FrameView.h" |
| 32 #include "core/input/EventHandler.h" | 32 #include "core/input/EventHandler.h" |
| 33 #include "core/page/Page.h" | 33 #include "core/page/Page.h" |
| 34 #include "core/page/TouchDisambiguation.h" | 34 #include "core/page/TouchDisambiguation.h" |
| 35 #include "platform/geometry/IntRect.h" | 35 #include "platform/geometry/IntRect.h" |
| 36 #include "platform/testing/URLTestHelpers.h" | 36 #include "platform/testing/URLTestHelpers.h" |
| 37 #include "platform/testing/UnitTestHelpers.h" | 37 #include "platform/testing/UnitTestHelpers.h" |
| 38 #include "public/platform/Platform.h" | 38 #include "public/platform/Platform.h" |
| 39 #include "public/platform/WebCache.h" | |
| 40 #include "public/platform/WebContentLayer.h" | 39 #include "public/platform/WebContentLayer.h" |
| 41 #include "public/platform/WebFloatPoint.h" | 40 #include "public/platform/WebFloatPoint.h" |
| 42 #include "public/platform/WebInputEvent.h" | 41 #include "public/platform/WebInputEvent.h" |
| 43 #include "public/platform/WebSize.h" | 42 #include "public/platform/WebSize.h" |
| 44 #include "public/platform/WebURLLoaderMockFactory.h" | 43 #include "public/platform/WebURLLoaderMockFactory.h" |
| 45 #include "public/web/WebFrame.h" | 44 #include "public/web/WebFrame.h" |
| 46 #include "public/web/WebFrameClient.h" | 45 #include "public/web/WebFrameClient.h" |
| 47 #include "public/web/WebViewClient.h" | 46 #include "public/web/WebViewClient.h" |
| 48 #include "testing/gtest/include/gtest/gtest.h" | 47 #include "testing/gtest/include/gtest/gtest.h" |
| 49 #include "web/WebInputEventConversion.h" | 48 #include "web/WebInputEventConversion.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 touchEvent.y = 220; // An A-link with cross-hair cursor. | 119 touchEvent.y = 220; // An A-link with cross-hair cursor. |
| 121 webViewImpl->enableTapHighlightAtPoint( | 120 webViewImpl->enableTapHighlightAtPoint( |
| 122 getTargetedEvent(webViewImpl, touchEvent)); | 121 getTargetedEvent(webViewImpl, touchEvent)); |
| 123 ASSERT_EQ(0U, webViewImpl->numLinkHighlights()); | 122 ASSERT_EQ(0U, webViewImpl->numLinkHighlights()); |
| 124 | 123 |
| 125 touchEvent.y = 260; // A text input box. | 124 touchEvent.y = 260; // A text input box. |
| 126 webViewImpl->enableTapHighlightAtPoint( | 125 webViewImpl->enableTapHighlightAtPoint( |
| 127 getTargetedEvent(webViewImpl, touchEvent)); | 126 getTargetedEvent(webViewImpl, touchEvent)); |
| 128 ASSERT_EQ(0U, webViewImpl->numLinkHighlights()); | 127 ASSERT_EQ(0U, webViewImpl->numLinkHighlights()); |
| 129 | 128 |
| 130 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); | 129 Platform::current() |
| 131 WebCache::clear(); | 130 ->getURLLoaderMockFactory() |
| 131 ->unregisterAllURLsAndClearMemoryCache(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 namespace { | 134 namespace { |
| 135 | 135 |
| 136 class FakeCompositingWebViewClient | 136 class FakeCompositingWebViewClient |
| 137 : public FrameTestHelpers::TestWebViewClient { | 137 : public FrameTestHelpers::TestWebViewClient { |
| 138 public: | 138 public: |
| 139 FrameTestHelpers::TestWebFrameClient m_fakeWebFrameClient; | 139 FrameTestHelpers::TestWebFrameClient m_fakeWebFrameClient; |
| 140 }; | 140 }; |
| 141 | 141 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 174 |
| 175 GraphicsLayer* highlightLayer = | 175 GraphicsLayer* highlightLayer = |
| 176 webViewImpl->getLinkHighlight(0)->currentGraphicsLayerForTesting(); | 176 webViewImpl->getLinkHighlight(0)->currentGraphicsLayerForTesting(); |
| 177 ASSERT_TRUE(highlightLayer); | 177 ASSERT_TRUE(highlightLayer); |
| 178 EXPECT_TRUE(highlightLayer->getLinkHighlight(0)); | 178 EXPECT_TRUE(highlightLayer->getLinkHighlight(0)); |
| 179 | 179 |
| 180 touchNode->remove(IGNORE_EXCEPTION_FOR_TESTING); | 180 touchNode->remove(IGNORE_EXCEPTION_FOR_TESTING); |
| 181 webViewImpl->updateAllLifecyclePhases(); | 181 webViewImpl->updateAllLifecyclePhases(); |
| 182 ASSERT_EQ(0U, highlightLayer->numLinkHighlights()); | 182 ASSERT_EQ(0U, highlightLayer->numLinkHighlights()); |
| 183 | 183 |
| 184 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); | 184 Platform::current() |
| 185 WebCache::clear(); | 185 ->getURLLoaderMockFactory() |
| 186 ->unregisterAllURLsAndClearMemoryCache(); |
| 186 } | 187 } |
| 187 | 188 |
| 188 // A lifetime test: delete LayerTreeView while running LinkHighlights. | 189 // A lifetime test: delete LayerTreeView while running LinkHighlights. |
| 189 TEST(LinkHighlightImplTest, resetLayerTreeView) { | 190 TEST(LinkHighlightImplTest, resetLayerTreeView) { |
| 190 std::unique_ptr<FakeCompositingWebViewClient> webViewClient = | 191 std::unique_ptr<FakeCompositingWebViewClient> webViewClient = |
| 191 WTF::makeUnique<FakeCompositingWebViewClient>(); | 192 WTF::makeUnique<FakeCompositingWebViewClient>(); |
| 192 | 193 |
| 193 const std::string url = registerMockedURLLoad(); | 194 const std::string url = registerMockedURLLoad(); |
| 194 FrameTestHelpers::WebViewHelper webViewHelper; | 195 FrameTestHelpers::WebViewHelper webViewHelper; |
| 195 WebViewImpl* webViewImpl = | 196 WebViewImpl* webViewImpl = |
| (...skipping 21 matching lines...) Expand all Loading... |
| 217 | 218 |
| 218 GraphicsLayer* highlightLayer = | 219 GraphicsLayer* highlightLayer = |
| 219 webViewImpl->getLinkHighlight(0)->currentGraphicsLayerForTesting(); | 220 webViewImpl->getLinkHighlight(0)->currentGraphicsLayerForTesting(); |
| 220 ASSERT_TRUE(highlightLayer); | 221 ASSERT_TRUE(highlightLayer); |
| 221 EXPECT_TRUE(highlightLayer->getLinkHighlight(0)); | 222 EXPECT_TRUE(highlightLayer->getLinkHighlight(0)); |
| 222 | 223 |
| 223 // Mimic the logic from RenderWidget::Close: | 224 // Mimic the logic from RenderWidget::Close: |
| 224 webViewImpl->willCloseLayerTreeView(); | 225 webViewImpl->willCloseLayerTreeView(); |
| 225 webViewHelper.reset(); | 226 webViewHelper.reset(); |
| 226 | 227 |
| 227 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); | 228 Platform::current() |
| 228 WebCache::clear(); | 229 ->getURLLoaderMockFactory() |
| 230 ->unregisterAllURLsAndClearMemoryCache(); |
| 229 } | 231 } |
| 230 | 232 |
| 231 TEST(LinkHighlightImplTest, multipleHighlights) { | 233 TEST(LinkHighlightImplTest, multipleHighlights) { |
| 232 const std::string url = registerMockedURLLoad(); | 234 const std::string url = registerMockedURLLoad(); |
| 233 FrameTestHelpers::WebViewHelper webViewHelper; | 235 FrameTestHelpers::WebViewHelper webViewHelper; |
| 234 WebViewImpl* webViewImpl = | 236 WebViewImpl* webViewImpl = |
| 235 webViewHelper.initializeAndLoad(url, true, 0, compositingWebViewClient()); | 237 webViewHelper.initializeAndLoad(url, true, 0, compositingWebViewClient()); |
| 236 | 238 |
| 237 int pageWidth = 640; | 239 int pageWidth = 640; |
| 238 int pageHeight = 480; | 240 int pageHeight = 480; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 249 HeapVector<Member<Node>> highlightNodes; | 251 HeapVector<Member<Node>> highlightNodes; |
| 250 IntRect boundingBox(touchEvent.x - touchEvent.data.tap.width / 2, | 252 IntRect boundingBox(touchEvent.x - touchEvent.data.tap.width / 2, |
| 251 touchEvent.y - touchEvent.data.tap.height / 2, | 253 touchEvent.y - touchEvent.data.tap.height / 2, |
| 252 touchEvent.data.tap.width, touchEvent.data.tap.height); | 254 touchEvent.data.tap.width, touchEvent.data.tap.height); |
| 253 findGoodTouchTargets(boundingBox, webViewImpl->mainFrameImpl()->frame(), | 255 findGoodTouchTargets(boundingBox, webViewImpl->mainFrameImpl()->frame(), |
| 254 goodTargets, highlightNodes); | 256 goodTargets, highlightNodes); |
| 255 | 257 |
| 256 webViewImpl->enableTapHighlights(highlightNodes); | 258 webViewImpl->enableTapHighlights(highlightNodes); |
| 257 EXPECT_EQ(2U, webViewImpl->numLinkHighlights()); | 259 EXPECT_EQ(2U, webViewImpl->numLinkHighlights()); |
| 258 | 260 |
| 259 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); | 261 Platform::current() |
| 260 WebCache::clear(); | 262 ->getURLLoaderMockFactory() |
| 263 ->unregisterAllURLsAndClearMemoryCache(); |
| 261 } | 264 } |
| 262 | 265 |
| 263 } // namespace blink | 266 } // namespace blink |
| OLD | NEW |