Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset f14a900 in mainline


Ignore:
Timestamp:
2021-02-01T19:55:51Z (4 weeks ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
5a68791
Parents:
7020d1f
Message:

Radio button unit tests need work

Location:
uspace/lib/ui/test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/test/paint.c

    r7020d1f rf14a900  
    134134        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    135135
     136        ui_resource_destroy(resource);
     137        rc = gfx_context_delete(gc);
     138        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     139}
     140
     141/** Paint filled circle */
     142PCUT_TEST(filled_circle)
     143{
     144        errno_t rc;
     145        gfx_context_t *gc = NULL;
     146        test_gc_t tgc;
     147        gfx_coord2_t center;
     148
     149        memset(&tgc, 0, sizeof(tgc));
     150        rc = gfx_context_new(&ops, &tgc, &gc);
     151        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     152
     153        /* Paint filled circle / upper-left half */
     154        rc = ui_paint_filled_circle(gc, &center, 10, ui_fcircle_upleft);
     155        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     156
     157        /* Paint filled circle / lower-right half */
     158        rc = ui_paint_filled_circle(gc, &center, 10, ui_fcircle_lowright);
     159        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     160
     161        /* Paint entire filled circle */
     162        rc = ui_paint_filled_circle(gc, &center, 10, ui_fcircle_entire);
     163        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     164
    136165        rc = gfx_context_delete(gc);
    137166        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
  • uspace/lib/ui/test/rbutton.c

    r7020d1f rf14a900  
    236236        ui_resource_t *resource = NULL;
    237237        ui_rbutton_group_t *group = NULL;
    238         ui_rbutton_t *rbutton;
     238        ui_rbutton_t *rbutton1;
     239        ui_rbutton_t *rbutton2;
    239240        test_cb_resp_t resp;
    240241
     
    251252        PCUT_ASSERT_NULL(group->selected);
    252253
    253         rc = ui_rbutton_create(group, "Hello", NULL, &rbutton);
    254         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    255         PCUT_ASSERT_EQUALS(group->selected, rbutton);
     254        rc = ui_rbutton_create(group, "One", NULL, &rbutton1);
     255        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     256        PCUT_ASSERT_EQUALS(group->selected, rbutton1);
     257
     258        rc = ui_rbutton_create(group, "Two", NULL, &rbutton2);
     259        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     260        PCUT_ASSERT_EQUALS(group->selected, rbutton1);
    256261
    257262        resp.selected = false;
    258263        ui_rbutton_group_set_cb(group, &test_rbutton_group_cb, &resp);
    259264
    260         PCUT_ASSERT_FALSE(rbutton->held);
    261         PCUT_ASSERT_FALSE(rbutton->inside);
    262 
    263         ui_rbutton_press(rbutton);
    264         PCUT_ASSERT_TRUE(rbutton->held);
    265         PCUT_ASSERT_TRUE(rbutton->inside);
     265        PCUT_ASSERT_FALSE(rbutton2->held);
     266        PCUT_ASSERT_FALSE(rbutton2->inside);
     267
     268        ui_rbutton_press(rbutton2);
     269        PCUT_ASSERT_TRUE(rbutton2->held);
     270        PCUT_ASSERT_TRUE(rbutton2->inside);
    266271        PCUT_ASSERT_FALSE(resp.selected);
    267         PCUT_ASSERT_EQUALS(group->selected, rbutton);
    268 
    269         ui_rbutton_release(rbutton);
    270         PCUT_ASSERT_FALSE(rbutton->held);
    271         PCUT_ASSERT_TRUE(rbutton->inside);
     272        PCUT_ASSERT_EQUALS(group->selected, rbutton1);
     273
     274        ui_rbutton_release(rbutton2);
     275        PCUT_ASSERT_FALSE(rbutton2->held);
     276        PCUT_ASSERT_TRUE(rbutton2->inside);
    272277        PCUT_ASSERT_TRUE(resp.selected);
    273         PCUT_ASSERT_EQUALS(group->selected, rbutton);
    274 
    275         ui_rbutton_destroy(rbutton);
     278        PCUT_ASSERT_EQUALS(group->selected, rbutton2);
     279
     280        ui_rbutton_destroy(rbutton1);
     281        ui_rbutton_destroy(rbutton2);
    276282        ui_rbutton_group_destroy(group);
    277283        ui_resource_destroy(resource);
     
    289295        ui_resource_t *resource = NULL;
    290296        ui_rbutton_group_t *group = NULL;
    291         ui_rbutton_t *rbutton;
     297        ui_rbutton_t *rbutton1;
     298        ui_rbutton_t *rbutton2;
    292299        test_cb_resp_t resp;
    293300
     
    302309        rc = ui_rbutton_group_create(resource, &group);
    303310        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    304 
    305         rc = ui_rbutton_create(group, "Hello", NULL, &rbutton);
    306         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     311        PCUT_ASSERT_NULL(group->selected);
     312
     313        rc = ui_rbutton_create(group, "One", NULL, &rbutton1);
     314        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     315        PCUT_ASSERT_EQUALS(group->selected, rbutton1);
     316
     317        rc = ui_rbutton_create(group, "Two", NULL, &rbutton2);
     318        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     319        PCUT_ASSERT_EQUALS(group->selected, rbutton1);
    307320
    308321        resp.selected = false;
    309322        ui_rbutton_group_set_cb(group, &test_rbutton_group_cb, &resp);
    310323
    311         PCUT_ASSERT_FALSE(rbutton->held);
    312         PCUT_ASSERT_FALSE(rbutton->inside);
    313 
    314         ui_rbutton_press(rbutton);
    315         PCUT_ASSERT_TRUE(rbutton->held);
    316         PCUT_ASSERT_TRUE(rbutton->inside);
     324        PCUT_ASSERT_FALSE(rbutton2->held);
     325        PCUT_ASSERT_FALSE(rbutton2->inside);
     326
     327        ui_rbutton_press(rbutton2);
     328        PCUT_ASSERT_TRUE(rbutton2->held);
     329        PCUT_ASSERT_TRUE(rbutton2->inside);
    317330        PCUT_ASSERT_FALSE(resp.selected);
    318         PCUT_ASSERT_EQUALS(group->selected, rbutton);
    319 
    320         ui_rbutton_leave(rbutton);
    321         PCUT_ASSERT_TRUE(rbutton->held);
    322         PCUT_ASSERT_FALSE(rbutton->inside);
     331        PCUT_ASSERT_EQUALS(group->selected, rbutton1);
     332
     333        ui_rbutton_leave(rbutton2);
     334        PCUT_ASSERT_TRUE(rbutton2->held);
     335        PCUT_ASSERT_FALSE(rbutton2->inside);
    323336        PCUT_ASSERT_FALSE(resp.selected);
    324         PCUT_ASSERT_EQUALS(group->selected, rbutton);
    325 
    326         ui_rbutton_release(rbutton);
    327         PCUT_ASSERT_FALSE(rbutton->held);
    328         PCUT_ASSERT_FALSE(rbutton->inside);
     337        PCUT_ASSERT_EQUALS(group->selected, rbutton1);
     338
     339        ui_rbutton_release(rbutton2);
     340        PCUT_ASSERT_FALSE(rbutton2->held);
     341        PCUT_ASSERT_FALSE(rbutton2->inside);
    329342        PCUT_ASSERT_FALSE(resp.selected);
    330         PCUT_ASSERT_EQUALS(group->selected, rbutton);
    331 
    332         ui_rbutton_destroy(rbutton);
     343        PCUT_ASSERT_EQUALS(group->selected, rbutton1);
     344
     345        ui_rbutton_destroy(rbutton1);
     346        ui_rbutton_destroy(rbutton2);
    333347        ui_rbutton_group_destroy(group);
    334348        ui_resource_destroy(resource);
     
    346360        ui_resource_t *resource = NULL;
    347361        ui_rbutton_group_t *group = NULL;
    348         ui_rbutton_t *rbutton;
     362        ui_rbutton_t *rbutton1;
     363        ui_rbutton_t *rbutton2;
    349364        test_cb_resp_t resp;
    350365
     
    359374        rc = ui_rbutton_group_create(resource, &group);
    360375        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    361 
    362         rc = ui_rbutton_create(group, "Hello", NULL, &rbutton);
    363         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    364         PCUT_ASSERT_EQUALS(group->selected, rbutton);
     376        PCUT_ASSERT_NULL(group->selected);
     377
     378        rc = ui_rbutton_create(group, "One", NULL, &rbutton1);
     379        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     380        PCUT_ASSERT_EQUALS(group->selected, rbutton1);
     381
     382        rc = ui_rbutton_create(group, "Two", NULL, &rbutton2);
     383        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     384        PCUT_ASSERT_EQUALS(group->selected, rbutton1);
    365385
    366386        resp.selected = false;
    367387        ui_rbutton_group_set_cb(group, &test_rbutton_group_cb, &resp);
    368388
    369         PCUT_ASSERT_FALSE(rbutton->held);
    370         PCUT_ASSERT_FALSE(rbutton->inside);
    371 
    372         ui_rbutton_press(rbutton);
    373         PCUT_ASSERT_TRUE(rbutton->held);
    374         PCUT_ASSERT_TRUE(rbutton->inside);
     389        PCUT_ASSERT_FALSE(rbutton2->held);
     390        PCUT_ASSERT_FALSE(rbutton2->inside);
     391
     392        ui_rbutton_press(rbutton2);
     393        PCUT_ASSERT_TRUE(rbutton2->held);
     394        PCUT_ASSERT_TRUE(rbutton2->inside);
    375395        PCUT_ASSERT_FALSE(resp.selected);
    376         PCUT_ASSERT_EQUALS(group->selected, rbutton);
    377 
    378         ui_rbutton_leave(rbutton);
    379         PCUT_ASSERT_TRUE(rbutton->held);
    380         PCUT_ASSERT_FALSE(rbutton->inside);
     396        PCUT_ASSERT_EQUALS(group->selected, rbutton1);
     397
     398        ui_rbutton_leave(rbutton2);
     399        PCUT_ASSERT_TRUE(rbutton2->held);
     400        PCUT_ASSERT_FALSE(rbutton2->inside);
    381401        PCUT_ASSERT_FALSE(resp.selected);
    382         PCUT_ASSERT_EQUALS(group->selected, rbutton);
    383 
    384         ui_rbutton_enter(rbutton);
    385         PCUT_ASSERT_TRUE(rbutton->held);
    386         PCUT_ASSERT_TRUE(rbutton->inside);
     402        PCUT_ASSERT_EQUALS(group->selected, rbutton1);
     403
     404        ui_rbutton_enter(rbutton2);
     405        PCUT_ASSERT_TRUE(rbutton2->held);
     406        PCUT_ASSERT_TRUE(rbutton2->inside);
    387407        PCUT_ASSERT_FALSE(resp.selected);
    388         PCUT_ASSERT_EQUALS(group->selected, rbutton);
    389 
    390         ui_rbutton_release(rbutton);
    391         PCUT_ASSERT_FALSE(rbutton->held);
    392         PCUT_ASSERT_TRUE(rbutton->inside);
     408        PCUT_ASSERT_EQUALS(group->selected, rbutton1);
     409
     410        ui_rbutton_release(rbutton2);
     411        PCUT_ASSERT_FALSE(rbutton2->held);
     412        PCUT_ASSERT_TRUE(rbutton2->inside);
    393413        PCUT_ASSERT_TRUE(resp.selected);
    394         PCUT_ASSERT_EQUALS(group->selected, rbutton);
    395 
    396         ui_rbutton_destroy(rbutton);
     414        PCUT_ASSERT_EQUALS(group->selected, rbutton2);
     415
     416        ui_rbutton_destroy(rbutton1);
     417        ui_rbutton_destroy(rbutton2);
    397418        ui_rbutton_group_destroy(group);
    398419        ui_resource_destroy(resource);
Note: See TracChangeset for help on using the changeset viewer.