Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp

Issue 1775023003: Re-land "Split CPDF_SyntaxParser into its own named .cpp/.h files." (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Include <vector>. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp ('k') | pdfium.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "core/include/fpdfapi/fpdf_parser.h" 5 #include "core/include/fpdfapi/fpdf_parser.h"
6 #include "core/include/fxcrt/fx_stream.h" 6 #include "core/include/fxcrt/fx_stream.h"
7 #include "core/src/fpdfapi/fpdf_parser/cpdf_syntax_parser.h"
7 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
8 #include "testing/utils/path_service.h" 9 #include "testing/utils/path_service.h"
9 10
10 // Provide a way to read test data from a buffer instead of a file. 11 // Provide a way to read test data from a buffer instead of a file.
11 class CFX_TestBufferRead : public IFX_FileRead { 12 class CFX_TestBufferRead : public IFX_FileRead {
12 public: 13 public:
13 CFX_TestBufferRead(const unsigned char* buffer_in, size_t buf_size) 14 CFX_TestBufferRead(const unsigned char* buffer_in, size_t buf_size)
14 : buffer_(buffer_in), total_size_(buf_size) {} 15 : buffer_(buffer_in), total_size_(buf_size) {}
15 16
16 // IFX_Stream 17 // IFX_Stream
(...skipping 21 matching lines...) Expand all
38 CPDF_TestParser() {} 39 CPDF_TestParser() {}
39 ~CPDF_TestParser() {} 40 ~CPDF_TestParser() {}
40 41
41 // Setup reading from a file and initial states. 42 // Setup reading from a file and initial states.
42 bool InitTestFromFile(const FX_CHAR* path) { 43 bool InitTestFromFile(const FX_CHAR* path) {
43 IFX_FileRead* pFileAccess = FX_CreateFileRead(path); 44 IFX_FileRead* pFileAccess = FX_CreateFileRead(path);
44 if (!pFileAccess) 45 if (!pFileAccess)
45 return false; 46 return false;
46 47
47 // For the test file, the header is set at the beginning. 48 // For the test file, the header is set at the beginning.
48 m_Syntax.InitParser(pFileAccess, 0); 49 m_pSyntax->InitParser(pFileAccess, 0);
49 return true; 50 return true;
50 } 51 }
51 52
52 // Setup reading from a buffer and initial states. 53 // Setup reading from a buffer and initial states.
53 bool InitTestFromBuffer(const unsigned char* buffer, size_t len) { 54 bool InitTestFromBuffer(const unsigned char* buffer, size_t len) {
54 CFX_TestBufferRead* buffer_reader = new CFX_TestBufferRead(buffer, len); 55 CFX_TestBufferRead* buffer_reader = new CFX_TestBufferRead(buffer, len);
55 56
56 // For the test file, the header is set at the beginning. 57 // For the test file, the header is set at the beginning.
57 m_Syntax.InitParser(buffer_reader, 0); 58 m_pSyntax->InitParser(buffer_reader, 0);
58 return true; 59 return true;
59 } 60 }
60 61
61 private: 62 private:
62 // Add test cases here as private friend so that protected members in 63 // Add test cases here as private friend so that protected members in
63 // CPDF_Parser can be accessed by test cases. 64 // CPDF_Parser can be accessed by test cases.
64 // Need to access RebuildCrossRef. 65 // Need to access RebuildCrossRef.
65 FRIEND_TEST(fpdf_parser_parser, RebuildCrossRefCorrectly); 66 FRIEND_TEST(fpdf_parser_parser, RebuildCrossRefCorrectly);
66 FRIEND_TEST(fpdf_parser_parser, RebuildCrossRefFailed); 67 FRIEND_TEST(fpdf_parser_parser, RebuildCrossRefFailed);
67 // Need to access LoadCrossRefV4. 68 // Need to access LoadCrossRefV4.
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 347
347 ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, FALSE)); 348 ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, FALSE));
348 const FX_FILESIZE offsets[] = {0, 23, 0, 0, 0, 45, 179}; 349 const FX_FILESIZE offsets[] = {0, 23, 0, 0, 0, 45, 179};
349 const uint8_t types[] = {0, 1, 0, 0, 0, 1, 1}; 350 const uint8_t types[] = {0, 1, 0, 0, 0, 1, 1};
350 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) { 351 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) {
351 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos); 352 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos);
352 EXPECT_EQ(types[i], parser.m_ObjectInfo[i].type); 353 EXPECT_EQ(types[i], parser.m_ObjectInfo[i].type);
353 } 354 }
354 } 355 }
355 } 356 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp ('k') | pdfium.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698