aboutsummaryrefslogtreecommitdiff
path: root/tests/test-notify.cc
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-07-24 22:51:03 -0500
committerCharles Kerr <charles.kerr@canonical.com>2014-07-24 22:51:03 -0500
commite9ba47b83251f40234059b1bd2bc25e30b5aa9b2 (patch)
tree7360e76ec4be3e968e95cdc6de1aa1a69c733916 /tests/test-notify.cc
parentb715352603062a4a4dbb5bc69388b1db632c34ae (diff)
downloadayatana-indicator-power-e9ba47b83251f40234059b1bd2bc25e30b5aa9b2.tar.gz
ayatana-indicator-power-e9ba47b83251f40234059b1bd2bc25e30b5aa9b2.tar.bz2
ayatana-indicator-power-e9ba47b83251f40234059b1bd2bc25e30b5aa9b2.zip
in notifier.c, fix potential callchain loop when closing a notification
Diffstat (limited to 'tests/test-notify.cc')
-rw-r--r--tests/test-notify.cc33
1 files changed, 28 insertions, 5 deletions
diff --git a/tests/test-notify.cc b/tests/test-notify.cc
index 1fc843e..a8d66d3 100644
--- a/tests/test-notify.cc
+++ b/tests/test-notify.cc
@@ -54,7 +54,7 @@ protected:
DbusTestDbusMockObject * obj = nullptr;
GDBusConnection * bus = nullptr;
- static constexpr int NOTIFY_ID {1234};
+ static constexpr int FIRST_NOTIFY_ID {1234};
static constexpr int NOTIFICATION_CLOSED_EXPIRED {1};
static constexpr int NOTIFICATION_CLOSED_DISMISSED {2};
@@ -63,9 +63,11 @@ protected:
static constexpr char const * APP_NAME {"indicator-power-service"};
+ static constexpr char const * METHOD_CLOSE {"CloseNotification"};
static constexpr char const * METHOD_NOTIFY {"Notify"};
static constexpr char const * METHOD_GET_CAPS {"GetCapabilities"};
static constexpr char const * METHOD_GET_INFO {"GetServerInformation"};
+ static constexpr char const * SIGNAL_CLOSED {"NotificationClosed"};
static constexpr char const * HINT_TIMEOUT {"x-canonical-snap-decisions-timeout"};
@@ -86,7 +88,8 @@ protected:
NOTIFY_INTERFACE,
&error);
g_assert_no_error (error);
-
+
+ // METHOD_GET_INFO
dbus_test_dbus_mock_object_add_method(mock, obj, METHOD_GET_INFO,
nullptr,
G_VARIANT_TYPE("(ssss)"),
@@ -94,14 +97,34 @@ protected:
&error);
g_assert_no_error (error);
- auto python_str = g_strdup_printf ("ret = %d", NOTIFY_ID);
+ // METHOD_NOTIFY
+ auto str = g_strdup_printf("try:\n"
+ " self.NextNotifyId\n"
+ "except AttributeError:\n"
+ " self.NextNotifyId = %d\n"
+ "ret = self.NextNotifyId\n"
+ "self.NextNotifyId += 1\n",
+ FIRST_NOTIFY_ID);
dbus_test_dbus_mock_object_add_method(mock, obj, METHOD_NOTIFY,
G_VARIANT_TYPE("(susssasa{sv}i)"),
G_VARIANT_TYPE_UINT32,
- python_str,
+ str,
&error);
- g_free (python_str);
g_assert_no_error (error);
+ g_free (str);
+
+ // METHOD_CLOSE
+ str = g_strdup_printf("self.EmitSignal('%s', '%s', 'uu', [ args[0], %d ])",
+ NOTIFY_INTERFACE,
+ SIGNAL_CLOSED,
+ NOTIFICATION_CLOSED_API);
+ dbus_test_dbus_mock_object_add_method(mock, obj, METHOD_CLOSE,
+ G_VARIANT_TYPE("(u)"),
+ nullptr,
+ str,
+ &error);
+ g_assert_no_error (error);
+ g_free (str);
dbus_test_service_add_task(service, DBUS_TEST_TASK(mock));
dbus_test_service_start_tasks(service);