Changeset 8965860c in mainline for uspace/lib/ui/test/scrollbar.c
- Timestamp:
- 2022-03-23T18:35:16Z (3 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7ca7215
- Parents:
- d4ea1f6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/test/scrollbar.c
rd4ea1f6 r8965860c 35 35 #include <ui/scrollbar.h> 36 36 #include <ui/resource.h> 37 #include <ui/ui.h> 38 #include <ui/window.h> 37 39 #include "../private/pbutton.h" 38 40 #include "../private/scrollbar.h" … … 41 43 42 44 PCUT_TEST_SUITE(scrollbar); 43 44 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);45 static errno_t testgc_set_color(void *, gfx_color_t *);46 static errno_t testgc_fill_rect(void *, gfx_rect_t *);47 static errno_t testgc_update(void *);48 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,49 gfx_bitmap_alloc_t *, void **);50 static errno_t testgc_bitmap_destroy(void *);51 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);52 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);53 54 static gfx_context_ops_t ops = {55 .set_clip_rect = testgc_set_clip_rect,56 .set_color = testgc_set_color,57 .fill_rect = testgc_fill_rect,58 .update = testgc_update,59 .bitmap_create = testgc_bitmap_create,60 .bitmap_destroy = testgc_bitmap_destroy,61 .bitmap_render = testgc_bitmap_render,62 .bitmap_get_alloc = testgc_bitmap_get_alloc63 };64 45 65 46 static void test_scrollbar_up(ui_scrollbar_t *, void *); … … 79 60 static ui_scrollbar_cb_t dummy_scrollbar_cb = { 80 61 }; 81 82 typedef struct {83 bool bm_created;84 bool bm_destroyed;85 gfx_bitmap_params_t bm_params;86 void *bm_pixels;87 gfx_rect_t bm_srect;88 gfx_coord2_t bm_offs;89 bool bm_rendered;90 bool bm_got_alloc;91 } test_gc_t;92 93 typedef struct {94 test_gc_t *tgc;95 gfx_bitmap_alloc_t alloc;96 bool myalloc;97 } testgc_bitmap_t;98 62 99 63 typedef struct { … … 109 73 PCUT_TEST(create_destroy) 110 74 { 111 errno_t rc; 112 gfx_context_t *gc = NULL; 113 test_gc_t tgc; 114 ui_resource_t *resource = NULL; 75 ui_t *ui = NULL; 76 ui_window_t *window = NULL; 77 ui_wnd_params_t params; 115 78 ui_scrollbar_t *scrollbar = NULL; 116 117 memset(&tgc, 0, sizeof(tgc)); 118 rc = gfx_context_new(&ops, &tgc, &gc); 119 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 120 121 rc = ui_resource_create(gc, false, &resource); 122 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 123 PCUT_ASSERT_NOT_NULL(resource); 124 125 rc = ui_scrollbar_create(resource, &scrollbar); 79 errno_t rc; 80 81 rc = ui_create_disp(NULL, &ui); 82 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 83 84 ui_wnd_params_init(¶ms); 85 params.caption = "Hello"; 86 87 rc = ui_window_create(ui, ¶ms, &window); 88 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 89 PCUT_ASSERT_NOT_NULL(window); 90 91 rc = ui_scrollbar_create(ui, window, &scrollbar); 126 92 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 127 93 PCUT_ASSERT_NOT_NULL(scrollbar); 128 94 129 95 ui_scrollbar_destroy(scrollbar); 130 ui_resource_destroy(resource); 131 132 rc = gfx_context_delete(gc); 133 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 96 ui_window_destroy(window); 97 ui_destroy(ui); 134 98 } 135 99 … … 143 107 PCUT_TEST(ctl) 144 108 { 145 errno_t rc; 146 gfx_context_t *gc = NULL; 147 test_gc_t tgc; 148 ui_resource_t *resource = NULL; 109 ui_t *ui = NULL; 110 ui_window_t *window = NULL; 111 ui_wnd_params_t params; 149 112 ui_scrollbar_t *scrollbar = NULL; 150 113 ui_control_t *control; 151 152 memset(&tgc, 0, sizeof(tgc)); 153 rc = gfx_context_new(&ops, &tgc, &gc); 154 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 155 156 rc = ui_resource_create(gc, false, &resource); 157 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 158 PCUT_ASSERT_NOT_NULL(resource); 159 160 rc = ui_scrollbar_create(resource, &scrollbar); 114 errno_t rc; 115 116 rc = ui_create_disp(NULL, &ui); 117 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 118 119 ui_wnd_params_init(¶ms); 120 params.caption = "Hello"; 121 122 rc = ui_window_create(ui, ¶ms, &window); 123 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 124 PCUT_ASSERT_NOT_NULL(window); 125 126 rc = ui_scrollbar_create(ui, window, &scrollbar); 161 127 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 162 128 PCUT_ASSERT_NOT_NULL(scrollbar); … … 166 132 167 133 ui_control_destroy(control); 168 ui_resource_destroy(resource); 169 170 rc = gfx_context_delete(gc); 171 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 134 ui_window_destroy(window); 135 ui_destroy(ui); 172 136 } 173 137 … … 175 139 PCUT_TEST(set_rect) 176 140 { 177 errno_t rc; 178 gfx_context_t *gc = NULL; 179 test_gc_t tgc; 180 ui_resource_t *resource = NULL; 141 ui_t *ui = NULL; 142 ui_window_t *window = NULL; 143 ui_wnd_params_t params; 181 144 ui_scrollbar_t *scrollbar = NULL; 182 145 gfx_rect_t rect; 183 184 memset(&tgc, 0, sizeof(tgc)); 185 rc = gfx_context_new(&ops, &tgc, &gc); 186 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 187 188 rc = ui_resource_create(gc, false, &resource); 189 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 190 PCUT_ASSERT_NOT_NULL(resource); 191 192 rc = ui_scrollbar_create(resource, &scrollbar); 146 errno_t rc; 147 148 rc = ui_create_disp(NULL, &ui); 149 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 150 151 ui_wnd_params_init(¶ms); 152 params.caption = "Hello"; 153 154 rc = ui_window_create(ui, ¶ms, &window); 155 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 156 PCUT_ASSERT_NOT_NULL(window); 157 158 rc = ui_scrollbar_create(ui, window, &scrollbar); 193 159 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 194 160 PCUT_ASSERT_NOT_NULL(scrollbar); … … 206 172 207 173 ui_scrollbar_destroy(scrollbar); 208 ui_resource_destroy(resource); 209 210 rc = gfx_context_delete(gc); 211 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 174 ui_window_destroy(window); 175 ui_destroy(ui); 212 176 } 213 177 … … 215 179 PCUT_TEST(paint_gfx) 216 180 { 217 errno_t rc; 218 gfx_context_t *gc = NULL; 219 test_gc_t tgc; 220 ui_resource_t *resource = NULL; 221 ui_scrollbar_t *scrollbar; 222 223 memset(&tgc, 0, sizeof(tgc)); 224 rc = gfx_context_new(&ops, &tgc, &gc); 225 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 226 227 rc = ui_resource_create(gc, false, &resource); 228 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 229 PCUT_ASSERT_NOT_NULL(resource); 230 231 rc = ui_scrollbar_create(resource, &scrollbar); 181 ui_t *ui = NULL; 182 ui_window_t *window = NULL; 183 ui_wnd_params_t params; 184 ui_scrollbar_t *scrollbar; 185 errno_t rc; 186 187 rc = ui_create_disp(NULL, &ui); 188 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 189 190 ui_wnd_params_init(¶ms); 191 params.caption = "Hello"; 192 193 rc = ui_window_create(ui, ¶ms, &window); 194 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 195 PCUT_ASSERT_NOT_NULL(window); 196 197 rc = ui_scrollbar_create(ui, window, &scrollbar); 232 198 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 233 199 … … 236 202 237 203 ui_scrollbar_destroy(scrollbar); 238 ui_resource_destroy(resource); 239 240 rc = gfx_context_delete(gc); 241 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 204 ui_window_destroy(window); 205 ui_destroy(ui); 242 206 } 243 207 … … 245 209 PCUT_TEST(paint_text) 246 210 { 247 errno_t rc; 248 gfx_context_t *gc = NULL; 249 test_gc_t tgc; 250 ui_resource_t *resource = NULL; 251 ui_scrollbar_t *scrollbar; 252 gfx_rect_t rect; 253 254 memset(&tgc, 0, sizeof(tgc)); 255 rc = gfx_context_new(&ops, &tgc, &gc); 256 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 257 258 rc = ui_resource_create(gc, true, &resource); 259 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 260 PCUT_ASSERT_NOT_NULL(resource); 261 262 rc = ui_scrollbar_create(resource, &scrollbar); 211 ui_t *ui = NULL; 212 ui_window_t *window = NULL; 213 ui_wnd_params_t params; 214 ui_scrollbar_t *scrollbar; 215 gfx_rect_t rect; 216 errno_t rc; 217 218 rc = ui_create_disp(NULL, &ui); 219 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 220 221 ui_wnd_params_init(¶ms); 222 params.caption = "Hello"; 223 224 rc = ui_window_create(ui, ¶ms, &window); 225 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 226 PCUT_ASSERT_NOT_NULL(window); 227 228 rc = ui_scrollbar_create(ui, window, &scrollbar); 263 229 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 264 230 … … 273 239 274 240 ui_scrollbar_destroy(scrollbar); 275 ui_resource_destroy(resource); 276 277 rc = gfx_context_delete(gc); 278 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 241 ui_window_destroy(window); 242 ui_destroy(ui); 243 } 244 245 /** ui_scrollbar_get_geom() returns scrollbar geometry */ 246 PCUT_TEST(get_geom) 247 { 248 ui_t *ui = NULL; 249 ui_window_t *window = NULL; 250 ui_wnd_params_t params; 251 ui_scrollbar_t *scrollbar; 252 ui_scrollbar_geom_t geom; 253 gfx_rect_t rect; 254 errno_t rc; 255 256 rc = ui_create_disp(NULL, &ui); 257 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 258 259 ui_wnd_params_init(¶ms); 260 params.caption = "Hello"; 261 262 rc = ui_window_create(ui, ¶ms, &window); 263 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 264 PCUT_ASSERT_NOT_NULL(window); 265 266 rc = ui_scrollbar_create(ui, window, &scrollbar); 267 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 268 269 rect.p0.x = 10; 270 rect.p0.y = 10; 271 rect.p1.x = 100; 272 rect.p1.y = 30; 273 ui_scrollbar_set_rect(scrollbar, &rect); 274 275 ui_scrollbar_get_geom(scrollbar, &geom); 276 PCUT_ASSERT_INT_EQUALS(11, geom.up_btn_rect.p0.x); 277 PCUT_ASSERT_INT_EQUALS(11, geom.up_btn_rect.p0.y); 278 PCUT_ASSERT_INT_EQUALS(99, geom.down_btn_rect.p1.x); 279 PCUT_ASSERT_INT_EQUALS(29, geom.down_btn_rect.p1.y); 280 281 ui_scrollbar_destroy(scrollbar); 282 ui_window_destroy(window); 283 ui_destroy(ui); 279 284 } 280 285 … … 282 287 PCUT_TEST(through_length) 283 288 { 284 errno_t rc; 285 gfx_context_t *gc = NULL; 286 test_gc_t tgc; 287 ui_resource_t *resource = NULL; 289 ui_t *ui = NULL; 290 ui_window_t *window = NULL; 291 ui_wnd_params_t params; 288 292 ui_scrollbar_t *scrollbar; 289 293 gfx_coord_t length; 290 294 gfx_rect_t rect; 291 292 memset(&tgc, 0, sizeof(tgc)); 293 rc = gfx_context_new(&ops, &tgc, &gc); 294 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 295 296 rc = ui_resource_create(gc, false, &resource); 297 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 298 PCUT_ASSERT_NOT_NULL(resource); 299 300 rc = ui_scrollbar_create(resource, &scrollbar); 295 errno_t rc; 296 297 rc = ui_create_disp(NULL, &ui); 298 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 299 300 ui_wnd_params_init(¶ms); 301 params.caption = "Hello"; 302 303 rc = ui_window_create(ui, ¶ms, &window); 304 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 305 PCUT_ASSERT_NOT_NULL(window); 306 307 rc = ui_scrollbar_create(ui, window, &scrollbar); 301 308 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 302 309 … … 315 322 316 323 ui_scrollbar_destroy(scrollbar); 317 ui_resource_destroy(resource); 318 319 rc = gfx_context_delete(gc); 320 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 324 ui_window_destroy(window); 325 ui_destroy(ui); 321 326 } 322 327 … … 324 329 PCUT_TEST(move_length) 325 330 { 326 errno_t rc; 327 gfx_context_t *gc = NULL; 328 test_gc_t tgc; 329 ui_resource_t *resource = NULL; 331 ui_t *ui = NULL; 332 ui_window_t *window = NULL; 333 ui_wnd_params_t params; 330 334 ui_scrollbar_t *scrollbar; 331 335 gfx_coord_t length; 332 336 gfx_rect_t rect; 333 334 memset(&tgc, 0, sizeof(tgc)); 335 rc = gfx_context_new(&ops, &tgc, &gc); 336 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 337 338 rc = ui_resource_create(gc, false, &resource); 339 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 340 PCUT_ASSERT_NOT_NULL(resource); 341 342 rc = ui_scrollbar_create(resource, &scrollbar); 337 errno_t rc; 338 339 rc = ui_create_disp(NULL, &ui); 340 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 341 342 ui_wnd_params_init(¶ms); 343 params.caption = "Hello"; 344 345 rc = ui_window_create(ui, ¶ms, &window); 346 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 347 PCUT_ASSERT_NOT_NULL(window); 348 349 rc = ui_scrollbar_create(ui, window, &scrollbar); 343 350 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 344 351 … … 357 364 358 365 ui_scrollbar_destroy(scrollbar); 359 ui_resource_destroy(resource); 360 361 rc = gfx_context_delete(gc); 362 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 366 ui_window_destroy(window); 367 ui_destroy(ui); 363 368 } 364 369 … … 366 371 PCUT_TEST(get_pos) 367 372 { 368 errno_t rc; 369 gfx_context_t *gc = NULL; 370 test_gc_t tgc; 371 ui_resource_t *resource = NULL; 373 ui_t *ui = NULL; 374 ui_window_t *window = NULL; 375 ui_wnd_params_t params; 372 376 ui_scrollbar_t *scrollbar; 373 377 gfx_coord_t pos; 374 378 gfx_rect_t rect; 375 376 memset(&tgc, 0, sizeof(tgc)); 377 rc = gfx_context_new(&ops, &tgc, &gc); 378 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 379 380 rc = ui_resource_create(gc, false, &resource); 381 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 382 PCUT_ASSERT_NOT_NULL(resource); 383 384 rc = ui_scrollbar_create(resource, &scrollbar); 379 errno_t rc; 380 381 rc = ui_create_disp(NULL, &ui); 382 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 383 384 ui_wnd_params_init(¶ms); 385 params.caption = "Hello"; 386 387 rc = ui_window_create(ui, ¶ms, &window); 388 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 389 PCUT_ASSERT_NOT_NULL(window); 390 391 rc = ui_scrollbar_create(ui, window, &scrollbar); 385 392 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 386 393 … … 398 405 399 406 ui_scrollbar_destroy(scrollbar); 400 ui_resource_destroy(resource); 401 402 rc = gfx_context_delete(gc); 403 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 407 ui_window_destroy(window); 408 ui_destroy(ui); 404 409 } 405 410 … … 407 412 PCUT_TEST(set_thumb_length) 408 413 { 409 errno_t rc; 410 gfx_context_t *gc = NULL; 411 test_gc_t tgc; 412 ui_resource_t *resource = NULL; 413 ui_scrollbar_t *scrollbar; 414 gfx_rect_t rect; 415 416 memset(&tgc, 0, sizeof(tgc)); 417 rc = gfx_context_new(&ops, &tgc, &gc); 418 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 419 420 rc = ui_resource_create(gc, false, &resource); 421 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 422 PCUT_ASSERT_NOT_NULL(resource); 423 424 rc = ui_scrollbar_create(resource, &scrollbar); 414 ui_t *ui = NULL; 415 ui_window_t *window = NULL; 416 ui_wnd_params_t params; 417 ui_scrollbar_t *scrollbar; 418 gfx_rect_t rect; 419 errno_t rc; 420 421 rc = ui_create_disp(NULL, &ui); 422 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 423 424 ui_wnd_params_init(¶ms); 425 params.caption = "Hello"; 426 427 rc = ui_window_create(ui, ¶ms, &window); 428 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 429 PCUT_ASSERT_NOT_NULL(window); 430 431 rc = ui_scrollbar_create(ui, window, &scrollbar); 425 432 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 426 433 … … 437 444 438 445 ui_scrollbar_destroy(scrollbar); 439 ui_resource_destroy(resource); 440 441 rc = gfx_context_delete(gc); 442 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 446 ui_window_destroy(window); 447 ui_destroy(ui); 443 448 } 444 449 … … 446 451 PCUT_TEST(set_pos) 447 452 { 448 errno_t rc; 449 gfx_context_t *gc = NULL; 450 test_gc_t tgc; 451 ui_resource_t *resource = NULL; 453 ui_t *ui = NULL; 454 ui_window_t *window = NULL; 455 ui_wnd_params_t params; 452 456 ui_scrollbar_t *scrollbar; 453 457 gfx_coord_t pos; 454 458 gfx_rect_t rect; 455 456 memset(&tgc, 0, sizeof(tgc)); 457 rc = gfx_context_new(&ops, &tgc, &gc); 458 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 459 460 rc = ui_resource_create(gc, false, &resource); 461 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 462 PCUT_ASSERT_NOT_NULL(resource); 463 464 rc = ui_scrollbar_create(resource, &scrollbar); 459 errno_t rc; 460 461 rc = ui_create_disp(NULL, &ui); 462 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 463 464 ui_wnd_params_init(¶ms); 465 params.caption = "Hello"; 466 467 rc = ui_window_create(ui, ¶ms, &window); 468 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 469 PCUT_ASSERT_NOT_NULL(window); 470 471 rc = ui_scrollbar_create(ui, window, &scrollbar); 465 472 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 466 473 … … 489 496 490 497 ui_scrollbar_destroy(scrollbar); 491 ui_resource_destroy(resource); 492 493 rc = gfx_context_delete(gc); 494 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 498 ui_window_destroy(window); 499 ui_destroy(ui); 495 500 } 496 501 … … 498 503 PCUT_TEST(thumb_press_release) 499 504 { 500 errno_t rc; 501 gfx_context_t *gc = NULL; 502 test_gc_t tgc; 503 ui_resource_t *resource = NULL; 505 ui_t *ui = NULL; 506 ui_window_t *window = NULL; 507 ui_wnd_params_t params; 504 508 gfx_coord2_t pos; 505 509 gfx_rect_t rect; 506 510 ui_scrollbar_t *scrollbar; 507 511 test_cb_resp_t resp; 508 509 memset(&tgc, 0, sizeof(tgc)); 510 rc = gfx_context_new(&ops, &tgc, &gc); 511 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 512 513 rc = ui_resource_create(gc, false, &resource); 514 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 515 PCUT_ASSERT_NOT_NULL(resource); 516 517 rc = ui_scrollbar_create(resource, &scrollbar); 512 errno_t rc; 513 514 rc = ui_create_disp(NULL, &ui); 515 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 516 517 ui_wnd_params_init(¶ms); 518 params.caption = "Hello"; 519 520 rc = ui_window_create(ui, ¶ms, &window); 521 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 522 PCUT_ASSERT_NOT_NULL(window); 523 524 rc = ui_scrollbar_create(ui, window, &scrollbar); 518 525 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 519 526 … … 545 552 546 553 ui_scrollbar_destroy(scrollbar); 547 ui_resource_destroy(resource); 548 549 rc = gfx_context_delete(gc); 550 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 554 ui_window_destroy(window); 555 ui_destroy(ui); 551 556 } 552 557 … … 554 559 PCUT_TEST(thumb_press_update_release) 555 560 { 556 errno_t rc; 557 gfx_context_t *gc = NULL; 558 test_gc_t tgc; 559 ui_resource_t *resource = NULL; 561 ui_t *ui = NULL; 562 ui_window_t *window = NULL; 563 ui_wnd_params_t params; 560 564 gfx_coord2_t pos; 561 565 gfx_rect_t rect; 562 566 ui_scrollbar_t *scrollbar; 563 567 test_cb_resp_t resp; 564 565 memset(&tgc, 0, sizeof(tgc)); 566 rc = gfx_context_new(&ops, &tgc, &gc); 567 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 568 569 rc = ui_resource_create(gc, false, &resource); 570 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 571 PCUT_ASSERT_NOT_NULL(resource); 572 573 rc = ui_scrollbar_create(resource, &scrollbar); 568 errno_t rc; 569 570 rc = ui_create_disp(NULL, &ui); 571 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 572 573 ui_wnd_params_init(¶ms); 574 params.caption = "Hello"; 575 576 rc = ui_window_create(ui, ¶ms, &window); 577 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 578 PCUT_ASSERT_NOT_NULL(window); 579 580 rc = ui_scrollbar_create(ui, window, &scrollbar); 574 581 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 575 582 … … 609 616 610 617 ui_scrollbar_destroy(scrollbar); 611 ui_resource_destroy(resource); 612 613 rc = gfx_context_delete(gc); 614 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 618 ui_window_destroy(window); 619 ui_destroy(ui); 615 620 } 616 621 … … 618 623 PCUT_TEST(up_through_press_release) 619 624 { 620 errno_t rc; 621 gfx_context_t *gc = NULL; 622 test_gc_t tgc; 623 ui_resource_t *resource = NULL; 625 ui_t *ui = NULL; 626 ui_window_t *window = NULL; 627 ui_wnd_params_t params; 624 628 gfx_coord2_t pos; 625 629 gfx_rect_t rect; 626 630 ui_scrollbar_t *scrollbar; 627 631 test_cb_resp_t resp; 628 629 memset(&tgc, 0, sizeof(tgc)); 630 rc = gfx_context_new(&ops, &tgc, &gc); 631 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 632 633 rc = ui_resource_create(gc, false, &resource); 634 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 635 PCUT_ASSERT_NOT_NULL(resource); 636 637 rc = ui_scrollbar_create(resource, &scrollbar); 632 errno_t rc; 633 634 rc = ui_create_disp(NULL, &ui); 635 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 636 637 ui_wnd_params_init(¶ms); 638 params.caption = "Hello"; 639 640 rc = ui_window_create(ui, ¶ms, &window); 641 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 642 PCUT_ASSERT_NOT_NULL(window); 643 644 rc = ui_scrollbar_create(ui, window, &scrollbar); 638 645 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 639 646 … … 661 668 662 669 ui_scrollbar_destroy(scrollbar); 663 ui_resource_destroy(resource); 664 665 rc = gfx_context_delete(gc); 666 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 670 ui_window_destroy(window); 671 ui_destroy(ui); 667 672 } 668 673 … … 670 675 PCUT_TEST(down_through_press_release) 671 676 { 672 errno_t rc; 673 gfx_context_t *gc = NULL; 674 test_gc_t tgc; 675 ui_resource_t *resource = NULL; 677 ui_t *ui = NULL; 678 ui_window_t *window = NULL; 679 ui_wnd_params_t params; 676 680 gfx_coord2_t pos; 677 681 gfx_rect_t rect; 678 682 ui_scrollbar_t *scrollbar; 679 683 test_cb_resp_t resp; 680 681 memset(&tgc, 0, sizeof(tgc)); 682 rc = gfx_context_new(&ops, &tgc, &gc); 683 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 684 685 rc = ui_resource_create(gc, false, &resource); 686 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 687 PCUT_ASSERT_NOT_NULL(resource); 688 689 rc = ui_scrollbar_create(resource, &scrollbar); 684 errno_t rc; 685 686 rc = ui_create_disp(NULL, &ui); 687 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 688 689 ui_wnd_params_init(¶ms); 690 params.caption = "Hello"; 691 692 rc = ui_window_create(ui, ¶ms, &window); 693 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 694 PCUT_ASSERT_NOT_NULL(window); 695 696 rc = ui_scrollbar_create(ui, window, &scrollbar); 690 697 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 691 698 … … 713 720 714 721 ui_scrollbar_destroy(scrollbar); 715 ui_resource_destroy(resource); 716 717 rc = gfx_context_delete(gc); 718 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 722 ui_window_destroy(window); 723 ui_destroy(ui); 724 } 725 726 /** Updating state of throughs when cursor or thumb moves */ 727 PCUT_TEST(throughs_update) 728 { 729 ui_t *ui = NULL; 730 ui_window_t *window = NULL; 731 ui_wnd_params_t params; 732 gfx_coord2_t pos; 733 gfx_rect_t rect; 734 ui_scrollbar_t *scrollbar; 735 errno_t rc; 736 737 rc = ui_create_disp(NULL, &ui); 738 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 739 740 ui_wnd_params_init(¶ms); 741 params.caption = "Hello"; 742 743 rc = ui_window_create(ui, ¶ms, &window); 744 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 745 PCUT_ASSERT_NOT_NULL(window); 746 747 rc = ui_scrollbar_create(ui, window, &scrollbar); 748 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 749 750 rect.p0.x = 10; 751 rect.p0.y = 20; 752 rect.p1.x = 110; 753 rect.p1.y = 120; 754 ui_scrollbar_set_rect(scrollbar, &rect); 755 756 PCUT_ASSERT_FALSE(scrollbar->down_through_inside); 757 758 pos.x = 60; 759 pos.y = 22; 760 761 ui_scrollbar_throughs_update(scrollbar, &pos); 762 PCUT_ASSERT_TRUE(scrollbar->down_through_inside); 763 764 ui_scrollbar_destroy(scrollbar); 765 ui_window_destroy(window); 766 ui_destroy(ui); 719 767 } 720 768 … … 722 770 PCUT_TEST(up) 723 771 { 724 ui_scrollbar_t *scrollbar; 725 errno_t rc; 726 gfx_context_t *gc = NULL; 727 test_gc_t tgc; 728 ui_resource_t *resource = NULL; 772 ui_t *ui = NULL; 773 ui_window_t *window = NULL; 774 ui_wnd_params_t params; 775 ui_scrollbar_t *scrollbar; 729 776 test_cb_resp_t resp; 730 731 memset(&tgc, 0, sizeof(tgc)); 732 rc = gfx_context_new(&ops, &tgc, &gc); 733 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 734 735 rc = ui_resource_create(gc, false, &resource); 736 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 737 PCUT_ASSERT_NOT_NULL(resource); 738 739 rc = ui_scrollbar_create(resource, &scrollbar); 777 errno_t rc; 778 779 rc = ui_create_disp(NULL, &ui); 780 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 781 782 ui_wnd_params_init(¶ms); 783 params.caption = "Hello"; 784 785 rc = ui_window_create(ui, ¶ms, &window); 786 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 787 PCUT_ASSERT_NOT_NULL(window); 788 789 rc = ui_scrollbar_create(ui, window, &scrollbar); 740 790 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 741 791 … … 754 804 755 805 ui_scrollbar_destroy(scrollbar); 756 ui_resource_destroy(resource); 757 758 rc = gfx_context_delete(gc); 759 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 806 ui_window_destroy(window); 807 ui_destroy(ui); 760 808 } 761 809 … … 763 811 PCUT_TEST(down) 764 812 { 765 ui_scrollbar_t *scrollbar; 766 errno_t rc; 767 gfx_context_t *gc = NULL; 768 test_gc_t tgc; 769 ui_resource_t *resource = NULL; 813 ui_t *ui = NULL; 814 ui_window_t *window = NULL; 815 ui_wnd_params_t params; 816 ui_scrollbar_t *scrollbar; 770 817 test_cb_resp_t resp; 771 772 memset(&tgc, 0, sizeof(tgc)); 773 rc = gfx_context_new(&ops, &tgc, &gc); 774 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 775 776 rc = ui_resource_create(gc, false, &resource); 777 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 778 PCUT_ASSERT_NOT_NULL(resource); 779 780 rc = ui_scrollbar_create(resource, &scrollbar); 818 errno_t rc; 819 820 rc = ui_create_disp(NULL, &ui); 821 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 822 823 ui_wnd_params_init(¶ms); 824 params.caption = "Hello"; 825 826 rc = ui_window_create(ui, ¶ms, &window); 827 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 828 PCUT_ASSERT_NOT_NULL(window); 829 830 rc = ui_scrollbar_create(ui, window, &scrollbar); 781 831 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 782 832 … … 795 845 796 846 ui_scrollbar_destroy(scrollbar); 797 ui_resource_destroy(resource); 798 799 rc = gfx_context_delete(gc); 800 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 847 ui_window_destroy(window); 848 ui_destroy(ui); 801 849 } 802 850 … … 804 852 PCUT_TEST(page_up) 805 853 { 806 ui_scrollbar_t *scrollbar; 807 errno_t rc; 808 gfx_context_t *gc = NULL; 809 test_gc_t tgc; 810 ui_resource_t *resource = NULL; 854 ui_t *ui = NULL; 855 ui_window_t *window = NULL; 856 ui_wnd_params_t params; 857 ui_scrollbar_t *scrollbar; 811 858 test_cb_resp_t resp; 812 813 memset(&tgc, 0, sizeof(tgc)); 814 rc = gfx_context_new(&ops, &tgc, &gc); 815 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 816 817 rc = ui_resource_create(gc, false, &resource); 818 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 819 PCUT_ASSERT_NOT_NULL(resource); 820 821 rc = ui_scrollbar_create(resource, &scrollbar); 859 errno_t rc; 860 861 rc = ui_create_disp(NULL, &ui); 862 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 863 864 ui_wnd_params_init(¶ms); 865 params.caption = "Hello"; 866 867 rc = ui_window_create(ui, ¶ms, &window); 868 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 869 PCUT_ASSERT_NOT_NULL(window); 870 871 rc = ui_scrollbar_create(ui, window, &scrollbar); 822 872 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 823 873 … … 836 886 837 887 ui_scrollbar_destroy(scrollbar); 838 ui_resource_destroy(resource); 839 840 rc = gfx_context_delete(gc); 841 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 888 ui_window_destroy(window); 889 ui_destroy(ui); 842 890 } 843 891 … … 845 893 PCUT_TEST(page_down) 846 894 { 847 ui_scrollbar_t *scrollbar; 848 errno_t rc; 849 gfx_context_t *gc = NULL; 850 test_gc_t tgc; 851 ui_resource_t *resource = NULL; 895 ui_t *ui = NULL; 896 ui_window_t *window = NULL; 897 ui_wnd_params_t params; 898 ui_scrollbar_t *scrollbar; 852 899 test_cb_resp_t resp; 853 854 memset(&tgc, 0, sizeof(tgc)); 855 rc = gfx_context_new(&ops, &tgc, &gc); 856 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 857 858 rc = ui_resource_create(gc, false, &resource); 859 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 860 PCUT_ASSERT_NOT_NULL(resource); 861 862 rc = ui_scrollbar_create(resource, &scrollbar); 900 errno_t rc; 901 902 rc = ui_create_disp(NULL, &ui); 903 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 904 905 ui_wnd_params_init(¶ms); 906 params.caption = "Hello"; 907 908 rc = ui_window_create(ui, ¶ms, &window); 909 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 910 PCUT_ASSERT_NOT_NULL(window); 911 912 rc = ui_scrollbar_create(ui, window, &scrollbar); 863 913 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 864 914 … … 877 927 878 928 ui_scrollbar_destroy(scrollbar); 879 ui_resource_destroy(resource); 880 881 rc = gfx_context_delete(gc); 882 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 929 ui_window_destroy(window); 930 ui_destroy(ui); 883 931 } 884 932 … … 886 934 PCUT_TEST(moved) 887 935 { 888 ui_scrollbar_t *scrollbar; 889 errno_t rc; 890 gfx_context_t *gc = NULL; 891 test_gc_t tgc; 892 ui_resource_t *resource = NULL; 936 ui_t *ui = NULL; 937 ui_window_t *window = NULL; 938 ui_wnd_params_t params; 939 ui_scrollbar_t *scrollbar; 893 940 test_cb_resp_t resp; 894 895 memset(&tgc, 0, sizeof(tgc)); 896 rc = gfx_context_new(&ops, &tgc, &gc); 897 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 898 899 rc = ui_resource_create(gc, false, &resource); 900 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 901 PCUT_ASSERT_NOT_NULL(resource); 902 903 rc = ui_scrollbar_create(resource, &scrollbar); 941 errno_t rc; 942 943 rc = ui_create_disp(NULL, &ui); 944 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 945 946 ui_wnd_params_init(¶ms); 947 params.caption = "Hello"; 948 949 rc = ui_window_create(ui, ¶ms, &window); 950 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 951 PCUT_ASSERT_NOT_NULL(window); 952 953 rc = ui_scrollbar_create(ui, window, &scrollbar); 904 954 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 905 955 … … 920 970 921 971 ui_scrollbar_destroy(scrollbar); 922 ui_resource_destroy(resource); 923 924 rc = gfx_context_delete(gc); 925 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 972 ui_window_destroy(window); 973 ui_destroy(ui); 926 974 } 927 975 … … 929 977 PCUT_TEST(pos_event_press_release_thumb) 930 978 { 931 errno_t rc; 932 gfx_context_t *gc = NULL; 933 test_gc_t tgc; 934 ui_resource_t *resource = NULL; 979 ui_t *ui = NULL; 980 ui_window_t *window = NULL; 981 ui_wnd_params_t params; 935 982 ui_scrollbar_t *scrollbar; 936 983 ui_evclaim_t claim; 937 984 pos_event_t event; 938 985 gfx_rect_t rect; 939 940 memset(&tgc, 0, sizeof(tgc)); 941 rc = gfx_context_new(&ops, &tgc, &gc); 942 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 943 944 rc = ui_resource_create(gc, false, &resource); 945 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 946 PCUT_ASSERT_NOT_NULL(resource); 947 948 rc = ui_scrollbar_create(resource, &scrollbar); 986 errno_t rc; 987 988 rc = ui_create_disp(NULL, &ui); 989 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 990 991 ui_wnd_params_init(¶ms); 992 params.caption = "Hello"; 993 994 rc = ui_window_create(ui, ¶ms, &window); 995 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 996 PCUT_ASSERT_NOT_NULL(window); 997 998 rc = ui_scrollbar_create(ui, window, &scrollbar); 949 999 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 950 1000 … … 982 1032 983 1033 ui_scrollbar_destroy(scrollbar); 984 ui_resource_destroy(resource); 985 986 rc = gfx_context_delete(gc); 987 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1034 ui_window_destroy(window); 1035 ui_destroy(ui); 988 1036 } 989 1037 … … 991 1039 PCUT_TEST(pos_event_press_release_up_btn) 992 1040 { 993 errno_t rc; 994 gfx_context_t *gc = NULL; 995 test_gc_t tgc; 996 ui_resource_t *resource = NULL; 1041 ui_t *ui = NULL; 1042 ui_window_t *window = NULL; 1043 ui_wnd_params_t params; 997 1044 ui_scrollbar_t *scrollbar; 998 1045 ui_evclaim_t claim; 999 1046 pos_event_t event; 1000 1047 gfx_rect_t rect; 1001 1002 memset(&tgc, 0, sizeof(tgc)); 1003 rc = gfx_context_new(&ops, &tgc, &gc); 1004 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1005 1006 rc = ui_resource_create(gc, false, &resource); 1007 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1008 PCUT_ASSERT_NOT_NULL(resource); 1009 1010 rc = ui_scrollbar_create(resource, &scrollbar); 1048 errno_t rc; 1049 1050 rc = ui_create_disp(NULL, &ui); 1051 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1052 1053 ui_wnd_params_init(¶ms); 1054 params.caption = "Hello"; 1055 1056 rc = ui_window_create(ui, ¶ms, &window); 1057 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1058 PCUT_ASSERT_NOT_NULL(window); 1059 1060 rc = ui_scrollbar_create(ui, window, &scrollbar); 1011 1061 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1012 1062 … … 1028 1078 1029 1079 ui_scrollbar_destroy(scrollbar); 1030 ui_resource_destroy(resource); 1031 1032 rc = gfx_context_delete(gc); 1033 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1080 ui_window_destroy(window); 1081 ui_destroy(ui); 1034 1082 } 1035 1083 … … 1037 1085 PCUT_TEST(pos_event_press_release_up_through) 1038 1086 { 1039 errno_t rc; 1040 gfx_context_t *gc = NULL; 1041 test_gc_t tgc; 1042 ui_resource_t *resource = NULL; 1087 ui_t *ui = NULL; 1088 ui_window_t *window = NULL; 1089 ui_wnd_params_t params; 1043 1090 ui_scrollbar_t *scrollbar; 1044 1091 ui_evclaim_t claim; 1045 1092 pos_event_t event; 1046 1093 gfx_rect_t rect; 1047 1048 memset(&tgc, 0, sizeof(tgc)); 1049 rc = gfx_context_new(&ops, &tgc, &gc); 1050 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1051 1052 rc = ui_resource_create(gc, false, &resource); 1053 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1054 PCUT_ASSERT_NOT_NULL(resource); 1055 1056 rc = ui_scrollbar_create(resource, &scrollbar); 1094 errno_t rc; 1095 1096 rc = ui_create_disp(NULL, &ui); 1097 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1098 1099 ui_wnd_params_init(¶ms); 1100 params.caption = "Hello"; 1101 1102 rc = ui_window_create(ui, ¶ms, &window); 1103 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1104 PCUT_ASSERT_NOT_NULL(window); 1105 1106 rc = ui_scrollbar_create(ui, window, &scrollbar); 1057 1107 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1058 1108 … … 1085 1135 1086 1136 ui_scrollbar_destroy(scrollbar); 1087 ui_resource_destroy(resource); 1088 1089 rc = gfx_context_delete(gc); 1090 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1137 ui_window_destroy(window); 1138 ui_destroy(ui); 1091 1139 } 1092 1140 … … 1094 1142 PCUT_TEST(pos_event_press_release_down_through) 1095 1143 { 1096 errno_t rc; 1097 gfx_context_t *gc = NULL; 1098 test_gc_t tgc; 1099 ui_resource_t *resource = NULL; 1144 ui_t *ui = NULL; 1145 ui_window_t *window = NULL; 1146 ui_wnd_params_t params; 1100 1147 ui_scrollbar_t *scrollbar; 1101 1148 ui_evclaim_t claim; 1102 1149 pos_event_t event; 1103 1150 gfx_rect_t rect; 1104 1105 memset(&tgc, 0, sizeof(tgc)); 1106 rc = gfx_context_new(&ops, &tgc, &gc); 1107 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1108 1109 rc = ui_resource_create(gc, false, &resource); 1110 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1111 PCUT_ASSERT_NOT_NULL(resource); 1112 1113 rc = ui_scrollbar_create(resource, &scrollbar); 1151 errno_t rc; 1152 1153 rc = ui_create_disp(NULL, &ui); 1154 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1155 1156 ui_wnd_params_init(¶ms); 1157 params.caption = "Hello"; 1158 1159 rc = ui_window_create(ui, ¶ms, &window); 1160 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1161 PCUT_ASSERT_NOT_NULL(window); 1162 1163 rc = ui_scrollbar_create(ui, window, &scrollbar); 1114 1164 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1115 1165 … … 1139 1189 1140 1190 ui_scrollbar_destroy(scrollbar); 1141 ui_resource_destroy(resource); 1142 1143 rc = gfx_context_delete(gc); 1144 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1191 ui_window_destroy(window); 1192 ui_destroy(ui); 1145 1193 } 1146 1194 … … 1148 1196 PCUT_TEST(pos_event_press_relese_down_btn) 1149 1197 { 1150 errno_t rc; 1151 gfx_context_t *gc = NULL; 1152 test_gc_t tgc; 1153 ui_resource_t *resource = NULL; 1198 ui_t *ui = NULL; 1199 ui_window_t *window = NULL; 1200 ui_wnd_params_t params; 1154 1201 ui_scrollbar_t *scrollbar; 1155 1202 ui_evclaim_t claim; 1156 1203 pos_event_t event; 1157 1204 gfx_rect_t rect; 1158 1159 memset(&tgc, 0, sizeof(tgc)); 1160 rc = gfx_context_new(&ops, &tgc, &gc); 1161 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1162 1163 rc = ui_resource_create(gc, false, &resource); 1164 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1165 PCUT_ASSERT_NOT_NULL(resource); 1166 1167 rc = ui_scrollbar_create(resource, &scrollbar); 1205 errno_t rc; 1206 1207 rc = ui_create_disp(NULL, &ui); 1208 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1209 1210 ui_wnd_params_init(¶ms); 1211 params.caption = "Hello"; 1212 1213 rc = ui_window_create(ui, ¶ms, &window); 1214 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1215 PCUT_ASSERT_NOT_NULL(window); 1216 1217 rc = ui_scrollbar_create(ui, window, &scrollbar); 1168 1218 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1169 1219 … … 1185 1235 1186 1236 ui_scrollbar_destroy(scrollbar); 1187 ui_resource_destroy(resource); 1188 1189 rc = gfx_context_delete(gc); 1190 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1191 } 1192 1193 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect) 1194 { 1195 (void) arg; 1196 (void) rect; 1197 return EOK; 1198 } 1199 1200 static errno_t testgc_set_color(void *arg, gfx_color_t *color) 1201 { 1202 (void) arg; 1203 (void) color; 1204 return EOK; 1205 } 1206 1207 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect) 1208 { 1209 (void) arg; 1210 (void) rect; 1211 return EOK; 1212 } 1213 1214 static errno_t testgc_update(void *arg) 1215 { 1216 (void) arg; 1217 return EOK; 1218 } 1219 1220 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params, 1221 gfx_bitmap_alloc_t *alloc, void **rbm) 1222 { 1223 test_gc_t *tgc = (test_gc_t *) arg; 1224 testgc_bitmap_t *tbm; 1225 1226 tbm = calloc(1, sizeof(testgc_bitmap_t)); 1227 if (tbm == NULL) 1228 return ENOMEM; 1229 1230 if (alloc == NULL) { 1231 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) * 1232 sizeof(uint32_t); 1233 tbm->alloc.off0 = 0; 1234 tbm->alloc.pixels = calloc(sizeof(uint32_t), 1235 (params->rect.p1.x - params->rect.p0.x) * 1236 (params->rect.p1.y - params->rect.p0.y)); 1237 tbm->myalloc = true; 1238 if (tbm->alloc.pixels == NULL) { 1239 free(tbm); 1240 return ENOMEM; 1241 } 1242 } else { 1243 tbm->alloc = *alloc; 1244 } 1245 1246 tbm->tgc = tgc; 1247 tgc->bm_created = true; 1248 tgc->bm_params = *params; 1249 tgc->bm_pixels = tbm->alloc.pixels; 1250 *rbm = (void *)tbm; 1251 return EOK; 1252 } 1253 1254 static errno_t testgc_bitmap_destroy(void *bm) 1255 { 1256 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm; 1257 if (tbm->myalloc) 1258 free(tbm->alloc.pixels); 1259 tbm->tgc->bm_destroyed = true; 1260 free(tbm); 1261 return EOK; 1262 } 1263 1264 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect, 1265 gfx_coord2_t *offs) 1266 { 1267 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm; 1268 1269 tbm->tgc->bm_rendered = true; 1270 if (srect != NULL) 1271 tbm->tgc->bm_srect = *srect; 1272 if (offs != NULL) 1273 tbm->tgc->bm_offs = *offs; 1274 return EOK; 1275 } 1276 1277 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc) 1278 { 1279 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm; 1280 *alloc = tbm->alloc; 1281 tbm->tgc->bm_got_alloc = true; 1282 return EOK; 1237 ui_window_destroy(window); 1238 ui_destroy(ui); 1283 1239 } 1284 1240
Note:
See TracChangeset
for help on using the changeset viewer.