Changeset 20d2c6c in mainline for uspace/lib/ui/test/wdecor.c
- Timestamp:
- 2020-10-21T20:58:52Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 172188a
- Parents:
- ba09d06
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/test/wdecor.c
rba09d06 r20d2c6c 32 32 #include <pcut/pcut.h> 33 33 #include <stdbool.h> 34 #include <ui/pbutton.h> 34 35 #include <ui/resource.h> 35 36 #include <ui/wdecor.h> … … 57 58 }; 58 59 60 static void test_wdecor_close(ui_wdecor_t *, void *); 59 61 static void test_wdecor_move(ui_wdecor_t *, void *, gfx_coord2_t *); 60 62 61 63 static ui_wdecor_cb_t test_wdecor_cb = { 64 .close = test_wdecor_close, 62 65 .move = test_wdecor_move 63 66 }; … … 84 87 85 88 typedef struct { 89 bool close; 86 90 bool move; 87 91 gfx_coord2_t pos; … … 179 183 rc = gfx_context_delete(gc); 180 184 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 185 } 186 187 /** Test ui_wdecor_close() */ 188 PCUT_TEST(close) 189 { 190 errno_t rc; 191 ui_wdecor_t *wdecor; 192 test_cb_resp_t resp; 193 194 rc = ui_wdecor_create(NULL, "Hello", &wdecor); 195 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 196 197 /* Close callback with no callbacks set */ 198 ui_wdecor_close(wdecor); 199 200 /* Close callback with close callback not implemented */ 201 ui_wdecor_set_cb(wdecor, &dummy_wdecor_cb, NULL); 202 ui_wdecor_close(wdecor); 203 204 /* Close callback with real callback set */ 205 resp.close = false; 206 ui_wdecor_set_cb(wdecor, &test_wdecor_cb, &resp); 207 ui_wdecor_close(wdecor); 208 PCUT_ASSERT_TRUE(resp.close); 209 210 ui_wdecor_destroy(wdecor); 181 211 } 182 212 … … 211 241 PCUT_ASSERT_INT_EQUALS(pos.x, resp.pos.x); 212 242 PCUT_ASSERT_INT_EQUALS(pos.y, resp.pos.y); 243 244 ui_wdecor_destroy(wdecor); 245 } 246 247 /** Clicking the close button generates close callback */ 248 PCUT_TEST(close_btn_clicked) 249 { 250 ui_wdecor_t *wdecor; 251 gfx_rect_t rect; 252 test_cb_resp_t resp; 253 errno_t rc; 254 255 rc = ui_wdecor_create(NULL, "Hello", &wdecor); 256 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 257 258 rect.p0.x = 10; 259 rect.p0.y = 20; 260 rect.p1.x = 100; 261 rect.p1.y = 200; 262 263 ui_wdecor_set_rect(wdecor, &rect); 264 265 ui_wdecor_set_cb(wdecor, &test_wdecor_cb, (void *) &resp); 266 267 resp.close = false; 268 269 ui_pbutton_clicked(wdecor->btn_close); 270 PCUT_ASSERT_TRUE(resp.close); 213 271 214 272 ui_wdecor_destroy(wdecor); … … 328 386 } 329 387 388 static void test_wdecor_close(ui_wdecor_t *wdecor, void *arg) 389 { 390 test_cb_resp_t *resp = (test_cb_resp_t *) arg; 391 392 resp->close = true; 393 } 394 330 395 static void test_wdecor_move(ui_wdecor_t *wdecor, void *arg, gfx_coord2_t *pos) 331 396 {
Note:
See TracChangeset
for help on using the changeset viewer.