From 63593d32415a2abe14b67a9b0bbb5051e3f7c408 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Tue, 17 Apr 2018 18:24:09 +0000 Subject: 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 Commit-Queue: dsinclair --- core/fxcrt/css/cfx_css.h | 1 - core/fxcrt/xml/cfx_xmlparser_unittest.cpp | 101 ++++++++---------------------- 2 files changed, 26 insertions(+), 76 deletions(-) (limited to 'core/fxcrt') 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 MakeProxy(const char* input) { + auto stream = pdfium::MakeRetain( + reinterpret_cast(const_cast(input)), strlen(input)); + stream->SetCodePage(FX_CODEPAGE_UTF8); + return stream; +} + +} // namespace + TEST(CFX_XMLParserTest, CData) { const char* input = "\n" L" "; - RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -138,11 +141,7 @@ TEST(CFX_XMLParserTest, ArrowBangArrow) { " \n" ""; - RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -174,11 +173,7 @@ TEST(CFX_XMLParserTest, ArrowBangBracketArrow) { " \n" ""; - RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -205,11 +200,7 @@ TEST(CFX_XMLParserTest, IncompleteCData) { " \n" ""; - RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -236,11 +227,7 @@ TEST(CFX_XMLParserTest, UnClosedCData) { " "; - RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -267,11 +254,7 @@ TEST(CFX_XMLParserTest, EmptyCData) { " \n" ""; - RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -305,11 +288,7 @@ TEST(CFX_XMLParserTest, Comment) { " \n" ""; - RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -340,11 +319,7 @@ TEST(CFX_XMLParserTest, IncorrectCommentStart) { " \n" ""; - RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -375,11 +350,7 @@ TEST(CFX_XMLParserTest, CommentEmpty) { " \n" ""; - RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -410,11 +381,7 @@ TEST(CFX_XMLParserTest, CommentThreeDash) { " \n" ""; - RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -439,11 +406,7 @@ TEST(CFX_XMLParserTest, CommentTwoDash) { " \n" ""; - RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -472,11 +435,7 @@ TEST(CFX_XMLParserTest, Entities) { "�" ""; - RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -505,11 +464,7 @@ TEST(CFX_XMLParserTest, EntityOverflowHex) { "�" ""; - RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -538,11 +493,7 @@ TEST(CFX_XMLParserTest, EntityOverflowDecimal) { "�" ""; - RetainPtr stream = - pdfium::MakeRetain( - reinterpret_cast(const_cast(input)), strlen(input)); - stream->SetCodePage(FX_CODEPAGE_UTF8); - + auto stream = MakeProxy(input); auto root = pdfium::MakeUnique(); CFX_XMLTestParser parser(root.get(), stream); ASSERT_EQ(FX_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); -- cgit v1.2.3