From baa7ff4390b8b36c2d58c1b1f8d9775c76da656a Mon Sep 17 00:00:00 2001 From: Jane Liu Date: Thu, 29 Jun 2017 19:18:23 -0400 Subject: Basic APIs and tests for extracting and setting annotation paths 1. Added APIs for retrieving existing annotation paths and setting annotation paths. * Added an embedder test testing all the new functions. Bug=pdfium:737 Change-Id: Ic451bcd3be488261baf2182549c4238b887b219e Reviewed-on: https://pdfium-review.googlesource.com/6676 Commit-Queue: Jane Liu Reviewed-by: Lei Zhang Reviewed-by: dsinclair --- .../edit/cpdf_pagecontentgenerator_unittest.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp') diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp index ef186666f1..62b10c9149 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp @@ -58,7 +58,7 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessRect) { CPDF_PageContentGenerator generator(pTestPage.get()); std::ostringstream buf; TestProcessPath(&generator, &buf, pPathObj.get()); - EXPECT_EQ("q 10 5 3 25 re B* Q\n", CFX_ByteString(buf)); + EXPECT_EQ("q 1 0 0 1 0 0 cm 10 5 3 25 re B* Q\n", CFX_ByteString(buf)); pPathObj = pdfium::MakeUnique(); pPathObj->m_Path.AppendPoint(CFX_PointF(0, 0), FXPT_TYPE::MoveTo, false); @@ -71,7 +71,7 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessRect) { buf.str(""); TestProcessPath(&generator, &buf, pPathObj.get()); - EXPECT_EQ("q 0 0 5.2 3.78 re n Q\n", CFX_ByteString(buf)); + EXPECT_EQ("q 1 0 0 1 0 0 cm 0 0 5.2 3.78 re n Q\n", CFX_ByteString(buf)); } TEST_F(CPDF_PageContentGeneratorTest, ProcessPath) { @@ -103,8 +103,8 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessPath) { std::ostringstream buf; TestProcessPath(&generator, &buf, pPathObj.get()); EXPECT_EQ( - "q 3.102 4.67 m 5.45 0.29 l 4.24 3.15 4.65 2.98 3.456 0.24 c 10.6 11.15 " - "l 11 12.5 l 11.46 12.67 11.84 12.96 12 13.64 c h f Q\n", + "q 1 0 0 1 0 0 cm 3.102 4.67 m 5.45 0.29 l 4.24 3.15 4.65 2.98 3.456 0.24" + " c 10.6 11.15 l 11 12.5 l 11.46 12.67 11.84 12.96 12 13.64 c h f Q\n", CFX_ByteString(buf)); } @@ -137,10 +137,11 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessGraphics) { // Color RGB values used are integers divided by 255. EXPECT_EQ("q 0.501961 0.701961 0.34902 rg 1 0.901961 0 RG /", pathString.Left(48)); - EXPECT_EQ(" gs 1 2 m 3 4 l 5 6 l h B Q\n", pathString.Right(28)); - ASSERT_TRUE(pathString.GetLength() > 76); + EXPECT_EQ(" gs 1 0 0 1 0 0 cm 1 2 m 3 4 l 5 6 l h B Q\n", + pathString.Right(43)); + ASSERT_TRUE(pathString.GetLength() > 91); CPDF_Dictionary* externalGS = TestGetResource( - &generator, "ExtGState", pathString.Mid(48, pathString.GetLength() - 76)); + &generator, "ExtGState", pathString.Mid(48, pathString.GetLength() - 91)); ASSERT_TRUE(externalGS); EXPECT_EQ(0.5f, externalGS->GetNumberFor("ca")); EXPECT_EQ(0.8f, externalGS->GetNumberFor("CA")); @@ -152,7 +153,8 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessGraphics) { CFX_ByteString pathString2(buf); EXPECT_EQ("q 0.501961 0.701961 0.34902 rg 1 0.901961 0 RG 10.5 w /", pathString2.Left(55)); - EXPECT_EQ(" gs 1 2 m 3 4 l 5 6 l h B Q\n", pathString2.Right(28)); + EXPECT_EQ(" gs 1 0 0 1 0 0 cm 1 2 m 3 4 l 5 6 l h B Q\n", + pathString2.Right(43)); // Compare with the previous (should use same dictionary for gs) EXPECT_EQ(pathString.GetLength() + 7, pathString2.GetLength()); @@ -302,8 +304,8 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessFormWithPath) { pDoc->CreateNewDoc(); auto pDict = pdfium::MakeUnique(); const char content[] = - "q 3.102 4.67 m 5.45 0.29 l 4.24 3.15 4.65 2.98 3.456 0.24 c 3.102 4.67 " - "l h f Q\n"; + "q 1 0 0 1 0 0 cm 3.102 4.67 m 5.45 0.29 l 4.24 3.15 4.65 2.98 3.456 " + "0.24 c 3.102 4.67 l h f Q\n"; size_t buf_len = FX_ArraySize(content); std::unique_ptr buf(FX_Alloc(uint8_t, buf_len)); memcpy(buf.get(), content, buf_len); -- cgit v1.2.3