Changeset efca2e4 in mainline for uspace/lib/gfxfont/test


Ignore:
Timestamp:
2020-09-25T17:40:47Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
dd65f4f7
Parents:
16357ec
git-author:
Jiri Svoboda <jiri@…> (2020-09-24 19:40:35)
git-committer:
Jiri Svoboda <jiri@…> (2020-09-25 17:40:47)
Message:

Clear glyph using Ctrl-X

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/gfxfont/test/glyph_bmp.c

    r16357ec refca2e4  
    342342
    343343/** Test glyph_bmp_setpix() properly extends pixel array */
    344 PCUT_TEST(setpix_externd)
     344PCUT_TEST(setpix_extend)
    345345{
    346346        gfx_font_props_t fprops;
     
    406406                }
    407407        }
     408
     409        gfx_glyph_bmp_close(bmp);
     410
     411        gfx_glyph_destroy(glyph);
     412
     413        gfx_font_close(font);
     414        gfx_typeface_destroy(tface);
     415        rc = gfx_context_delete(gc);
     416        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     417}
     418
     419/** Test glyph_bmp_clear() properly clears bitmap */
     420PCUT_TEST(clear)
     421{
     422        gfx_font_props_t fprops;
     423        gfx_font_metrics_t fmetrics;
     424        gfx_typeface_t *tface;
     425        gfx_font_t *font;
     426        gfx_glyph_metrics_t gmetrics;
     427        gfx_glyph_t *glyph;
     428        gfx_context_t *gc;
     429        gfx_glyph_bmp_t *bmp;
     430        gfx_rect_t rect;
     431        test_gc_t tgc;
     432        int pix;
     433        errno_t rc;
     434
     435        rc = gfx_context_new(&test_ops, (void *) &tgc, &gc);
     436        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     437
     438        rc = gfx_typeface_create(gc, &tface);
     439        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     440
     441        gfx_font_props_init(&fprops);
     442        gfx_font_metrics_init(&fmetrics);
     443        rc = gfx_font_create(tface, &fprops, &fmetrics, &font);
     444        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     445
     446        gfx_glyph_metrics_init(&gmetrics);
     447        gmetrics.advance = 1;
     448
     449        rc = gfx_glyph_create(font, &gmetrics, &glyph);
     450        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     451
     452        bmp = NULL;
     453
     454        rc = gfx_glyph_bmp_open(glyph, &bmp);
     455        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     456        PCUT_ASSERT_NOT_NULL(bmp);
     457
     458        /* Set some pixels */
     459
     460        rc = gfx_glyph_bmp_setpix(bmp, 0, 0, 1);
     461        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     462
     463        rc = gfx_glyph_bmp_setpix(bmp, 1, 1, 1);
     464        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     465
     466        /* Clear the bitmap and check */
     467        gfx_glyph_bmp_clear(bmp);
     468
     469        gfx_glyph_bmp_get_rect(bmp, &rect);
     470        PCUT_ASSERT_INT_EQUALS(0, rect.p0.x);
     471        PCUT_ASSERT_INT_EQUALS(0, rect.p0.y);
     472        PCUT_ASSERT_INT_EQUALS(0, rect.p1.x);
     473        PCUT_ASSERT_INT_EQUALS(0, rect.p1.y);
     474
     475        pix = gfx_glyph_bmp_getpix(bmp, 0, 0);
     476        PCUT_ASSERT_INT_EQUALS(0, pix);
     477        pix = gfx_glyph_bmp_getpix(bmp, 1, 1);
     478        PCUT_ASSERT_INT_EQUALS(0, pix);
    408479
    409480        gfx_glyph_bmp_close(bmp);
Note: See TracChangeset for help on using the changeset viewer.