summaryrefslogtreecommitdiff
path: root/core/fxcrt
diff options
context:
space:
mode:
authordan sinclair <dsinclair@chromium.org>2018-04-17 18:24:09 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-17 18:24:09 +0000
commit63593d32415a2abe14b67a9b0bbb5051e3f7c408 (patch)
tree5047572830bc2b30241ae6d316170c25acf218c5 /core/fxcrt
parentbddc60d0977068fbe89a1dad403f2e6ddd7ff1a1 (diff)
downloadpdfium-63593d32415a2abe14b67a9b0bbb5051e3f7c408.tar.xz
Cleanup some seekablestreamproxy code
This CL fixes up some cfx_seekablestreamproxy includes and adds a helper to the xmlparser tests. Change-Id: If1b67dee51b49fa39527274f6c68da5ec673704f Reviewed-on: https://pdfium-review.googlesource.com/30854 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt')
-rw-r--r--core/fxcrt/css/cfx_css.h1
-rw-r--r--core/fxcrt/xml/cfx_xmlparser_unittest.cpp101
2 files changed, 26 insertions, 76 deletions
diff --git a/core/fxcrt/css/cfx_css.h b/core/fxcrt/css/cfx_css.h
index 32f376f327..e9ff722d08 100644
--- a/core/fxcrt/css/cfx_css.h
+++ b/core/fxcrt/css/cfx_css.h
@@ -7,7 +7,6 @@
#ifndef CORE_FXCRT_CSS_CFX_CSS_H_
#define CORE_FXCRT_CSS_CFX_CSS_H_
-#include "core/fxcrt/cfx_seekablestreamproxy.h"
#include "core/fxge/fx_dib.h"
enum CFX_CSSVALUETYPE {
diff --git a/core/fxcrt/xml/cfx_xmlparser_unittest.cpp b/core/fxcrt/xml/cfx_xmlparser_unittest.cpp
index 39ddc32987..97a81f7640 100644
--- a/core/fxcrt/xml/cfx_xmlparser_unittest.cpp
+++ b/core/fxcrt/xml/cfx_xmlparser_unittest.cpp
@@ -13,6 +13,8 @@
#include "testing/test_support.h"
#include "third_party/base/ptr_util.h"
+namespace {
+
class CFX_XMLTestParser : public CFX_XMLParser {
public:
CFX_XMLTestParser(CFX_XMLNode* pParent,
@@ -36,6 +38,15 @@ class CFX_XMLTestParser : public CFX_XMLParser {
WideString GetTextData() const { return CFX_XMLParser::GetTextData(); }
};
+RetainPtr<CFX_SeekableStreamProxy> MakeProxy(const char* input) {
+ auto stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>(
+ reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
+ stream->SetCodePage(FX_CODEPAGE_UTF8);
+ return stream;
+}
+
+} // namespace
+
TEST(CFX_XMLParserTest, CData) {
const char* input =
"<script contentType=\"application/x-javascript\">\n"
@@ -51,11 +62,7 @@ TEST(CFX_XMLParserTest, CData) {
L" app.alert(\"Tclams\");\n"
L" ";
- RetainPtr<CFX_SeekableStreamProxy> stream =
- pdfium::MakeRetain<CFX_SeekableStreamProxy>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
- stream->SetCodePage(FX_CODEPAGE_UTF8);
-
+ auto stream = MakeProxy(input);
auto root = pdfium::MakeUnique<CFX_XMLNode>();
CFX_XMLTestParser parser(root.get(), stream);
ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
@@ -100,11 +107,7 @@ TEST(CFX_XMLParserTest, CDataWithInnerScript) {
L" </script>\n"
L" ";
- RetainPtr<CFX_SeekableStreamProxy> stream =
- pdfium::MakeRetain<CFX_SeekableStreamProxy>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
- stream->SetCodePage(FX_CODEPAGE_UTF8);
-
+ auto stream = MakeProxy(input);
auto root = pdfium::MakeUnique<CFX_XMLNode>();
CFX_XMLTestParser parser(root.get(), stream);
ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
@@ -138,11 +141,7 @@ TEST(CFX_XMLParserTest, ArrowBangArrow) {
" <!>\n"
"</script>";
- RetainPtr<CFX_SeekableStreamProxy> stream =
- pdfium::MakeRetain<CFX_SeekableStreamProxy>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
- stream->SetCodePage(FX_CODEPAGE_UTF8);
-
+ auto stream = MakeProxy(input);
auto root = pdfium::MakeUnique<CFX_XMLNode>();
CFX_XMLTestParser parser(root.get(), stream);
ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
@@ -174,11 +173,7 @@ TEST(CFX_XMLParserTest, ArrowBangBracketArrow) {
" <![>\n"
"</script>";
- RetainPtr<CFX_SeekableStreamProxy> stream =
- pdfium::MakeRetain<CFX_SeekableStreamProxy>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
- stream->SetCodePage(FX_CODEPAGE_UTF8);
-
+ auto stream = MakeProxy(input);
auto root = pdfium::MakeUnique<CFX_XMLNode>();
CFX_XMLTestParser parser(root.get(), stream);
ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
@@ -205,11 +200,7 @@ TEST(CFX_XMLParserTest, IncompleteCData) {
" <![CDATA>\n"
"</script>";
- RetainPtr<CFX_SeekableStreamProxy> stream =
- pdfium::MakeRetain<CFX_SeekableStreamProxy>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
- stream->SetCodePage(FX_CODEPAGE_UTF8);
-
+ auto stream = MakeProxy(input);
auto root = pdfium::MakeUnique<CFX_XMLNode>();
CFX_XMLTestParser parser(root.get(), stream);
ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
@@ -236,11 +227,7 @@ TEST(CFX_XMLParserTest, UnClosedCData) {
" <![CDATA[\n"
"</script>";
- RetainPtr<CFX_SeekableStreamProxy> stream =
- pdfium::MakeRetain<CFX_SeekableStreamProxy>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
- stream->SetCodePage(FX_CODEPAGE_UTF8);
-
+ auto stream = MakeProxy(input);
auto root = pdfium::MakeUnique<CFX_XMLNode>();
CFX_XMLTestParser parser(root.get(), stream);
ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
@@ -267,11 +254,7 @@ TEST(CFX_XMLParserTest, EmptyCData) {
" <![CDATA[]]>\n"
"</script>";
- RetainPtr<CFX_SeekableStreamProxy> stream =
- pdfium::MakeRetain<CFX_SeekableStreamProxy>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
- stream->SetCodePage(FX_CODEPAGE_UTF8);
-
+ auto stream = MakeProxy(input);
auto root = pdfium::MakeUnique<CFX_XMLNode>();
CFX_XMLTestParser parser(root.get(), stream);
ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
@@ -305,11 +288,7 @@ TEST(CFX_XMLParserTest, Comment) {
" <!-- A Comment -->\n"
"</script>";
- RetainPtr<CFX_SeekableStreamProxy> stream =
- pdfium::MakeRetain<CFX_SeekableStreamProxy>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
- stream->SetCodePage(FX_CODEPAGE_UTF8);
-
+ auto stream = MakeProxy(input);
auto root = pdfium::MakeUnique<CFX_XMLNode>();
CFX_XMLTestParser parser(root.get(), stream);
ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
@@ -340,11 +319,7 @@ TEST(CFX_XMLParserTest, IncorrectCommentStart) {
" <!- A Comment -->\n"
"</script>";
- RetainPtr<CFX_SeekableStreamProxy> stream =
- pdfium::MakeRetain<CFX_SeekableStreamProxy>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
- stream->SetCodePage(FX_CODEPAGE_UTF8);
-
+ auto stream = MakeProxy(input);
auto root = pdfium::MakeUnique<CFX_XMLNode>();
CFX_XMLTestParser parser(root.get(), stream);
ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
@@ -375,11 +350,7 @@ TEST(CFX_XMLParserTest, CommentEmpty) {
" <!---->\n"
"</script>";
- RetainPtr<CFX_SeekableStreamProxy> stream =
- pdfium::MakeRetain<CFX_SeekableStreamProxy>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
- stream->SetCodePage(FX_CODEPAGE_UTF8);
-
+ auto stream = MakeProxy(input);
auto root = pdfium::MakeUnique<CFX_XMLNode>();
CFX_XMLTestParser parser(root.get(), stream);
ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
@@ -410,11 +381,7 @@ TEST(CFX_XMLParserTest, CommentThreeDash) {
" <!--->\n"
"</script>";
- RetainPtr<CFX_SeekableStreamProxy> stream =
- pdfium::MakeRetain<CFX_SeekableStreamProxy>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
- stream->SetCodePage(FX_CODEPAGE_UTF8);
-
+ auto stream = MakeProxy(input);
auto root = pdfium::MakeUnique<CFX_XMLNode>();
CFX_XMLTestParser parser(root.get(), stream);
ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
@@ -439,11 +406,7 @@ TEST(CFX_XMLParserTest, CommentTwoDash) {
" <!-->\n"
"</script>";
- RetainPtr<CFX_SeekableStreamProxy> stream =
- pdfium::MakeRetain<CFX_SeekableStreamProxy>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
- stream->SetCodePage(FX_CODEPAGE_UTF8);
-
+ auto stream = MakeProxy(input);
auto root = pdfium::MakeUnique<CFX_XMLNode>();
CFX_XMLTestParser parser(root.get(), stream);
ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
@@ -472,11 +435,7 @@ TEST(CFX_XMLParserTest, Entities) {
"&#x0000000000000000000;"
"</script>";
- RetainPtr<CFX_SeekableStreamProxy> stream =
- pdfium::MakeRetain<CFX_SeekableStreamProxy>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
- stream->SetCodePage(FX_CODEPAGE_UTF8);
-
+ auto stream = MakeProxy(input);
auto root = pdfium::MakeUnique<CFX_XMLNode>();
CFX_XMLTestParser parser(root.get(), stream);
ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
@@ -505,11 +464,7 @@ TEST(CFX_XMLParserTest, EntityOverflowHex) {
"&#xafffffffffffffffffffffffffffffffff;"
"</script>";
- RetainPtr<CFX_SeekableStreamProxy> stream =
- pdfium::MakeRetain<CFX_SeekableStreamProxy>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
- stream->SetCodePage(FX_CODEPAGE_UTF8);
-
+ auto stream = MakeProxy(input);
auto root = pdfium::MakeUnique<CFX_XMLNode>();
CFX_XMLTestParser parser(root.get(), stream);
ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
@@ -538,11 +493,7 @@ TEST(CFX_XMLParserTest, EntityOverflowDecimal) {
"&#29149102052342342134521341234512351234213452315;"
"</script>";
- RetainPtr<CFX_SeekableStreamProxy> stream =
- pdfium::MakeRetain<CFX_SeekableStreamProxy>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
- stream->SetCodePage(FX_CODEPAGE_UTF8);
-
+ auto stream = MakeProxy(input);
auto root = pdfium::MakeUnique<CFX_XMLNode>();
CFX_XMLTestParser parser(root.get(), stream);
ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());