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

Side by Side Diff: third_party/WebKit/Source/core/testing/CacheAwareFontDisplayTest.cpp

Issue 2438033003: [NOT FOR COMMIT] Layout test for WebFonts cache-aware timeout adaption (Closed)
Patch Set: rebase Created 4 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "core/testing/CacheAwareFontDisplayTest.h"
6
7 #include "core/dom/Document.h"
8 #include "core/fetch/FetchRequest.h"
9 #include "core/fetch/FontResource.h"
10 #include "core/fetch/ResourceFetcher.h"
11 #include "core/fetch/ResourceLoader.h"
12 #include "platform/CrossOriginAttributeValue.h"
13
14 namespace blink {
15
16 CacheAwareFontDisplayTest::CacheAwareFontDisplayTest(Document* document,
17 const String& fontUrl) {
18 FetchRequest fetchRequest(document->completeURL(fontUrl),
19 FetchInitiatorInfo());
20 fetchRequest.setCacheAwareLoadingEnabled(IsCacheAwareLoadingEnabled);
21 fetchRequest.setCrossOriginAccessControl(document->getSecurityOrigin(),
22 CrossOriginAttributeAnonymous);
23 m_fontResource = FontResource::fetch(fetchRequest, document->fetcher());
24 if (!m_fontResource)
25 return;
26 m_fontResource->m_isCallbackDisabledForTesting = true;
27 document->fetcher()->startLoad(m_fontResource);
28 DCHECK(m_fontResource->loader()->isCacheAwareLoadingActivated());
29 m_fontResource->m_loadLimitState = FontResource::UnderLimit;
30 }
31
32 void CacheAwareFontDisplayTest::fontLoadShortLimitCallback() {
33 if (!m_fontResource)
34 return;
35 m_fontResource->fontLoadShortLimitCallback(nullptr);
36 }
37
38 void CacheAwareFontDisplayTest::fontLoadLongLimitCallback() {
39 if (!m_fontResource)
40 return;
41 m_fontResource->fontLoadLongLimitCallback(nullptr);
42 }
43
44 void CacheAwareFontDisplayTest::willReloadAfterDiskCacheMiss() {
45 if (!m_fontResource)
46 return;
47 DCHECK(m_fontResource->m_isCallbackDisabledForTesting);
48 m_fontResource->m_isCallbackDisabledForTesting = false;
49 m_fontResource->willReloadAfterDiskCacheMiss();
50 }
51
52 DEFINE_TRACE(CacheAwareFontDisplayTest) {
53 visitor->trace(m_fontResource);
54 }
55
56 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698