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

Side by Side Diff: third_party/WebKit/Source/web/LinkHighlightImplTest.cpp

Issue 1845323002: Remove WebUnitTestSupport (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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 18 matching lines...) Expand all
29 #include "core/frame/FrameView.h" 29 #include "core/frame/FrameView.h"
30 #include "core/input/EventHandler.h" 30 #include "core/input/EventHandler.h"
31 #include "core/page/Page.h" 31 #include "core/page/Page.h"
32 #include "core/page/TouchDisambiguation.h" 32 #include "core/page/TouchDisambiguation.h"
33 #include "platform/geometry/IntRect.h" 33 #include "platform/geometry/IntRect.h"
34 #include "platform/testing/URLTestHelpers.h" 34 #include "platform/testing/URLTestHelpers.h"
35 #include "public/platform/Platform.h" 35 #include "public/platform/Platform.h"
36 #include "public/platform/WebContentLayer.h" 36 #include "public/platform/WebContentLayer.h"
37 #include "public/platform/WebFloatPoint.h" 37 #include "public/platform/WebFloatPoint.h"
38 #include "public/platform/WebSize.h" 38 #include "public/platform/WebSize.h"
39 #include "public/platform/WebUnitTestSupport.h" 39 #include "public/platform/WebURLLoaderMockFactory.h"
40 #include "public/web/WebCache.h"
40 #include "public/web/WebFrame.h" 41 #include "public/web/WebFrame.h"
41 #include "public/web/WebFrameClient.h" 42 #include "public/web/WebFrameClient.h"
42 #include "public/web/WebInputEvent.h" 43 #include "public/web/WebInputEvent.h"
43 #include "public/web/WebViewClient.h" 44 #include "public/web/WebViewClient.h"
44 #include "testing/gtest/include/gtest/gtest.h" 45 #include "testing/gtest/include/gtest/gtest.h"
45 #include "web/WebInputEventConversion.h" 46 #include "web/WebInputEventConversion.h"
46 #include "web/WebLocalFrameImpl.h" 47 #include "web/WebLocalFrameImpl.h"
47 #include "web/WebViewImpl.h" 48 #include "web/WebViewImpl.h"
48 #include "web/tests/FrameTestHelpers.h" 49 #include "web/tests/FrameTestHelpers.h"
49 #include "wtf/PassOwnPtr.h" 50 #include "wtf/PassOwnPtr.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 98
98 // Don't highlight if no "hand cursor" 99 // Don't highlight if no "hand cursor"
99 touchEvent.y = 220; // An A-link with cross-hair cursor. 100 touchEvent.y = 220; // An A-link with cross-hair cursor.
100 webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEv ent)); 101 webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEv ent));
101 ASSERT_EQ(0U, webViewImpl->numLinkHighlights()); 102 ASSERT_EQ(0U, webViewImpl->numLinkHighlights());
102 103
103 touchEvent.y = 260; // A text input box. 104 touchEvent.y = 260; // A text input box.
104 webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEv ent)); 105 webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEv ent));
105 ASSERT_EQ(0U, webViewImpl->numLinkHighlights()); 106 ASSERT_EQ(0U, webViewImpl->numLinkHighlights());
106 107
107 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); 108 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs();
109 WebCache::clear();
108 } 110 }
109 111
110 namespace { 112 namespace {
111 113
112 class FakeWebFrameClient : public WebFrameClient { 114 class FakeWebFrameClient : public WebFrameClient {
113 // To make the destructor public. 115 // To make the destructor public.
114 }; 116 };
115 117
116 class FakeCompositingWebViewClient : public FrameTestHelpers::TestWebViewClient { 118 class FakeCompositingWebViewClient : public FrameTestHelpers::TestWebViewClient {
117 public: 119 public:
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 ASSERT_TRUE(webViewImpl->getLinkHighlight(0)); 156 ASSERT_TRUE(webViewImpl->getLinkHighlight(0));
155 157
156 GraphicsLayer* highlightLayer = webViewImpl->getLinkHighlight(0)->currentGra phicsLayerForTesting(); 158 GraphicsLayer* highlightLayer = webViewImpl->getLinkHighlight(0)->currentGra phicsLayerForTesting();
157 ASSERT_TRUE(highlightLayer); 159 ASSERT_TRUE(highlightLayer);
158 EXPECT_TRUE(highlightLayer->getLinkHighlight(0)); 160 EXPECT_TRUE(highlightLayer->getLinkHighlight(0));
159 161
160 touchNode->remove(IGNORE_EXCEPTION); 162 touchNode->remove(IGNORE_EXCEPTION);
161 webViewImpl->updateAllLifecyclePhases(); 163 webViewImpl->updateAllLifecyclePhases();
162 ASSERT_EQ(0U, highlightLayer->numLinkHighlights()); 164 ASSERT_EQ(0U, highlightLayer->numLinkHighlights());
163 165
164 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); 166 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs();
167 WebCache::clear();
165 } 168 }
166 169
167 // A lifetime test: delete LayerTreeView while running LinkHighlights. 170 // A lifetime test: delete LayerTreeView while running LinkHighlights.
168 TEST(LinkHighlightImplTest, resetLayerTreeView) 171 TEST(LinkHighlightImplTest, resetLayerTreeView)
169 { 172 {
170 OwnPtr<FakeCompositingWebViewClient> webViewClient = adoptPtr(new FakeCompos itingWebViewClient()); 173 OwnPtr<FakeCompositingWebViewClient> webViewClient = adoptPtr(new FakeCompos itingWebViewClient());
171 174
172 const std::string baseURL("http://www.test.com/"); 175 const std::string baseURL("http://www.test.com/");
173 const std::string fileName("test_touch_link_highlight.html"); 176 const std::string fileName("test_touch_link_highlight.html");
174 177
(...skipping 20 matching lines...) Expand all
195 ASSERT_TRUE(webViewImpl->getLinkHighlight(0)); 198 ASSERT_TRUE(webViewImpl->getLinkHighlight(0));
196 199
197 GraphicsLayer* highlightLayer = webViewImpl->getLinkHighlight(0)->currentGra phicsLayerForTesting(); 200 GraphicsLayer* highlightLayer = webViewImpl->getLinkHighlight(0)->currentGra phicsLayerForTesting();
198 ASSERT_TRUE(highlightLayer); 201 ASSERT_TRUE(highlightLayer);
199 EXPECT_TRUE(highlightLayer->getLinkHighlight(0)); 202 EXPECT_TRUE(highlightLayer->getLinkHighlight(0));
200 203
201 // Mimic the logic from RenderWidget::Close: 204 // Mimic the logic from RenderWidget::Close:
202 webViewImpl->willCloseLayerTreeView(); 205 webViewImpl->willCloseLayerTreeView();
203 webViewHelper.reset(); 206 webViewHelper.reset();
204 207
205 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); 208 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs();
209 WebCache::clear();
206 } 210 }
207 211
208 TEST(LinkHighlightImplTest, multipleHighlights) 212 TEST(LinkHighlightImplTest, multipleHighlights)
209 { 213 {
210 const std::string baseURL("http://www.test.com/"); 214 const std::string baseURL("http://www.test.com/");
211 const std::string fileName("test_touch_link_highlight.html"); 215 const std::string fileName("test_touch_link_highlight.html");
212 216
213 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("test_touch_link_highlight.html")); 217 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("test_touch_link_highlight.html"));
214 FrameTestHelpers::WebViewHelper webViewHelper; 218 FrameTestHelpers::WebViewHelper webViewHelper;
215 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam e, true, 0, compositingWebViewClient()); 219 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam e, true, 0, compositingWebViewClient());
(...skipping 10 matching lines...) Expand all
226 touchEvent.data.tap.height = 30; 230 touchEvent.data.tap.height = 30;
227 231
228 Vector<IntRect> goodTargets; 232 Vector<IntRect> goodTargets;
229 HeapVector<Member<Node>> highlightNodes; 233 HeapVector<Member<Node>> highlightNodes;
230 IntRect boundingBox(touchEvent.x - touchEvent.data.tap.width / 2, touchEvent .y - touchEvent.data.tap.height / 2, touchEvent.data.tap.width, touchEvent.data. tap.height); 234 IntRect boundingBox(touchEvent.x - touchEvent.data.tap.width / 2, touchEvent .y - touchEvent.data.tap.height / 2, touchEvent.data.tap.width, touchEvent.data. tap.height);
231 findGoodTouchTargets(boundingBox, webViewImpl->mainFrameImpl()->frame(), goo dTargets, highlightNodes); 235 findGoodTouchTargets(boundingBox, webViewImpl->mainFrameImpl()->frame(), goo dTargets, highlightNodes);
232 236
233 webViewImpl->enableTapHighlights(highlightNodes); 237 webViewImpl->enableTapHighlights(highlightNodes);
234 EXPECT_EQ(2U, webViewImpl->numLinkHighlights()); 238 EXPECT_EQ(2U, webViewImpl->numLinkHighlights());
235 239
236 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); 240 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs();
241 WebCache::clear();
237 } 242 }
238 243
239 } // namespace blink 244 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/ExternalPopupMenuTest.cpp ('k') | third_party/WebKit/Source/web/WebEmbeddedWorkerImplTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698