Create testing command line helpers
Promote ParseSwitchKeyValue() out of pdfium_test sample into a helper
file so that it can be shared with other testing executables.
Similarly move BuildDefaultRendererType() out of pdfium_test sample.
Rename this to avoid possible confusion with a builder pattern, as
this routine is a query which does not build anything.
Bug: pdfium:1878
Change-Id: I24e4830a5130a1f46f89be68ab9c814aa0b85e9f
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/98311
Commit-Queue: Alan Screen <awscreen@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Nigi <nigi@chromium.org>
diff --git a/testing/command_line_helpers.cpp b/testing/command_line_helpers.cpp
new file mode 100644
index 0000000..758f278
--- /dev/null
+++ b/testing/command_line_helpers.cpp
@@ -0,0 +1,23 @@
+// Copyright 2022 The PDFium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "testing/command_line_helpers.h"
+
+bool ParseSwitchKeyValue(const std::string& arg,
+ const std::string& key,
+ std::string* value) {
+ if (arg.size() <= key.size() || arg.compare(0, key.size(), key) != 0)
+ return false;
+
+ *value = arg.substr(key.size());
+ return true;
+}
+
+FPDF_RENDERER_TYPE GetDefaultRendererType() {
+#if defined(_SKIA_SUPPORT_)
+ return FPDF_RENDERERTYPE_SKIA;
+#else
+ return FPDF_RENDERERTYPE_AGG;
+#endif
+}