Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(829)

Side by Side Diff: Source/WebKit/chromium/tests/LinkHighlightTest.cpp

Issue 15670013: Merge 149838 "Reland "Clear highlight when the highlighted node ..." (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/1500/
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/WebKit/chromium/src/LinkHighlight.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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"
34 #include "WebFrameImpl.h" 35 #include "WebFrameImpl.h"
35 #include "WebInputEvent.h" 36 #include "WebInputEvent.h"
36 #include "WebInputEventConversion.h" 37 #include "WebInputEventConversion.h"
38 #include "WebViewClient.h"
37 #include "WebViewImpl.h" 39 #include "WebViewImpl.h"
38 #include "core/dom/Node.h" 40 #include "core/dom/Node.h"
39 #include "core/page/FrameView.h" 41 #include "core/page/FrameView.h"
40 #include "core/platform/graphics/IntRect.h" 42 #include "core/platform/graphics/IntRect.h"
41 #include <public/WebContentLayer.h> 43 #include <public/WebContentLayer.h>
42 #include <public/WebFloatPoint.h> 44 #include <public/WebFloatPoint.h>
43 #include <public/WebSize.h> 45 #include <public/WebSize.h>
46 #include <public/WebUnitTestSupport.h>
44 #include <wtf/PassOwnPtr.h> 47 #include <wtf/PassOwnPtr.h>
45 48
49
46 using namespace WebKit; 50 using namespace WebKit;
47 using namespace WebCore; 51 using namespace WebCore;
48 52
49 namespace { 53 namespace {
50 54
51 TEST(LinkHighlightTest, verifyWebViewImplIntegration) 55 TEST(LinkHighlightTest, verifyWebViewImplIntegration)
52 { 56 {
53 WebKitTests::WebCompositorInitializer compositorInitializer(0); 57 WebKitTests::WebCompositorInitializer compositorInitializer(0);
54 58
55 const std::string baseURL("http://www.test.com/"); 59 const std::string baseURL("http://www.test.com/");
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 ASSERT_FALSE(webViewImpl->linkHighlight()); 116 ASSERT_FALSE(webViewImpl->linkHighlight());
113 117
114 touchEvent.y = 260; // A text input box. 118 touchEvent.y = 260; // A text input box.
115 { 119 {
116 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()-> frameView(), touchEvent); 120 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()-> frameView(), touchEvent);
117 webViewImpl->enableTapHighlight(platformEvent); 121 webViewImpl->enableTapHighlight(platformEvent);
118 } 122 }
119 ASSERT_FALSE(webViewImpl->linkHighlight()); 123 ASSERT_FALSE(webViewImpl->linkHighlight());
120 124
121 webViewImpl->close(); 125 webViewImpl->close();
126 Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
127 }
128
129 class FakeWebFrameClient : public WebFrameClient {
130 // To make the destructor public.
131 };
132
133 class FakeCompositingWebViewClient : public WebViewClient {
134 public:
135 virtual ~FakeCompositingWebViewClient()
136 {
137 }
138
139 virtual void initializeLayerTreeView() OVERRIDE
140 {
141 m_layerTreeView = adoptPtr(Platform::current()->unitTestSupport()->creat eLayerTreeViewForTesting(WebUnitTestSupport::TestViewTypeUnitTest));
142 ASSERT(m_layerTreeView);
143 }
144
145 virtual WebLayerTreeView* layerTreeView() OVERRIDE
146 {
147 return m_layerTreeView.get();
148 }
149
150 FakeWebFrameClient m_fakeWebFrameClient;
151
152 private:
153 OwnPtr<WebLayerTreeView> m_layerTreeView;
154 };
155
156 static WebViewClient* compositingWebViewClient()
157 {
158 DEFINE_STATIC_LOCAL(FakeCompositingWebViewClient, client, ());
159 return &client;
160 }
161
162 TEST(LinkHighlightTest, resetDuringNodeRemoval)
163 {
164 WebKitTests::WebCompositorInitializer compositorInitializer(0);
165
166 const std::string baseURL("http://www.test.com/");
167 const std::string fileName("test_touch_link_highlight.html");
168
169 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("test_touch_link_highlight.html"));
170 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::creat eWebViewAndLoad(baseURL + fileName, true, 0, compositingWebViewClient()));
171
172 int pageWidth = 640;
173 int pageHeight = 480;
174 webViewImpl->resize(WebSize(pageWidth, pageHeight));
175 webViewImpl->layout();
176
177 WebGestureEvent touchEvent;
178 touchEvent.type = WebInputEvent::GestureTapDown;
179 touchEvent.x = 20;
180 touchEvent.y = 20;
181
182 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->fram eView(), touchEvent);
183 Node* touchNode = webViewImpl->bestTapNode(platformEvent);
184 ASSERT_TRUE(touchNode);
185
186 webViewImpl->enableTapHighlight(platformEvent);
187 ASSERT_TRUE(webViewImpl->linkHighlight());
188
189 GraphicsLayerChromium* highlightLayer = webViewImpl->linkHighlight()->curren tGraphicsLayerForTesting();
190 ASSERT_TRUE(highlightLayer);
191 EXPECT_TRUE(highlightLayer->linkHighlight());
192
193 touchNode->remove(IGNORE_EXCEPTION);
194 webViewImpl->layout();
195 EXPECT_FALSE(highlightLayer->linkHighlight());
196
197 webViewImpl->close();
198 Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
122 } 199 }
123 200
124 } // namespace 201 } // namespace
OLDNEW
« no previous file with comments | « Source/WebKit/chromium/src/LinkHighlight.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698