Skip to content
Snippets Groups Projects
ivi_layout-internal-test.c 32.2 KiB
Newer Older
	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
}

/************************ 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);

	test_layer_properties_changed_notification(ctx);
	test_layer_create_notification(ctx);
	test_layer_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_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;
}