diff options
author | Ucan, Emre (ADITG/SW1) <eucan@de.adit-jv.com> | 2016-04-04 08:05:03 +0000 |
---|---|---|
committer | Pekka Paalanen <pekka.paalanen@collabora.co.uk> | 2016-04-05 11:53:48 +0300 |
commit | 706cb5aa7ce7c106e4d5218e49d5940155ac0e0b (patch) | |
tree | 19e69116e96491aa7e7d16b50b2cf3a0c96447a1 /tests | |
parent | 0bd29b6a52f0dfbc2d8f96e5da967fc36e52190c (diff) | |
download | weston-706cb5aa7ce7c106e4d5218e49d5940155ac0e0b.tar.gz |
ivi-shell: rework surface_add_notification API
The surface_add_notification API accepts a simple
wl_listener instead of a ivi-shell specific notification
function. Therefore, the API is renamed to surface_add_listener.
This change has several advantages:
1. Code cleanup
2. No dynamic memory allocation. Listeners are allocated
by controller plugins
3. Remove API is not needed. Controller plugins can easily
remove the listener link.
This patch also remove two APIs which are not needed:
- ivi_layout_surface_remove_notification
- ivi_layout_surface_remove_notification_by_callback
Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ivi_layout-test-plugin.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/tests/ivi_layout-test-plugin.c b/tests/ivi_layout-test-plugin.c index 7c72c36c..aaba7246 100644 --- a/tests/ivi_layout-test-plugin.c +++ b/tests/ivi_layout-test-plugin.c @@ -83,6 +83,8 @@ struct test_context { const struct ivi_layout_interface *layout_interface; struct wl_resource *runner_resource; uint32_t user_flags; + + struct wl_listener surface_property_changed; }; static struct test_context static_context; @@ -809,13 +811,14 @@ RUNNER_TEST(cleanup_layer) } static void -test_surface_properties_changed_notification_callback(struct ivi_layout_surface *ivisurf, - const struct ivi_layout_surface_properties *prop, - enum ivi_layout_notification_mask mask, - void *userdata) +test_surface_properties_changed_notification_callback(struct wl_listener *listener, void *data) + { - struct test_context *ctx = userdata; + struct test_context *ctx = + container_of(listener, struct test_context, + surface_property_changed); const struct ivi_layout_interface *lyt = ctx->layout_interface; + struct ivi_layout_surface *ivisurf = data; runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0)); @@ -833,8 +836,10 @@ RUNNER_TEST(surface_properties_changed_notification) ivisurf = lyt->get_surface_from_id(id_surface); runner_assert(ivisurf != NULL); - runner_assert(lyt->surface_add_notification( - ivisurf, test_surface_properties_changed_notification_callback, ctx) == IVI_SUCCEEDED); + ctx->surface_property_changed.notify = test_surface_properties_changed_notification_callback; + + runner_assert(lyt->surface_add_listener( + ivisurf, &ctx->surface_property_changed) == IVI_SUCCEEDED); lyt->commit_changes(); @@ -855,7 +860,8 @@ RUNNER_TEST(surface_properties_changed_notification) runner_assert(ctx->user_flags == 0); - lyt->surface_remove_notification(ivisurf); + // remove surface property changed listener. + wl_list_remove(&ctx->surface_property_changed.link); ctx->user_flags = 0; runner_assert(lyt->surface_set_destination_rectangle( ivisurf, 40, 50, 400, 500) == IVI_SUCCEEDED); @@ -981,10 +987,7 @@ RUNNER_TEST(surface_remove_notification_p3) } static void -test_surface_bad_properties_changed_notification_callback(struct ivi_layout_surface *ivisurf, - const struct ivi_layout_surface_properties *prop, - enum ivi_layout_notification_mask mask, - void *userdata) +test_surface_bad_properties_changed_notification_callback(struct wl_listener *listener, void *data) { } @@ -996,8 +999,10 @@ RUNNER_TEST(surface_bad_properties_changed_notification) ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0)); runner_assert(ivisurf != NULL); - runner_assert(lyt->surface_add_notification( - NULL, test_surface_bad_properties_changed_notification_callback, NULL) == IVI_FAILED); - runner_assert(lyt->surface_add_notification( - ivisurf, NULL, NULL) == IVI_FAILED); + ctx->surface_property_changed.notify = test_surface_bad_properties_changed_notification_callback; + + runner_assert(lyt->surface_add_listener( + NULL, &ctx->surface_property_changed) == IVI_FAILED); + runner_assert(lyt->surface_add_listener( + ivisurf, NULL) == IVI_FAILED); } |