diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-10-18 12:17:14 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-10-18 17:19:26 +0000 |
commit | 04e4dc88da34c323e7a16586bddf377a610d63c5 (patch) | |
tree | 3edad973a50e8a24aed47a4aa6ab6e267720876a /fpdfsdk/fpdfeditpath_embeddertest.cpp | |
parent | 854d71c1420eb80ec79755a6cdf829f3f39aead7 (diff) | |
download | pdfium-04e4dc88da34c323e7a16586bddf377a610d63c5.tar.xz |
Fix rounding of colour values
This CL fixes rounding issues with the colour values when written then
read from path objects.
Bug: pdfium:919
Change-Id: I8ab33706f1c7d81c3ec755706b1a613cf2a557b3
Reviewed-on: https://pdfium-review.googlesource.com/16270
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfeditpath_embeddertest.cpp')
-rw-r--r-- | fpdfsdk/fpdfeditpath_embeddertest.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfeditpath_embeddertest.cpp b/fpdfsdk/fpdfeditpath_embeddertest.cpp new file mode 100644 index 0000000000..71af2fad55 --- /dev/null +++ b/fpdfsdk/fpdfeditpath_embeddertest.cpp @@ -0,0 +1,63 @@ +// Copyright 2017 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 "core/fxcrt/fx_system.h" +#include "public/fpdf_edit.h" +#include "testing/embedder_test.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "testing/test_support.h" + +class FPDFEditPathEmbedderTest : public EmbedderTest {}; + +TEST_F(FPDFEditPathEmbedderTest, VerifyCorrectColoursReturned) { + CreateEmptyDocument(); + FPDF_PAGE page = FPDFPage_New(document(), 0, 612, 792); + + for (size_t i = 0; i < 256; ++i) { + FPDF_PAGEOBJECT path = FPDFPageObj_CreateNewPath(400, 100); + EXPECT_TRUE(FPDFPath_SetFillColor(path, i, i, i, i)); + EXPECT_TRUE(FPDFPath_SetStrokeColor(path, i, i, i, i)); + EXPECT_TRUE(FPDFPath_SetDrawMode(path, FPDF_FILLMODE_ALTERNATE, 0)); + EXPECT_TRUE(FPDFPath_LineTo(path, 400, 200)); + EXPECT_TRUE(FPDFPath_LineTo(path, 300, 100)); + EXPECT_TRUE(FPDFPath_Close(path)); + + FPDFPage_InsertObject(page, path); + } + + EXPECT_TRUE(FPDFPage_GenerateContent(page)); + EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0)); + FPDF_ClosePage(page); + page = nullptr; + + OpenSavedDocument(); + page = LoadSavedPage(); + ASSERT(page); + + for (size_t i = 0; i < 256; ++i) { + FPDF_PAGEOBJECT path = FPDFPage_GetObject(page, i); + ASSERT(path); + + EXPECT_EQ(FPDF_PAGEOBJ_PATH, FPDFPageObj_GetType(path)); + + unsigned int r; + unsigned int g; + unsigned int b; + unsigned int a; + FPDFPath_GetFillColor(path, &r, &g, &b, &a); + EXPECT_EQ(i, r); + EXPECT_EQ(i, g); + EXPECT_EQ(i, b); + EXPECT_EQ(i, a); + + FPDFPath_GetStrokeColor(path, &r, &g, &b, &a); + EXPECT_EQ(i, r); + EXPECT_EQ(i, g); + EXPECT_EQ(i, b); + EXPECT_EQ(i, a); + } + + CloseSavedPage(); + CloseSavedDocument(); +} |