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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/testing/CacheAwareFontDisplayTest.cpp
diff --git a/third_party/WebKit/Source/core/testing/CacheAwareFontDisplayTest.cpp b/third_party/WebKit/Source/core/testing/CacheAwareFontDisplayTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..aa5500cdad53167e9cb31a905960b874975b4719
--- /dev/null
+++ b/third_party/WebKit/Source/core/testing/CacheAwareFontDisplayTest.cpp
@@ -0,0 +1,56 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/testing/CacheAwareFontDisplayTest.h"
+
+#include "core/dom/Document.h"
+#include "core/fetch/FetchRequest.h"
+#include "core/fetch/FontResource.h"
+#include "core/fetch/ResourceFetcher.h"
+#include "core/fetch/ResourceLoader.h"
+#include "platform/CrossOriginAttributeValue.h"
+
+namespace blink {
+
+CacheAwareFontDisplayTest::CacheAwareFontDisplayTest(Document* document,
+ const String& fontUrl) {
+ FetchRequest fetchRequest(document->completeURL(fontUrl),
+ FetchInitiatorInfo());
+ fetchRequest.setCacheAwareLoadingEnabled(IsCacheAwareLoadingEnabled);
+ fetchRequest.setCrossOriginAccessControl(document->getSecurityOrigin(),
+ CrossOriginAttributeAnonymous);
+ m_fontResource = FontResource::fetch(fetchRequest, document->fetcher());
+ if (!m_fontResource)
+ return;
+ m_fontResource->m_isCallbackDisabledForTesting = true;
+ document->fetcher()->startLoad(m_fontResource);
+ DCHECK(m_fontResource->loader()->isCacheAwareLoadingActivated());
+ m_fontResource->m_loadLimitState = FontResource::UnderLimit;
+}
+
+void CacheAwareFontDisplayTest::fontLoadShortLimitCallback() {
+ if (!m_fontResource)
+ return;
+ m_fontResource->fontLoadShortLimitCallback(nullptr);
+}
+
+void CacheAwareFontDisplayTest::fontLoadLongLimitCallback() {
+ if (!m_fontResource)
+ return;
+ m_fontResource->fontLoadLongLimitCallback(nullptr);
+}
+
+void CacheAwareFontDisplayTest::willReloadAfterDiskCacheMiss() {
+ if (!m_fontResource)
+ return;
+ DCHECK(m_fontResource->m_isCallbackDisabledForTesting);
+ m_fontResource->m_isCallbackDisabledForTesting = false;
+ m_fontResource->willReloadAfterDiskCacheMiss();
+}
+
+DEFINE_TRACE(CacheAwareFontDisplayTest) {
+ visitor->trace(m_fontResource);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698