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

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

Issue 14582012: Clear highlight when the highlighted node gets removed from the document (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add releaseResources() Created 7 years, 7 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
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
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();
122 } 126 }
123 127
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 tGraphicsLayer();
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
124 } // namespace 199 } // namespace
OLDNEW
« Source/WebKit/chromium/src/LinkHighlight.h ('K') | « Source/WebKit/chromium/src/LinkHighlight.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698