diff options
Diffstat (limited to 'core/fxcrt')
-rw-r--r-- | core/fxcrt/css/cfx_css.h | 1 | ||||
-rw-r--r-- | core/fxcrt/xml/cfx_xmlparser_unittest.cpp | 101 |
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) { "�" "</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) { "�" "</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) { "�" "</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()); |