[PATCH weston 3/3] ivi-shell: implement surface_on_many_layer test

Ucan, Emre (ADITG/SW1) eucan at de.adit-jv.com
Tue Jun 7 09:40:21 UTC 2016


A surface can be added to many layers.
This test is implemented to test this use-case
and the correct behaviour of get_layers_under_surface
API.

Signed-off-by: Emre Ucan <eucan at de.adit-jv.com>
---
 tests/ivi-test.h               |    1 +
 tests/ivi_layout-test-plugin.c |   45 ++++++++++++++++++++++++++++++++++++++++
 tests/ivi_layout-test.c        |    1 +
 3 files changed, 47 insertions(+)

diff --git a/tests/ivi-test.h b/tests/ivi-test.h
index 5cb4739..5706ed8 100644
--- a/tests/ivi-test.h
+++ b/tests/ivi-test.h
@@ -37,5 +37,6 @@
 #define IVI_TEST_LAYER_ID(i) (IVI_TEST_LAYER_ID_BASE + i)
 
 #define IVI_TEST_SURFACE_COUNT (3)
+#define IVI_TEST_LAYER_COUNT (3)
 
 #endif /* IVI_TEST_H */
diff --git a/tests/ivi_layout-test-plugin.c b/tests/ivi_layout-test-plugin.c
index 362893e..4dbb8f5 100644
--- a/tests/ivi_layout-test-plugin.c
+++ b/tests/ivi_layout-test-plugin.c
@@ -588,6 +588,51 @@ RUNNER_TEST(surface_bad_opacity)
 	lyt->commit_changes();
 }
 
+RUNNER_TEST(surface_on_many_layer)
+{
+	const struct ivi_layout_interface *lyt = ctx->layout_interface;
+	struct ivi_layout_surface *ivisurf;
+	struct ivi_layout_layer *ivilayers[IVI_TEST_LAYER_COUNT] = {};
+	struct ivi_layout_layer **array;
+	int32_t length = 0;
+	uint32_t i;
+
+	ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
+	runner_assert(ivisurf != NULL);
+
+	for (i = 0; i < IVI_TEST_LAYER_COUNT; i++) {
+		ivilayers[i] = lyt->layer_create_with_dimension(
+				IVI_TEST_LAYER_ID(i), 200, 300);
+		runner_assert(lyt->layer_add_surface(
+				ivilayers[i], ivisurf) == IVI_SUCCEEDED);
+	}
+
+	lyt->commit_changes();
+
+	runner_assert(lyt->get_layers_under_surface(
+		      ivisurf, &length, &array) == IVI_SUCCEEDED);
+	runner_assert(IVI_TEST_LAYER_COUNT == length);
+	for (i = 0; i < IVI_TEST_LAYER_COUNT; i++)
+		runner_assert(array[i] == ivilayers[i]);
+
+	if (length > 0)
+		free(array);
+
+	for (i = 0; i < IVI_TEST_LAYER_COUNT; i++)
+		lyt->layer_remove_surface(ivilayers[i], ivisurf);
+
+	array = NULL;
+
+	lyt->commit_changes();
+
+	runner_assert(lyt->get_layers_under_surface(
+		      ivisurf, &length, &array) == IVI_SUCCEEDED);
+	runner_assert(length == 0 && array == NULL);
+
+	for (i = 0; i < IVI_TEST_LAYER_COUNT; i++)
+		lyt->layer_destroy(ivilayers[i]);
+}
+
 RUNNER_TEST(ivi_layout_commit_changes)
 {
 	const struct ivi_layout_interface *lyt = ctx->layout_interface;
diff --git a/tests/ivi_layout-test.c b/tests/ivi_layout-test.c
index b775abe..4814e2d 100644
--- a/tests/ivi_layout-test.c
+++ b/tests/ivi_layout-test.c
@@ -199,6 +199,7 @@ const char * const basic_test_names[] = {
 	"surface_bad_opacity",
 	"surface_properties_changed_notification",
 	"surface_bad_properties_changed_notification",
+	"surface_on_many_layer",
 };
 
 const char * const surface_property_commit_changes_test_names[] = {
-- 
1.7.9.5



More information about the wayland-devel mailing list