[PATCH weston 9/9] tests: add ivi_layout stand-alone test module

Tanibata, Nobuhiko (ADITJ/SWG) ntanibata at jp.adit-jv.com
Wed Apr 1 18:05:09 PDT 2015



> -----Original Message-----
> From: wayland-devel
> [mailto:wayland-devel-bounces at lists.freedesktop.org] On Behalf Of Pekka
> Paalanen
> Sent: Monday, March 30, 2015 6:21 PM
> To: wayland-devel at lists.freedesktop.org
> Cc: Pekka Paalanen; Nobuhiko Tanibata
> Subject: [PATCH weston 9/9] tests: add ivi_layout stand-alone test module
> 
> From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> 
> This is the ivi_layout stand-alone test controller module that does not
> require any clients to run. Therefore it is much simpler than
> ivi_layout-test-plugin.c and does not need a matching part in
> ivi_layout-test.c.
> 
> Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
[ntanibata] 
Tested-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA at xddp.denso.co.jp>

BR,
Nobuhiko Tanibata

> ---
>  Makefile.am                      |   7 +++
>  tests/ivi_layout-internal-test.c | 121
> +++++++++++++++++++++++++++++++++++++++
>  2 files changed, 128 insertions(+)
>  create mode 100644 tests/ivi_layout-internal-test.c
> 
> diff --git a/Makefile.am b/Makefile.am
> index 6a4e121..626c2f3 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -1092,8 +1092,15 @@ matrix_test_LDADD = -lm -lrt
> 
>  if ENABLE_IVI_SHELL
>  module_tests += 				\
> +	ivi-layout-internal-test.la		\
>  	ivi-layout-test.la
> 
> +ivi_layout_internal_test_la_LIBADD = $(COMPOSITOR_LIBS)
> +ivi_layout_internal_test_la_LDFLAGS = $(test_module_ldflags)
> +ivi_layout_internal_test_la_CFLAGS = $(GCC_CFLAGS) $(COMPOSITOR_CFLAGS)
> +ivi_layout_internal_test_la_SOURCES =			\
> +	tests/ivi_layout-internal-test.c
> +
>  ivi_layout_test_la_LIBADD = $(COMPOSITOR_LIBS)
> ivi_layout_test_la_LDFLAGS = $(test_module_ldflags)
> ivi_layout_test_la_CFLAGS = $(GCC_CFLAGS) $(COMPOSITOR_CFLAGS) diff --git
> a/tests/ivi_layout-internal-test.c b/tests/ivi_layout-internal-test.c
> new file mode 100644
> index 0000000..f8ffdee
> --- /dev/null
> +++ b/tests/ivi_layout-internal-test.c
> @@ -0,0 +1,121 @@
> +/*
> + * Copyright © 2013 DENSO CORPORATION
> + * Copyright © 2015 Collabora, Ltd.
> + *
> + * Permission to use, copy, modify, distribute, and sell this software
> +and
> + * its documentation for any purpose is hereby granted without fee,
> +provided
> + * that the above copyright notice appear in all copies and that both
> +that
> + * copyright notice and this permission notice appear in supporting
> + * documentation, and that the name of the copyright holders not be
> +used in
> + * advertising or publicity pertaining to distribution of the software
> + * without specific, written prior permission.  The copyright holders
> +make
> + * no representations about the suitability of this software for any
> + * purpose.  It is provided "as is" without express or implied warranty.
> + *
> + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
> + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
> + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
> + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
> + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
> + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
> + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> + */
> +
> +#include "config.h"
> +
> +#include <unistd.h>
> +#include <signal.h>
> +#include <string.h>
> +#include <stdbool.h>
> +
> +#include "../src/compositor.h"
> +#include "../ivi-shell/ivi-layout-export.h"
> +
> +struct test_context {
> +	struct weston_compositor *compositor;
> +	const struct ivi_controller_interface *controller_interface; };
> +
> +static void
> +iassert_fail(const char *cond, const char *file, int line,
> +	     const char *func, struct test_context *ctx) {
> +	weston_log("Assert failure in %s:%d, %s: '%s'\n",
> +		   file, line, func, cond);
> +	weston_compositor_exit_with_code(ctx->compositor,
> EXIT_FAILURE); }
> +
> +#define iassert(cond) ({
> 	\
> +	bool b_ = (cond);
> 	\
> +	if (!b_)
> 	\
> +		iassert_fail(#cond, __FILE__, __LINE__, __func__, ctx);
> 	\
> +	b_;
> 	\
> +})
> +
> +/************************ tests begin ******************************/
> +
> +/*
> + * These are all internal ivi_layout API tests that do not require
> + * any client objects.
> + */
> +
> +static void
> +test_surface_bad_visibility(struct test_context *ctx) {
> +	const struct ivi_controller_interface *ctl =
> ctx->controller_interface;
> +	bool visibility;
> +
> +	iassert(ctl->surface_set_visibility(NULL, true) == IVI_FAILED);
> +
> +	ctl->commit_changes();
> +
> +	visibility = ctl->surface_get_visibility(NULL);
> +	iassert(visibility == false);
> +}
> +
> +/************************ tests end ********************************/
> +
> +static void
> +run_internal_tests(void *data)
> +{
> +	struct test_context *ctx = data;
> +
> +	test_surface_bad_visibility(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;
> +}
> --
> 2.0.5
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list