diff options
author | tsepez <tsepez@chromium.org> | 2016-04-18 16:08:26 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-18 16:08:26 -0700 |
commit | f09bdfa90d6324813309e987a07b28c1b75aec72 (patch) | |
tree | e715eaa0c7491ecb167a75beb3f6f461f038f310 /testing | |
parent | 360caf634db76ead46e99f842e8be50976fd8b10 (diff) | |
download | pdfium-f09bdfa90d6324813309e987a07b28c1b75aec72.tar.xz |
Allow pdfium_test to send simple events to each page.
We add the --send-events flag, which causes pdfium_test to look
for a .evt file with the same base name as the .pdf file being
rendered, and to use its contents to drive calls to FORM_*
APIs.
The .evt file syntax is crude, roughly:
# comments
keycode,65
mousedown,right,300,300 # more comments
mouseup,right,300,300
mousemove,300,300
Review URL: https://codereview.chromium.org/1898993002
Diffstat (limited to 'testing')
-rw-r--r-- | testing/test_support.cpp | 15 | ||||
-rw-r--r-- | testing/test_support.h | 3 |
2 files changed, 18 insertions, 0 deletions
diff --git a/testing/test_support.cpp b/testing/test_support.cpp index 1ccd32f084..c50edeba2d 100644 --- a/testing/test_support.cpp +++ b/testing/test_support.cpp @@ -118,6 +118,21 @@ std::wstring GetPlatformWString(FPDF_WIDESTRING wstr) { return platform_string; } +std::vector<std::string> StringSplit(const std::string& str, char delimiter) { + std::vector<std::string> result; + size_t pos = 0; + while (1) { + size_t found = str.find(delimiter, pos); + if (found == std::string::npos) + break; + + result.push_back(str.substr(pos, found - pos)); + pos = found + 1; + } + result.push_back(str.substr(pos)); + return result; +} + std::unique_ptr<unsigned short, pdfium::FreeDeleter> GetFPDFWideString( const std::wstring& wstr) { size_t length = sizeof(uint16_t) * (wstr.length() + 1); diff --git a/testing/test_support.h b/testing/test_support.h index 4b716ae772..fdb24fe61b 100644 --- a/testing/test_support.h +++ b/testing/test_support.h @@ -8,6 +8,7 @@ #include <stdlib.h> #include <memory> #include <string> +#include <vector> #include "public/fpdf_save.h" #include "public/fpdfview.h" @@ -63,6 +64,8 @@ struct FreeDeleter { std::unique_ptr<char, pdfium::FreeDeleter> GetFileContents(const char* filename, size_t* retlen); +std::vector<std::string> StringSplit(const std::string& str, char delimiter); + // Converts a FPDF_WIDESTRING to a std::wstring. // Deals with differences between UTF16LE and wchar_t. std::wstring GetPlatformWString(const FPDF_WIDESTRING wstr); |