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

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

Issue 12315056: Merge 142913 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1410/
Patch Set: Created 7 years, 10 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
« no previous file with comments | « Source/WebKit/chromium/src/WebViewImpl.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
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 26
27 #include "LinkHighlight.h" 27 #include "LinkHighlight.h"
28 28
29 #include "FrameTestHelpers.h" 29 #include "FrameTestHelpers.h"
30 #include "FrameView.h"
30 #include "IntRect.h" 31 #include "IntRect.h"
31 #include "Node.h" 32 #include "Node.h"
32 #include "URLTestHelpers.h" 33 #include "URLTestHelpers.h"
33 #include "WebCompositorInitializer.h" 34 #include "WebCompositorInitializer.h"
34 #include "WebFrame.h" 35 #include "WebFrame.h"
36 #include "WebFrameImpl.h"
35 #include "WebInputEvent.h" 37 #include "WebInputEvent.h"
38 #include "WebInputEventConversion.h"
36 #include "WebViewImpl.h" 39 #include "WebViewImpl.h"
37 #include <gtest/gtest.h> 40 #include <gtest/gtest.h>
38 #include <public/WebContentLayer.h> 41 #include <public/WebContentLayer.h>
39 #include <public/WebFloatPoint.h> 42 #include <public/WebFloatPoint.h>
40 #include <public/WebSize.h> 43 #include <public/WebSize.h>
41 #include <wtf/PassOwnPtr.h> 44 #include <wtf/PassOwnPtr.h>
42 45
43 using namespace WebKit; 46 using namespace WebKit;
44 using namespace WebCore; 47 using namespace WebCore;
45 48
(...skipping 13 matching lines...) Expand all
59 int pageHeight = 480; 62 int pageHeight = 480;
60 webViewImpl->resize(WebSize(pageWidth, pageHeight)); 63 webViewImpl->resize(WebSize(pageWidth, pageHeight));
61 webViewImpl->layout(); 64 webViewImpl->layout();
62 65
63 WebGestureEvent touchEvent; 66 WebGestureEvent touchEvent;
64 touchEvent.type = WebInputEvent::GestureTapDown; 67 touchEvent.type = WebInputEvent::GestureTapDown;
65 68
66 // The coordinates below are linked to absolute positions in the referenced .html file. 69 // The coordinates below are linked to absolute positions in the referenced .html file.
67 touchEvent.x = 20; 70 touchEvent.x = 20;
68 touchEvent.y = 20; 71 touchEvent.y = 20;
69 Node* touchNode = webViewImpl->bestTouchLinkNode(touchEvent); 72
70 ASSERT_TRUE(touchNode); 73 {
74 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()-> frameView(), touchEvent);
75 Node* touchNode = webViewImpl->bestTapNode(platformEvent);
76 ASSERT_TRUE(touchNode);
77 }
71 78
72 touchEvent.y = 40; 79 touchEvent.y = 40;
73 EXPECT_FALSE(webViewImpl->bestTouchLinkNode(touchEvent)); 80 {
81 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()-> frameView(), touchEvent);
82 EXPECT_FALSE(webViewImpl->bestTapNode(platformEvent));
83 }
74 84
75 touchEvent.y = 20; 85 touchEvent.y = 20;
76 // Shouldn't crash. 86 // Shouldn't crash.
77 87
78 webViewImpl->enableTouchHighlight(touchEvent); 88 {
89 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()-> frameView(), touchEvent);
90 webViewImpl->enableTapHighlight(platformEvent);
91 }
92
79 EXPECT_TRUE(webViewImpl->linkHighlight()); 93 EXPECT_TRUE(webViewImpl->linkHighlight());
80 EXPECT_TRUE(webViewImpl->linkHighlight()->contentLayer()); 94 EXPECT_TRUE(webViewImpl->linkHighlight()->contentLayer());
81 EXPECT_TRUE(webViewImpl->linkHighlight()->clipLayer()); 95 EXPECT_TRUE(webViewImpl->linkHighlight()->clipLayer());
82 96
83 // Find a target inside a scrollable div 97 // Find a target inside a scrollable div
84 98
85 touchEvent.y = 100; 99 touchEvent.y = 100;
86 webViewImpl->enableTouchHighlight(touchEvent); 100 {
101 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()-> frameView(), touchEvent);
102 webViewImpl->enableTapHighlight(platformEvent);
103 }
104
87 ASSERT_TRUE(webViewImpl->linkHighlight()); 105 ASSERT_TRUE(webViewImpl->linkHighlight());
88 106
89 // Don't highlight if no "hand cursor" 107 // Don't highlight if no "hand cursor"
90 touchEvent.y = 220; // An A-link with cross-hair cursor. 108 touchEvent.y = 220; // An A-link with cross-hair cursor.
91 webViewImpl->enableTouchHighlight(touchEvent); 109 {
110 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()-> frameView(), touchEvent);
111 webViewImpl->enableTapHighlight(platformEvent);
112 }
92 ASSERT_FALSE(webViewImpl->linkHighlight()); 113 ASSERT_FALSE(webViewImpl->linkHighlight());
93 114
94 touchEvent.y = 260; // A text input box. 115 touchEvent.y = 260; // A text input box.
95 webViewImpl->enableTouchHighlight(touchEvent); 116 {
117 PlatformGestureEventBuilder platformEvent(webViewImpl->mainFrameImpl()-> frameView(), touchEvent);
118 webViewImpl->enableTapHighlight(platformEvent);
119 }
96 ASSERT_FALSE(webViewImpl->linkHighlight()); 120 ASSERT_FALSE(webViewImpl->linkHighlight());
97 121
98 webViewImpl->close(); 122 webViewImpl->close();
99 } 123 }
100 #endif 124 #endif
101 125
102 } // namespace 126 } // namespace
OLDNEW
« no previous file with comments | « Source/WebKit/chromium/src/WebViewImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698