14 const char* rotated_checksum = []() {
16 return "eded83f75f3d0332c584c416c571c0df";
18 return "d599429574ff0dcad3bc898ea8b874ca";
22 ASSERT_TRUE(OpenDocument(
"rectangles.pdf"));
23 FPDF_PAGE page = LoadPage(0);
31 EXPECT_EQ(200, page_width);
32 EXPECT_EQ(300, page_height);
33 ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
34 CompareBitmap(bitmap.get(), page_width, page_height,
47 EXPECT_EQ(300, page_width);
48 EXPECT_EQ(200, page_height);
49 ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
50 CompareBitmap(bitmap.get(), page_width, page_height, rotated_checksum);
59 EXPECT_TRUE(FPDF_SaveAsCopy(document(),
this, 0));
60 ASSERT_TRUE(OpenSavedDocument());
61 FPDF_PAGE saved_page = LoadSavedPage(0);
62 ASSERT_TRUE(saved_page);
67 EXPECT_EQ(300, page_width);
68 EXPECT_EQ(200, page_height);
69 ScopedFPDFBitmap bitmap = RenderSavedPage(saved_page);
70 CompareBitmap(bitmap.get(), page_width, page_height, rotated_checksum);
72 CloseSavedPage(saved_page);
164 float phase = -1123.5f;
166 EXPECT_FLOAT_EQ(-1123.5f, phase);
170 EXPECT_FALSE(FPDFPageObj_GetDashArray(
nullptr,
nullptr, 3));
172 float get_array[] = {-1.0f, -1.0f, -1.0f};
173 EXPECT_FALSE(FPDFPageObj_GetDashArray(
nullptr, get_array, 3));
174 for (
int i = 0; i < 3; i++)
175 EXPECT_FLOAT_EQ(-1.0f, get_array[i]);
178 EXPECT_FALSE(FPDFPageObj_SetDashArray(
nullptr,
nullptr, 3, 5.0f));
180 float set_array[] = {1.0f, 2.0f, 3.0f};
181 EXPECT_FALSE(FPDFPageObj_SetDashArray(
nullptr, set_array, 3, 5.0f));
184 constexpr int kExpectedObjectCount = 3;
185 ASSERT_TRUE(OpenDocument(
"dashed_lines.pdf"));
186 FPDF_PAGE page = LoadPage(0);
197 EXPECT_FALSE(FPDFPageObj_GetDashArray(path,
nullptr, 3));
198 EXPECT_FALSE(FPDFPageObj_SetDashArray(path,
nullptr, 3, 5.0f));
200 float phase = -1123.5f;
202 EXPECT_FLOAT_EQ(0.0f, phase);
205 float get_array[] = {-1.0f, -1.0f, -1.0f};
206 EXPECT_TRUE(FPDFPageObj_GetDashArray(path, get_array, 3));
207 for (
int i = 0; i < 3; i++)
208 EXPECT_FLOAT_EQ(-1.0f, get_array[i]);
216 float phase = -1123.5f;
218 EXPECT_LT(0.0f, phase);
221 float dash_array[] = {-1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f};
222 ASSERT_TRUE(FPDFPageObj_GetDashArray(path, dash_array, 6));
224 for (
int i = 0; i < 6; i++)
225 EXPECT_LT(0.0f, dash_array[i]);
228 for (
int i = 0; i < 5; i++)
229 EXPECT_GT(dash_array[i], dash_array[i + 1]);
236 EXPECT_FLOAT_EQ(1.0f, phase);
239 EXPECT_TRUE(FPDFPageObj_SetDashArray(path,
nullptr, 0, 0.0f));
244 EXPECT_FLOAT_EQ(0.0f, phase);
252 float phase = -1123.5f;
254 EXPECT_FLOAT_EQ(0.0f, phase);
259 float get_array[] = {-1.0f, -1.0f, -1.0f, -1.0f};
260 EXPECT_TRUE(FPDFPageObj_GetDashArray(path, get_array, 4));
261 for (
int i = 0; i < 4; i++)
262 EXPECT_FLOAT_EQ(-1.0f, get_array[i]);
265 const float set_array[] = {1.0f, 2.0f, 3.0f};
266 EXPECT_TRUE(FPDFPageObj_SetDashArray(path, set_array, 3, 5.0f));
270 EXPECT_FLOAT_EQ(5.0f, phase);
274 EXPECT_FALSE(FPDFPageObj_GetDashArray(path, get_array, 2));
275 for (
int i = 0; i < 4; i++)
276 EXPECT_FLOAT_EQ(-1.0f, get_array[i]);
278 ASSERT_TRUE(FPDFPageObj_GetDashArray(path, get_array, 4));
281 for (
int i = 0; i < 3; i++)
282 EXPECT_FLOAT_EQ(
static_cast<
float>(i + 1), get_array[i]);
284 EXPECT_FLOAT_EQ(-1.0f, get_array[3]);
287 EXPECT_TRUE(FPDFPageObj_SetDashArray(path, set_array, 0, 4.0f));
292 EXPECT_FLOAT_EQ(4.0f, phase);
315 ASSERT_TRUE(OpenDocument(
"hello_world.pdf"));
316 FPDF_PAGE page = LoadPage(0);
322 constexpr float kExpectedLeft = 20.348f;
323 constexpr float kExpectedBottom = 48.164f;
324 constexpr float kExpectedRight = 83.36f;
325 constexpr float kExpectedTop = 58.328f;
332 EXPECT_FLOAT_EQ(kExpectedLeft, left);
333 EXPECT_FLOAT_EQ(kExpectedBottom, bottom);
334 EXPECT_FLOAT_EQ(kExpectedRight, right);
335 EXPECT_FLOAT_EQ(kExpectedTop, top);
339 EXPECT_FLOAT_EQ(kExpectedLeft, quad.x1);
340 EXPECT_FLOAT_EQ(kExpectedBottom, quad.y1);
341 EXPECT_FLOAT_EQ(kExpectedRight, quad.x2);
342 EXPECT_FLOAT_EQ(kExpectedBottom, quad.y2);
343 EXPECT_FLOAT_EQ(kExpectedRight, quad.x3);
344 EXPECT_FLOAT_EQ(kExpectedTop, quad.y3);
345 EXPECT_FLOAT_EQ(kExpectedLeft, quad.x4);
346 EXPECT_FLOAT_EQ(kExpectedTop, quad.y4);
352 ASSERT_TRUE(OpenDocument(
"rotated_text.pdf"));
353 FPDF_PAGE page = LoadPage(0);
359 constexpr float kExpectedLeft = 98.9478f;
360 constexpr float kExpectedBottom = 78.2607f;
361 constexpr float kExpectedRight = 126.32983f;
362 constexpr float kExpectedTop = 105.64272f;
369 EXPECT_FLOAT_EQ(kExpectedLeft, left);
370 EXPECT_FLOAT_EQ(kExpectedBottom, bottom);
371 EXPECT_FLOAT_EQ(kExpectedRight, right);
372 EXPECT_FLOAT_EQ(kExpectedTop, top);
376 EXPECT_FLOAT_EQ(kExpectedLeft, quad.x1);
377 EXPECT_FLOAT_EQ(98.4557f, quad.y1);
378 EXPECT_FLOAT_EQ(119.14279f, quad.x2);
379 EXPECT_FLOAT_EQ(kExpectedBottom, quad.y2);
380 EXPECT_FLOAT_EQ(kExpectedRight, quad.x3);
381 EXPECT_FLOAT_EQ(85.447739f, quad.y3);
382 EXPECT_FLOAT_EQ(106.13486f, quad.x4);
383 EXPECT_FLOAT_EQ(kExpectedTop, quad.y4);
389 ASSERT_TRUE(OpenDocument(
"matte.pdf"));
390 FPDF_PAGE page = LoadPage(0);
396 constexpr float kExpectedLeft = 0.0f;
397 constexpr float kExpectedBottom = 90.0f;
398 constexpr float kExpectedRight = 40.0f;
399 constexpr float kExpectedTop = 150.0f;
406 EXPECT_FLOAT_EQ(kExpectedLeft, left);
407 EXPECT_FLOAT_EQ(kExpectedBottom, bottom);
408 EXPECT_FLOAT_EQ(kExpectedRight, right);
409 EXPECT_FLOAT_EQ(kExpectedTop, top);
413 EXPECT_FLOAT_EQ(kExpectedLeft, quad.x1);
414 EXPECT_FLOAT_EQ(kExpectedBottom, quad.y1);
415 EXPECT_FLOAT_EQ(kExpectedRight, quad.x2);
416 EXPECT_FLOAT_EQ(kExpectedBottom, quad.y2);
417 EXPECT_FLOAT_EQ(kExpectedRight, quad.x3);
418 EXPECT_FLOAT_EQ(kExpectedTop, quad.y3);
419 EXPECT_FLOAT_EQ(kExpectedLeft, quad.x4);
420 EXPECT_FLOAT_EQ(kExpectedTop, quad.y4);
426 ASSERT_TRUE(OpenDocument(
"rotated_image.pdf"));
427 FPDF_PAGE page = LoadPage(0);
433 constexpr float kExpectedLeft = 100.0f;
434 constexpr float kExpectedBottom = 70.0f;
435 constexpr float kExpectedRight = 170.0f;
436 constexpr float kExpectedTop = 140.0f;
443 EXPECT_FLOAT_EQ(kExpectedLeft, left);
444 EXPECT_FLOAT_EQ(kExpectedBottom, bottom);
445 EXPECT_FLOAT_EQ(kExpectedRight, right);
446 EXPECT_FLOAT_EQ(kExpectedTop, top);
450 EXPECT_FLOAT_EQ(kExpectedLeft, quad.x1);
451 EXPECT_FLOAT_EQ(100.0f, quad.y1);
452 EXPECT_FLOAT_EQ(130.0f, quad.x2);
453 EXPECT_FLOAT_EQ(kExpectedBottom, quad.y2);
454 EXPECT_FLOAT_EQ(kExpectedRight, quad.x3);
455 EXPECT_FLOAT_EQ(110.0f, quad.y3);
456 EXPECT_FLOAT_EQ(140.0f, quad.x4);
457 EXPECT_FLOAT_EQ(kExpectedTop, quad.y4);
463 constexpr float kDashArray[] = {2.5, 3.6};
464 constexpr float kDashPhase = 1.2;
466 CreateEmptyDocument();
468 ScopedFPDFPage page(FPDFPage_New(document(), 0, 612, 792));
475 EXPECT_TRUE(FPDFPageObj_SetDashArray(path, kDashArray,
476 std::size(kDashArray), kDashPhase));
477 FPDFPage_InsertObject(page.get(), path);
479 EXPECT_TRUE(FPDFPage_GenerateContent(page.get()));
480 path = FPDFPage_GetObject(page.get(), 0);
484 EXPECT_TRUE(FPDF_SaveAsCopy(document(),
this, 0));
487 ASSERT_TRUE(OpenSavedDocument());
488 FPDF_PAGE page = LoadSavedPage(0);
494 float dash_array[] = {0, 0};
495 ASSERT_EQ(
static_cast<
int>(
std::size(dash_array)),
498 FPDFPageObj_GetDashArray(path, dash_array, std::size(dash_array)));
499 ASSERT_EQ(kDashArray[0], dash_array[0]);
500 ASSERT_EQ(kDashArray[1], dash_array[1]);
501 float dash_phase = 0;
503 ASSERT_EQ(kDashPhase, dash_phase);
505 CloseSavedPage(page);
506 CloseSavedDocument();
TEST_F(FPDFEditPageEmbedderTest, Rotation)