diff options
author | Lei Zhang <thestig@chromium.org> | 2018-10-24 17:27:39 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-10-24 17:27:39 +0000 |
commit | 57360839a2eeecc8e32e326994f8853099ccd2fa (patch) | |
tree | 9c72c9282dc08f09947faa7cbd4e87e58ab2b546 /fpdfsdk | |
parent | 2237541071da7f309c16b3033daa4c6be170dca4 (diff) | |
download | pdfium-57360839a2eeecc8e32e326994f8853099ccd2fa.tar.xz |
Implement FPDFPageObj_GetLineJoin().
Add unit tests for FPDFPageObj_[GS]etLineJoin().
BUG=pdfium:1185
Change-Id: I10c6f0ad5cc06b2b0ac11c1142353e7a275fc79e
Reviewed-on: https://pdfium-review.googlesource.com/c/44515
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/BUILD.gn | 1 | ||||
-rw-r--r-- | fpdfsdk/fpdf_edit_unittest.cpp | 41 | ||||
-rw-r--r-- | fpdfsdk/fpdf_editimg_unittest.cpp | 8 | ||||
-rw-r--r-- | fpdfsdk/fpdf_editpage.cpp | 6 | ||||
-rw-r--r-- | fpdfsdk/fpdf_view_c_api_test.c | 1 |
5 files changed, 53 insertions, 4 deletions
diff --git a/fpdfsdk/BUILD.gn b/fpdfsdk/BUILD.gn index ea44f0d410..3b1a04b8a2 100644 --- a/fpdfsdk/BUILD.gn +++ b/fpdfsdk/BUILD.gn @@ -95,6 +95,7 @@ pdfium_unittest_source_set("unittests") { sources = [ "fpdf_catalog_unittest.cpp", "fpdf_doc_unittest.cpp", + "fpdf_edit_unittest.cpp", "fpdf_editimg_unittest.cpp", ] deps = [ diff --git a/fpdfsdk/fpdf_edit_unittest.cpp b/fpdfsdk/fpdf_edit_unittest.cpp new file mode 100644 index 0000000000..7171f306dc --- /dev/null +++ b/fpdfsdk/fpdf_edit_unittest.cpp @@ -0,0 +1,41 @@ +// Copyright 2018 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "public/fpdf_edit.h" + +#include "core/fpdfapi/cpdf_modulemgr.h" +#include "testing/gtest/include/gtest/gtest.h" + +class PDFEditTest : public testing::Test { + void SetUp() override { CPDF_ModuleMgr::Get()->Init(); } + + void TearDown() override { CPDF_ModuleMgr::Destroy(); } +}; + +TEST_F(PDFEditTest, LineJoin) { + EXPECT_FALSE(FPDFPageObj_SetLineJoin(nullptr, -1)); + EXPECT_FALSE(FPDFPageObj_SetLineJoin(nullptr, FPDF_LINEJOIN_MITER)); + EXPECT_FALSE(FPDFPageObj_SetLineJoin(nullptr, FPDF_LINEJOIN_ROUND)); + EXPECT_FALSE(FPDFPageObj_SetLineJoin(nullptr, FPDF_LINEJOIN_BEVEL)); + EXPECT_FALSE(FPDFPageObj_SetLineJoin(nullptr, 3)); + EXPECT_FALSE(FPDFPageObj_SetLineJoin(nullptr, 1000)); + + FPDF_PAGEOBJECT path = FPDFPageObj_CreateNewPath(0, 0); + EXPECT_EQ(FPDF_LINEJOIN_MITER, FPDFPageObj_GetLineJoin(path)); + + EXPECT_FALSE(FPDFPageObj_SetLineJoin(path, -1)); + EXPECT_FALSE(FPDFPageObj_SetLineJoin(path, 3)); + EXPECT_FALSE(FPDFPageObj_SetLineJoin(path, 1000)); + + EXPECT_TRUE(FPDFPageObj_SetLineJoin(path, FPDF_LINEJOIN_BEVEL)); + EXPECT_EQ(FPDF_LINEJOIN_BEVEL, FPDFPageObj_GetLineJoin(path)); + + EXPECT_TRUE(FPDFPageObj_SetLineJoin(path, FPDF_LINEJOIN_ROUND)); + EXPECT_EQ(FPDF_LINEJOIN_ROUND, FPDFPageObj_GetLineJoin(path)); + + EXPECT_TRUE(FPDFPageObj_SetLineJoin(path, FPDF_LINEJOIN_MITER)); + EXPECT_EQ(FPDF_LINEJOIN_MITER, FPDFPageObj_GetLineJoin(path)); + + FPDFPageObj_Destroy(path); +} diff --git a/fpdfsdk/fpdf_editimg_unittest.cpp b/fpdfsdk/fpdf_editimg_unittest.cpp index fcc081ab76..48bd7f146b 100644 --- a/fpdfsdk/fpdf_editimg_unittest.cpp +++ b/fpdfsdk/fpdf_editimg_unittest.cpp @@ -7,13 +7,13 @@ #include "core/fpdfapi/cpdf_modulemgr.h" #include "testing/gtest/include/gtest/gtest.h" -class PDFEditTest : public testing::Test { +class PDFEditImgTest : public testing::Test { void SetUp() override { CPDF_ModuleMgr::Get()->Init(); } void TearDown() override { CPDF_ModuleMgr::Destroy(); } }; -TEST_F(PDFEditTest, InsertObjectWithInvalidPage) { +TEST_F(PDFEditImgTest, InsertObjectWithInvalidPage) { FPDF_DOCUMENT doc = FPDF_CreateNewDocument(); FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100); EXPECT_EQ(0, FPDFPage_CountObjects(page)); @@ -32,7 +32,7 @@ TEST_F(PDFEditTest, InsertObjectWithInvalidPage) { FPDF_CloseDocument(doc); } -TEST_F(PDFEditTest, NewImageObj) { +TEST_F(PDFEditImgTest, NewImageObj) { FPDF_DOCUMENT doc = FPDF_CreateNewDocument(); FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100); EXPECT_EQ(0, FPDFPage_CountObjects(page)); @@ -46,7 +46,7 @@ TEST_F(PDFEditTest, NewImageObj) { FPDF_CloseDocument(doc); } -TEST_F(PDFEditTest, NewImageObjGenerateContent) { +TEST_F(PDFEditImgTest, NewImageObjGenerateContent) { FPDF_DOCUMENT doc = FPDF_CreateNewDocument(); FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100); EXPECT_EQ(0, FPDFPage_CountObjects(page)); diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp index d0ff962252..27767465b3 100644 --- a/fpdfsdk/fpdf_editpage.cpp +++ b/fpdfsdk/fpdf_editpage.cpp @@ -793,6 +793,12 @@ FPDFPageObj_GetStrokeWidth(FPDF_PAGEOBJECT page_object, float* width) { return true; } +FPDF_EXPORT int FPDF_CALLCONV +FPDFPageObj_GetLineJoin(FPDF_PAGEOBJECT page_object) { + auto* pPageObj = CPDFPageObjectFromFPDFPageObject(page_object); + return pPageObj ? pPageObj->m_GraphState.GetLineJoin() : -1; +} + FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPageObj_SetLineJoin(FPDF_PAGEOBJECT page_object, int line_join) { auto* pPageObj = CPDFPageObjectFromFPDFPageObject(page_object); diff --git a/fpdfsdk/fpdf_view_c_api_test.c b/fpdfsdk/fpdf_view_c_api_test.c index 9cf037685e..eb66e14c37 100644 --- a/fpdfsdk/fpdf_view_c_api_test.c +++ b/fpdfsdk/fpdf_view_c_api_test.c @@ -157,6 +157,7 @@ int CheckPDFiumCApi() { CHK(FPDFPageObj_Destroy); CHK(FPDFPageObj_GetBounds); CHK(FPDFPageObj_GetFillColor); + CHK(FPDFPageObj_GetLineJoin); CHK(FPDFPageObj_GetMark); CHK(FPDFPageObj_GetStrokeColor); CHK(FPDFPageObj_GetStrokeWidth); |