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

Side by Side Diff: Source/web/tests/LinkHighlightTest.cpp

Issue 1174283002: Fix unit test style in Source/web/. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove static Created 5 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/web/tests/LayoutGeometryMapTest.cpp ('k') | Source/web/tests/ListenerLeakTest.cpp » ('j') | 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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24 24
25 #include "config.h" 25 #include "config.h"
26
27 #include "web/LinkHighlight.h" 26 #include "web/LinkHighlight.h"
28 27
29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 28 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
30 #include "core/dom/Node.h" 29 #include "core/dom/Node.h"
31 #include "core/frame/FrameView.h" 30 #include "core/frame/FrameView.h"
32 #include "core/input/EventHandler.h" 31 #include "core/input/EventHandler.h"
33 #include "core/page/Page.h" 32 #include "core/page/Page.h"
34 #include "core/page/TouchDisambiguation.h" 33 #include "core/page/TouchDisambiguation.h"
35 #include "platform/geometry/IntRect.h" 34 #include "platform/geometry/IntRect.h"
36 #include "platform/testing/URLTestHelpers.h" 35 #include "platform/testing/URLTestHelpers.h"
37 #include "public/platform/Platform.h" 36 #include "public/platform/Platform.h"
38 #include "public/platform/WebContentLayer.h" 37 #include "public/platform/WebContentLayer.h"
39 #include "public/platform/WebFloatPoint.h" 38 #include "public/platform/WebFloatPoint.h"
40 #include "public/platform/WebSize.h" 39 #include "public/platform/WebSize.h"
41 #include "public/platform/WebUnitTestSupport.h" 40 #include "public/platform/WebUnitTestSupport.h"
42 #include "public/web/WebFrame.h" 41 #include "public/web/WebFrame.h"
43 #include "public/web/WebFrameClient.h" 42 #include "public/web/WebFrameClient.h"
44 #include "public/web/WebInputEvent.h" 43 #include "public/web/WebInputEvent.h"
45 #include "public/web/WebViewClient.h" 44 #include "public/web/WebViewClient.h"
46 #include "web/WebInputEventConversion.h" 45 #include "web/WebInputEventConversion.h"
47 #include "web/WebLocalFrameImpl.h" 46 #include "web/WebLocalFrameImpl.h"
48 #include "web/WebViewImpl.h" 47 #include "web/WebViewImpl.h"
49 #include "web/tests/FrameTestHelpers.h" 48 #include "web/tests/FrameTestHelpers.h"
50 #include "wtf/PassOwnPtr.h" 49 #include "wtf/PassOwnPtr.h"
51 #include <gtest/gtest.h> 50 #include <gtest/gtest.h>
52 51
53 using namespace blink; 52 namespace blink {
54
55 namespace {
56 53
57 GestureEventWithHitTestResults getTargetedEvent(WebViewImpl* webViewImpl, WebGes tureEvent& touchEvent) 54 GestureEventWithHitTestResults getTargetedEvent(WebViewImpl* webViewImpl, WebGes tureEvent& touchEvent)
58 { 55 {
59 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->fram eView(), touchEvent); 56 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()->fram eView(), touchEvent);
60 return webViewImpl->page()->deprecatedLocalMainFrame()->eventHandler().targe tGestureEvent(platformEvent, true); 57 return webViewImpl->page()->deprecatedLocalMainFrame()->eventHandler().targe tGestureEvent(platformEvent, true);
61 } 58 }
62 59
63 TEST(LinkHighlightTest, verifyWebViewImplIntegration) 60 TEST(LinkHighlightTest, verifyWebViewImplIntegration)
64 { 61 {
65 const std::string baseURL("http://www.test.com/"); 62 const std::string baseURL("http://www.test.com/");
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEv ent)); 100 webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEv ent));
104 ASSERT_EQ(0U, webViewImpl->numLinkHighlights()); 101 ASSERT_EQ(0U, webViewImpl->numLinkHighlights());
105 102
106 touchEvent.y = 260; // A text input box. 103 touchEvent.y = 260; // A text input box.
107 webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEv ent)); 104 webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEv ent));
108 ASSERT_EQ(0U, webViewImpl->numLinkHighlights()); 105 ASSERT_EQ(0U, webViewImpl->numLinkHighlights());
109 106
110 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); 107 Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
111 } 108 }
112 109
110 namespace {
111
113 class FakeWebFrameClient : public WebFrameClient { 112 class FakeWebFrameClient : public WebFrameClient {
114 // To make the destructor public. 113 // To make the destructor public.
115 }; 114 };
116 115
117 class FakeCompositingWebViewClient : public FrameTestHelpers::TestWebViewClient { 116 class FakeCompositingWebViewClient : public FrameTestHelpers::TestWebViewClient {
118 public: 117 public:
119 FakeWebFrameClient m_fakeWebFrameClient; 118 FakeWebFrameClient m_fakeWebFrameClient;
120 }; 119 };
121 120
122 static WebViewClient* compositingWebViewClient() 121 WebViewClient* compositingWebViewClient()
123 { 122 {
124 DEFINE_STATIC_LOCAL(FakeCompositingWebViewClient, client, ()); 123 DEFINE_STATIC_LOCAL(FakeCompositingWebViewClient, client, ());
125 return &client; 124 return &client;
126 } 125 }
127 126
127 } // anonymous namespace
128
128 TEST(LinkHighlightTest, resetDuringNodeRemoval) 129 TEST(LinkHighlightTest, resetDuringNodeRemoval)
129 { 130 {
130 const std::string baseURL("http://www.test.com/"); 131 const std::string baseURL("http://www.test.com/");
131 const std::string fileName("test_touch_link_highlight.html"); 132 const std::string fileName("test_touch_link_highlight.html");
132 133
133 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("test_touch_link_highlight.html")); 134 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("test_touch_link_highlight.html"));
134 FrameTestHelpers::WebViewHelper webViewHelper; 135 FrameTestHelpers::WebViewHelper webViewHelper;
135 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam e, true, 0, compositingWebViewClient()); 136 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam e, true, 0, compositingWebViewClient());
136 137
137 int pageWidth = 640; 138 int pageWidth = 640;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 WillBeHeapVector<RawPtrWillBeMember<Node>> highlightNodes; 187 WillBeHeapVector<RawPtrWillBeMember<Node>> highlightNodes;
187 IntRect boundingBox(touchEvent.x - touchEvent.data.tap.width / 2, touchEvent .y - touchEvent.data.tap.height / 2, touchEvent.data.tap.width, touchEvent.data. tap.height); 188 IntRect boundingBox(touchEvent.x - touchEvent.data.tap.width / 2, touchEvent .y - touchEvent.data.tap.height / 2, touchEvent.data.tap.width, touchEvent.data. tap.height);
188 findGoodTouchTargets(boundingBox, webViewImpl->mainFrameImpl()->frame(), goo dTargets, highlightNodes); 189 findGoodTouchTargets(boundingBox, webViewImpl->mainFrameImpl()->frame(), goo dTargets, highlightNodes);
189 190
190 webViewImpl->enableTapHighlights(highlightNodes); 191 webViewImpl->enableTapHighlights(highlightNodes);
191 EXPECT_EQ(2U, webViewImpl->numLinkHighlights()); 192 EXPECT_EQ(2U, webViewImpl->numLinkHighlights());
192 193
193 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); 194 Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
194 } 195 }
195 196
196 } // namespace 197 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/tests/LayoutGeometryMapTest.cpp ('k') | Source/web/tests/ListenerLeakTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698