Newer
Older

Nobuhiko Tanibata
committed
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
ctl->layer_destroy(ivilayers[0]);
ctl->layer_destroy(ivilayers[1]);
#undef LAYER_NUM
}
static void
test_layer_remove_notification_callback(struct ivi_layout_layer *ivilayer,
void *userdata)
{
struct test_context *ctx = userdata;
const struct ivi_controller_interface *ctl = ctx->controller_interface;
const struct ivi_layout_layer_properties *prop =
ctl->get_properties_of_layer(ivilayer);
iassert(ctl->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
iassert(prop->source_width == 200);
iassert(prop->source_height == 300);
if (ctl->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
prop->source_width == 200 && prop->source_height == 300)
ctx->user_flags = 1;
}
static void
test_layer_remove_notification(struct test_context *ctx)
{
#define LAYER_NUM (2)
const struct ivi_controller_interface *ctl = ctx->controller_interface;
static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
ctx->user_flags = 0;
ivilayers[0] = ctl->layer_create_with_dimension(layers[0], 200, 300);
iassert(ctl->add_notification_remove_layer(
test_layer_remove_notification_callback, ctx) == IVI_SUCCEEDED);
ctl->layer_destroy(ivilayers[0]);
iassert(ctx->user_flags == 1);
ctx->user_flags = 0;
ivilayers[1] = ctl->layer_create_with_dimension(layers[1], 250, 350);
ctl->remove_notification_remove_layer(test_layer_remove_notification_callback, ctx);
ctl->layer_destroy(ivilayers[1]);
iassert(ctx->user_flags == 0);
#undef LAYER_NUM
}

Nobuhiko Tanibata
committed
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
static void
test_layer_bad_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
const struct ivi_layout_layer_properties *prop,
enum ivi_layout_notification_mask mask,
void *userdata)
{
}
static void
test_layer_bad_properties_changed_notification(struct test_context *ctx)
{
const struct ivi_controller_interface *ctl = ctx->controller_interface;
struct ivi_layout_layer *ivilayer;
ivilayer = ctl->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
iassert(ctl->layer_add_notification(
NULL, test_layer_bad_properties_changed_notification_callback, NULL) == IVI_FAILED);
iassert(ctl->layer_add_notification(ivilayer, NULL, NULL) == IVI_FAILED);
ctl->layer_destroy(ivilayer);
}
static void
test_surface_bad_configure_notification(struct test_context *ctx)
{
const struct ivi_controller_interface *ctl = ctx->controller_interface;
iassert(ctl->add_notification_configure_surface(NULL, NULL) == IVI_FAILED);
}
static void
test_layer_bad_create_notification(struct test_context *ctx)
{
const struct ivi_controller_interface *ctl = ctx->controller_interface;
iassert(ctl->add_notification_create_layer(NULL, NULL) == IVI_FAILED);
}
static void
test_surface_bad_create_notification(struct test_context *ctx)
{
const struct ivi_controller_interface *ctl = ctx->controller_interface;
iassert(ctl->add_notification_create_surface(NULL, NULL) == IVI_FAILED);
}
static void
test_layer_bad_remove_notification(struct test_context *ctx)
{
const struct ivi_controller_interface *ctl = ctx->controller_interface;
iassert(ctl->add_notification_remove_layer(NULL, NULL) == IVI_FAILED);
}
static void
test_surface_bad_remove_notification(struct test_context *ctx)
{
const struct ivi_controller_interface *ctl = ctx->controller_interface;
iassert(ctl->add_notification_remove_surface(NULL, NULL) == IVI_FAILED);
}
/************************ tests end ********************************/
static void
run_internal_tests(void *data)
{
struct test_context *ctx = data;
test_surface_bad_visibility(ctx);
test_surface_bad_destination_rectangle(ctx);
test_surface_bad_orientation(ctx);
test_surface_bad_dimension(ctx);
test_surface_bad_position(ctx);
test_surface_bad_source_rectangle(ctx);
test_surface_bad_properties(ctx);
test_layer_create(ctx);
test_layer_visibility(ctx);
test_layer_opacity(ctx);
test_layer_orientation(ctx);
test_layer_dimension(ctx);
test_layer_position(ctx);
test_layer_destination_rectangle(ctx);
test_layer_source_rectangle(ctx);
test_layer_bad_remove(ctx);
test_layer_bad_visibility(ctx);
test_layer_bad_opacity(ctx);
test_layer_bad_destination_rectangle(ctx);
test_layer_bad_orientation(ctx);
test_layer_bad_dimension(ctx);
test_layer_bad_position(ctx);
test_layer_bad_source_rectangle(ctx);
test_layer_bad_properties(ctx);
test_commit_changes_after_visibility_set_layer_destroy(ctx);
test_commit_changes_after_opacity_set_layer_destroy(ctx);
test_commit_changes_after_orientation_set_layer_destroy(ctx);
test_commit_changes_after_dimension_set_layer_destroy(ctx);
test_commit_changes_after_position_set_layer_destroy(ctx);
test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
test_layer_create_duplicate(ctx);
test_get_layer_after_destory_layer(ctx);
test_screen_id(ctx);
test_screen_resolution(ctx);
test_screen_render_order(ctx);
test_screen_bad_resolution(ctx);
test_screen_bad_render_order(ctx);
test_commit_changes_after_render_order_set_layer_destroy(ctx);

Nobuhiko Tanibata
committed
test_layer_properties_changed_notification(ctx);
test_layer_create_notification(ctx);
test_layer_remove_notification(ctx);

Nobuhiko Tanibata
committed
test_layer_bad_properties_changed_notification(ctx);
test_surface_bad_configure_notification(ctx);
test_layer_bad_create_notification(ctx);
test_surface_bad_create_notification(ctx);
test_layer_bad_remove_notification(ctx);
test_surface_bad_remove_notification(ctx);
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
free(ctx);
}
int
controller_module_init(struct weston_compositor *compositor,
int *argc, char *argv[],
const struct ivi_controller_interface *iface,
size_t iface_version);
WL_EXPORT int
controller_module_init(struct weston_compositor *compositor,
int *argc, char *argv[],
const struct ivi_controller_interface *iface,
size_t iface_version)
{
struct wl_event_loop *loop;
struct test_context *ctx;
/* strict check, since this is an internal test module */
if (iface_version != sizeof(*iface)) {
weston_log("fatal: controller interface mismatch\n");
return -1;
}
ctx = zalloc(sizeof(*ctx));
if (!ctx)
return -1;
ctx->compositor = compositor;
ctx->controller_interface = iface;
loop = wl_display_get_event_loop(compositor->wl_display);
wl_event_loop_add_idle(loop, run_internal_tests, ctx);
return 0;
}