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

Side by Side Diff: third_party/WebKit/Source/core/loader/resource/FontResourceTest.cpp

Issue 2533683002: Move the code in ResourceFetcher handling calls from WebURLLoaderImpl to ResourceLoader (Closed)
Patch Set: Fix test Created 4 years 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 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"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 new MockFontResourceClient(resource); 105 new MockFontResourceClient(resource);
106 fetcher->startLoad(resource); 106 fetcher->startLoad(resource);
107 EXPECT_TRUE(resource->loader()->isCacheAwareLoadingActivated()); 107 EXPECT_TRUE(resource->loader()->isCacheAwareLoadingActivated());
108 resource->m_loadLimitState = FontResource::UnderLimit; 108 resource->m_loadLimitState = FontResource::UnderLimit;
109 109
110 // FontResource callbacks should be blocked during cache-aware loading. 110 // FontResource callbacks should be blocked during cache-aware loading.
111 resource->fontLoadShortLimitCallback(nullptr); 111 resource->fontLoadShortLimitCallback(nullptr);
112 EXPECT_FALSE(client->fontLoadShortLimitExceededCalled()); 112 EXPECT_FALSE(client->fontLoadShortLimitExceededCalled());
113 113
114 // Fail first request as disk cache miss. 114 // Fail first request as disk cache miss.
115 resource->loader()->didFail(ResourceError::cacheMissError(url)); 115 resource->loader()->handleError(ResourceError::cacheMissError(url));
116 116
117 // Once cache miss error returns, previously blocked callbacks should be 117 // Once cache miss error returns, previously blocked callbacks should be
118 // called immediately. 118 // called immediately.
119 EXPECT_FALSE(resource->loader()->isCacheAwareLoadingActivated()); 119 EXPECT_FALSE(resource->loader()->isCacheAwareLoadingActivated());
120 EXPECT_TRUE(client->fontLoadShortLimitExceededCalled()); 120 EXPECT_TRUE(client->fontLoadShortLimitExceededCalled());
121 EXPECT_FALSE(client->fontLoadLongLimitExceededCalled()); 121 EXPECT_FALSE(client->fontLoadLongLimitExceededCalled());
122 122
123 // Add client now, fontLoadShortLimitExceeded() should be called. 123 // Add client now, fontLoadShortLimitExceeded() should be called.
124 Persistent<MockFontResourceClient> client2 = 124 Persistent<MockFontResourceClient> client2 =
125 new MockFontResourceClient(resource); 125 new MockFontResourceClient(resource);
126 EXPECT_TRUE(client2->fontLoadShortLimitExceededCalled()); 126 EXPECT_TRUE(client2->fontLoadShortLimitExceededCalled());
127 EXPECT_FALSE(client2->fontLoadLongLimitExceededCalled()); 127 EXPECT_FALSE(client2->fontLoadLongLimitExceededCalled());
128 128
129 // FontResource callbacks are not blocked now. 129 // FontResource callbacks are not blocked now.
130 resource->fontLoadLongLimitCallback(nullptr); 130 resource->fontLoadLongLimitCallback(nullptr);
131 EXPECT_TRUE(client->fontLoadLongLimitExceededCalled()); 131 EXPECT_TRUE(client->fontLoadLongLimitExceededCalled());
132 132
133 // Add client now, both callbacks should be called. 133 // Add client now, both callbacks should be called.
134 Persistent<MockFontResourceClient> client3 = 134 Persistent<MockFontResourceClient> client3 =
135 new MockFontResourceClient(resource); 135 new MockFontResourceClient(resource);
136 EXPECT_TRUE(client3->fontLoadShortLimitExceededCalled()); 136 EXPECT_TRUE(client3->fontLoadShortLimitExceededCalled());
137 EXPECT_TRUE(client3->fontLoadLongLimitExceededCalled()); 137 EXPECT_TRUE(client3->fontLoadLongLimitExceededCalled());
138 138
139 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests(); 139 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests();
140 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); 140 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url);
141 memoryCache()->remove(resource); 141 memoryCache()->remove(resource);
142 } 142 }
143 143
144 } // namespace blink 144 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceLoader.cpp ('k') | third_party/WebKit/Source/platform/weborigin/SecurityOrigin.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698