| 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 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 #include "config.h" | 25 #include "config.h" |
| 26 | 26 |
| 27 #include "LinkHighlight.h" | 27 #include "LinkHighlight.h" |
| 28 | 28 |
| 29 #include <gtest/gtest.h> | 29 #include <gtest/gtest.h> |
| 30 #include "FrameTestHelpers.h" | 30 #include "FrameTestHelpers.h" |
| 31 #include "URLTestHelpers.h" | 31 #include "URLTestHelpers.h" |
| 32 #include "WebCompositorInitializer.h" | 32 #include "WebCompositorInitializer.h" |
| 33 #include "WebFrame.h" | 33 #include "WebFrame.h" |
| 34 #include "WebFrameClient.h" | |
| 35 #include "WebFrameImpl.h" | 34 #include "WebFrameImpl.h" |
| 36 #include "WebInputEvent.h" | 35 #include "WebInputEvent.h" |
| 37 #include "WebInputEventConversion.h" | 36 #include "WebInputEventConversion.h" |
| 38 #include "WebViewClient.h" | |
| 39 #include "WebViewImpl.h" | 37 #include "WebViewImpl.h" |
| 40 #include "core/dom/Node.h" | 38 #include "core/dom/Node.h" |
| 41 #include "core/page/FrameView.h" | 39 #include "core/page/FrameView.h" |
| 42 #include "core/platform/graphics/IntRect.h" | 40 #include "core/platform/graphics/IntRect.h" |
| 43 #include <public/WebContentLayer.h> | 41 #include <public/WebContentLayer.h> |
| 44 #include <public/WebFloatPoint.h> | 42 #include <public/WebFloatPoint.h> |
| 45 #include <public/WebSize.h> | 43 #include <public/WebSize.h> |
| 46 #include <public/WebUnitTestSupport.h> | |
| 47 #include <wtf/PassOwnPtr.h> | 44 #include <wtf/PassOwnPtr.h> |
| 48 | 45 |
| 49 | |
| 50 using namespace WebKit; | 46 using namespace WebKit; |
| 51 using namespace WebCore; | 47 using namespace WebCore; |
| 52 | 48 |
| 53 namespace { | 49 namespace { |
| 54 | 50 |
| 55 TEST(LinkHighlightTest, verifyWebViewImplIntegration) | 51 TEST(LinkHighlightTest, verifyWebViewImplIntegration) |
| 56 { | 52 { |
| 57 WebKitTests::WebCompositorInitializer compositorInitializer(0); | 53 WebKitTests::WebCompositorInitializer compositorInitializer(0); |
| 58 | 54 |
| 59 const std::string baseURL("http://www.test.com/"); | 55 const std::string baseURL("http://www.test.com/"); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 touchEvent.y = 260; // A text input box. | 114 touchEvent.y = 260; // A text input box. |
| 119 { | 115 { |
| 120 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->
frameView(), touchEvent); | 116 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->
frameView(), touchEvent); |
| 121 webViewImpl->enableTapHighlight(platformEvent); | 117 webViewImpl->enableTapHighlight(platformEvent); |
| 122 } | 118 } |
| 123 ASSERT_FALSE(webViewImpl->linkHighlight()); | 119 ASSERT_FALSE(webViewImpl->linkHighlight()); |
| 124 | 120 |
| 125 webViewImpl->close(); | 121 webViewImpl->close(); |
| 126 } | 122 } |
| 127 | 123 |
| 128 class FakeWebFrameClient : public WebFrameClient { | |
| 129 // To make the destructor public. | |
| 130 }; | |
| 131 | |
| 132 class FakeCompositingWebViewClient : public WebViewClient { | |
| 133 public: | |
| 134 virtual ~FakeCompositingWebViewClient() | |
| 135 { | |
| 136 } | |
| 137 | |
| 138 virtual void initializeLayerTreeView() OVERRIDE | |
| 139 { | |
| 140 m_layerTreeView = adoptPtr(Platform::current()->unitTestSupport()->creat
eLayerTreeViewForTesting(WebUnitTestSupport::TestViewTypeUnitTest)); | |
| 141 ASSERT(m_layerTreeView); | |
| 142 } | |
| 143 | |
| 144 virtual WebLayerTreeView* layerTreeView() OVERRIDE | |
| 145 { | |
| 146 return m_layerTreeView.get(); | |
| 147 } | |
| 148 | |
| 149 FakeWebFrameClient m_fakeWebFrameClient; | |
| 150 | |
| 151 private: | |
| 152 OwnPtr<WebLayerTreeView> m_layerTreeView; | |
| 153 }; | |
| 154 | |
| 155 static WebViewClient* compositingWebViewClient() | |
| 156 { | |
| 157 DEFINE_STATIC_LOCAL(FakeCompositingWebViewClient, client, ()); | |
| 158 return &client; | |
| 159 } | |
| 160 | |
| 161 TEST(LinkHighlightTest, resetDuringNodeRemoval) | |
| 162 { | |
| 163 WebKitTests::WebCompositorInitializer compositorInitializer(0); | |
| 164 | |
| 165 const std::string baseURL("http://www.test.com/"); | |
| 166 const std::string fileName("test_touch_link_highlight.html"); | |
| 167 | |
| 168 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("test_touch_link_highlight.html")); | |
| 169 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::creat
eWebViewAndLoad(baseURL + fileName, true, 0, compositingWebViewClient())); | |
| 170 | |
| 171 int pageWidth = 640; | |
| 172 int pageHeight = 480; | |
| 173 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | |
| 174 webViewImpl->layout(); | |
| 175 | |
| 176 WebGestureEvent touchEvent; | |
| 177 touchEvent.type = WebInputEvent::GestureTapDown; | |
| 178 touchEvent.x = 20; | |
| 179 touchEvent.y = 20; | |
| 180 | |
| 181 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->fram
eView(), touchEvent); | |
| 182 Node* touchNode = webViewImpl->bestTapNode(platformEvent); | |
| 183 ASSERT_TRUE(touchNode); | |
| 184 | |
| 185 webViewImpl->enableTapHighlight(platformEvent); | |
| 186 ASSERT_TRUE(webViewImpl->linkHighlight()); | |
| 187 | |
| 188 GraphicsLayerChromium* highlightLayer = webViewImpl->linkHighlight()->curren
tGraphicsLayerForTesting(); | |
| 189 ASSERT_TRUE(highlightLayer); | |
| 190 EXPECT_TRUE(highlightLayer->linkHighlight()); | |
| 191 | |
| 192 touchNode->remove(IGNORE_EXCEPTION); | |
| 193 webViewImpl->layout(); | |
| 194 EXPECT_FALSE(highlightLayer->linkHighlight()); | |
| 195 | |
| 196 webViewImpl->close(); | |
| 197 } | |
| 198 | |
| 199 } // namespace | 124 } // namespace |
| OLD | NEW |