| OLD | NEW |
| 1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <limits> | 5 #include <limits> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "core/fpdfapi/parser/cpdf_parser.h" | 8 #include "core/fpdfapi/parser/cpdf_parser.h" |
| 9 #include "core/fpdfapi/parser/cpdf_syntax_parser.h" | 9 #include "core/fpdfapi/parser/cpdf_syntax_parser.h" |
| 10 #include "core/fxcrt/fx_ext.h" | 10 #include "core/fxcrt/fx_ext.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 // A wrapper class to help test member functions of CPDF_Parser. | 40 // A wrapper class to help test member functions of CPDF_Parser. |
| 41 class CPDF_TestParser : public CPDF_Parser { | 41 class CPDF_TestParser : public CPDF_Parser { |
| 42 public: | 42 public: |
| 43 CPDF_TestParser() {} | 43 CPDF_TestParser() {} |
| 44 ~CPDF_TestParser() {} | 44 ~CPDF_TestParser() {} |
| 45 | 45 |
| 46 // Setup reading from a file and initial states. | 46 // Setup reading from a file and initial states. |
| 47 bool InitTestFromFile(const FX_CHAR* path) { | 47 bool InitTestFromFile(const FX_CHAR* path) { |
| 48 IFX_SeekableReadStream* pFileAccess = FX_CreateFileRead(path); | 48 IFX_SeekableReadStream* pFileAccess = |
| 49 IFX_SeekableReadStream::CreateFromFilename(path); |
| 49 if (!pFileAccess) | 50 if (!pFileAccess) |
| 50 return false; | 51 return false; |
| 51 | 52 |
| 52 // For the test file, the header is set at the beginning. | 53 // For the test file, the header is set at the beginning. |
| 53 m_pSyntax->InitParser(pFileAccess, 0); | 54 m_pSyntax->InitParser(pFileAccess, 0); |
| 54 return true; | 55 return true; |
| 55 } | 56 } |
| 56 | 57 |
| 57 // Setup reading from a buffer and initial states. | 58 // Setup reading from a buffer and initial states. |
| 58 bool InitTestFromBuffer(const unsigned char* buffer, size_t len) { | 59 bool InitTestFromBuffer(const unsigned char* buffer, size_t len) { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 194 |
| 194 ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, false)); | 195 ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, false)); |
| 195 const FX_FILESIZE offsets[] = {0, 23, 0, 0, 0, 45, 179}; | 196 const FX_FILESIZE offsets[] = {0, 23, 0, 0, 0, 45, 179}; |
| 196 const uint8_t types[] = {0, 1, 0, 0, 0, 1, 1}; | 197 const uint8_t types[] = {0, 1, 0, 0, 0, 1, 1}; |
| 197 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) { | 198 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) { |
| 198 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos); | 199 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos); |
| 199 EXPECT_EQ(types[i], parser.m_ObjectInfo[i].type); | 200 EXPECT_EQ(types[i], parser.m_ObjectInfo[i].type); |
| 200 } | 201 } |
| 201 } | 202 } |
| 202 } | 203 } |
| OLD | NEW |