summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <withnall@endlessm.com>2018-08-01 15:58:56 +0100
committerPhilip Withnall <withnall@endlessm.com>2018-08-01 15:59:02 +0100
commit0a711636ddc9bc8a1405629534bdec9ebca67e06 (patch)
tree32171dc0bbb8579094a89ddefbb7460a9f0f00d2
parented27f3703f45ebf1566fd96a262a1074959ee541 (diff)
downloaddconf-0a711636ddc9bc8a1405629534bdec9ebca67e06.tar.gz
WIP
Signed-off-by: Philip Withnall <withnall@endlessm.com>
-rw-r--r--service/dconf-writer.h3
-rw-r--r--tests/meson.build6
-rw-r--r--tests/writer.c44
3 files changed, 51 insertions, 2 deletions
diff --git a/service/dconf-writer.h b/service/dconf-writer.h
index a41f115..17360c9 100644
--- a/service/dconf-writer.h
+++ b/service/dconf-writer.h
@@ -20,7 +20,9 @@
#ifndef __dconf_writer_h__
#define __dconf_writer_h__
+#include <glib.h>
#include <gio/gio.h>
+#include <gobject/gobject.h>
#include "../common/dconf-changeset.h"
#include "dconf-generated.h"
@@ -65,6 +67,7 @@ struct _DConfWriter
DConfWriterPrivate *priv;
};
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (DConfWriter, g_object_unref)
GType dconf_writer_get_type (void);
diff --git a/tests/meson.build b/tests/meson.build
index 6737a97..6d70212 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -24,7 +24,8 @@ unit_tests = [
['gdbus-thread', 'dbus.c', '-DDBUS_BACKEND="/gdbus/thread"', gio_unix_dep, libdconf_gdbus_thread],
['gdbus-filter', 'dbus.c', '-DDBUS_BACKEND="/gdbus/filter"', gio_unix_dep, libdconf_gdbus_filter],
['engine', 'engine.c', '-DSRCDIR="@0@"'.format(test_dir), [glib_dep, dl_dep, m_dep], [libdconf_engine, libdconf_common, libdconf_mock]],
- ['client', 'client.c', '-DSRCDIR="@0@"'.format(test_dir), gio_unix_dep, [libdconf_client, libdconf_engine, libdconf_common, libdconf_mock]]
+ ['client', 'client.c', '-DSRCDIR="@0@"'.format(test_dir), gio_unix_dep, [libdconf_client, libdconf_engine, libdconf_common, libdconf_mock]],
+ ['writer', 'writer.c', '-DSRCDIR="@0@"'.format(test_dir), [glib_dep, dl_dep, m_dep], [libdconf_engine, libdconf_common, libdconf_mock]],
]
foreach unit_test: unit_tests
@@ -33,7 +34,8 @@ foreach unit_test: unit_tests
unit_test[1],
c_args: unit_test[2],
dependencies: unit_test[3],
- link_with: unit_test[4]
+ link_with: unit_test[4],
+ include_directories: [top_inc, include_directories('../service')],
)
test(unit_test[0], exe, is_parallel: false)
diff --git a/tests/writer.c b/tests/writer.c
new file mode 100644
index 0000000..92757d1
--- /dev/null
+++ b/tests/writer.c
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2018 Endless Mobile, Inc
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Philip Withnall <withnall@endlessm.com>
+ */
+
+#include <glib.h>
+
+#include "service/dconf-generated.h"
+#include "service/dconf-writer.h"
+
+static void
+test_writer_basic (void)
+{
+ g_autoptr(DConfWriter) writer = NULL;
+
+ writer = dconf_writer_new (DCONF_TYPE_KEYFILE_WRITER, "some-name");
+ g_assert_nonnull (writer);
+
+ g_assert_cmpstr (dconf_writer_get_name (writer), ==, "some-name");
+}
+
+int
+main (int argc, char **argv)
+{
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/writer/basic", test_writer_basic);
+
+ return g_test_run ();
+}