Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
fpdf_editpath_embeddertest.cpp
Go to the documentation of this file.
1// Copyright 2017 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "core/fxcrt/fx_system.h"
6#include "public/fpdf_edit.h"
7#include "testing/embedder_test.h"
8#include "testing/gtest/include/gtest/gtest.h"
9#include "third_party/base/check.h"
10
12
14 constexpr int kObjectCount = 256;
15 CreateEmptyDocument();
16 FPDF_PAGE page = FPDFPage_New(document(), 0, 612, 792);
17
18 for (size_t i = 0; i < kObjectCount; ++i) {
19 FPDF_PAGEOBJECT path = FPDFPageObj_CreateNewPath(400, 100);
20 EXPECT_TRUE(FPDFPageObj_SetFillColor(path, i, i, i, i));
21 EXPECT_TRUE(FPDFPageObj_SetStrokeColor(path, i, i, i, i));
23 EXPECT_TRUE(FPDFPath_LineTo(path, 400, 200));
24 EXPECT_TRUE(FPDFPath_LineTo(path, 300, 100));
25 EXPECT_TRUE(FPDFPath_Close(path));
26
28 }
29
30 EXPECT_TRUE(FPDFPage_GenerateContent(page));
31 EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0));
33 page = nullptr;
34
35 ASSERT_TRUE(OpenSavedDocument());
36 page = LoadSavedPage(0);
37 ASSERT_TRUE(page);
38
39 for (size_t i = 0; i < kObjectCount; ++i) {
40 FPDF_PAGEOBJECT path = FPDFPage_GetObject(page, i);
41 ASSERT_TRUE(path);
42
44
45 unsigned int r;
46 unsigned int g;
47 unsigned int b;
48 unsigned int a;
49 ASSERT_TRUE(FPDFPageObj_GetFillColor(path, &r, &g, &b, &a));
50 EXPECT_EQ(i, r);
51 EXPECT_EQ(i, g);
52 EXPECT_EQ(i, b);
53 EXPECT_EQ(i, a);
54
55 ASSERT_TRUE(FPDFPageObj_GetStrokeColor(path, &r, &g, &b, &a));
56 EXPECT_EQ(i, r);
57 EXPECT_EQ(i, g);
58 EXPECT_EQ(i, b);
59 EXPECT_EQ(i, a);
60 }
61
62 CloseSavedPage(page);
63 CloseSavedDocument();
64}
#define FPDF_FILLMODE_ALTERNATE
Definition fpdf_edit.h:52
FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPageObj_CreateNewPath(float x, float y)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path, int fillmode, FPDF_BOOL stroke)
FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_object)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_Close(FPDF_PAGEOBJECT path)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPageObj_GetFillColor(FPDF_PAGEOBJECT page_object, unsigned int *R, unsigned int *G, unsigned int *B, unsigned int *A)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_LineTo(FPDF_PAGEOBJECT path, float x, float y)
FPDF_EXPORT int FPDF_CALLCONV FPDFPageObj_GetType(FPDF_PAGEOBJECT page_object)
#define FPDF_PAGEOBJ_PATH
Definition fpdf_edit.h:40
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GenerateContent(FPDF_PAGE page)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPageObj_GetStrokeColor(FPDF_PAGEOBJECT page_object, unsigned int *R, unsigned int *G, unsigned int *B, unsigned int *A)
TEST_F(FPDFEditPathEmbedderTest, VerifyCorrectColoursReturned)
FPDF_EXPORT void FPDF_CALLCONV FPDF_ClosePage(FPDF_PAGE page)