| Index: third_party/WebKit/Source/core/fetch/ResourceTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/fetch/ResourceTest.cpp b/third_party/WebKit/Source/core/fetch/ResourceTest.cpp
|
| index 3a100eff18a1c878eb1a8b4ae457651054ad015d..143d942f8ec200326e010b54a69bc78d5eb246ee 100644
|
| --- a/third_party/WebKit/Source/core/fetch/ResourceTest.cpp
|
| +++ b/third_party/WebKit/Source/core/fetch/ResourceTest.cpp
|
| @@ -8,7 +8,6 @@
|
| #include "core/fetch/ResourcePtr.h"
|
| #include "platform/network/ResourceRequest.h"
|
| #include "platform/network/ResourceResponse.h"
|
| -#include "platform/testing/TestingPlatformSupport.h"
|
| #include "platform/testing/URLTestHelpers.h"
|
| #include "public/platform/Platform.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| @@ -18,9 +17,9 @@
|
|
|
| namespace {
|
|
|
| -class MockPlatform final : public TestingPlatformSupport {
|
| +class MockPlatform final : public Platform {
|
| public:
|
| - MockPlatform() { }
|
| + MockPlatform() : m_oldPlatform(Platform::current()) { }
|
| ~MockPlatform() override { }
|
|
|
| // From blink::Platform:
|
| @@ -34,8 +33,43 @@
|
| return m_cachedURLs;
|
| }
|
|
|
| + WebThread* currentThread() override
|
| + {
|
| + return m_oldPlatform->currentThread();
|
| + }
|
| +
|
| + // These blink::Platform methods must be overriden to make a usable object.
|
| + void cryptographicallyRandomValues(unsigned char* buffer, size_t length) override
|
| + {
|
| + ASSERT_NOT_REACHED();
|
| + }
|
| +
|
| + const unsigned char* getTraceCategoryEnabledFlag(const char* categoryName) override
|
| + {
|
| + static const unsigned char tracingIsDisabled = 0;
|
| + return &tracingIsDisabled;
|
| + }
|
| +
|
| private:
|
| + Platform* m_oldPlatform; // Not owned.
|
| Vector<WebURL> m_cachedURLs;
|
| +};
|
| +
|
| +class AutoInstallMockPlatform {
|
| +public:
|
| + AutoInstallMockPlatform()
|
| + {
|
| + m_oldPlatform = Platform::current();
|
| + Platform::initialize(&m_mockPlatform);
|
| + }
|
| + ~AutoInstallMockPlatform()
|
| + {
|
| + Platform::initialize(m_oldPlatform);
|
| + }
|
| + MockPlatform* platform() { return &m_mockPlatform; }
|
| +private:
|
| + MockPlatform m_mockPlatform;
|
| + Platform* m_oldPlatform;
|
| };
|
|
|
| PassOwnPtr<ResourceResponse> createTestResourceResponse()
|
| @@ -59,19 +93,19 @@
|
|
|
| TEST(ResourceTest, SetCachedMetadata_SendsMetadataToPlatform)
|
| {
|
| - MockPlatform mock;
|
| + AutoInstallMockPlatform mock;
|
| OwnPtr<ResourceResponse> response(createTestResourceResponse());
|
| createTestResourceAndSetCachedMetadata(response.get());
|
| - EXPECT_EQ(1u, mock.cachedURLs().size());
|
| + EXPECT_EQ(1u, mock.platform()->cachedURLs().size());
|
| }
|
|
|
| TEST(ResourceTest, SetCachedMetadata_DoesNotSendMetadataToPlatformWhenFetchedViaServiceWorker)
|
| {
|
| - MockPlatform mock;
|
| + AutoInstallMockPlatform mock;
|
| OwnPtr<ResourceResponse> response(createTestResourceResponse());
|
| response->setWasFetchedViaServiceWorker(true);
|
| createTestResourceAndSetCachedMetadata(response.get());
|
| - EXPECT_EQ(0u, mock.cachedURLs().size());
|
| + EXPECT_EQ(0u, mock.platform()->cachedURLs().size());
|
| }
|
|
|
| } // namespace blink
|
|
|