summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/parser/cpdf_cross_ref_avail_unittest.cpp4
-rw-r--r--core/fpdfapi/parser/cpdf_hint_tables_unittest.cpp4
-rw-r--r--core/fpdfapi/parser/cpdf_parser_unittest.cpp5
-rw-r--r--core/fpdfapi/parser/cpdf_read_validator_unittest.cpp9
-rw-r--r--core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp33
-rw-r--r--core/fxcrt/cfx_readonlymemorystream.cpp2
-rw-r--r--core/fxcrt/xml/cfx_xmlinstruction_unittest.cpp6
-rw-r--r--core/fxcrt/xml/cfx_xmlparser_unittest.cpp6
-rw-r--r--testing/fuzzers/xfa_codec_fuzzer.h4
-rw-r--r--testing/fx_string_testhelpers.cpp21
-rw-r--r--testing/fx_string_testhelpers.h19
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser_unittest.cpp12
12 files changed, 42 insertions, 83 deletions
diff --git a/core/fpdfapi/parser/cpdf_cross_ref_avail_unittest.cpp b/core/fpdfapi/parser/cpdf_cross_ref_avail_unittest.cpp
index eab7330cf6..6cdc3f1817 100644
--- a/core/fpdfapi/parser/cpdf_cross_ref_avail_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_cross_ref_avail_unittest.cpp
@@ -8,7 +8,7 @@
#include <string>
#include "core/fpdfapi/parser/cpdf_syntax_parser.h"
-#include "testing/fx_string_testhelpers.h"
+#include "core/fxcrt/cfx_readonlymemorystream.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/base/ptr_util.h"
@@ -17,7 +17,7 @@ namespace {
std::unique_ptr<CPDF_SyntaxParser> MakeParserForBuffer(
pdfium::span<const uint8_t> buffer) {
return pdfium::MakeUnique<CPDF_SyntaxParser>(
- pdfium::MakeRetain<CFX_BufferSeekableReadStream>(buffer));
+ pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(buffer));
}
} // namespace
diff --git a/core/fpdfapi/parser/cpdf_hint_tables_unittest.cpp b/core/fpdfapi/parser/cpdf_hint_tables_unittest.cpp
index 97ba434768..c372d74a00 100644
--- a/core/fpdfapi/parser/cpdf_hint_tables_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_hint_tables_unittest.cpp
@@ -16,8 +16,8 @@
#include "core/fpdfapi/parser/cpdf_read_validator.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/cpdf_syntax_parser.h"
+#include "core/fxcrt/cfx_readonlymemorystream.h"
#include "core/fxcrt/fx_stream.h"
-#include "testing/fx_string_testhelpers.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/utils/path_service.h"
@@ -48,7 +48,7 @@ class TestLinearizedHeader : public CPDF_LinearizedHeader {
static std::unique_ptr<CPDF_LinearizedHeader> MakeHeader(
const std::string& inline_data) {
- CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::as_bytes(pdfium::make_span(inline_data))));
std::unique_ptr<CPDF_Dictionary> dict =
ToDictionary(parser.GetObjectBody(nullptr));
diff --git a/core/fpdfapi/parser/cpdf_parser_unittest.cpp b/core/fpdfapi/parser/cpdf_parser_unittest.cpp
index d5166fbdf0..00f3770e87 100644
--- a/core/fpdfapi/parser/cpdf_parser_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_parser_unittest.cpp
@@ -11,10 +11,10 @@
#include "core/fpdfapi/parser/cpdf_object.h"
#include "core/fpdfapi/parser/cpdf_parser.h"
#include "core/fpdfapi/parser/cpdf_syntax_parser.h"
+#include "core/fxcrt/cfx_readonlymemorystream.h"
#include "core/fxcrt/fx_extension.h"
#include "core/fxcrt/fx_stream.h"
#include "core/fxcrt/retain_ptr.h"
-#include "testing/fx_string_testhelpers.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/utils/path_service.h"
@@ -50,8 +50,7 @@ class CPDF_TestParser : public CPDF_Parser {
bool InitTestFromBufferWithOffset(pdfium::span<const uint8_t> buffer,
FX_FILESIZE header_offset) {
m_pSyntax = CPDF_SyntaxParser::CreateForTesting(
- pdfium::MakeRetain<CFX_BufferSeekableReadStream>(buffer),
- header_offset);
+ pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(buffer), header_offset);
return true;
}
diff --git a/core/fpdfapi/parser/cpdf_read_validator_unittest.cpp b/core/fpdfapi/parser/cpdf_read_validator_unittest.cpp
index ccfb451dd8..640269884d 100644
--- a/core/fpdfapi/parser/cpdf_read_validator_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_read_validator_unittest.cpp
@@ -8,6 +8,7 @@
#include <utility>
#include <vector>
+#include "core/fxcrt/cfx_readonlymemorystream.h"
#include "testing/fx_string_testhelpers.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -65,7 +66,7 @@ class MockDownloadHints : public CPDF_DataAvail::DownloadHints {
TEST(CPDF_ReadValidatorTest, UnavailableData) {
std::vector<uint8_t> test_data(kTestDataSize);
- auto file = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(test_data);
+ auto file = pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(test_data);
MockFileAvail file_avail;
auto validator = pdfium::MakeRetain<CPDF_ReadValidator>(file, &file_avail);
@@ -88,7 +89,7 @@ TEST(CPDF_ReadValidatorTest, UnavailableData) {
TEST(CPDF_ReadValidatorTest, UnavailableDataWithHints) {
std::vector<uint8_t> test_data(kTestDataSize);
- auto file = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(test_data);
+ auto file = pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(test_data);
MockFileAvail file_avail;
auto validator = pdfium::MakeRetain<CPDF_ReadValidator>(file, &file_avail);
@@ -143,7 +144,7 @@ TEST(CPDF_ReadValidatorTest, ReadError) {
TEST(CPDF_ReadValidatorTest, IntOverflow) {
std::vector<uint8_t> test_data(kTestDataSize);
- auto file = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(test_data);
+ auto file = pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(test_data);
MockFileAvail file_avail;
auto validator = pdfium::MakeRetain<CPDF_ReadValidator>(file, &file_avail);
@@ -241,7 +242,7 @@ TEST(CPDF_ReadValidatorTest, SessionReset) {
TEST(CPDF_ReadValidatorTest, CheckDataRangeAndRequestIfUnavailable) {
std::vector<uint8_t> test_data(kTestDataSize);
- auto file = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(test_data);
+ auto file = pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(test_data);
MockFileAvail file_avail;
auto validator = pdfium::MakeRetain<CPDF_ReadValidator>(file, &file_avail);
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp b/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp
index 498eddf12b..5b06d33d4b 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp
@@ -8,8 +8,8 @@
#include "core/fpdfapi/parser/cpdf_object.h"
#include "core/fpdfapi/parser/cpdf_parser.h"
#include "core/fpdfapi/parser/cpdf_syntax_parser.h"
+#include "core/fxcrt/cfx_readonlymemorystream.h"
#include "core/fxcrt/fx_extension.h"
-#include "testing/fx_string_testhelpers.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/utils/path_service.h"
@@ -17,7 +17,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Empty string.
static const uint8_t data[] = "";
- CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::make_span(data, 0)));
EXPECT_EQ("", parser.ReadHexString());
EXPECT_EQ(0, parser.GetPos());
@@ -26,7 +26,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Blank string.
static const uint8_t data[] = " ";
- CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::make_span(data, 2)));
EXPECT_EQ("", parser.ReadHexString());
EXPECT_EQ(2, parser.GetPos());
@@ -35,7 +35,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Skips unknown characters.
static const uint8_t data[] = "z12b";
- CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::make_span(data, 4)));
EXPECT_EQ("\x12\xb0", parser.ReadHexString());
EXPECT_EQ(4, parser.GetPos());
@@ -44,7 +44,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Skips unknown characters.
static const uint8_t data[] = "*<&*#$^&@1";
- CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::make_span(data, 10)));
EXPECT_EQ("\x10", parser.ReadHexString());
EXPECT_EQ(10, parser.GetPos());
@@ -53,7 +53,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Skips unknown characters.
static const uint8_t data[] = "\x80zab";
- CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::make_span(data, 4)));
EXPECT_EQ("\xab", parser.ReadHexString());
EXPECT_EQ(4, parser.GetPos());
@@ -62,7 +62,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Skips unknown characters.
static const uint8_t data[] = "\xffzab";
- CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::make_span(data, 4)));
EXPECT_EQ("\xab", parser.ReadHexString());
EXPECT_EQ(4, parser.GetPos());
@@ -71,7 +71,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Regular conversion.
static const uint8_t data[] = "1A2b>abcd";
- CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::make_span(data, 9)));
EXPECT_EQ("\x1a\x2b", parser.ReadHexString());
EXPECT_EQ(5, parser.GetPos());
@@ -80,7 +80,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Position out of bounds.
static const uint8_t data[] = "12ab>";
- CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::make_span(data, 5)));
parser.SetPos(5);
EXPECT_EQ("", parser.ReadHexString());
@@ -102,7 +102,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Missing ending >.
static const uint8_t data[] = "1A2b";
- CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::make_span(data, 4)));
EXPECT_EQ("\x1a\x2b", parser.ReadHexString());
EXPECT_EQ(4, parser.GetPos());
@@ -111,7 +111,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Missing ending >.
static const uint8_t data[] = "12abz";
- CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::make_span(data, 5)));
EXPECT_EQ("\x12\xab", parser.ReadHexString());
EXPECT_EQ(5, parser.GetPos());
@@ -120,7 +120,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Uneven number of bytes.
static const uint8_t data[] = "1A2>asdf";
- CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::make_span(data, 8)));
EXPECT_EQ("\x1a\x20", parser.ReadHexString());
EXPECT_EQ(4, parser.GetPos());
@@ -129,7 +129,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Uneven number of bytes.
static const uint8_t data[] = "1A2zasdf";
- CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::make_span(data, 8)));
EXPECT_EQ("\x1a\x2a\xdf", parser.ReadHexString());
EXPECT_EQ(8, parser.GetPos());
@@ -138,7 +138,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Just ending character.
static const uint8_t data[] = ">";
- CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::make_span(data, 1)));
EXPECT_EQ("", parser.ReadHexString());
EXPECT_EQ(1, parser.GetPos());
@@ -148,7 +148,7 @@ TEST(cpdf_syntax_parser, ReadHexString) {
TEST(cpdf_syntax_parser, GetInvalidReference) {
// Data with a reference with number CPDF_Object::kInvalidObjNum
static const uint8_t data[] = "4294967295 0 R";
- CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::make_span(data, 14)));
std::unique_ptr<CPDF_Object> ref = parser.GetObjectBody(nullptr);
EXPECT_FALSE(ref);
@@ -156,8 +156,7 @@ TEST(cpdf_syntax_parser, GetInvalidReference) {
TEST(cpdf_syntax_parser, PeekNextWord) {
static const uint8_t data[] = " WORD ";
- CPDF_SyntaxParser parser(
- pdfium::MakeRetain<CFX_BufferSeekableReadStream>(data));
+ CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(data));
EXPECT_EQ("WORD", parser.PeekNextWord(nullptr));
EXPECT_EQ("WORD", parser.GetNextWord(nullptr));
}
diff --git a/core/fxcrt/cfx_readonlymemorystream.cpp b/core/fxcrt/cfx_readonlymemorystream.cpp
index a01ed2e474..0a1a53a456 100644
--- a/core/fxcrt/cfx_readonlymemorystream.cpp
+++ b/core/fxcrt/cfx_readonlymemorystream.cpp
@@ -21,7 +21,7 @@ FX_FILESIZE CFX_ReadOnlyMemoryStream::GetSize() {
bool CFX_ReadOnlyMemoryStream::ReadBlock(void* buffer,
FX_FILESIZE offset,
size_t size) {
- if (offset < 0)
+ if (!buffer || offset < 0 || size == 0)
return false;
FX_SAFE_SIZE_T pos = size;
diff --git a/core/fxcrt/xml/cfx_xmlinstruction_unittest.cpp b/core/fxcrt/xml/cfx_xmlinstruction_unittest.cpp
index 0109ab2985..c1fbad5f0f 100644
--- a/core/fxcrt/xml/cfx_xmlinstruction_unittest.cpp
+++ b/core/fxcrt/xml/cfx_xmlinstruction_unittest.cpp
@@ -4,10 +4,10 @@
#include "core/fxcrt/xml/cfx_xmlinstruction.h"
+#include "core/fxcrt/cfx_readonlymemorystream.h"
#include "core/fxcrt/xml/cfx_xmldocument.h"
#include "core/fxcrt/xml/cfx_xmlelement.h"
#include "core/fxcrt/xml/cfx_xmlparser.h"
-#include "testing/fx_string_testhelpers.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/string_write_stream.h"
#include "testing/test_support.h"
@@ -86,7 +86,7 @@ TEST(CFX_XMLInstructionTest, ParseAndReSave) {
"<?acrobat http://www.xfa.org/schema/xfa-template/3.3/ Display:1 ?>\n"
"<node></node>";
- auto in_stream = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ auto in_stream = pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::as_bytes(pdfium::make_span(input)));
CFX_XMLParser parser(in_stream);
@@ -119,7 +119,7 @@ TEST(CFX_XMLInstructionTest, ParseAndReSaveInnerInstruction) {
"<?acrobat http://www.xfa.org/schema/xfa-template/3.3/ Display:1 ?>\n"
"</node>";
- auto in_stream = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ auto in_stream = pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::as_bytes(pdfium::make_span(input)));
CFX_XMLParser parser(in_stream);
diff --git a/core/fxcrt/xml/cfx_xmlparser_unittest.cpp b/core/fxcrt/xml/cfx_xmlparser_unittest.cpp
index c1236ce182..86d340ea83 100644
--- a/core/fxcrt/xml/cfx_xmlparser_unittest.cpp
+++ b/core/fxcrt/xml/cfx_xmlparser_unittest.cpp
@@ -6,11 +6,11 @@
#include <memory>
+#include "core/fxcrt/cfx_readonlymemorystream.h"
#include "core/fxcrt/fx_codepage.h"
#include "core/fxcrt/xml/cfx_xmldocument.h"
#include "core/fxcrt/xml/cfx_xmlelement.h"
#include "core/fxcrt/xml/cfx_xmlinstruction.h"
-#include "testing/fx_string_testhelpers.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/test_support.h"
#include "third_party/base/ptr_util.h"
@@ -18,8 +18,8 @@
class CFX_XMLParserTest : public testing::Test {
public:
std::unique_ptr<CFX_XMLDocument> Parse(pdfium::span<const char> input) {
- CFX_XMLParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
- pdfium::as_bytes(input)));
+ CFX_XMLParser parser(
+ pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(pdfium::as_bytes(input)));
return parser.Parse();
}
};
diff --git a/testing/fuzzers/xfa_codec_fuzzer.h b/testing/fuzzers/xfa_codec_fuzzer.h
index bc40f653af..fe9e72b89d 100644
--- a/testing/fuzzers/xfa_codec_fuzzer.h
+++ b/testing/fuzzers/xfa_codec_fuzzer.h
@@ -9,8 +9,8 @@
#include "core/fxcodec/codec/ccodec_progressivedecoder.h"
#include "core/fxcodec/fx_codec.h"
+#include "core/fxcrt/cfx_readonlymemorystream.h"
#include "core/fxge/dib/cfx_dibitmap.h"
-#include "testing/fx_string_testhelpers.h"
#include "third_party/base/ptr_util.h"
#include "third_party/base/span.h"
@@ -53,7 +53,7 @@ class XFACodecFuzzer {
std::unique_ptr<CCodec_ProgressiveDecoder> decoder =
mgr->CreateProgressiveDecoder();
- auto source = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ auto source = pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::make_span(data, size));
FXCODEC_STATUS status = decoder->LoadImageInfo(source, type, nullptr, true);
if (status != FXCODEC_STATUS_FRAME_READY)
diff --git a/testing/fx_string_testhelpers.cpp b/testing/fx_string_testhelpers.cpp
index e3c443ac4e..96f2c64535 100644
--- a/testing/fx_string_testhelpers.cpp
+++ b/testing/fx_string_testhelpers.cpp
@@ -22,24 +22,3 @@ CFX_InvalidSeekableReadStream::CFX_InvalidSeekableReadStream(
: data_size_(data_size) {}
CFX_InvalidSeekableReadStream::~CFX_InvalidSeekableReadStream() = default;
-
-CFX_BufferSeekableReadStream::CFX_BufferSeekableReadStream(
- pdfium::span<const uint8_t> data)
- : data_(data) {}
-
-CFX_BufferSeekableReadStream::~CFX_BufferSeekableReadStream() = default;
-
-bool CFX_BufferSeekableReadStream::ReadBlock(void* buffer,
- FX_FILESIZE offset,
- size_t size) {
- if (offset < 0 || static_cast<size_t>(offset) >= data_.size())
- return false;
-
- if (static_cast<size_t>(offset) + size > data_.size())
- size = data_.size() - static_cast<size_t>(offset);
- if (size == 0)
- return false;
-
- memcpy(buffer, &data_[offset], size);
- return true;
-}
diff --git a/testing/fx_string_testhelpers.h b/testing/fx_string_testhelpers.h
index 4cddefab0a..a828d825ab 100644
--- a/testing/fx_string_testhelpers.h
+++ b/testing/fx_string_testhelpers.h
@@ -32,23 +32,4 @@ class CFX_InvalidSeekableReadStream : public IFX_SeekableReadStream {
const FX_FILESIZE data_size_;
};
-class CFX_BufferSeekableReadStream : public IFX_SeekableReadStream {
- public:
- template <typename T, typename... Args>
- friend RetainPtr<T> pdfium::MakeRetain(Args&&... args);
-
- // IFX_SeekableReadStream:
- bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
-
- FX_FILESIZE GetSize() override {
- return static_cast<FX_FILESIZE>(data_.size());
- }
-
- private:
- explicit CFX_BufferSeekableReadStream(pdfium::span<const uint8_t> data);
- ~CFX_BufferSeekableReadStream() override;
-
- pdfium::span<const uint8_t> data_;
-};
-
#endif // TESTING_FX_STRING_TESTHELPERS_H_
diff --git a/xfa/fxfa/parser/cxfa_document_parser_unittest.cpp b/xfa/fxfa/parser/cxfa_document_parser_unittest.cpp
index 62bd380326..7ce2efe954 100644
--- a/xfa/fxfa/parser/cxfa_document_parser_unittest.cpp
+++ b/xfa/fxfa/parser/cxfa_document_parser_unittest.cpp
@@ -4,7 +4,7 @@
#include "xfa/fxfa/parser/cxfa_document_parser.h"
-#include "testing/fx_string_testhelpers.h"
+#include "core/fxcrt/cfx_readonlymemorystream.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/test_support.h"
#include "xfa/fxfa/parser/cxfa_document.h"
@@ -39,7 +39,7 @@ TEST_F(CXFA_DocumentParserTest, XMLInstructionsScriptOff) {
"</config>";
EXPECT_FALSE(GetDoc()->HasFlag(XFA_DOCFLAG_Scripting));
- auto stream = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ auto stream = pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::as_bytes(pdfium::make_span(input)));
ASSERT_TRUE(GetParser()->Parse(stream, XFA_PacketType::Config));
@@ -57,7 +57,7 @@ TEST_F(CXFA_DocumentParserTest, XMLInstructionsScriptOn) {
EXPECT_FALSE(GetDoc()->HasFlag(XFA_DOCFLAG_Scripting));
- auto stream = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ auto stream = pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::as_bytes(pdfium::make_span(input)));
ASSERT_TRUE(GetParser()->Parse(stream, XFA_PacketType::Config));
@@ -74,7 +74,7 @@ TEST_F(CXFA_DocumentParserTest, XMLInstructionsStrictScope) {
EXPECT_FALSE(GetDoc()->HasFlag(XFA_DOCFLAG_StrictScoping));
- auto stream = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ auto stream = pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::as_bytes(pdfium::make_span(input)));
ASSERT_TRUE(GetParser()->Parse(stream, XFA_PacketType::Config));
@@ -91,7 +91,7 @@ TEST_F(CXFA_DocumentParserTest, XMLInstructionsStrictScopeBad) {
EXPECT_FALSE(GetDoc()->HasFlag(XFA_DOCFLAG_StrictScoping));
- auto stream = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ auto stream = pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::as_bytes(pdfium::make_span(input)));
ASSERT_TRUE(GetParser()->Parse(stream, XFA_PacketType::Config));
@@ -111,7 +111,7 @@ TEST_F(CXFA_DocumentParserTest, MultipleXMLInstructions) {
EXPECT_FALSE(GetDoc()->HasFlag(XFA_DOCFLAG_Scripting));
EXPECT_FALSE(GetDoc()->HasFlag(XFA_DOCFLAG_StrictScoping));
- auto stream = pdfium::MakeRetain<CFX_BufferSeekableReadStream>(
+ auto stream = pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::as_bytes(pdfium::make_span(input)));
ASSERT_TRUE(GetParser()->Parse(stream, XFA_PacketType::Config));