Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/parser/HTMLResourcePreloaderTest.cpp |
| diff --git a/third_party/WebKit/Source/core/html/parser/HTMLResourcePreloaderTest.cpp b/third_party/WebKit/Source/core/html/parser/HTMLResourcePreloaderTest.cpp |
| index 4326fd380bc7020672cd85d65baff7b28936a218..224c1b1b9de298819c2027a8931a05a8a3e585c8 100644 |
| --- a/third_party/WebKit/Source/core/html/parser/HTMLResourcePreloaderTest.cpp |
| +++ b/third_party/WebKit/Source/core/html/parser/HTMLResourcePreloaderTest.cpp |
| @@ -6,10 +6,14 @@ |
| #include "core/html/parser/PreloadRequest.h" |
| #include "core/testing/DummyPageHolder.h" |
| +#include "platform/testing/PlatformMojoMock.h" |
| +#include "testing/gmock/include/gmock/gmock.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| namespace blink { |
| +using ::testing::_; |
| + |
| struct PreconnectTestCase { |
| const char* baseURL; |
| const char* url; |
| @@ -17,31 +21,6 @@ struct PreconnectTestCase { |
| bool isHTTPS; |
| }; |
| -class PreloaderNetworkHintsMock : public NetworkHintsInterface { |
| -public: |
| - PreloaderNetworkHintsMock() |
| - : m_didPreconnect(false) |
| - { |
| - } |
| - |
| - void dnsPrefetchHost(const String& host) const { } |
| - void preconnectHost(const KURL& host, const CrossOriginAttributeValue crossOrigin) const override |
| - { |
| - m_didPreconnect = true; |
| - m_isHTTPS = host.protocolIs("https"); |
| - m_isCrossOrigin = (crossOrigin == CrossOriginAttributeAnonymous); |
| - } |
| - |
| - bool didPreconnect() { return m_didPreconnect; } |
| - bool isHTTPS() { return m_isHTTPS; } |
| - bool isCrossOrigin() { return m_isCrossOrigin; } |
| - |
| -private: |
| - mutable bool m_didPreconnect; |
| - mutable bool m_isHTTPS; |
| - mutable bool m_isCrossOrigin; |
| -}; |
| - |
| class HTMLResourcePreloaderTest : public testing::Test { |
| protected: |
| HTMLResourcePreloaderTest() |
| @@ -52,7 +31,14 @@ protected: |
| void test(PreconnectTestCase testCase) |
| { |
| // TODO(yoav): Need a mock loader here to verify things are happenning beyond preconnect. |
| - PreloaderNetworkHintsMock networkHints; |
| + KURL hrefURL = KURL(KURL(ParsedURLStringTag(), String(testCase.baseURL)), testCase.url); |
| + |
| + PlatformMojoMock mockPlatform; |
| + EXPECT_CALL(mockPlatform, preconnect(hrefURL, ::testing::Ne(testCase.isCORS), 1)) |
| + .Times(1); |
| + EXPECT_CALL(mockPlatform, preresolve(_)) |
| + .Times(0); |
| + |
| OwnPtr<PreloadRequest> preloadRequest = PreloadRequest::create(String(), |
| TextPosition(), |
| testCase.url, |
| @@ -65,10 +51,7 @@ protected: |
| if (testCase.isCORS) |
| preloadRequest->setCrossOrigin(CrossOriginAttributeAnonymous); |
| HTMLResourcePreloader* preloader = HTMLResourcePreloader::create(m_dummyPageHolder->document()); |
| - preloader->preload(std::move(preloadRequest), networkHints); |
| - ASSERT_TRUE(networkHints.didPreconnect()); |
| - ASSERT_EQ(testCase.isCORS, networkHints.isCrossOrigin()); |
| - ASSERT_EQ(testCase.isHTTPS, networkHints.isHTTPS()); |
| + preloader->preload(std::move(preloadRequest)); |
|
Yoav Weiss
2016/06/13 08:26:08
Where are we verifying that we're actually preconn
Charlie Harrison
2016/06/14 19:28:45
The protocol is included in the EXPECT_CALL with t
|
| } |
| private: |