Pekka Paalanen | 46804ca | 2015-03-27 11:55:21 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2013 DENSO CORPORATION |
| 3 | * Copyright © 2015 Collabora, Ltd. |
| 4 | * |
Bryce Harrington | 2cc9297 | 2015-06-11 15:39:40 -0700 | [diff] [blame] | 5 | * Permission is hereby granted, free of charge, to any person obtaining |
| 6 | * a copy of this software and associated documentation files (the |
| 7 | * "Software"), to deal in the Software without restriction, including |
| 8 | * without limitation the rights to use, copy, modify, merge, publish, |
| 9 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 10 | * permit persons to whom the Software is furnished to do so, subject to |
| 11 | * the following conditions: |
Pekka Paalanen | 46804ca | 2015-03-27 11:55:21 +0200 | [diff] [blame] | 12 | * |
Bryce Harrington | 2cc9297 | 2015-06-11 15:39:40 -0700 | [diff] [blame] | 13 | * The above copyright notice and this permission notice (including the |
| 14 | * next paragraph) shall be included in all copies or substantial |
| 15 | * portions of the Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 24 | * SOFTWARE. |
Pekka Paalanen | 46804ca | 2015-03-27 11:55:21 +0200 | [diff] [blame] | 25 | */ |
| 26 | |
| 27 | #include "config.h" |
| 28 | |
| 29 | #include <unistd.h> |
| 30 | #include <signal.h> |
| 31 | #include <string.h> |
| 32 | #include <stdbool.h> |
| 33 | |
Jon Cruz | 4678bab | 2015-06-15 15:37:07 -0700 | [diff] [blame] | 34 | #include "src/compositor.h" |
| 35 | #include "ivi-shell/ivi-layout-export.h" |
Nobuhiko Tanibata | 17d4494 | 2015-06-22 15:35:12 +0900 | [diff] [blame] | 36 | #include "ivi-shell/ivi-layout-private.h" |
Nobuhiko Tanibata | 9e992d9 | 2015-06-22 15:34:18 +0900 | [diff] [blame] | 37 | #include "ivi-test.h" |
Pekka Paalanen | 46804ca | 2015-03-27 11:55:21 +0200 | [diff] [blame] | 38 | |
| 39 | struct test_context { |
| 40 | struct weston_compositor *compositor; |
| 41 | const struct ivi_controller_interface *controller_interface; |
Nobuhiko Tanibata | 495c6ef | 2015-06-22 15:36:11 +0900 | [diff] [blame] | 42 | uint32_t user_flags; |
Pekka Paalanen | 46804ca | 2015-03-27 11:55:21 +0200 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | static void |
| 46 | iassert_fail(const char *cond, const char *file, int line, |
| 47 | const char *func, struct test_context *ctx) |
| 48 | { |
| 49 | weston_log("Assert failure in %s:%d, %s: '%s'\n", |
| 50 | file, line, func, cond); |
| 51 | weston_compositor_exit_with_code(ctx->compositor, EXIT_FAILURE); |
| 52 | } |
| 53 | |
| 54 | #define iassert(cond) ({ \ |
| 55 | bool b_ = (cond); \ |
| 56 | if (!b_) \ |
| 57 | iassert_fail(#cond, __FILE__, __LINE__, __func__, ctx); \ |
| 58 | b_; \ |
| 59 | }) |
| 60 | |
| 61 | /************************ tests begin ******************************/ |
| 62 | |
| 63 | /* |
| 64 | * These are all internal ivi_layout API tests that do not require |
| 65 | * any client objects. |
| 66 | */ |
Pekka Paalanen | 46804ca | 2015-03-27 11:55:21 +0200 | [diff] [blame] | 67 | static void |
| 68 | test_surface_bad_visibility(struct test_context *ctx) |
| 69 | { |
| 70 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 71 | bool visibility; |
| 72 | |
| 73 | iassert(ctl->surface_set_visibility(NULL, true) == IVI_FAILED); |
| 74 | |
| 75 | ctl->commit_changes(); |
| 76 | |
| 77 | visibility = ctl->surface_get_visibility(NULL); |
| 78 | iassert(visibility == false); |
| 79 | } |
| 80 | |
Nobuhiko Tanibata | 16ed543 | 2015-06-22 15:33:59 +0900 | [diff] [blame] | 81 | static void |
| 82 | test_surface_bad_destination_rectangle(struct test_context *ctx) |
| 83 | { |
| 84 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 85 | |
| 86 | iassert(ctl->surface_set_destination_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED); |
| 87 | } |
| 88 | |
| 89 | static void |
| 90 | test_surface_bad_orientation(struct test_context *ctx) |
| 91 | { |
| 92 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 93 | |
| 94 | iassert(ctl->surface_set_orientation(NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED); |
| 95 | |
| 96 | iassert(ctl->surface_get_orientation(NULL) == WL_OUTPUT_TRANSFORM_NORMAL); |
| 97 | } |
| 98 | |
| 99 | static void |
| 100 | test_surface_bad_dimension(struct test_context *ctx) |
| 101 | { |
| 102 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 103 | struct ivi_layout_surface *ivisurf = NULL; |
| 104 | int32_t dest_width; |
| 105 | int32_t dest_height; |
| 106 | |
| 107 | iassert(ctl->surface_set_dimension(NULL, 200, 300) == IVI_FAILED); |
| 108 | |
| 109 | ctl->commit_changes(); |
| 110 | |
| 111 | iassert(ctl->surface_get_dimension(NULL, &dest_width, &dest_height) == IVI_FAILED); |
| 112 | iassert(ctl->surface_get_dimension(ivisurf, NULL, &dest_height) == IVI_FAILED); |
| 113 | iassert(ctl->surface_get_dimension(ivisurf, &dest_width, NULL) == IVI_FAILED); |
| 114 | } |
| 115 | |
| 116 | static void |
| 117 | test_surface_bad_position(struct test_context *ctx) |
| 118 | { |
| 119 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 120 | struct ivi_layout_surface *ivisurf = NULL; |
| 121 | int32_t dest_x; |
| 122 | int32_t dest_y; |
| 123 | |
| 124 | iassert(ctl->surface_set_position(NULL, 20, 30) == IVI_FAILED); |
| 125 | |
| 126 | ctl->commit_changes(); |
| 127 | |
| 128 | iassert(ctl->surface_get_position(NULL, &dest_x, &dest_y) == IVI_FAILED); |
| 129 | iassert(ctl->surface_get_position(ivisurf, NULL, &dest_y) == IVI_FAILED); |
| 130 | iassert(ctl->surface_get_position(ivisurf, &dest_x, NULL) == IVI_FAILED); |
| 131 | } |
| 132 | |
| 133 | static void |
| 134 | test_surface_bad_source_rectangle(struct test_context *ctx) |
| 135 | { |
| 136 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 137 | |
| 138 | iassert(ctl->surface_set_source_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED); |
| 139 | } |
| 140 | |
| 141 | static void |
| 142 | test_surface_bad_properties(struct test_context *ctx) |
| 143 | { |
| 144 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 145 | |
| 146 | iassert(ctl->get_properties_of_surface(NULL) == NULL); |
| 147 | } |
| 148 | |
Nobuhiko Tanibata | 9e992d9 | 2015-06-22 15:34:18 +0900 | [diff] [blame] | 149 | static void |
| 150 | test_layer_create(struct test_context *ctx) |
| 151 | { |
| 152 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 153 | uint32_t id1; |
| 154 | uint32_t id2; |
| 155 | struct ivi_layout_layer *ivilayer; |
| 156 | struct ivi_layout_layer *new_ivilayer; |
| 157 | |
| 158 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 159 | iassert(ivilayer != NULL); |
| 160 | |
| 161 | iassert(IVI_TEST_LAYER_ID(0) == ctl->get_id_of_layer(ivilayer)); |
| 162 | |
| 163 | new_ivilayer = ctl->get_layer_from_id(IVI_TEST_LAYER_ID(0)); |
| 164 | iassert(ivilayer == new_ivilayer); |
| 165 | |
| 166 | id1 = ctl->get_id_of_layer(ivilayer); |
| 167 | id2 = ctl->get_id_of_layer(new_ivilayer); |
| 168 | iassert(id1 == id2); |
| 169 | |
| 170 | ctl->layer_destroy(ivilayer); |
| 171 | iassert(ctl->get_layer_from_id(IVI_TEST_LAYER_ID(0)) == NULL); |
| 172 | } |
| 173 | |
| 174 | static void |
| 175 | test_layer_visibility(struct test_context *ctx) |
| 176 | { |
| 177 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 178 | struct ivi_layout_layer *ivilayer; |
| 179 | const struct ivi_layout_layer_properties *prop; |
| 180 | |
| 181 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 182 | iassert(ivilayer != NULL); |
| 183 | |
| 184 | iassert(ctl->layer_get_visibility(ivilayer) == false); |
| 185 | |
| 186 | iassert(ctl->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED); |
| 187 | |
| 188 | iassert(ctl->layer_get_visibility(ivilayer) == false); |
| 189 | |
| 190 | ctl->commit_changes(); |
| 191 | |
| 192 | iassert(ctl->layer_get_visibility(ivilayer) == true); |
| 193 | |
| 194 | prop = ctl->get_properties_of_layer(ivilayer); |
| 195 | iassert(prop->visibility == true); |
| 196 | |
| 197 | ctl->layer_destroy(ivilayer); |
| 198 | } |
| 199 | |
| 200 | static void |
| 201 | test_layer_opacity(struct test_context *ctx) |
| 202 | { |
| 203 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 204 | struct ivi_layout_layer *ivilayer; |
| 205 | const struct ivi_layout_layer_properties *prop; |
| 206 | |
| 207 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 208 | iassert(ivilayer != NULL); |
| 209 | |
| 210 | iassert(ctl->layer_get_opacity(ivilayer) == wl_fixed_from_double(1.0)); |
| 211 | |
| 212 | iassert(ctl->layer_set_opacity( |
| 213 | ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED); |
| 214 | |
| 215 | iassert(ctl->layer_get_opacity(ivilayer) == wl_fixed_from_double(1.0)); |
| 216 | |
| 217 | ctl->commit_changes(); |
| 218 | |
| 219 | iassert(ctl->layer_get_opacity(ivilayer) == wl_fixed_from_double(0.5)); |
| 220 | |
| 221 | prop = ctl->get_properties_of_layer(ivilayer); |
| 222 | iassert(prop->opacity == wl_fixed_from_double(0.5)); |
| 223 | |
| 224 | ctl->layer_destroy(ivilayer); |
| 225 | } |
| 226 | |
| 227 | static void |
| 228 | test_layer_orientation(struct test_context *ctx) |
| 229 | { |
| 230 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 231 | struct ivi_layout_layer *ivilayer; |
| 232 | const struct ivi_layout_layer_properties *prop; |
| 233 | |
| 234 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 235 | iassert(ivilayer != NULL); |
| 236 | |
| 237 | iassert(ctl->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_NORMAL); |
| 238 | |
| 239 | iassert(ctl->layer_set_orientation( |
| 240 | ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED); |
| 241 | |
| 242 | iassert(ctl->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_NORMAL); |
| 243 | |
| 244 | ctl->commit_changes(); |
| 245 | |
| 246 | iassert(ctl->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_90); |
| 247 | |
| 248 | prop = ctl->get_properties_of_layer(ivilayer); |
| 249 | iassert(prop->orientation == WL_OUTPUT_TRANSFORM_90); |
| 250 | |
| 251 | ctl->layer_destroy(ivilayer); |
| 252 | } |
| 253 | |
| 254 | static void |
| 255 | test_layer_dimension(struct test_context *ctx) |
| 256 | { |
| 257 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 258 | struct ivi_layout_layer *ivilayer; |
| 259 | const struct ivi_layout_layer_properties *prop; |
| 260 | int32_t dest_width; |
| 261 | int32_t dest_height; |
| 262 | |
| 263 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 264 | iassert(ivilayer != NULL); |
| 265 | |
| 266 | iassert(ctl->layer_get_dimension( |
| 267 | ivilayer, &dest_width, &dest_height) == IVI_SUCCEEDED); |
| 268 | iassert(dest_width == 200); |
| 269 | iassert(dest_height == 300); |
| 270 | |
| 271 | iassert(ctl->layer_set_dimension(ivilayer, 400, 600) == IVI_SUCCEEDED); |
| 272 | |
| 273 | iassert(ctl->layer_get_dimension( |
| 274 | ivilayer, &dest_width, &dest_height) == IVI_SUCCEEDED); |
| 275 | iassert(dest_width == 200); |
| 276 | iassert(dest_height == 300); |
| 277 | |
| 278 | ctl->commit_changes(); |
| 279 | |
| 280 | iassert(IVI_SUCCEEDED == ctl->layer_get_dimension( |
| 281 | ivilayer, &dest_width, &dest_height)); |
| 282 | iassert(dest_width == 400); |
| 283 | iassert(dest_height == 600); |
| 284 | |
| 285 | prop = ctl->get_properties_of_layer(ivilayer); |
| 286 | iassert(prop->dest_width == 400); |
| 287 | iassert(prop->dest_height == 600); |
| 288 | |
| 289 | ctl->layer_destroy(ivilayer); |
| 290 | } |
| 291 | |
| 292 | static void |
| 293 | test_layer_position(struct test_context *ctx) |
| 294 | { |
| 295 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 296 | struct ivi_layout_layer *ivilayer; |
| 297 | const struct ivi_layout_layer_properties *prop; |
| 298 | int32_t dest_x; |
| 299 | int32_t dest_y; |
| 300 | |
| 301 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 302 | iassert(ivilayer != NULL); |
| 303 | |
| 304 | iassert(ctl->layer_get_position( |
| 305 | ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED); |
| 306 | iassert(dest_x == 0); |
| 307 | iassert(dest_y == 0); |
| 308 | |
| 309 | iassert(ctl->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED); |
| 310 | |
| 311 | iassert(ctl->layer_get_position( |
| 312 | ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED); |
| 313 | iassert(dest_x == 0); |
| 314 | iassert(dest_y == 0); |
| 315 | |
| 316 | ctl->commit_changes(); |
| 317 | |
| 318 | iassert(ctl->layer_get_position( |
| 319 | ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED); |
| 320 | iassert(dest_x == 20); |
| 321 | iassert(dest_y == 30); |
| 322 | |
| 323 | prop = ctl->get_properties_of_layer(ivilayer); |
| 324 | iassert(prop->dest_x == 20); |
| 325 | iassert(prop->dest_y == 30); |
| 326 | |
| 327 | ctl->layer_destroy(ivilayer); |
| 328 | } |
| 329 | |
| 330 | static void |
| 331 | test_layer_destination_rectangle(struct test_context *ctx) |
| 332 | { |
| 333 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 334 | struct ivi_layout_layer *ivilayer; |
| 335 | const struct ivi_layout_layer_properties *prop; |
| 336 | int32_t dest_width; |
| 337 | int32_t dest_height; |
| 338 | int32_t dest_x; |
| 339 | int32_t dest_y; |
| 340 | |
| 341 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 342 | iassert(ivilayer != NULL); |
| 343 | |
| 344 | prop = ctl->get_properties_of_layer(ivilayer); |
| 345 | iassert(prop->dest_width == 200); |
| 346 | iassert(prop->dest_height == 300); |
| 347 | iassert(prop->dest_x == 0); |
| 348 | iassert(prop->dest_y == 0); |
| 349 | |
| 350 | iassert(ctl->layer_set_destination_rectangle( |
| 351 | ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED); |
| 352 | |
| 353 | prop = ctl->get_properties_of_layer(ivilayer); |
| 354 | iassert(prop->dest_width == 200); |
| 355 | iassert(prop->dest_height == 300); |
| 356 | iassert(prop->dest_x == 0); |
| 357 | iassert(prop->dest_y == 0); |
| 358 | |
| 359 | ctl->commit_changes(); |
| 360 | |
| 361 | iassert(ctl->layer_get_dimension( |
| 362 | ivilayer, &dest_width, &dest_height) == IVI_SUCCEEDED); |
| 363 | iassert(dest_width == 400); |
| 364 | iassert(dest_height == 600); |
| 365 | |
| 366 | iassert(ctl->layer_get_position( |
| 367 | ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED); |
| 368 | iassert(dest_x == 20); |
| 369 | iassert(dest_y == 30); |
| 370 | |
| 371 | prop = ctl->get_properties_of_layer(ivilayer); |
| 372 | iassert(prop->dest_width == 400); |
| 373 | iassert(prop->dest_height == 600); |
| 374 | iassert(prop->dest_x == 20); |
| 375 | iassert(prop->dest_y == 30); |
| 376 | |
| 377 | ctl->layer_destroy(ivilayer); |
| 378 | } |
| 379 | |
| 380 | static void |
| 381 | test_layer_source_rectangle(struct test_context *ctx) |
| 382 | { |
| 383 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 384 | struct ivi_layout_layer *ivilayer; |
| 385 | const struct ivi_layout_layer_properties *prop; |
| 386 | |
| 387 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 388 | iassert(ivilayer != NULL); |
| 389 | |
| 390 | prop = ctl->get_properties_of_layer(ivilayer); |
| 391 | iassert(prop->source_width == 200); |
| 392 | iassert(prop->source_height == 300); |
| 393 | iassert(prop->source_x == 0); |
| 394 | iassert(prop->source_y == 0); |
| 395 | |
| 396 | iassert(ctl->layer_set_source_rectangle( |
| 397 | ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED); |
| 398 | |
| 399 | prop = ctl->get_properties_of_layer(ivilayer); |
| 400 | iassert(prop->source_width == 200); |
| 401 | iassert(prop->source_height == 300); |
| 402 | iassert(prop->source_x == 0); |
| 403 | iassert(prop->source_y == 0); |
| 404 | |
| 405 | ctl->commit_changes(); |
| 406 | |
| 407 | prop = ctl->get_properties_of_layer(ivilayer); |
| 408 | iassert(prop->source_width == 400); |
| 409 | iassert(prop->source_height == 600); |
| 410 | iassert(prop->source_x == 20); |
| 411 | iassert(prop->source_y == 30); |
| 412 | |
| 413 | ctl->layer_destroy(ivilayer); |
| 414 | } |
| 415 | |
Nobuhiko Tanibata | 17d4494 | 2015-06-22 15:35:12 +0900 | [diff] [blame] | 416 | static void |
| 417 | test_layer_bad_remove(struct test_context *ctx) |
| 418 | { |
| 419 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 420 | ctl->layer_destroy(NULL); |
| 421 | } |
| 422 | |
| 423 | static void |
| 424 | test_layer_bad_visibility(struct test_context *ctx) |
| 425 | { |
| 426 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 427 | |
| 428 | iassert(ctl->layer_set_visibility(NULL, true) == IVI_FAILED); |
| 429 | |
| 430 | ctl->commit_changes(); |
| 431 | |
| 432 | iassert(ctl->layer_get_visibility(NULL) == false); |
| 433 | } |
| 434 | |
| 435 | static void |
| 436 | test_layer_bad_opacity(struct test_context *ctx) |
| 437 | { |
| 438 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 439 | struct ivi_layout_layer *ivilayer; |
| 440 | |
| 441 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 442 | iassert(ivilayer != NULL); |
| 443 | |
| 444 | iassert(ctl->layer_set_opacity( |
| 445 | NULL, wl_fixed_from_double(0.3)) == IVI_FAILED); |
| 446 | |
| 447 | iassert(ctl->layer_set_opacity( |
| 448 | ivilayer, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED); |
| 449 | |
| 450 | iassert(ctl->layer_set_opacity( |
| 451 | ivilayer, wl_fixed_from_double(-1)) == IVI_FAILED); |
| 452 | |
| 453 | ctl->commit_changes(); |
| 454 | |
| 455 | iassert(ctl->layer_get_opacity(ivilayer) == wl_fixed_from_double(0.3)); |
| 456 | |
| 457 | iassert(ctl->layer_set_opacity( |
| 458 | ivilayer, wl_fixed_from_double(1.1)) == IVI_FAILED); |
| 459 | |
| 460 | ctl->commit_changes(); |
| 461 | |
| 462 | iassert(ctl->layer_get_opacity(ivilayer) == wl_fixed_from_double(0.3)); |
| 463 | |
| 464 | iassert(ctl->layer_set_opacity( |
| 465 | NULL, wl_fixed_from_double(0.5)) == IVI_FAILED); |
| 466 | |
| 467 | ctl->commit_changes(); |
| 468 | |
| 469 | iassert(ctl->layer_get_opacity(NULL) == wl_fixed_from_double(0.0)); |
| 470 | |
| 471 | ctl->layer_destroy(ivilayer); |
| 472 | } |
| 473 | |
| 474 | static void |
| 475 | test_layer_bad_destination_rectangle(struct test_context *ctx) |
| 476 | { |
| 477 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 478 | |
| 479 | iassert(ctl->layer_set_destination_rectangle( |
| 480 | NULL, 20, 30, 200, 300) == IVI_FAILED); |
| 481 | } |
| 482 | |
| 483 | static void |
| 484 | test_layer_bad_orientation(struct test_context *ctx) |
| 485 | { |
| 486 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 487 | |
| 488 | iassert(ctl->layer_set_orientation( |
| 489 | NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED); |
| 490 | |
| 491 | ctl->commit_changes(); |
| 492 | |
| 493 | iassert(ctl->layer_get_orientation(NULL) == WL_OUTPUT_TRANSFORM_NORMAL); |
| 494 | } |
| 495 | |
| 496 | static void |
| 497 | test_layer_bad_dimension(struct test_context *ctx) |
| 498 | { |
| 499 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 500 | struct ivi_layout_layer *ivilayer; |
| 501 | int32_t dest_width; |
| 502 | int32_t dest_height; |
| 503 | |
| 504 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 505 | iassert(ivilayer != NULL); |
| 506 | |
| 507 | iassert(ctl->layer_set_dimension(NULL, 200, 300) == IVI_FAILED); |
| 508 | |
| 509 | ctl->commit_changes(); |
| 510 | |
| 511 | iassert(ctl->layer_get_dimension( |
| 512 | NULL, &dest_width, &dest_height) == IVI_FAILED); |
| 513 | iassert(ctl->layer_get_dimension( |
| 514 | ivilayer, NULL, &dest_height) == IVI_FAILED); |
| 515 | iassert(ctl->layer_get_dimension( |
| 516 | ivilayer, &dest_width, NULL) == IVI_FAILED); |
| 517 | |
| 518 | ctl->layer_destroy(ivilayer); |
| 519 | } |
| 520 | |
| 521 | static void |
| 522 | test_layer_bad_position(struct test_context *ctx) |
| 523 | { |
| 524 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 525 | struct ivi_layout_layer *ivilayer; |
| 526 | int32_t dest_x; |
| 527 | int32_t dest_y; |
| 528 | |
| 529 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 530 | iassert(ivilayer != NULL); |
| 531 | |
| 532 | iassert(ctl->layer_set_position(NULL, 20, 30) == IVI_FAILED); |
| 533 | |
| 534 | ctl->commit_changes(); |
| 535 | |
| 536 | iassert(ctl->layer_get_position(NULL, &dest_x, &dest_y) == IVI_FAILED); |
| 537 | iassert(ctl->layer_get_position(ivilayer, NULL, &dest_y) == IVI_FAILED); |
| 538 | iassert(ctl->layer_get_position(ivilayer, &dest_x, NULL) == IVI_FAILED); |
| 539 | |
| 540 | ctl->layer_destroy(ivilayer); |
| 541 | } |
| 542 | |
| 543 | static void |
| 544 | test_layer_bad_source_rectangle(struct test_context *ctx) |
| 545 | { |
| 546 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 547 | |
| 548 | iassert(ctl->layer_set_source_rectangle( |
| 549 | NULL, 20, 30, 200, 300) == IVI_FAILED); |
| 550 | } |
| 551 | |
| 552 | static void |
| 553 | test_layer_bad_properties(struct test_context *ctx) |
| 554 | { |
| 555 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 556 | |
| 557 | iassert(ctl->get_properties_of_layer(NULL) == NULL); |
| 558 | } |
| 559 | |
| 560 | static void |
| 561 | test_commit_changes_after_visibility_set_layer_destroy(struct test_context *ctx) |
| 562 | { |
| 563 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 564 | struct ivi_layout_layer *ivilayer; |
| 565 | |
| 566 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 567 | iassert(ivilayer != NULL); |
| 568 | |
| 569 | iassert(ctl->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED); |
| 570 | ctl->layer_destroy(ivilayer); |
| 571 | ctl->commit_changes(); |
| 572 | } |
| 573 | |
| 574 | static void |
| 575 | test_commit_changes_after_opacity_set_layer_destroy(struct test_context *ctx) |
| 576 | { |
| 577 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 578 | struct ivi_layout_layer *ivilayer; |
| 579 | |
| 580 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 581 | iassert(ivilayer != NULL); |
| 582 | |
| 583 | iassert(ctl->layer_set_opacity( |
| 584 | ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED); |
| 585 | ctl->layer_destroy(ivilayer); |
| 586 | ctl->commit_changes(); |
| 587 | } |
| 588 | |
| 589 | static void |
| 590 | test_commit_changes_after_orientation_set_layer_destroy(struct test_context *ctx) |
| 591 | { |
| 592 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 593 | struct ivi_layout_layer *ivilayer; |
| 594 | |
| 595 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 596 | iassert(ivilayer != NULL); |
| 597 | |
| 598 | iassert(ctl->layer_set_orientation( |
| 599 | ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED); |
| 600 | ctl->layer_destroy(ivilayer); |
| 601 | ctl->commit_changes(); |
| 602 | } |
| 603 | |
| 604 | static void |
| 605 | test_commit_changes_after_dimension_set_layer_destroy(struct test_context *ctx) |
| 606 | { |
| 607 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 608 | struct ivi_layout_layer *ivilayer; |
| 609 | |
| 610 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 611 | iassert(ivilayer != NULL); |
| 612 | |
| 613 | iassert(ctl->layer_set_dimension(ivilayer, 200, 300) == IVI_SUCCEEDED); |
| 614 | ctl->layer_destroy(ivilayer); |
| 615 | ctl->commit_changes(); |
| 616 | } |
| 617 | |
| 618 | static void |
| 619 | test_commit_changes_after_position_set_layer_destroy(struct test_context *ctx) |
| 620 | { |
| 621 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 622 | struct ivi_layout_layer *ivilayer; |
| 623 | |
| 624 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 625 | iassert(ivilayer != NULL); |
| 626 | |
| 627 | iassert(ctl->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED); |
| 628 | ctl->layer_destroy(ivilayer); |
| 629 | ctl->commit_changes(); |
| 630 | } |
| 631 | |
| 632 | static void |
| 633 | test_commit_changes_after_source_rectangle_set_layer_destroy(struct test_context *ctx) |
| 634 | { |
| 635 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 636 | struct ivi_layout_layer *ivilayer; |
| 637 | |
| 638 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 639 | iassert(ivilayer != NULL); |
| 640 | |
| 641 | iassert(ctl->layer_set_source_rectangle( |
| 642 | ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED); |
| 643 | ctl->layer_destroy(ivilayer); |
| 644 | ctl->commit_changes(); |
| 645 | } |
| 646 | |
| 647 | static void |
| 648 | test_commit_changes_after_destination_rectangle_set_layer_destroy(struct test_context *ctx) |
| 649 | { |
| 650 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 651 | struct ivi_layout_layer *ivilayer; |
| 652 | |
| 653 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 654 | iassert(ivilayer != NULL); |
| 655 | |
| 656 | iassert(ctl->layer_set_destination_rectangle( |
| 657 | ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED); |
| 658 | ctl->layer_destroy(ivilayer); |
| 659 | ctl->commit_changes(); |
| 660 | } |
| 661 | |
| 662 | static void |
| 663 | test_layer_create_duplicate(struct test_context *ctx) |
| 664 | { |
| 665 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 666 | struct ivi_layout_layer *ivilayer; |
| 667 | struct ivi_layout_layer *duplicatelayer; |
| 668 | |
| 669 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 670 | iassert(ivilayer != NULL); |
| 671 | |
| 672 | if (ivilayer != NULL) |
| 673 | iassert(ivilayer->ref_count == 1); |
| 674 | |
| 675 | duplicatelayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 676 | iassert(ivilayer == duplicatelayer); |
| 677 | |
| 678 | if (ivilayer != NULL) |
| 679 | iassert(ivilayer->ref_count == 2); |
| 680 | |
| 681 | ctl->layer_destroy(ivilayer); |
| 682 | |
| 683 | if (ivilayer != NULL) |
| 684 | iassert(ivilayer->ref_count == 1); |
| 685 | |
| 686 | ctl->layer_destroy(ivilayer); |
| 687 | } |
| 688 | |
| 689 | static void |
| 690 | test_get_layer_after_destory_layer(struct test_context *ctx) |
| 691 | { |
| 692 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 693 | struct ivi_layout_layer *ivilayer; |
| 694 | |
| 695 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 696 | iassert(ivilayer != NULL); |
| 697 | |
| 698 | ctl->layer_destroy(ivilayer); |
| 699 | |
| 700 | ivilayer = ctl->get_layer_from_id(IVI_TEST_LAYER_ID(0)); |
| 701 | iassert(ivilayer == NULL); |
| 702 | } |
| 703 | |
Nobuhiko Tanibata | e78a7af | 2015-06-22 15:35:25 +0900 | [diff] [blame] | 704 | static void |
| 705 | test_screen_id(struct test_context *ctx) |
| 706 | { |
| 707 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 708 | struct ivi_layout_screen **iviscrns; |
| 709 | int32_t screen_length = 0; |
| 710 | uint32_t id_screen; |
| 711 | int32_t i; |
| 712 | |
| 713 | iassert(ctl->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED); |
| 714 | iassert(screen_length > 0); |
| 715 | |
| 716 | for (i = 0; i < screen_length; ++i) { |
| 717 | id_screen = ctl->get_id_of_screen(iviscrns[i]); |
| 718 | iassert(ctl->get_screen_from_id(id_screen) == iviscrns[i]); |
| 719 | } |
| 720 | |
| 721 | if (screen_length > 0) |
| 722 | free(iviscrns); |
| 723 | } |
| 724 | |
| 725 | static void |
| 726 | test_screen_resolution(struct test_context *ctx) |
| 727 | { |
| 728 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 729 | struct ivi_layout_screen **iviscrns; |
| 730 | int32_t screen_length = 0; |
| 731 | struct weston_output *output; |
| 732 | int32_t width; |
| 733 | int32_t height; |
| 734 | int32_t i; |
| 735 | |
| 736 | iassert(ctl->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED); |
| 737 | iassert(screen_length > 0); |
| 738 | |
| 739 | for (i = 0; i < screen_length; ++i) { |
| 740 | output = ctl->screen_get_output(iviscrns[i]); |
| 741 | iassert(output != NULL); |
| 742 | iassert(ctl->get_screen_resolution( |
| 743 | iviscrns[i], &width, &height) == IVI_SUCCEEDED); |
| 744 | iassert(width == output->current_mode->width); |
| 745 | iassert(height == output->current_mode->height); |
| 746 | } |
| 747 | |
| 748 | if (screen_length > 0) |
| 749 | free(iviscrns); |
| 750 | } |
| 751 | |
| 752 | static void |
| 753 | test_screen_render_order(struct test_context *ctx) |
| 754 | { |
| 755 | #define LAYER_NUM (3) |
| 756 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 757 | struct ivi_layout_screen **iviscrns; |
| 758 | int32_t screen_length = 0; |
| 759 | struct ivi_layout_screen *iviscrn; |
| 760 | struct ivi_layout_layer *ivilayers[LAYER_NUM] = {}; |
| 761 | struct ivi_layout_layer **array; |
| 762 | int32_t length = 0; |
| 763 | uint32_t i; |
| 764 | |
| 765 | iassert(ctl->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED); |
| 766 | iassert(screen_length > 0); |
| 767 | |
| 768 | if (screen_length <= 0) |
| 769 | return; |
| 770 | |
| 771 | iviscrn = iviscrns[0]; |
| 772 | |
| 773 | for (i = 0; i < LAYER_NUM; i++) |
| 774 | ivilayers[i] = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300); |
| 775 | |
| 776 | iassert(ctl->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED); |
| 777 | |
| 778 | ctl->commit_changes(); |
| 779 | |
| 780 | iassert(ctl->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED); |
| 781 | iassert(length == LAYER_NUM); |
| 782 | for (i = 0; i < LAYER_NUM; i++) |
| 783 | iassert(array[i] == ivilayers[i]); |
| 784 | |
| 785 | if (length > 0) |
| 786 | free(array); |
| 787 | |
| 788 | array = NULL; |
| 789 | |
| 790 | iassert(ctl->screen_set_render_order(iviscrn, NULL, 0) == IVI_SUCCEEDED); |
| 791 | |
| 792 | ctl->commit_changes(); |
| 793 | |
| 794 | iassert(ctl->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED); |
| 795 | iassert(length == 0 && array == NULL); |
| 796 | |
| 797 | for (i = 0; i < LAYER_NUM; i++) |
| 798 | ctl->layer_destroy(ivilayers[i]); |
| 799 | |
| 800 | free(iviscrns); |
| 801 | #undef LAYER_NUM |
| 802 | } |
| 803 | |
Nobuhiko Tanibata | 83c20bc | 2015-06-22 15:35:39 +0900 | [diff] [blame] | 804 | static void |
| 805 | test_screen_bad_resolution(struct test_context *ctx) |
| 806 | { |
| 807 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 808 | struct ivi_layout_screen **iviscrns; |
| 809 | int32_t screen_length = 0; |
| 810 | struct ivi_layout_screen *iviscrn; |
| 811 | int32_t width; |
| 812 | int32_t height; |
| 813 | |
| 814 | iassert(ctl->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED); |
| 815 | iassert(screen_length > 0); |
| 816 | |
| 817 | if (screen_length <= 0) |
| 818 | return; |
| 819 | |
| 820 | iviscrn = iviscrns[0]; |
| 821 | iassert(ctl->get_screen_resolution(NULL, &width, &height) == IVI_FAILED); |
| 822 | iassert(ctl->get_screen_resolution(iviscrn, NULL, &height) == IVI_FAILED); |
| 823 | iassert(ctl->get_screen_resolution(iviscrn, &width, NULL) == IVI_FAILED); |
| 824 | free(iviscrns); |
| 825 | } |
| 826 | |
| 827 | static void |
| 828 | test_screen_bad_render_order(struct test_context *ctx) |
| 829 | { |
| 830 | #define LAYER_NUM (3) |
| 831 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 832 | struct ivi_layout_screen **iviscrns; |
| 833 | int32_t screen_length; |
| 834 | struct ivi_layout_screen *iviscrn; |
| 835 | struct ivi_layout_layer *ivilayers[LAYER_NUM] = {}; |
| 836 | struct ivi_layout_layer **array; |
| 837 | int32_t length = 0; |
| 838 | uint32_t i; |
| 839 | |
| 840 | iassert(ctl->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED); |
| 841 | iassert(screen_length > 0); |
| 842 | |
| 843 | if (screen_length <= 0) |
| 844 | return; |
| 845 | |
| 846 | iviscrn = iviscrns[0]; |
| 847 | |
| 848 | for (i = 0; i < LAYER_NUM; i++) |
| 849 | ivilayers[i] = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300); |
| 850 | |
| 851 | iassert(ctl->screen_set_render_order(NULL, ivilayers, LAYER_NUM) == IVI_FAILED); |
| 852 | |
| 853 | ctl->commit_changes(); |
| 854 | |
| 855 | iassert(ctl->get_layers_on_screen(NULL, &length, &array) == IVI_FAILED); |
| 856 | iassert(ctl->get_layers_on_screen(iviscrn, NULL, &array) == IVI_FAILED); |
| 857 | iassert(ctl->get_layers_on_screen(iviscrn, &length, NULL) == IVI_FAILED); |
| 858 | |
| 859 | for (i = 0; i < LAYER_NUM; i++) |
| 860 | ctl->layer_destroy(ivilayers[i]); |
| 861 | |
| 862 | free(iviscrns); |
| 863 | #undef LAYER_NUM |
| 864 | } |
| 865 | |
| 866 | static void |
| 867 | test_commit_changes_after_render_order_set_layer_destroy( |
| 868 | struct test_context *ctx) |
| 869 | { |
| 870 | #define LAYER_NUM (3) |
| 871 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 872 | struct ivi_layout_screen **iviscrns; |
| 873 | int32_t screen_length; |
| 874 | struct ivi_layout_screen *iviscrn; |
| 875 | struct ivi_layout_layer *ivilayers[LAYER_NUM] = {}; |
| 876 | uint32_t i; |
| 877 | |
| 878 | iassert(ctl->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED); |
| 879 | iassert(screen_length > 0); |
| 880 | |
| 881 | if (screen_length <= 0) |
| 882 | return; |
| 883 | |
| 884 | iviscrn = iviscrns[0]; |
| 885 | |
| 886 | for (i = 0; i < LAYER_NUM; i++) |
| 887 | ivilayers[i] = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300); |
| 888 | |
| 889 | iassert(ctl->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED); |
| 890 | |
| 891 | ctl->layer_destroy(ivilayers[1]); |
| 892 | |
| 893 | ctl->commit_changes(); |
| 894 | |
| 895 | ctl->layer_destroy(ivilayers[0]); |
| 896 | ctl->layer_destroy(ivilayers[2]); |
| 897 | |
| 898 | free(iviscrns); |
| 899 | #undef LAYER_NUM |
| 900 | } |
| 901 | |
Nobuhiko Tanibata | 495c6ef | 2015-06-22 15:36:11 +0900 | [diff] [blame] | 902 | static void |
| 903 | test_layer_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer, |
| 904 | const struct ivi_layout_layer_properties *prop, |
| 905 | enum ivi_layout_notification_mask mask, |
| 906 | void *userdata) |
| 907 | { |
| 908 | struct test_context *ctx = userdata; |
| 909 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 910 | |
| 911 | iassert(ctl->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0)); |
| 912 | iassert(prop->source_width == 200); |
| 913 | iassert(prop->source_height == 300); |
| 914 | |
| 915 | if (ctl->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) && |
| 916 | prop->source_width == 200 && prop->source_height == 300) |
| 917 | ctx->user_flags = 1; |
| 918 | } |
| 919 | |
| 920 | static void |
| 921 | test_layer_properties_changed_notification(struct test_context *ctx) |
| 922 | { |
| 923 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 924 | struct ivi_layout_layer *ivilayer; |
| 925 | |
| 926 | ctx->user_flags = 0; |
| 927 | |
| 928 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 929 | |
| 930 | iassert(ctl->layer_add_notification(ivilayer, test_layer_properties_changed_notification_callback, ctx) == IVI_SUCCEEDED); |
| 931 | |
| 932 | ctl->commit_changes(); |
| 933 | |
| 934 | iassert(ctx->user_flags == 0); |
| 935 | |
| 936 | iassert(ctl->layer_set_destination_rectangle( |
| 937 | ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED); |
| 938 | |
| 939 | ctl->commit_changes(); |
| 940 | |
| 941 | iassert(ctx->user_flags == 1); |
| 942 | |
| 943 | ctx->user_flags = 0; |
| 944 | iassert(ctl->layer_set_destination_rectangle( |
| 945 | ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED); |
| 946 | |
| 947 | ctl->commit_changes(); |
| 948 | |
| 949 | iassert(ctx->user_flags == 0); |
| 950 | |
| 951 | ctl->layer_remove_notification(ivilayer); |
| 952 | |
| 953 | ctx->user_flags = 0; |
| 954 | ctl->commit_changes(); |
| 955 | |
| 956 | iassert(ctx->user_flags == 0); |
| 957 | |
| 958 | ctl->layer_destroy(ivilayer); |
| 959 | } |
| 960 | |
| 961 | static void |
| 962 | test_layer_create_notification_callback(struct ivi_layout_layer *ivilayer, |
| 963 | void *userdata) |
| 964 | { |
| 965 | struct test_context *ctx = userdata; |
| 966 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 967 | const struct ivi_layout_layer_properties *prop = ctl->get_properties_of_layer(ivilayer); |
| 968 | |
| 969 | iassert(ctl->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0)); |
| 970 | iassert(prop->source_width == 200); |
| 971 | iassert(prop->source_height == 300); |
| 972 | |
| 973 | if (ctl->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) && |
| 974 | prop->source_width == 200 && prop->source_height == 300) |
| 975 | ctx->user_flags = 1; |
| 976 | } |
| 977 | |
| 978 | static void |
| 979 | test_layer_create_notification(struct test_context *ctx) |
| 980 | { |
| 981 | #define LAYER_NUM (2) |
| 982 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 983 | static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)}; |
| 984 | struct ivi_layout_layer *ivilayers[LAYER_NUM] = {}; |
| 985 | |
| 986 | ctx->user_flags = 0; |
| 987 | |
| 988 | iassert(ctl->add_notification_create_layer( |
| 989 | test_layer_create_notification_callback, ctx) == IVI_SUCCEEDED); |
| 990 | ivilayers[0] = ctl->layer_create_with_dimension(layers[0], 200, 300); |
| 991 | |
| 992 | iassert(ctx->user_flags == 1); |
| 993 | |
| 994 | ctx->user_flags = 0; |
| 995 | ctl->remove_notification_create_layer(test_layer_create_notification_callback, ctx); |
| 996 | |
| 997 | ivilayers[1] = ctl->layer_create_with_dimension(layers[1], 400, 500); |
| 998 | |
| 999 | iassert(ctx->user_flags == 0); |
| 1000 | |
| 1001 | ctl->layer_destroy(ivilayers[0]); |
| 1002 | ctl->layer_destroy(ivilayers[1]); |
| 1003 | #undef LAYER_NUM |
| 1004 | } |
| 1005 | |
| 1006 | static void |
| 1007 | test_layer_remove_notification_callback(struct ivi_layout_layer *ivilayer, |
| 1008 | void *userdata) |
| 1009 | { |
| 1010 | struct test_context *ctx = userdata; |
| 1011 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 1012 | const struct ivi_layout_layer_properties *prop = |
| 1013 | ctl->get_properties_of_layer(ivilayer); |
| 1014 | |
| 1015 | iassert(ctl->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0)); |
| 1016 | iassert(prop->source_width == 200); |
| 1017 | iassert(prop->source_height == 300); |
| 1018 | |
| 1019 | if (ctl->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) && |
| 1020 | prop->source_width == 200 && prop->source_height == 300) |
| 1021 | ctx->user_flags = 1; |
| 1022 | } |
| 1023 | |
| 1024 | static void |
| 1025 | test_layer_remove_notification(struct test_context *ctx) |
| 1026 | { |
| 1027 | #define LAYER_NUM (2) |
| 1028 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 1029 | static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)}; |
| 1030 | struct ivi_layout_layer *ivilayers[LAYER_NUM] = {}; |
| 1031 | |
| 1032 | ctx->user_flags = 0; |
| 1033 | |
| 1034 | ivilayers[0] = ctl->layer_create_with_dimension(layers[0], 200, 300); |
| 1035 | iassert(ctl->add_notification_remove_layer( |
| 1036 | test_layer_remove_notification_callback, ctx) == IVI_SUCCEEDED); |
| 1037 | ctl->layer_destroy(ivilayers[0]); |
| 1038 | |
| 1039 | iassert(ctx->user_flags == 1); |
| 1040 | |
| 1041 | ctx->user_flags = 0; |
| 1042 | ivilayers[1] = ctl->layer_create_with_dimension(layers[1], 250, 350); |
| 1043 | ctl->remove_notification_remove_layer(test_layer_remove_notification_callback, ctx); |
| 1044 | ctl->layer_destroy(ivilayers[1]); |
| 1045 | |
| 1046 | iassert(ctx->user_flags == 0); |
| 1047 | #undef LAYER_NUM |
| 1048 | } |
| 1049 | |
Nobuhiko Tanibata | ffcc452 | 2015-06-22 15:37:41 +0900 | [diff] [blame] | 1050 | static void |
| 1051 | test_layer_bad_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer, |
| 1052 | const struct ivi_layout_layer_properties *prop, |
| 1053 | enum ivi_layout_notification_mask mask, |
| 1054 | void *userdata) |
| 1055 | { |
| 1056 | } |
| 1057 | |
| 1058 | static void |
| 1059 | test_layer_bad_properties_changed_notification(struct test_context *ctx) |
| 1060 | { |
| 1061 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 1062 | struct ivi_layout_layer *ivilayer; |
| 1063 | |
| 1064 | ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300); |
| 1065 | |
| 1066 | iassert(ctl->layer_add_notification( |
| 1067 | NULL, test_layer_bad_properties_changed_notification_callback, NULL) == IVI_FAILED); |
| 1068 | iassert(ctl->layer_add_notification(ivilayer, NULL, NULL) == IVI_FAILED); |
| 1069 | |
| 1070 | ctl->layer_destroy(ivilayer); |
| 1071 | } |
| 1072 | |
| 1073 | static void |
| 1074 | test_surface_bad_configure_notification(struct test_context *ctx) |
| 1075 | { |
| 1076 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 1077 | |
| 1078 | iassert(ctl->add_notification_configure_surface(NULL, NULL) == IVI_FAILED); |
| 1079 | } |
| 1080 | |
| 1081 | static void |
| 1082 | test_layer_bad_create_notification(struct test_context *ctx) |
| 1083 | { |
| 1084 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 1085 | |
| 1086 | iassert(ctl->add_notification_create_layer(NULL, NULL) == IVI_FAILED); |
| 1087 | } |
| 1088 | |
| 1089 | static void |
| 1090 | test_surface_bad_create_notification(struct test_context *ctx) |
| 1091 | { |
| 1092 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 1093 | |
| 1094 | iassert(ctl->add_notification_create_surface(NULL, NULL) == IVI_FAILED); |
| 1095 | } |
| 1096 | |
| 1097 | static void |
| 1098 | test_layer_bad_remove_notification(struct test_context *ctx) |
| 1099 | { |
| 1100 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 1101 | |
| 1102 | iassert(ctl->add_notification_remove_layer(NULL, NULL) == IVI_FAILED); |
| 1103 | } |
| 1104 | |
| 1105 | static void |
| 1106 | test_surface_bad_remove_notification(struct test_context *ctx) |
| 1107 | { |
| 1108 | const struct ivi_controller_interface *ctl = ctx->controller_interface; |
| 1109 | |
| 1110 | iassert(ctl->add_notification_remove_surface(NULL, NULL) == IVI_FAILED); |
| 1111 | } |
| 1112 | |
Pekka Paalanen | 46804ca | 2015-03-27 11:55:21 +0200 | [diff] [blame] | 1113 | /************************ tests end ********************************/ |
| 1114 | |
| 1115 | static void |
| 1116 | run_internal_tests(void *data) |
| 1117 | { |
| 1118 | struct test_context *ctx = data; |
| 1119 | |
| 1120 | test_surface_bad_visibility(ctx); |
Nobuhiko Tanibata | 16ed543 | 2015-06-22 15:33:59 +0900 | [diff] [blame] | 1121 | test_surface_bad_destination_rectangle(ctx); |
| 1122 | test_surface_bad_orientation(ctx); |
| 1123 | test_surface_bad_dimension(ctx); |
| 1124 | test_surface_bad_position(ctx); |
| 1125 | test_surface_bad_source_rectangle(ctx); |
| 1126 | test_surface_bad_properties(ctx); |
Pekka Paalanen | 46804ca | 2015-03-27 11:55:21 +0200 | [diff] [blame] | 1127 | |
Nobuhiko Tanibata | 9e992d9 | 2015-06-22 15:34:18 +0900 | [diff] [blame] | 1128 | test_layer_create(ctx); |
| 1129 | test_layer_visibility(ctx); |
| 1130 | test_layer_opacity(ctx); |
| 1131 | test_layer_orientation(ctx); |
| 1132 | test_layer_dimension(ctx); |
| 1133 | test_layer_position(ctx); |
| 1134 | test_layer_destination_rectangle(ctx); |
| 1135 | test_layer_source_rectangle(ctx); |
Nobuhiko Tanibata | 17d4494 | 2015-06-22 15:35:12 +0900 | [diff] [blame] | 1136 | test_layer_bad_remove(ctx); |
| 1137 | test_layer_bad_visibility(ctx); |
| 1138 | test_layer_bad_opacity(ctx); |
| 1139 | test_layer_bad_destination_rectangle(ctx); |
| 1140 | test_layer_bad_orientation(ctx); |
| 1141 | test_layer_bad_dimension(ctx); |
| 1142 | test_layer_bad_position(ctx); |
| 1143 | test_layer_bad_source_rectangle(ctx); |
| 1144 | test_layer_bad_properties(ctx); |
| 1145 | test_commit_changes_after_visibility_set_layer_destroy(ctx); |
| 1146 | test_commit_changes_after_opacity_set_layer_destroy(ctx); |
| 1147 | test_commit_changes_after_orientation_set_layer_destroy(ctx); |
| 1148 | test_commit_changes_after_dimension_set_layer_destroy(ctx); |
| 1149 | test_commit_changes_after_position_set_layer_destroy(ctx); |
| 1150 | test_commit_changes_after_source_rectangle_set_layer_destroy(ctx); |
| 1151 | test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx); |
| 1152 | test_layer_create_duplicate(ctx); |
| 1153 | test_get_layer_after_destory_layer(ctx); |
Nobuhiko Tanibata | 9e992d9 | 2015-06-22 15:34:18 +0900 | [diff] [blame] | 1154 | |
Nobuhiko Tanibata | e78a7af | 2015-06-22 15:35:25 +0900 | [diff] [blame] | 1155 | test_screen_id(ctx); |
| 1156 | test_screen_resolution(ctx); |
| 1157 | test_screen_render_order(ctx); |
Nobuhiko Tanibata | 83c20bc | 2015-06-22 15:35:39 +0900 | [diff] [blame] | 1158 | test_screen_bad_resolution(ctx); |
| 1159 | test_screen_bad_render_order(ctx); |
| 1160 | test_commit_changes_after_render_order_set_layer_destroy(ctx); |
| 1161 | |
Nobuhiko Tanibata | 495c6ef | 2015-06-22 15:36:11 +0900 | [diff] [blame] | 1162 | test_layer_properties_changed_notification(ctx); |
| 1163 | test_layer_create_notification(ctx); |
| 1164 | test_layer_remove_notification(ctx); |
Nobuhiko Tanibata | ffcc452 | 2015-06-22 15:37:41 +0900 | [diff] [blame] | 1165 | test_layer_bad_properties_changed_notification(ctx); |
| 1166 | test_surface_bad_configure_notification(ctx); |
| 1167 | test_layer_bad_create_notification(ctx); |
| 1168 | test_surface_bad_create_notification(ctx); |
| 1169 | test_layer_bad_remove_notification(ctx); |
| 1170 | test_surface_bad_remove_notification(ctx); |
Nobuhiko Tanibata | e78a7af | 2015-06-22 15:35:25 +0900 | [diff] [blame] | 1171 | |
Pekka Paalanen | 46804ca | 2015-03-27 11:55:21 +0200 | [diff] [blame] | 1172 | weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS); |
| 1173 | free(ctx); |
| 1174 | } |
| 1175 | |
| 1176 | int |
| 1177 | controller_module_init(struct weston_compositor *compositor, |
| 1178 | int *argc, char *argv[], |
| 1179 | const struct ivi_controller_interface *iface, |
| 1180 | size_t iface_version); |
| 1181 | |
| 1182 | WL_EXPORT int |
| 1183 | controller_module_init(struct weston_compositor *compositor, |
| 1184 | int *argc, char *argv[], |
| 1185 | const struct ivi_controller_interface *iface, |
| 1186 | size_t iface_version) |
| 1187 | { |
| 1188 | struct wl_event_loop *loop; |
| 1189 | struct test_context *ctx; |
| 1190 | |
| 1191 | /* strict check, since this is an internal test module */ |
| 1192 | if (iface_version != sizeof(*iface)) { |
| 1193 | weston_log("fatal: controller interface mismatch\n"); |
| 1194 | return -1; |
| 1195 | } |
| 1196 | |
| 1197 | ctx = zalloc(sizeof(*ctx)); |
| 1198 | if (!ctx) |
| 1199 | return -1; |
| 1200 | |
| 1201 | ctx->compositor = compositor; |
| 1202 | ctx->controller_interface = iface; |
| 1203 | |
| 1204 | loop = wl_display_get_event_loop(compositor->wl_display); |
| 1205 | wl_event_loop_add_idle(loop, run_internal_tests, ctx); |
| 1206 | |
| 1207 | return 0; |
| 1208 | } |