Changes in uspace/app/nav/test/panel.c [a29af37:54ddb59] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nav/test/panel.c
ra29af37 r54ddb59 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 55 55 PCUT_TEST(create_destroy) 56 56 { 57 panel_t *panel; 58 errno_t rc; 59 60 rc = panel_create(NULL, true, &panel); 61 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 62 63 panel_destroy(panel); 64 } 65 66 /** panel_set_cb() sets callback */ 67 PCUT_TEST(set_cb) 68 { 69 panel_t *panel; 70 errno_t rc; 71 test_resp_t resp; 72 73 rc = panel_create(NULL, true, &panel); 74 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 75 76 panel_set_cb(panel, &test_cb, &resp); 77 PCUT_ASSERT_EQUALS(&test_cb, panel->cb); 78 PCUT_ASSERT_EQUALS(&resp, panel->cb_arg); 79 80 panel_destroy(panel); 81 } 82 83 /** Test panel_paint() */ 84 PCUT_TEST(paint) 85 { 57 86 ui_t *ui; 58 87 ui_window_t *window; … … 73 102 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 74 103 104 rc = panel_paint(panel); 105 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 106 75 107 panel_destroy(panel); 76 108 ui_window_destroy(window); … … 78 110 } 79 111 80 /** panel_set_cb() sets callback */81 PCUT_TEST(set_cb)82 {83 ui_t *ui;84 ui_window_t *window;85 ui_wnd_params_t params;86 panel_t *panel;87 errno_t rc;88 test_resp_t resp;89 90 rc = ui_create_disp(NULL, &ui);91 PCUT_ASSERT_ERRNO_VAL(EOK, rc);92 93 ui_wnd_params_init(¶ms);94 params.caption = "Test";95 96 rc = ui_window_create(ui, ¶ms, &window);97 PCUT_ASSERT_ERRNO_VAL(EOK, rc);98 99 rc = panel_create(window, true, &panel);100 PCUT_ASSERT_ERRNO_VAL(EOK, rc);101 102 panel_set_cb(panel, &test_cb, &resp);103 PCUT_ASSERT_EQUALS(&test_cb, panel->cb);104 PCUT_ASSERT_EQUALS(&resp, panel->cb_arg);105 106 panel_destroy(panel);107 ui_window_destroy(window);108 ui_destroy(ui);109 }110 111 /** Test panel_paint() */112 PCUT_TEST(paint)113 {114 ui_t *ui;115 ui_window_t *window;116 ui_wnd_params_t params;117 panel_t *panel;118 errno_t rc;119 120 rc = ui_create_disp(NULL, &ui);121 PCUT_ASSERT_ERRNO_VAL(EOK, rc);122 123 ui_wnd_params_init(¶ms);124 params.caption = "Test";125 126 rc = ui_window_create(ui, ¶ms, &window);127 PCUT_ASSERT_ERRNO_VAL(EOK, rc);128 129 rc = panel_create(window, true, &panel);130 PCUT_ASSERT_ERRNO_VAL(EOK, rc);131 132 rc = panel_paint(panel);133 PCUT_ASSERT_ERRNO_VAL(EOK, rc);134 135 panel_destroy(panel);136 ui_window_destroy(window);137 ui_destroy(ui);138 }139 140 112 /** panel_ctl() returns a valid UI control */ 141 113 PCUT_TEST(ctl) 142 114 { 143 ui_t *ui;144 ui_window_t *window;145 ui_wnd_params_t params;146 115 panel_t *panel; 147 116 ui_control_t *control; 148 117 errno_t rc; 149 118 150 rc = ui_create_disp(NULL, &ui); 151 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 152 153 ui_wnd_params_init(¶ms); 154 params.caption = "Test"; 155 156 rc = ui_window_create(ui, ¶ms, &window); 157 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 158 159 rc = panel_create(window, true, &panel); 119 rc = panel_create(NULL, true, &panel); 160 120 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 161 121 … … 164 124 165 125 panel_destroy(panel); 166 ui_window_destroy(window);167 ui_destroy(ui);168 126 } 169 127 … … 171 129 PCUT_TEST(kbd_event) 172 130 { 173 ui_t *ui;174 ui_window_t *window;175 ui_wnd_params_t params;176 131 panel_t *panel; 177 132 ui_evclaim_t claimed; … … 181 136 /* Active panel should claim events */ 182 137 183 rc = ui_create_disp(NULL, &ui); 184 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 185 186 ui_wnd_params_init(¶ms); 187 params.caption = "Test"; 188 189 rc = ui_window_create(ui, ¶ms, &window); 190 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 191 192 rc = panel_create(window, true, &panel); 138 rc = panel_create(NULL, true, &panel); 193 139 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 194 140 … … 205 151 /* Inactive panel should not claim events */ 206 152 207 rc = panel_create( window, false, &panel);153 rc = panel_create(NULL, false, &panel); 208 154 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 209 155 … … 217 163 218 164 panel_destroy(panel); 219 ui_window_destroy(window);220 ui_destroy(ui);221 165 } 222 166 … … 229 173 PCUT_TEST(set_rect) 230 174 { 231 ui_t *ui;232 ui_window_t *window;233 ui_wnd_params_t params;234 175 panel_t *panel; 235 176 gfx_rect_t rect; 236 177 errno_t rc; 237 178 238 rc = ui_create_disp(NULL, &ui); 239 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 240 241 ui_wnd_params_init(¶ms); 242 params.caption = "Test"; 243 244 rc = ui_window_create(ui, ¶ms, &window); 245 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 246 247 rc = panel_create(window, true, &panel); 179 rc = panel_create(NULL, true, &panel); 248 180 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 249 181 … … 260 192 261 193 panel_destroy(panel); 262 ui_window_destroy(window);263 ui_destroy(ui);264 194 } 265 195 266 196 /** panel_is_active() returns panel activity state */ 267 197 PCUT_TEST(is_active) 198 { 199 panel_t *panel; 200 errno_t rc; 201 202 rc = panel_create(NULL, true, &panel); 203 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 204 PCUT_ASSERT_TRUE(panel_is_active(panel)); 205 panel_destroy(panel); 206 207 rc = panel_create(NULL, false, &panel); 208 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 209 PCUT_ASSERT_FALSE(panel_is_active(panel)); 210 panel_destroy(panel); 211 } 212 213 /** panel_activate() activates panel */ 214 PCUT_TEST(activate) 268 215 { 269 216 ui_t *ui; … … 282 229 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 283 230 284 rc = panel_create(window, true, &panel); 231 rc = panel_create(window, false, &panel); 232 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 233 234 PCUT_ASSERT_FALSE(panel_is_active(panel)); 235 rc = panel_activate(panel); 285 236 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 286 237 PCUT_ASSERT_TRUE(panel_is_active(panel)); 287 panel_destroy(panel); 288 289 rc = panel_create(window, false, &panel); 290 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 291 PCUT_ASSERT_FALSE(panel_is_active(panel)); 238 292 239 panel_destroy(panel); 293 240 ui_window_destroy(window); … … 295 242 } 296 243 297 /** panel_ activate()activates panel */298 PCUT_TEST( activate)244 /** panel_deactivate() deactivates panel */ 245 PCUT_TEST(deactivate) 299 246 { 300 247 ui_t *ui; … … 313 260 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 314 261 315 rc = panel_create(window, false, &panel);316 PCUT_ASSERT_ERRNO_VAL(EOK, rc);317 318 PCUT_ASSERT_FALSE(panel_is_active(panel));319 rc = panel_activate(panel);320 PCUT_ASSERT_ERRNO_VAL(EOK, rc);321 PCUT_ASSERT_TRUE(panel_is_active(panel));322 323 panel_destroy(panel);324 ui_window_destroy(window);325 ui_destroy(ui);326 }327 328 /** panel_deactivate() deactivates panel */329 PCUT_TEST(deactivate)330 {331 ui_t *ui;332 ui_window_t *window;333 ui_wnd_params_t params;334 panel_t *panel;335 errno_t rc;336 337 rc = ui_create_disp(NULL, &ui);338 PCUT_ASSERT_ERRNO_VAL(EOK, rc);339 340 ui_wnd_params_init(¶ms);341 params.caption = "Test";342 343 rc = ui_window_create(ui, ¶ms, &window);344 PCUT_ASSERT_ERRNO_VAL(EOK, rc);345 346 262 rc = panel_create(window, true, &panel); 347 263 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 359 275 PCUT_TEST(activate_req) 360 276 { 361 ui_t *ui;362 ui_window_t *window;363 ui_wnd_params_t params;364 277 panel_t *panel; 365 278 errno_t rc; 366 279 test_resp_t resp; 367 280 368 rc = ui_create_disp(NULL, &ui); 369 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 370 371 ui_wnd_params_init(¶ms); 372 params.caption = "Test"; 373 374 rc = ui_window_create(ui, ¶ms, &window); 375 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 376 377 rc = panel_create(window, true, &panel); 281 rc = panel_create(NULL, true, &panel); 378 282 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 379 283 … … 388 292 389 293 panel_destroy(panel); 390 ui_window_destroy(window);391 ui_destroy(ui);392 294 } 393 295
Note:
See TracChangeset
for help on using the changeset viewer.