Changeset dd65f4f7 in mainline for uspace/lib/gfxfont/test/glyph_bmp.c
- Timestamp:
- 2020-09-27T09:26:41Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d8cdaf1b
- Parents:
- efca2e4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gfxfont/test/glyph_bmp.c
refca2e4 rdd65f4f7 33 33 #include <gfx/typeface.h> 34 34 #include <pcut/pcut.h> 35 #include "../private/glyph_bmp.h" 35 36 36 37 PCUT_INIT; … … 477 478 pix = gfx_glyph_bmp_getpix(bmp, 1, 1); 478 479 PCUT_ASSERT_INT_EQUALS(0, pix); 480 481 gfx_glyph_bmp_close(bmp); 482 483 gfx_glyph_destroy(glyph); 484 485 gfx_font_close(font); 486 gfx_typeface_destroy(tface); 487 rc = gfx_context_delete(gc); 488 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 489 } 490 491 /** Test glyph_bmp_find_used_rect() find minimum used rectangle */ 492 PCUT_TEST(find_used_rect) 493 { 494 gfx_font_props_t fprops; 495 gfx_font_metrics_t fmetrics; 496 gfx_typeface_t *tface; 497 gfx_font_t *font; 498 gfx_glyph_metrics_t gmetrics; 499 gfx_glyph_t *glyph; 500 gfx_context_t *gc; 501 gfx_glyph_bmp_t *bmp; 502 gfx_rect_t rect; 503 test_gc_t tgc; 504 errno_t rc; 505 506 rc = gfx_context_new(&test_ops, (void *) &tgc, &gc); 507 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 508 509 rc = gfx_typeface_create(gc, &tface); 510 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 511 512 gfx_font_props_init(&fprops); 513 gfx_font_metrics_init(&fmetrics); 514 rc = gfx_font_create(tface, &fprops, &fmetrics, &font); 515 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 516 517 gfx_glyph_metrics_init(&gmetrics); 518 gmetrics.advance = 1; 519 520 rc = gfx_glyph_create(font, &gmetrics, &glyph); 521 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 522 523 bmp = NULL; 524 525 rc = gfx_glyph_bmp_open(glyph, &bmp); 526 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 527 PCUT_ASSERT_NOT_NULL(bmp); 528 529 /* Check used rectangle */ 530 531 gfx_glyph_bmp_find_used_rect(bmp, &rect); 532 PCUT_ASSERT_INT_EQUALS(0, rect.p0.x); 533 PCUT_ASSERT_INT_EQUALS(0, rect.p0.y); 534 PCUT_ASSERT_INT_EQUALS(0, rect.p1.x); 535 PCUT_ASSERT_INT_EQUALS(0, rect.p1.y); 536 537 /* Set some pixels */ 538 539 rc = gfx_glyph_bmp_setpix(bmp, -4, -5, 1); 540 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 541 542 rc = gfx_glyph_bmp_setpix(bmp, -2, -1, 1); 543 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 544 545 rc = gfx_glyph_bmp_setpix(bmp, 3, 4, 1); 546 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 547 548 rc = gfx_glyph_bmp_setpix(bmp, 7, 6, 1); 549 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 550 551 /* Check used rectangle */ 552 553 gfx_glyph_bmp_find_used_rect(bmp, &rect); 554 PCUT_ASSERT_INT_EQUALS(-4, rect.p0.x); 555 PCUT_ASSERT_INT_EQUALS(-5, rect.p0.y); 556 PCUT_ASSERT_INT_EQUALS(8, rect.p1.x); 557 PCUT_ASSERT_INT_EQUALS(7, rect.p1.y); 558 559 /* Clear the corner pixels */ 560 561 rc = gfx_glyph_bmp_setpix(bmp, -4, -5, 0); 562 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 563 564 rc = gfx_glyph_bmp_setpix(bmp, 7, 6, 0); 565 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 566 567 /* Check used rectangle got smaller */ 568 569 gfx_glyph_bmp_find_used_rect(bmp, &rect); 570 PCUT_ASSERT_INT_EQUALS(-2, rect.p0.x); 571 PCUT_ASSERT_INT_EQUALS(-1, rect.p0.y); 572 PCUT_ASSERT_INT_EQUALS(4, rect.p1.x); 573 PCUT_ASSERT_INT_EQUALS(5, rect.p1.y); 479 574 480 575 gfx_glyph_bmp_close(bmp);
Note:
See TracChangeset
for help on using the changeset viewer.