Commit 22aaaa25 authored by Daniel Hosseinian's avatar Daniel Hosseinian Committed by Commit Bot

Add more PdfMetafileCg tests

Add tests that show current printing behavior of contents being aligned
to the bottom right corner of the printed page. Show the behavior for
both portrait and landscape PDFs. Also show the behavior on large and
small destinations.

Bug: 919596
Change-Id: I1519f59b22e9c29f46c941e10b851f5d78d2fafc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2124986
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756379}
parent 91ac5e20
{{header}}
{{object 1 0}} <<
/Type /Catalog
/Pages 2 0 R
>>
endobj
{{object 2 0}} <<
/Type /Pages
/MediaBox [ 0 0 800 500 ]
/CropBox [ 200 100 800 500 ]
/Count 1
/Kids [ 3 0 R ]
>>
endobj
{{object 3 0}} <<
/Type /Page
/Parent 2 0 R
/Contents 4 0 R
>>
endobj
{{object 4 0}} <<
{{streamlen}}
>>
stream
q
0 0 0 rg
200 100 20 20 re B*
220 250 130 100 re B*
1 0 1 rg
780 480 20 20 re B*
650 250 130 100 re B*
1 1 0 rg
780 100 20 20 re B*
450 120 100 130 re B*
0 1 1 rg
200 480 20 20 re B*
450 350 100 130 re B*
Q
endstream
endobj
{{xref}}
{{trailer}}
{{startxref}}
%%EOF
This diff was suppressed by a .gitattributes entry.
...@@ -212,11 +212,51 @@ TEST(PdfMetafileCgTest, GetPageBounds) { ...@@ -212,11 +212,51 @@ TEST(PdfMetafileCgTest, GetPageBounds) {
} }
} }
TEST(PdfMetafileCgTest, RenderPageBasic) { TEST(PdfMetafileCgTest, RenderPortraitRectangles) {
constexpr gfx::Rect kPageBounds(200, 300); constexpr gfx::Rect kPageBounds(200, 300);
constexpr gfx::Size kDestinationSize(200, 300); constexpr gfx::Size kDestinationSize(200, 300);
TestRenderPage("rectangles.pdf", /*page_number=*/1, kPageBounds, TestRenderPage("rectangles.pdf", /*page_number=*/1, kPageBounds,
"rectangles_cg_expected.pdf.0.png", kDestinationSize); "render_portrait_rectangles_expected.0.png", kDestinationSize);
}
TEST(PdfMetafileCgTest, RenderLargePortraitRectangles) {
constexpr gfx::Rect kPageBounds(200, 300);
constexpr gfx::Size kDestinationSize(100, 120);
TestRenderPage("rectangles.pdf", /*page_number=*/1, kPageBounds,
"render_large_portrait_rectangles_expected.0.png",
kDestinationSize);
}
TEST(PdfMetafileCgTest, RenderSmallPortraitRectangles) {
constexpr gfx::Rect kPageBounds(200, 300);
constexpr gfx::Size kDestinationSize(300, 450);
TestRenderPage("rectangles.pdf", /*page_number=*/1, kPageBounds,
"render_small_portrait_rectangles_expected.0.png",
kDestinationSize);
}
TEST(PdfMetafileCgTest, RenderLandscapeRectangles) {
constexpr gfx::Rect kPageBounds(800, 500);
constexpr gfx::Size kDestinationSize(400, 600);
TestRenderPage("landscape_rectangles.pdf", /*page_number=*/1, kPageBounds,
"render_landscape_rectangles_expected.0.png",
kDestinationSize);
}
TEST(PdfMetafileCgTest, RenderLargeLandscapeRectangles) {
constexpr gfx::Rect kPageBounds(800, 500);
constexpr gfx::Size kDestinationSize(200, 300);
TestRenderPage("landscape_rectangles.pdf", /*page_number=*/1, kPageBounds,
"render_large_landscape_rectangles_expected.0.png",
kDestinationSize);
}
TEST(PdfMetafileCgTest, RenderSmallLandscapeRectangles) {
constexpr gfx::Rect kPageBounds(800, 500);
constexpr gfx::Size kDestinationSize(600, 900);
TestRenderPage("landscape_rectangles.pdf", /*page_number=*/1, kPageBounds,
"render_small_landscape_rectangles_expected.0.png",
kDestinationSize);
} }
} // namespace printing } // namespace printing
...@@ -3,4 +3,5 @@ pdf_cg test expectations ...@@ -3,4 +3,5 @@ pdf_cg test expectations
The PNG files in this directory are the CoreGraphics rendering outputs for PDFs The PNG files in this directory are the CoreGraphics rendering outputs for PDFs
in //pdf/test/data/. They are generated from raw bitmaps using in //pdf/test/data/. They are generated from raw bitmaps using
gfx::PNGCodec::Encode() using the |gfx::PNGCodec::FORMAT_BGRA| format. The PNGs gfx::PNGCodec::Encode() using the |gfx::PNGCodec::FORMAT_BGRA| format. The PNGs
are further optimized with optipng. are further optimized with optipng. Each PNG file is named after the
PdfMetafileCgTest instance that uses it.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment