| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/resource/FontResource.h" | 5 #include "core/loader/resource/FontResource.h" |
| 6 | 6 |
| 7 #include "core/fetch/FetchInitiatorInfo.h" | 7 #include "core/fetch/FetchInitiatorInfo.h" |
| 8 #include "core/fetch/FetchRequest.h" | 8 #include "core/fetch/FetchRequest.h" |
| 9 #include "core/fetch/MemoryCache.h" | 9 #include "core/fetch/MemoryCache.h" |
| 10 #include "core/fetch/MockFetchContext.h" | 10 #include "core/fetch/MockFetchContext.h" |
| 11 #include "core/fetch/MockResourceClient.h" | 11 #include "core/fetch/MockResourceClient.h" |
| 12 #include "core/fetch/ResourceFetcher.h" | 12 #include "core/fetch/ResourceFetcher.h" |
| 13 #include "core/fetch/ResourceLoader.h" | 13 #include "core/fetch/ResourceLoader.h" |
| 14 #include "core/loader/resource/MockFontResourceClient.h" | 14 #include "core/loader/resource/MockFontResourceClient.h" |
| 15 #include "platform/exported/WrappedResourceResponse.h" | 15 #include "platform/exported/WrappedResourceResponse.h" |
| 16 #include "platform/network/ResourceError.h" | 16 #include "platform/network/ResourceError.h" |
| 17 #include "platform/network/ResourceRequest.h" | 17 #include "platform/network/ResourceRequest.h" |
| 18 #include "platform/network/ResourceResponse.h" | 18 #include "platform/network/ResourceResponse.h" |
| 19 #include "platform/weborigin/KURL.h" | 19 #include "platform/weborigin/KURL.h" |
| 20 #include "public/platform/Platform.h" | 20 #include "public/platform/Platform.h" |
| 21 #include "public/platform/WebURLLoaderMockFactory.h" | 21 #include "public/platform/WebURLLoaderMockFactory.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 23 | 23 |
| 24 namespace blink { | 24 namespace blink { |
| 25 | 25 |
| 26 class FontResourceTest : public ::testing::Test {}; | 26 class FontResourceTest : public ::testing::Test { |
| 27 void TearDown() override { |
| 28 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); |
| 29 } |
| 30 }; |
| 27 | 31 |
| 28 // Tests if ResourceFetcher works fine with FontResource that requires defered | 32 // Tests if ResourceFetcher works fine with FontResource that requires defered |
| 29 // loading supports. | 33 // loading supports. |
| 30 TEST_F(FontResourceTest, | 34 TEST_F(FontResourceTest, |
| 31 ResourceFetcherRevalidateDeferedResourceFromTwoInitiators) { | 35 ResourceFetcherRevalidateDeferedResourceFromTwoInitiators) { |
| 32 KURL url(ParsedURLString, "http://127.0.0.1:8000/font.woff"); | 36 KURL url(ParsedURLString, "http://127.0.0.1:8000/font.woff"); |
| 33 ResourceResponse response; | 37 ResourceResponse response; |
| 34 response.setURL(url); | 38 response.setURL(url); |
| 35 response.setHTTPStatusCode(200); | 39 response.setHTTPStatusCode(200); |
| 36 response.setHTTPHeaderField(HTTPNames::ETag, "1234567890"); | 40 response.setHTTPHeaderField(HTTPNames::ETag, "1234567890"); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 resource->fontLoadLongLimitCallback(nullptr); | 135 resource->fontLoadLongLimitCallback(nullptr); |
| 132 EXPECT_TRUE(client->fontLoadLongLimitExceededCalled()); | 136 EXPECT_TRUE(client->fontLoadLongLimitExceededCalled()); |
| 133 | 137 |
| 134 // Add client now, both callbacks should be called. | 138 // Add client now, both callbacks should be called. |
| 135 Persistent<MockFontResourceClient> client3 = | 139 Persistent<MockFontResourceClient> client3 = |
| 136 new MockFontResourceClient(resource); | 140 new MockFontResourceClient(resource); |
| 137 EXPECT_TRUE(client3->fontLoadShortLimitExceededCalled()); | 141 EXPECT_TRUE(client3->fontLoadShortLimitExceededCalled()); |
| 138 EXPECT_TRUE(client3->fontLoadLongLimitExceededCalled()); | 142 EXPECT_TRUE(client3->fontLoadLongLimitExceededCalled()); |
| 139 | 143 |
| 140 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests(); | 144 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests(); |
| 141 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); | |
| 142 memoryCache()->remove(resource); | 145 memoryCache()->remove(resource); |
| 143 } | 146 } |
| 144 | 147 |
| 145 } // namespace blink | 148 } // namespace blink |
| OLD | NEW |