summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_document_parser_unittest.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-07-25 20:13:48 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-25 20:13:48 +0000
commita5d2bf1131fed479195011cbf6463df3612d31f6 (patch)
tree170dc3ca4b242be2b4148fd0c718d25db8966210 /xfa/fxfa/parser/cxfa_document_parser_unittest.cpp
parentc356472262b736607d3daf07046d4796c3a51eee (diff)
downloadpdfium-a5d2bf1131fed479195011cbf6463df3612d31f6.tar.xz
Remove CFX_MemoryStream uses in tests.
Replace with CFX_BufferSeekableReadStream, which allows for spans and const inputs. Change CXFA_DocumentParser to take IFX_SeekableReadStream instead of IFX_SeekableStream in the process. Change-Id: I0168451350c9fc250231f0414c38738a4d86ca42 Reviewed-on: https://pdfium-review.googlesource.com/38852 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_document_parser_unittest.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser_unittest.cpp38
1 files changed, 17 insertions, 21 deletions
diff --git a/xfa/fxfa/parser/cxfa_document_parser_unittest.cpp b/xfa/fxfa/parser/cxfa_document_parser_unittest.cpp
index b150abc3ea..62bd380326 100644
--- a/xfa/fxfa/parser/cxfa_document_parser_unittest.cpp
+++ b/xfa/fxfa/parser/cxfa_document_parser_unittest.cpp
@@ -3,7 +3,8 @@
// found in the LICENSE file.
#include "xfa/fxfa/parser/cxfa_document_parser.h"
-#include "core/fxcrt/cfx_memorystream.h"
+
+#include "testing/fx_string_testhelpers.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/test_support.h"
#include "xfa/fxfa/parser/cxfa_document.h"
@@ -31,16 +32,15 @@ class CXFA_DocumentParserTest : public testing::Test {
};
TEST_F(CXFA_DocumentParserTest, XMLInstructionsScriptOff) {
- const char* input =
+ static const char input[] =
"<config>\n"
"<?originalXFAVersion http://www.xfa.org/schema/xfa-template/2.7 "
"v2.7-scripting:0 ?>\n"
"</config>";
EXPECT_FALSE(GetDoc()->HasFlag(XFA_DOCFLAG_Scripting));
- auto stream = pdfium::MakeRetain<CFX_MemoryStream>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input),
- false);
+ auto stream = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ pdfium::as_bytes(pdfium::make_span(input)));
ASSERT_TRUE(GetParser()->Parse(stream, XFA_PacketType::Config));
CXFA_Node* root = GetParser()->GetRootNode();
@@ -49,7 +49,7 @@ TEST_F(CXFA_DocumentParserTest, XMLInstructionsScriptOff) {
}
TEST_F(CXFA_DocumentParserTest, XMLInstructionsScriptOn) {
- const char* input =
+ static const char input[] =
"<config>\n"
"<?originalXFAVersion http://www.xfa.org/schema/xfa-template/2.7 "
"v2.7-scripting:1 ?>\n"
@@ -57,9 +57,8 @@ TEST_F(CXFA_DocumentParserTest, XMLInstructionsScriptOn) {
EXPECT_FALSE(GetDoc()->HasFlag(XFA_DOCFLAG_Scripting));
- auto stream = pdfium::MakeRetain<CFX_MemoryStream>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input),
- false);
+ auto stream = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ pdfium::as_bytes(pdfium::make_span(input)));
ASSERT_TRUE(GetParser()->Parse(stream, XFA_PacketType::Config));
CXFA_Node* root = GetParser()->GetRootNode();
@@ -68,16 +67,15 @@ TEST_F(CXFA_DocumentParserTest, XMLInstructionsScriptOn) {
}
TEST_F(CXFA_DocumentParserTest, XMLInstructionsStrictScope) {
- const char* input =
+ static const char input[] =
"<config>"
"<?acrobat JavaScript strictScoping ?>\n"
"</config>";
EXPECT_FALSE(GetDoc()->HasFlag(XFA_DOCFLAG_StrictScoping));
- auto stream = pdfium::MakeRetain<CFX_MemoryStream>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input),
- false);
+ auto stream = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ pdfium::as_bytes(pdfium::make_span(input)));
ASSERT_TRUE(GetParser()->Parse(stream, XFA_PacketType::Config));
CXFA_Node* root = GetParser()->GetRootNode();
@@ -86,16 +84,15 @@ TEST_F(CXFA_DocumentParserTest, XMLInstructionsStrictScope) {
}
TEST_F(CXFA_DocumentParserTest, XMLInstructionsStrictScopeBad) {
- const char* input =
+ static const char input[] =
"<config>"
"<?acrobat JavaScript otherScoping ?>\n"
"</config>";
EXPECT_FALSE(GetDoc()->HasFlag(XFA_DOCFLAG_StrictScoping));
- auto stream = pdfium::MakeRetain<CFX_MemoryStream>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input),
- false);
+ auto stream = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ pdfium::as_bytes(pdfium::make_span(input)));
ASSERT_TRUE(GetParser()->Parse(stream, XFA_PacketType::Config));
CXFA_Node* root = GetParser()->GetRootNode();
@@ -104,7 +101,7 @@ TEST_F(CXFA_DocumentParserTest, XMLInstructionsStrictScopeBad) {
}
TEST_F(CXFA_DocumentParserTest, MultipleXMLInstructions) {
- const char* input =
+ static const char input[] =
"<config>"
"<?originalXFAVersion http://www.xfa.org/schema/xfa-template/2.7 "
"v2.7-scripting:1 ?>\n"
@@ -114,9 +111,8 @@ TEST_F(CXFA_DocumentParserTest, MultipleXMLInstructions) {
EXPECT_FALSE(GetDoc()->HasFlag(XFA_DOCFLAG_Scripting));
EXPECT_FALSE(GetDoc()->HasFlag(XFA_DOCFLAG_StrictScoping));
- auto stream = pdfium::MakeRetain<CFX_MemoryStream>(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input),
- false);
+ auto stream = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ pdfium::as_bytes(pdfium::make_span(input)));
ASSERT_TRUE(GetParser()->Parse(stream, XFA_PacketType::Config));
CXFA_Node* root = GetParser()->GetRootNode();