Newer
Older

Nobuhiko Tanibata
committed
void *userdata)
{
struct test_context *ctx = userdata;
const struct ivi_layout_interface *lyt = ctx->layout_interface;

Nobuhiko Tanibata
committed
const struct ivi_layout_layer_properties *prop =
lyt->get_properties_of_layer(ivilayer);

Nobuhiko Tanibata
committed
iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));

Nobuhiko Tanibata
committed
iassert(prop->source_width == 200);
iassert(prop->source_height == 300);
if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&

Nobuhiko Tanibata
committed
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_layout_interface *lyt = ctx->layout_interface;

Nobuhiko Tanibata
committed
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] = lyt->layer_create_with_dimension(layers[0], 200, 300);
iassert(lyt->add_notification_remove_layer(

Nobuhiko Tanibata
committed
test_layer_remove_notification_callback, ctx) == IVI_SUCCEEDED);
lyt->layer_destroy(ivilayers[0]);

Nobuhiko Tanibata
committed
iassert(ctx->user_flags == 1);
ctx->user_flags = 0;
ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
lyt->remove_notification_remove_layer(test_layer_remove_notification_callback, ctx);
lyt->layer_destroy(ivilayers[1]);

Nobuhiko Tanibata
committed
iassert(ctx->user_flags == 0);
#undef LAYER_NUM
}

Nobuhiko Tanibata
committed
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_layout_interface *lyt = ctx->layout_interface;

Nobuhiko Tanibata
committed
struct ivi_layout_layer *ivilayer;
ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);

Nobuhiko Tanibata
committed
iassert(lyt->layer_add_notification(

Nobuhiko Tanibata
committed
NULL, test_layer_bad_properties_changed_notification_callback, NULL) == IVI_FAILED);
iassert(lyt->layer_add_notification(ivilayer, NULL, NULL) == IVI_FAILED);

Nobuhiko Tanibata
committed
lyt->layer_destroy(ivilayer);

Nobuhiko Tanibata
committed
}
static void
test_surface_bad_configure_notification(struct test_context *ctx)
{
const struct ivi_layout_interface *lyt = ctx->layout_interface;

Nobuhiko Tanibata
committed
iassert(lyt->add_notification_configure_surface(NULL, NULL) == IVI_FAILED);

Nobuhiko Tanibata
committed
}
static void
test_layer_bad_create_notification(struct test_context *ctx)
{
const struct ivi_layout_interface *lyt = ctx->layout_interface;

Nobuhiko Tanibata
committed
iassert(lyt->add_notification_create_layer(NULL, NULL) == IVI_FAILED);

Nobuhiko Tanibata
committed
}
static void
test_surface_bad_create_notification(struct test_context *ctx)
{
const struct ivi_layout_interface *lyt = ctx->layout_interface;

Nobuhiko Tanibata
committed
iassert(lyt->add_notification_create_surface(NULL, NULL) == IVI_FAILED);

Nobuhiko Tanibata
committed
}
static void
test_layer_bad_remove_notification(struct test_context *ctx)
{
const struct ivi_layout_interface *lyt = ctx->layout_interface;

Nobuhiko Tanibata
committed
iassert(lyt->add_notification_remove_layer(NULL, NULL) == IVI_FAILED);

Nobuhiko Tanibata
committed
}
static void
test_surface_bad_remove_notification(struct test_context *ctx)
{
const struct ivi_layout_interface *lyt = ctx->layout_interface;

Nobuhiko Tanibata
committed
iassert(lyt->add_notification_remove_surface(NULL, NULL) == IVI_FAILED);

Nobuhiko Tanibata
committed
}
/************************ 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);
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_layout_interface *iface,
size_t iface_version);
WL_EXPORT int
controller_module_init(struct weston_compositor *compositor,
int *argc, char *argv[],
const struct ivi_layout_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->layout_interface = iface;
loop = wl_display_get_event_loop(compositor->wl_display);
wl_event_loop_add_idle(loop, run_internal_tests, ctx);
return 0;
}