summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi')
-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
5 files changed, 27 insertions, 28 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));
}