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

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

Issue 2683033005: URLLoaderMockFactory: clear MemoryCache in unregisterAllURLs (Closed)
Patch Set: Created 3 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
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 "bindings/core/v8/ExceptionState.h" 29 #include "bindings/core/v8/ExceptionState.h"
30 #include "core/dom/Node.h" 30 #include "core/dom/Node.h"
31 #include "core/frame/FrameView.h" 31 #include "core/frame/FrameView.h"
32 #include "core/input/EventHandler.h" 32 #include "core/input/EventHandler.h"
33 #include "core/page/Page.h" 33 #include "core/page/Page.h"
34 #include "core/page/TouchDisambiguation.h" 34 #include "core/page/TouchDisambiguation.h"
35 #include "platform/geometry/IntRect.h" 35 #include "platform/geometry/IntRect.h"
36 #include "platform/testing/URLTestHelpers.h" 36 #include "platform/testing/URLTestHelpers.h"
37 #include "platform/testing/UnitTestHelpers.h" 37 #include "platform/testing/UnitTestHelpers.h"
38 #include "public/platform/Platform.h" 38 #include "public/platform/Platform.h"
39 #include "public/platform/WebCache.h"
40 #include "public/platform/WebContentLayer.h" 39 #include "public/platform/WebContentLayer.h"
41 #include "public/platform/WebFloatPoint.h" 40 #include "public/platform/WebFloatPoint.h"
42 #include "public/platform/WebInputEvent.h" 41 #include "public/platform/WebInputEvent.h"
43 #include "public/platform/WebSize.h" 42 #include "public/platform/WebSize.h"
44 #include "public/platform/WebURLLoaderMockFactory.h" 43 #include "public/platform/WebURLLoaderMockFactory.h"
45 #include "public/web/WebFrame.h" 44 #include "public/web/WebFrame.h"
46 #include "public/web/WebFrameClient.h" 45 #include "public/web/WebFrameClient.h"
47 #include "public/web/WebViewClient.h" 46 #include "public/web/WebViewClient.h"
48 #include "testing/gtest/include/gtest/gtest.h" 47 #include "testing/gtest/include/gtest/gtest.h"
49 #include "web/WebInputEventConversion.h" 48 #include "web/WebInputEventConversion.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 webViewImpl->enableTapHighlightAtPoint( 120 webViewImpl->enableTapHighlightAtPoint(
122 getTargetedEvent(webViewImpl, touchEvent)); 121 getTargetedEvent(webViewImpl, touchEvent));
123 ASSERT_EQ(0U, webViewImpl->numLinkHighlights()); 122 ASSERT_EQ(0U, webViewImpl->numLinkHighlights());
124 123
125 touchEvent.y = 260; // A text input box. 124 touchEvent.y = 260; // A text input box.
126 webViewImpl->enableTapHighlightAtPoint( 125 webViewImpl->enableTapHighlightAtPoint(
127 getTargetedEvent(webViewImpl, touchEvent)); 126 getTargetedEvent(webViewImpl, touchEvent));
128 ASSERT_EQ(0U, webViewImpl->numLinkHighlights()); 127 ASSERT_EQ(0U, webViewImpl->numLinkHighlights());
129 128
130 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); 129 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs();
131 WebCache::clear();
132 } 130 }
133 131
134 namespace { 132 namespace {
135 133
136 class FakeCompositingWebViewClient 134 class FakeCompositingWebViewClient
137 : public FrameTestHelpers::TestWebViewClient { 135 : public FrameTestHelpers::TestWebViewClient {
138 public: 136 public:
139 FrameTestHelpers::TestWebFrameClient m_fakeWebFrameClient; 137 FrameTestHelpers::TestWebFrameClient m_fakeWebFrameClient;
140 }; 138 };
141 139
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 GraphicsLayer* highlightLayer = 173 GraphicsLayer* highlightLayer =
176 webViewImpl->getLinkHighlight(0)->currentGraphicsLayerForTesting(); 174 webViewImpl->getLinkHighlight(0)->currentGraphicsLayerForTesting();
177 ASSERT_TRUE(highlightLayer); 175 ASSERT_TRUE(highlightLayer);
178 EXPECT_TRUE(highlightLayer->getLinkHighlight(0)); 176 EXPECT_TRUE(highlightLayer->getLinkHighlight(0));
179 177
180 touchNode->remove(IGNORE_EXCEPTION_FOR_TESTING); 178 touchNode->remove(IGNORE_EXCEPTION_FOR_TESTING);
181 webViewImpl->updateAllLifecyclePhases(); 179 webViewImpl->updateAllLifecyclePhases();
182 ASSERT_EQ(0U, highlightLayer->numLinkHighlights()); 180 ASSERT_EQ(0U, highlightLayer->numLinkHighlights());
183 181
184 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); 182 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs();
185 WebCache::clear();
186 } 183 }
187 184
188 // A lifetime test: delete LayerTreeView while running LinkHighlights. 185 // A lifetime test: delete LayerTreeView while running LinkHighlights.
189 TEST(LinkHighlightImplTest, resetLayerTreeView) { 186 TEST(LinkHighlightImplTest, resetLayerTreeView) {
190 std::unique_ptr<FakeCompositingWebViewClient> webViewClient = 187 std::unique_ptr<FakeCompositingWebViewClient> webViewClient =
191 WTF::makeUnique<FakeCompositingWebViewClient>(); 188 WTF::makeUnique<FakeCompositingWebViewClient>();
192 189
193 const std::string url = registerMockedURLLoad(); 190 const std::string url = registerMockedURLLoad();
194 FrameTestHelpers::WebViewHelper webViewHelper; 191 FrameTestHelpers::WebViewHelper webViewHelper;
195 WebViewImpl* webViewImpl = 192 WebViewImpl* webViewImpl =
(...skipping 22 matching lines...) Expand all
218 GraphicsLayer* highlightLayer = 215 GraphicsLayer* highlightLayer =
219 webViewImpl->getLinkHighlight(0)->currentGraphicsLayerForTesting(); 216 webViewImpl->getLinkHighlight(0)->currentGraphicsLayerForTesting();
220 ASSERT_TRUE(highlightLayer); 217 ASSERT_TRUE(highlightLayer);
221 EXPECT_TRUE(highlightLayer->getLinkHighlight(0)); 218 EXPECT_TRUE(highlightLayer->getLinkHighlight(0));
222 219
223 // Mimic the logic from RenderWidget::Close: 220 // Mimic the logic from RenderWidget::Close:
224 webViewImpl->willCloseLayerTreeView(); 221 webViewImpl->willCloseLayerTreeView();
225 webViewHelper.reset(); 222 webViewHelper.reset();
226 223
227 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); 224 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs();
228 WebCache::clear();
229 } 225 }
230 226
231 TEST(LinkHighlightImplTest, multipleHighlights) { 227 TEST(LinkHighlightImplTest, multipleHighlights) {
232 const std::string url = registerMockedURLLoad(); 228 const std::string url = registerMockedURLLoad();
233 FrameTestHelpers::WebViewHelper webViewHelper; 229 FrameTestHelpers::WebViewHelper webViewHelper;
234 WebViewImpl* webViewImpl = 230 WebViewImpl* webViewImpl =
235 webViewHelper.initializeAndLoad(url, true, 0, compositingWebViewClient()); 231 webViewHelper.initializeAndLoad(url, true, 0, compositingWebViewClient());
236 232
237 int pageWidth = 640; 233 int pageWidth = 640;
238 int pageHeight = 480; 234 int pageHeight = 480;
(...skipping 11 matching lines...) Expand all
250 IntRect boundingBox(touchEvent.x - touchEvent.data.tap.width / 2, 246 IntRect boundingBox(touchEvent.x - touchEvent.data.tap.width / 2,
251 touchEvent.y - touchEvent.data.tap.height / 2, 247 touchEvent.y - touchEvent.data.tap.height / 2,
252 touchEvent.data.tap.width, touchEvent.data.tap.height); 248 touchEvent.data.tap.width, touchEvent.data.tap.height);
253 findGoodTouchTargets(boundingBox, webViewImpl->mainFrameImpl()->frame(), 249 findGoodTouchTargets(boundingBox, webViewImpl->mainFrameImpl()->frame(),
254 goodTargets, highlightNodes); 250 goodTargets, highlightNodes);
255 251
256 webViewImpl->enableTapHighlights(highlightNodes); 252 webViewImpl->enableTapHighlights(highlightNodes);
257 EXPECT_EQ(2U, webViewImpl->numLinkHighlights()); 253 EXPECT_EQ(2U, webViewImpl->numLinkHighlights());
258 254
259 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); 255 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs();
260 WebCache::clear();
261 } 256 }
262 257
263 } // namespace blink 258 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698