Changeset 9eb8d12 in mainline for uspace/lib/gfxfont/test/text.c


Ignore:
Timestamp:
2021-07-19T22:35:19Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c9722c1
Parents:
ead72f2
Message:

Entry text selection (using keyboard)

Text can be selected with movement keys while holding down Shift.
Selection can be deleted by pressing Backspace, Delete or typing
in replacement text.

File:
1 edited

Legend:

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

    read72f2 r9eb8d12  
    356356}
    357357
     358/** gfx_text_cont() produces correct continuation parameters */
     359PCUT_TEST(text_cont)
     360{
     361        gfx_typeface_t *tface;
     362        gfx_font_t *font;
     363        gfx_context_t *gc;
     364        gfx_color_t *color;
     365        test_gc_t tgc;
     366        gfx_text_fmt_t fmt;
     367        gfx_coord2_t anchor;
     368        gfx_coord2_t cpos;
     369        gfx_text_fmt_t cfmt;
     370        errno_t rc;
     371
     372        rc = gfx_context_new(&test_ops, (void *)&tgc, &gc);
     373        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     374
     375        rc = gfx_typeface_create(gc, &tface);
     376        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     377
     378        rc = gfx_font_create_textmode(tface, &font);
     379        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     380
     381        rc = gfx_color_new_rgb_i16(0, 0, 0, &color);
     382        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     383
     384        anchor.x = 10;
     385        anchor.y = 20;
     386        gfx_text_fmt_init(&fmt);
     387        fmt.color = color;
     388
     389        gfx_text_cont(font, &anchor, &fmt, "Abc", &cpos, &cfmt);
     390
     391        PCUT_ASSERT_INT_EQUALS(13, cpos.x);
     392        PCUT_ASSERT_INT_EQUALS(20, cpos.y);
     393        PCUT_ASSERT_EQUALS(fmt.color, cfmt.color);
     394        PCUT_ASSERT_EQUALS(gfx_halign_left, cfmt.halign);
     395        PCUT_ASSERT_EQUALS(gfx_valign_baseline, cfmt.valign);
     396
     397        gfx_font_close(font);
     398        gfx_typeface_destroy(tface);
     399        gfx_color_delete(color);
     400
     401        rc = gfx_context_delete(gc);
     402        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     403}
     404
     405/** gfx_text_rect() computes bounding rectangle */
     406PCUT_TEST(text_rect)
     407{
     408        gfx_typeface_t *tface;
     409        gfx_font_t *font;
     410        gfx_context_t *gc;
     411        gfx_color_t *color;
     412        test_gc_t tgc;
     413        gfx_text_fmt_t fmt;
     414        gfx_coord2_t anchor;
     415        gfx_rect_t rect;
     416        errno_t rc;
     417
     418        rc = gfx_context_new(&test_ops, (void *)&tgc, &gc);
     419        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     420
     421        rc = gfx_typeface_create(gc, &tface);
     422        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     423
     424        rc = gfx_font_create_textmode(tface, &font);
     425        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     426
     427        rc = gfx_color_new_rgb_i16(0, 0, 0, &color);
     428        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     429
     430        anchor.x = 10;
     431        anchor.y = 20;
     432        gfx_text_fmt_init(&fmt);
     433        fmt.color = color;
     434
     435        gfx_text_rect(font, &anchor, &fmt, "Abc", &rect);
     436
     437        PCUT_ASSERT_INT_EQUALS(10, rect.p0.x);
     438        PCUT_ASSERT_INT_EQUALS(20, rect.p0.y);
     439        PCUT_ASSERT_INT_EQUALS(13, rect.p1.x);
     440        PCUT_ASSERT_INT_EQUALS(21, rect.p1.y);
     441
     442        gfx_font_close(font);
     443        gfx_typeface_destroy(tface);
     444        gfx_color_delete(color);
     445
     446        rc = gfx_context_delete(gc);
     447        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     448}
     449
    358450static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)
    359451{
Note: See TracChangeset for help on using the changeset viewer.