aboutsummaryrefslogtreecommitdiff
path: root/tests/name-watch-test.cc
diff options
context:
space:
mode:
authorRobert Tari <robert@tari.in>2021-12-09 11:54:30 +0100
committerRobert Tari <robert@tari.in>2021-12-09 12:03:07 +0100
commit09dde5270d94be7ec55a4ede3ca4007be097b343 (patch)
treebd6bd151d8b2c0059152e1e896004a43860360f9 /tests/name-watch-test.cc
parent1a36cae0aa0fc9c4b55efa47a419a3fafdae4923 (diff)
downloadayatana-indicator-sound-09dde5270d94be7ec55a4ede3ca4007be097b343.tar.gz
ayatana-indicator-sound-09dde5270d94be7ec55a4ede3ca4007be097b343.tar.bz2
ayatana-indicator-sound-09dde5270d94be7ec55a4ede3ca4007be097b343.zip
Whitespace fix
Diffstat (limited to 'tests/name-watch-test.cc')
-rw-r--r--tests/name-watch-test.cc188
1 files changed, 94 insertions, 94 deletions
diff --git a/tests/name-watch-test.cc b/tests/name-watch-test.cc
index d7e85b4..cf06403 100644
--- a/tests/name-watch-test.cc
+++ b/tests/name-watch-test.cc
@@ -26,150 +26,150 @@ extern "C" {
class NameWatchTest : public ::testing::Test
{
- private:
- GTestDBus * testbus = NULL;
-
- protected:
- virtual void SetUp() {
- testbus = g_test_dbus_new(G_TEST_DBUS_NONE);
- g_test_dbus_up(testbus);
- }
-
- virtual void TearDown() {
- g_test_dbus_down(testbus);
- g_clear_object(&testbus);
- }
-
- static gboolean timeout_cb (gpointer user_data) {
- GMainLoop * loop = static_cast<GMainLoop *>(user_data);
- g_main_loop_quit(loop);
- return G_SOURCE_REMOVE;
- }
-
- void loop (unsigned int ms) {
- GMainLoop * loop = g_main_loop_new(NULL, FALSE);
- g_timeout_add(ms, timeout_cb, loop);
- g_main_loop_run(loop);
- g_main_loop_unref(loop);
- }
+ private:
+ GTestDBus * testbus = NULL;
+
+ protected:
+ virtual void SetUp() {
+ testbus = g_test_dbus_new(G_TEST_DBUS_NONE);
+ g_test_dbus_up(testbus);
+ }
+
+ virtual void TearDown() {
+ g_test_dbus_down(testbus);
+ g_clear_object(&testbus);
+ }
+
+ static gboolean timeout_cb (gpointer user_data) {
+ GMainLoop * loop = static_cast<GMainLoop *>(user_data);
+ g_main_loop_quit(loop);
+ return G_SOURCE_REMOVE;
+ }
+
+ void loop (unsigned int ms) {
+ GMainLoop * loop = g_main_loop_new(NULL, FALSE);
+ g_timeout_add(ms, timeout_cb, loop);
+ g_main_loop_run(loop);
+ g_main_loop_unref(loop);
+ }
};
typedef struct {
- guint appeared;
- guint vanished;
+ guint appeared;
+ guint vanished;
} callback_count_t;
static void
appeared_simple_cb (GDBusConnection * bus, const gchar * name, const gchar * owner, gpointer user_data)
{
- callback_count_t * callback_count = static_cast<callback_count_t *>(user_data);
- callback_count->appeared++;
+ callback_count_t * callback_count = static_cast<callback_count_t *>(user_data);
+ callback_count->appeared++;
}
static void
vanished_simple_cb (GDBusConnection * bus, const gchar * name, gpointer user_data)
{
- callback_count_t * callback_count = static_cast<callback_count_t *>(user_data);
- callback_count->vanished++;
+ callback_count_t * callback_count = static_cast<callback_count_t *>(user_data);
+ callback_count->vanished++;
}
TEST_F(NameWatchTest, BaseWatch)
{
- callback_count_t callback_count = {0};
+ callback_count_t callback_count = {0};
- guint ns_watch = bus_watch_namespace(G_BUS_TYPE_SESSION,
- "com.foo",
- appeared_simple_cb,
- vanished_simple_cb,
- &callback_count,
- NULL);
+ guint ns_watch = bus_watch_namespace(G_BUS_TYPE_SESSION,
+ "com.foo",
+ appeared_simple_cb,
+ vanished_simple_cb,
+ &callback_count,
+ NULL);
- guint name1 = g_bus_own_name(G_BUS_TYPE_SESSION,
- "com.foo.bar",
- G_BUS_NAME_OWNER_FLAGS_NONE,
- NULL, NULL, NULL, NULL, NULL);
- guint name2 = g_bus_own_name(G_BUS_TYPE_SESSION,
- "com.foo.bar_too",
- G_BUS_NAME_OWNER_FLAGS_NONE,
- NULL, NULL, NULL, NULL, NULL);
+ guint name1 = g_bus_own_name(G_BUS_TYPE_SESSION,
+ "com.foo.bar",
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ NULL, NULL, NULL, NULL, NULL);
+ guint name2 = g_bus_own_name(G_BUS_TYPE_SESSION,
+ "com.foo.bar_too",
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ NULL, NULL, NULL, NULL, NULL);
- loop(100);
+ loop(100);
- ASSERT_EQ(callback_count.appeared, 2);
+ ASSERT_EQ(callback_count.appeared, 2);
- g_bus_unown_name(name1);
- g_bus_unown_name(name2);
+ g_bus_unown_name(name1);
+ g_bus_unown_name(name2);
- loop(100);
+ loop(100);
- ASSERT_EQ(callback_count.vanished, 2);
+ ASSERT_EQ(callback_count.vanished, 2);
- bus_unwatch_namespace(ns_watch);
+ bus_unwatch_namespace(ns_watch);
}
TEST_F(NameWatchTest, NonMatches)
{
- callback_count_t callback_count = {0};
+ callback_count_t callback_count = {0};
- guint ns_watch = bus_watch_namespace(G_BUS_TYPE_SESSION,
- "com.foo",
- appeared_simple_cb,
- vanished_simple_cb,
- &callback_count,
- NULL);
+ guint ns_watch = bus_watch_namespace(G_BUS_TYPE_SESSION,
+ "com.foo",
+ appeared_simple_cb,
+ vanished_simple_cb,
+ &callback_count,
+ NULL);
- guint name1 = g_bus_own_name(G_BUS_TYPE_SESSION,
- "com.foobar.bar",
- G_BUS_NAME_OWNER_FLAGS_NONE,
- NULL, NULL, NULL, NULL, NULL);
- guint name2 = g_bus_own_name(G_BUS_TYPE_SESSION,
- "com.bar.com.foo",
- G_BUS_NAME_OWNER_FLAGS_NONE,
- NULL, NULL, NULL, NULL, NULL);
+ guint name1 = g_bus_own_name(G_BUS_TYPE_SESSION,
+ "com.foobar.bar",
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ NULL, NULL, NULL, NULL, NULL);
+ guint name2 = g_bus_own_name(G_BUS_TYPE_SESSION,
+ "com.bar.com.foo",
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ NULL, NULL, NULL, NULL, NULL);
- loop(100);
+ loop(100);
- ASSERT_EQ(callback_count.appeared, 0);
+ ASSERT_EQ(callback_count.appeared, 0);
- g_bus_unown_name(name1);
- g_bus_unown_name(name2);
+ g_bus_unown_name(name1);
+ g_bus_unown_name(name2);
- loop(100);
+ loop(100);
- ASSERT_EQ(callback_count.vanished, 0);
+ ASSERT_EQ(callback_count.vanished, 0);
- bus_unwatch_namespace(ns_watch);
+ bus_unwatch_namespace(ns_watch);
}
TEST_F(NameWatchTest, StartupNames)
{
- guint name1 = g_bus_own_name(G_BUS_TYPE_SESSION,
- "com.foo.bar",
- G_BUS_NAME_OWNER_FLAGS_NONE,
- NULL, NULL, NULL, NULL, NULL);
+ guint name1 = g_bus_own_name(G_BUS_TYPE_SESSION,
+ "com.foo.bar",
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ NULL, NULL, NULL, NULL, NULL);
- loop(100);
+ loop(100);
- callback_count_t callback_count = {0};
+ callback_count_t callback_count = {0};
- guint ns_watch = bus_watch_namespace(G_BUS_TYPE_SESSION,
- "com.foo",
- appeared_simple_cb,
- vanished_simple_cb,
- &callback_count,
- NULL);
+ guint ns_watch = bus_watch_namespace(G_BUS_TYPE_SESSION,
+ "com.foo",
+ appeared_simple_cb,
+ vanished_simple_cb,
+ &callback_count,
+ NULL);
- loop(100);
+ loop(100);
- ASSERT_EQ(callback_count.appeared, 1);
+ ASSERT_EQ(callback_count.appeared, 1);
- g_bus_unown_name(name1);
+ g_bus_unown_name(name1);
- loop(100);
+ loop(100);
- ASSERT_EQ(callback_count.vanished, 1);
+ ASSERT_EQ(callback_count.vanished, 1);
- bus_unwatch_namespace(ns_watch);
+ bus_unwatch_namespace(ns_watch);
}