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/loader/resource/MockFontResourceClient.h" | 7 #include "core/loader/resource/MockFontResourceClient.h" |
8 #include "platform/exported/WrappedResourceResponse.h" | 8 #include "platform/exported/WrappedResourceResponse.h" |
9 #include "platform/loader/fetch/FetchInitiatorInfo.h" | 9 #include "platform/loader/fetch/FetchInitiatorInfo.h" |
10 #include "platform/loader/fetch/FetchParameters.h" | 10 #include "platform/loader/fetch/FetchParameters.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 KURL url(kParsedURLString, "http://127.0.0.1:8000/font.woff"); | 101 KURL url(kParsedURLString, "http://127.0.0.1:8000/font.woff"); |
102 ResourceResponse response; | 102 ResourceResponse response; |
103 response.SetURL(url); | 103 response.SetURL(url); |
104 response.SetHTTPStatusCode(200); | 104 response.SetHTTPStatusCode(200); |
105 Platform::Current()->GetURLLoaderMockFactory()->RegisterURL( | 105 Platform::Current()->GetURLLoaderMockFactory()->RegisterURL( |
106 url, WrappedResourceResponse(response), ""); | 106 url, WrappedResourceResponse(response), ""); |
107 | 107 |
108 ResourceFetcher* fetcher = ResourceFetcher::Create( | 108 ResourceFetcher* fetcher = ResourceFetcher::Create( |
109 MockFetchContext::Create(MockFetchContext::kShouldLoadNewResource)); | 109 MockFetchContext::Create(MockFetchContext::kShouldLoadNewResource)); |
110 | 110 |
111 FetchParameters fetch_params = FetchParameters(url, FetchInitiatorInfo()); | 111 FetchParameters fetch_params = |
| 112 FetchParameters(ResourceRequest(url), FetchInitiatorInfo()); |
112 fetch_params.SetCacheAwareLoadingEnabled(kIsCacheAwareLoadingEnabled); | 113 fetch_params.SetCacheAwareLoadingEnabled(kIsCacheAwareLoadingEnabled); |
113 FontResource* resource = FontResource::Fetch(fetch_params, fetcher); | 114 FontResource* resource = FontResource::Fetch(fetch_params, fetcher); |
114 ASSERT_TRUE(resource); | 115 ASSERT_TRUE(resource); |
115 | 116 |
116 Persistent<MockFontResourceClient> client = | 117 Persistent<MockFontResourceClient> client = |
117 new MockFontResourceClient(resource); | 118 new MockFontResourceClient(resource); |
118 fetcher->StartLoad(resource); | 119 fetcher->StartLoad(resource); |
119 EXPECT_TRUE(resource->Loader()->IsCacheAwareLoadingActivated()); | 120 EXPECT_TRUE(resource->Loader()->IsCacheAwareLoadingActivated()); |
120 resource->load_limit_state_ = FontResource::kUnderLimit; | 121 resource->load_limit_state_ = FontResource::kUnderLimit; |
121 | 122 |
(...skipping 24 matching lines...) Expand all Loading... |
146 Persistent<MockFontResourceClient> client3 = | 147 Persistent<MockFontResourceClient> client3 = |
147 new MockFontResourceClient(resource); | 148 new MockFontResourceClient(resource); |
148 EXPECT_TRUE(client3->FontLoadShortLimitExceededCalled()); | 149 EXPECT_TRUE(client3->FontLoadShortLimitExceededCalled()); |
149 EXPECT_TRUE(client3->FontLoadLongLimitExceededCalled()); | 150 EXPECT_TRUE(client3->FontLoadLongLimitExceededCalled()); |
150 | 151 |
151 Platform::Current()->GetURLLoaderMockFactory()->ServeAsynchronousRequests(); | 152 Platform::Current()->GetURLLoaderMockFactory()->ServeAsynchronousRequests(); |
152 GetMemoryCache()->Remove(resource); | 153 GetMemoryCache()->Remove(resource); |
153 } | 154 } |
154 | 155 |
155 } // namespace blink | 156 } // namespace blink |
OLD | NEW |