summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_edit_embeddertest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/fpdf_edit_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdf_edit_embeddertest.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp
index e692a94e04..b957ca3dcc 100644
--- a/fpdfsdk/fpdf_edit_embeddertest.cpp
+++ b/fpdfsdk/fpdf_edit_embeddertest.cpp
@@ -8,6 +8,7 @@
#include <vector>
#include "core/fpdfapi/font/cpdf_font.h"
+#include "core/fpdfapi/page/cpdf_formobject.h"
#include "core/fpdfapi/page/cpdf_page.h"
#include "core/fpdfapi/page/cpdf_pageobject.h"
#include "core/fpdfapi/parser/cpdf_array.h"
@@ -1823,6 +1824,39 @@ TEST_F(FPDFEditEmbeddertest, TestFormGetObjects) {
ASSERT_EQ(nullptr, FPDFFormObj_GetObject(form, -1));
ASSERT_EQ(nullptr, FPDFFormObj_GetObject(form, 2));
+ // Reset the form object matrix to identity.
+ auto* pPageObj = CPDFPageObjectFromFPDFPageObject(form);
+ CPDF_FormObject* pFormObj = pPageObj->AsForm();
+ pFormObj->Transform(pFormObj->form_matrix().GetInverse());
+
+ // FPDFFormObj_GetMatrix() positive testing.
+ static constexpr float kFloats[6] = {1.0, 1.5, 2.0, 2.5, 100.0, 200.0};
+ CFX_Matrix matrix(kFloats);
+ pFormObj->Transform(matrix);
+
+ double matrix_a = 0;
+ double matrix_b = 0;
+ double matrix_c = 0;
+ double matrix_d = 0;
+ double matrix_e = 0;
+ double matrix_f = 0;
+ EXPECT_TRUE(FPDFFormObj_GetMatrix(form, &matrix_a, &matrix_b, &matrix_c,
+ &matrix_d, &matrix_e, &matrix_f));
+ EXPECT_DOUBLE_EQ(kFloats[0], matrix_a);
+ EXPECT_DOUBLE_EQ(kFloats[1], matrix_b);
+ EXPECT_DOUBLE_EQ(kFloats[2], matrix_c);
+ EXPECT_DOUBLE_EQ(kFloats[3], matrix_d);
+ EXPECT_DOUBLE_EQ(kFloats[4], matrix_e);
+ EXPECT_DOUBLE_EQ(kFloats[5], matrix_f);
+
+ // FPDFFormObj_GetMatrix() negative testing.
+ EXPECT_FALSE(FPDFFormObj_GetMatrix(nullptr, &matrix_a, &matrix_b, &matrix_c,
+ &matrix_d, &matrix_e, &matrix_f));
+ EXPECT_FALSE(FPDFFormObj_GetMatrix(form, nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr));
+ EXPECT_FALSE(FPDFFormObj_GetMatrix(nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr));
+
UnloadPage(page);
}