summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordan sinclair <dsinclair@chromium.org>2018-02-19 15:33:13 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-19 15:33:13 +0000
commit916b4b05ce7b4dd5a254a72a1d98051655627dbc (patch)
tree68a8de3867a4a0e766d3cc33bfd96071950b54b6
parent03632fb7fd1f6924f464708155ed0338d46f9862 (diff)
downloadpdfium-916b4b05ce7b4dd5a254a72a1d98051655627dbc.tar.xz
Skip font loading in formcalc embedder tests
This CL changes XFA to skip font loading for embedder tests. This takes the runtime for the CFXJSE_Formcalc_ECFXJSE_FormCalcContextEmbedderTest run from ~25sec to ~5sec. Change-Id: If9989c5a3474cccd3915ec3f5c178d7af48aae37 Reviewed-on: https://pdfium-review.googlesource.com/27191 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
-rw-r--r--testing/xfa_js_embedder_test.cpp5
-rw-r--r--xfa/fxfa/cxfa_ffapp.cpp17
-rw-r--r--xfa/fxfa/cxfa_ffapp.h2
3 files changed, 22 insertions, 2 deletions
diff --git a/testing/xfa_js_embedder_test.cpp b/testing/xfa_js_embedder_test.cpp
index 8ac17f3083..133a938643 100644
--- a/testing/xfa_js_embedder_test.cpp
+++ b/testing/xfa_js_embedder_test.cpp
@@ -11,6 +11,7 @@
#include "fxjs/cfxjse_engine.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/base/ptr_util.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
XFAJSEmbedderTest::XFAJSEmbedderTest()
: array_buffer_allocator_(
@@ -26,9 +27,13 @@ void XFAJSEmbedderTest::SetUp() {
EmbedderTest::SetExternalIsolate(isolate_);
EmbedderTest::SetUp();
+
+ CXFA_FFApp::SkipFontLoadForTesting(true);
}
void XFAJSEmbedderTest::TearDown() {
+ CXFA_FFApp::SkipFontLoadForTesting(false);
+
value_.reset();
script_context_ = nullptr;
diff --git a/xfa/fxfa/cxfa_ffapp.cpp b/xfa/fxfa/cxfa_ffapp.cpp
index 4cb9deb466..cdbc6461b5 100644
--- a/xfa/fxfa/cxfa_ffapp.cpp
+++ b/xfa/fxfa/cxfa_ffapp.cpp
@@ -22,6 +22,17 @@
#include "xfa/fxfa/cxfa_fwladapterwidgetmgr.h"
#include "xfa/fxfa/cxfa_fwltheme.h"
+namespace {
+
+static bool kSkipFontLoadForTesting = false;
+
+} // namespace
+
+// static
+void CXFA_FFApp::SkipFontLoadForTesting(bool skip) {
+ kSkipFontLoadForTesting = skip;
+}
+
CXFA_FFApp::CXFA_FFApp(IXFA_AppProvider* pProvider) : m_pProvider(pProvider) {
// Ensure fully initialized before making an app based on |this|.
m_pFWLApp = pdfium::MakeUnique<CFWL_App>(this);
@@ -56,8 +67,10 @@ CXFA_FontMgr* CXFA_FFApp::GetXFAFontMgr() const {
CFGAS_FontMgr* CXFA_FFApp::GetFDEFontMgr() {
if (!m_pFDEFontMgr) {
m_pFDEFontMgr = pdfium::MakeUnique<CFGAS_FontMgr>();
- if (!m_pFDEFontMgr->EnumFonts())
- m_pFDEFontMgr = nullptr;
+ if (!kSkipFontLoadForTesting) {
+ if (!m_pFDEFontMgr->EnumFonts())
+ m_pFDEFontMgr = nullptr;
+ }
}
return m_pFDEFontMgr.get();
}
diff --git a/xfa/fxfa/cxfa_ffapp.h b/xfa/fxfa/cxfa_ffapp.h
index 8ffd657897..b63f058367 100644
--- a/xfa/fxfa/cxfa_ffapp.h
+++ b/xfa/fxfa/cxfa_ffapp.h
@@ -29,6 +29,8 @@ class IFWL_AdapterTimerMgr;
class CXFA_FFApp {
public:
+ static void SkipFontLoadForTesting(bool skip);
+
explicit CXFA_FFApp(IXFA_AppProvider* pProvider);
~CXFA_FFApp();