Changeset a2f173b in mainline for uspace/lib/ui/test/pbutton.c


Ignore:
Timestamp:
2020-10-21T21:49:13Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
58a67050
Parents:
172188a
Message:

Improve close button event routing

Button event processing routine is the best place to determine whether
the event goes to the button or not. It can also 'grab' button release
events simply by claiming them.

File:
1 edited

Legend:

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

    r172188a ra2f173b  
    359359        ui_resource_t *resource = NULL;
    360360        ui_pbutton_t *pbutton;
     361        ui_evclaim_t claim;
    361362        pos_event_t event;
    362363        gfx_rect_t rect;
     
    381382        ui_pbutton_set_rect(pbutton, &rect);
    382383
    383         /* Press outside does nothing */
     384        /* Press outside is not claimed and does nothing */
    384385        event.type = POS_PRESS;
    385386        event.hpos = 9;
    386387        event.vpos = 20;
    387         ui_pbutton_pos_event(pbutton, &event);
    388         PCUT_ASSERT_FALSE(pbutton->held);
    389 
    390         /* Press inside depresses button */
     388        claim = ui_pbutton_pos_event(pbutton, &event);
     389        PCUT_ASSERT_FALSE(pbutton->held);
     390        PCUT_ASSERT_EQUALS(ui_unclaimed, claim);
     391
     392        /* Press inside is claimed and depresses button */
    391393        event.type = POS_PRESS;
    392394        event.hpos = 10;
    393395        event.vpos = 20;
    394         ui_pbutton_pos_event(pbutton, &event);
    395         PCUT_ASSERT_TRUE(pbutton->held);
    396 
    397         /* Release outside (or anywhere) relases button */
     396        claim = ui_pbutton_pos_event(pbutton, &event);
     397        PCUT_ASSERT_TRUE(pbutton->held);
     398        PCUT_ASSERT_EQUALS(ui_claimed, claim);
     399
     400        /* Release outside (or anywhere) is claimed and relases button */
    398401        event.type = POS_RELEASE;
    399402        event.hpos = 9;
    400403        event.vpos = 20;
    401         ui_pbutton_pos_event(pbutton, &event);
    402         PCUT_ASSERT_FALSE(pbutton->held);
     404        claim = ui_pbutton_pos_event(pbutton, &event);
     405        PCUT_ASSERT_FALSE(pbutton->held);
     406        PCUT_ASSERT_EQUALS(ui_claimed, claim);
    403407
    404408        ui_pbutton_destroy(pbutton);
Note: See TracChangeset for help on using the changeset viewer.