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

Side by Side Diff: third_party/WebKit/Source/web/tests/DocumentLoaderTest.cpp

Issue 2683033005: URLLoaderMockFactory: clear MemoryCache in unregisterAllURLs (Closed)
Patch Set: fix 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/loader/DocumentLoader.h" 5 #include "core/loader/DocumentLoader.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include "core/page/Page.h" 8 #include "core/page/Page.h"
9 #include "platform/testing/URLTestHelpers.h" 9 #include "platform/testing/URLTestHelpers.h"
10 #include "platform/testing/UnitTestHelpers.h" 10 #include "platform/testing/UnitTestHelpers.h"
11 #include "public/platform/Platform.h" 11 #include "public/platform/Platform.h"
12 #include "public/platform/WebCache.h"
13 #include "public/platform/WebURLLoaderClient.h" 12 #include "public/platform/WebURLLoaderClient.h"
14 #include "public/platform/WebURLLoaderMockFactory.h" 13 #include "public/platform/WebURLLoaderMockFactory.h"
15 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
16 #include "web/WebLocalFrameImpl.h" 15 #include "web/WebLocalFrameImpl.h"
17 #include "web/tests/FrameTestHelpers.h" 16 #include "web/tests/FrameTestHelpers.h"
18 #include "wtf/AutoReset.h" 17 #include "wtf/AutoReset.h"
19 18
20 namespace blink { 19 namespace blink {
21 20
22 // TODO(dcheng): Ideally, enough of FrameTestHelpers would be in core/ that 21 // TODO(dcheng): Ideally, enough of FrameTestHelpers would be in core/ that
23 // placing a test for a core/ class in web/ wouldn't be necessary. 22 // placing a test for a core/ class in web/ wouldn't be necessary.
24 class DocumentLoaderTest : public ::testing::Test { 23 class DocumentLoaderTest : public ::testing::Test {
25 protected: 24 protected:
26 void SetUp() override { 25 void SetUp() override {
27 m_webViewHelper.initialize(); 26 m_webViewHelper.initialize();
28 URLTestHelpers::registerMockedURLLoad( 27 URLTestHelpers::registerMockedURLLoad(
29 URLTestHelpers::toKURL("https://example.com/foo.html"), 28 URLTestHelpers::toKURL("https://example.com/foo.html"),
30 testing::webTestDataPath("foo.html")); 29 testing::webTestDataPath("foo.html"));
31 } 30 }
32 31
33 void TearDown() override { 32 void TearDown() override {
34 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); 33 Platform::current()
35 WebCache::clear(); 34 ->getURLLoaderMockFactory()
35 ->unregisterAllURLsAndClearMemoryCache();
36 } 36 }
37 37
38 WebLocalFrameImpl* mainFrame() { 38 WebLocalFrameImpl* mainFrame() {
39 return m_webViewHelper.webView()->mainFrameImpl(); 39 return m_webViewHelper.webView()->mainFrameImpl();
40 } 40 }
41 41
42 FrameTestHelpers::WebViewHelper m_webViewHelper; 42 FrameTestHelpers::WebViewHelper m_webViewHelper;
43 }; 43 };
44 44
45 TEST_F(DocumentLoaderTest, SingleChunk) { 45 TEST_F(DocumentLoaderTest, SingleChunk) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 TEST_F(DocumentLoaderTest, isCommittedButEmpty) { 172 TEST_F(DocumentLoaderTest, isCommittedButEmpty) {
173 WebViewImpl* webViewImpl = 173 WebViewImpl* webViewImpl =
174 m_webViewHelper.initializeAndLoad("about:blank", true); 174 m_webViewHelper.initializeAndLoad("about:blank", true);
175 EXPECT_TRUE(toLocalFrame(webViewImpl->page()->mainFrame()) 175 EXPECT_TRUE(toLocalFrame(webViewImpl->page()->mainFrame())
176 ->loader() 176 ->loader()
177 .documentLoader() 177 .documentLoader()
178 ->isCommittedButEmpty()); 178 ->isCommittedButEmpty());
179 } 179 }
180 180
181 } // namespace blink 181 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698