Changes in uspace/srv/hid/display/test/seat.c [195b7b3:9e84d2c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/test/seat.c
r195b7b3 r9e84d2c 1 1 /* 2 * Copyright (c) 20 19Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 90 90 } 91 91 92 /** Evacuate focus . */93 PCUT_TEST(evac_focus )92 /** Evacuate focus when another window is available. */ 93 PCUT_TEST(evac_focus_two_windows) 94 94 { 95 95 ds_display_t *disp; … … 126 126 called_cb = false; 127 127 128 ds_seat_evac_ focus(seat, w1);128 ds_seat_evac_wnd_refs(seat, w1); 129 129 PCUT_ASSERT_EQUALS(w0, seat->focus); 130 130 PCUT_ASSERT_TRUE(called_cb); … … 132 132 ds_window_destroy(w0); 133 133 ds_window_destroy(w1); 134 ds_seat_destroy(seat); 135 ds_client_destroy(client); 136 ds_display_destroy(disp); 137 } 138 139 /** Evacuate focus from the only existing window. 140 * 141 * After evacuating no window should be focused 142 */ 143 PCUT_TEST(evac_focus_one_window) 144 { 145 ds_display_t *disp; 146 ds_client_t *client; 147 ds_seat_t *seat; 148 ds_window_t *wnd; 149 display_wnd_params_t params; 150 bool called_cb = false; 151 errno_t rc; 152 153 rc = ds_display_create(NULL, df_none, &disp); 154 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 155 156 rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client); 157 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 158 159 rc = ds_seat_create(disp, &seat); 160 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 161 162 display_wnd_params_init(¶ms); 163 params.rect.p0.x = params.rect.p0.y = 0; 164 params.rect.p1.x = params.rect.p1.y = 1; 165 166 rc = ds_window_create(client, ¶ms, &wnd); 167 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 168 169 ds_seat_set_focus(seat, wnd); 170 PCUT_ASSERT_EQUALS(wnd, seat->focus); 171 PCUT_ASSERT_TRUE(called_cb); 172 called_cb = false; 173 174 ds_seat_evac_wnd_refs(seat, wnd); 175 PCUT_ASSERT_NULL(seat->focus); 176 PCUT_ASSERT_TRUE(called_cb); 177 178 ds_window_destroy(wnd); 179 ds_seat_destroy(seat); 180 ds_client_destroy(client); 181 ds_display_destroy(disp); 182 } 183 184 /** Evacuate popup reference from window. 185 * 186 * After evacuating no window should be set as the popup 187 */ 188 PCUT_TEST(evac_popup) 189 { 190 ds_display_t *disp; 191 ds_client_t *client; 192 ds_seat_t *seat; 193 ds_window_t *wnd; 194 display_wnd_params_t params; 195 bool called_cb = false; 196 errno_t rc; 197 198 rc = ds_display_create(NULL, df_none, &disp); 199 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 200 201 rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client); 202 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 203 204 rc = ds_seat_create(disp, &seat); 205 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 206 207 display_wnd_params_init(¶ms); 208 params.rect.p0.x = params.rect.p0.y = 0; 209 params.rect.p1.x = params.rect.p1.y = 1; 210 params.flags |= wndf_popup; 211 212 rc = ds_window_create(client, ¶ms, &wnd); 213 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 214 215 PCUT_ASSERT_EQUALS(wnd, seat->popup); 216 217 ds_seat_evac_wnd_refs(seat, wnd); 218 PCUT_ASSERT_NULL(seat->popup); 219 220 ds_window_destroy(wnd); 221 ds_seat_destroy(seat); 222 ds_client_destroy(client); 223 ds_display_destroy(disp); 224 } 225 226 /** Switch focus when another window is available. */ 227 PCUT_TEST(switch_focus_two_windows) 228 { 229 ds_display_t *disp; 230 ds_client_t *client; 231 ds_seat_t *seat; 232 ds_window_t *w0; 233 ds_window_t *w1; 234 display_wnd_params_t params; 235 bool called_cb = false; 236 errno_t rc; 237 238 rc = ds_display_create(NULL, df_none, &disp); 239 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 240 241 rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client); 242 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 243 244 rc = ds_seat_create(disp, &seat); 245 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 246 247 display_wnd_params_init(¶ms); 248 params.rect.p0.x = params.rect.p0.y = 0; 249 params.rect.p1.x = params.rect.p1.y = 1; 250 251 rc = ds_window_create(client, ¶ms, &w1); 252 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 253 254 rc = ds_window_create(client, ¶ms, &w0); 255 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 256 257 ds_seat_set_focus(seat, w1); 258 PCUT_ASSERT_EQUALS(w1, seat->focus); 259 PCUT_ASSERT_TRUE(called_cb); 260 called_cb = false; 261 262 ds_seat_switch_focus(seat); 263 PCUT_ASSERT_EQUALS(w0, seat->focus); 264 PCUT_ASSERT_TRUE(called_cb); 265 266 ds_window_destroy(w0); 267 ds_window_destroy(w1); 268 ds_seat_destroy(seat); 269 ds_client_destroy(client); 270 ds_display_destroy(disp); 271 } 272 273 /** Switch focus with just one existing window. 274 * 275 * After switching the focus should remain with the same window. 276 */ 277 PCUT_TEST(switch_focus_one_window) 278 { 279 ds_display_t *disp; 280 ds_client_t *client; 281 ds_seat_t *seat; 282 ds_window_t *wnd; 283 display_wnd_params_t params; 284 bool called_cb = false; 285 errno_t rc; 286 287 rc = ds_display_create(NULL, df_none, &disp); 288 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 289 290 rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client); 291 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 292 293 rc = ds_seat_create(disp, &seat); 294 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 295 296 display_wnd_params_init(¶ms); 297 params.rect.p0.x = params.rect.p0.y = 0; 298 params.rect.p1.x = params.rect.p1.y = 1; 299 300 rc = ds_window_create(client, ¶ms, &wnd); 301 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 302 303 ds_seat_set_focus(seat, wnd); 304 PCUT_ASSERT_EQUALS(wnd, seat->focus); 305 PCUT_ASSERT_TRUE(called_cb); 306 called_cb = false; 307 308 ds_seat_switch_focus(seat); 309 PCUT_ASSERT_EQUALS(wnd, seat->focus); 310 PCUT_ASSERT_FALSE(called_cb); 311 312 ds_window_destroy(wnd); 134 313 ds_seat_destroy(seat); 135 314 ds_client_destroy(client); … … 299 478 w1->dpos.y = 400; 300 479 301 PCUT_ASSERT_FALSE(called_cb); 480 /* New window gets focused event */ 481 PCUT_ASSERT_TRUE(called_cb); 482 483 called_cb = false; 302 484 303 485 ds_seat_set_focus(seat, w0);
Note:
See TracChangeset
for help on using the changeset viewer.