Merge lp:~attente/content-hub/content-hub-glib-2 into lp:content-hub

Proposed by William Hua
Status: Superseded
Proposed branch: lp:~attente/content-hub/content-hub-glib-2
Merge into: lp:content-hub
Prerequisite: lp:~ken-vandine/content-hub/dbus_test_runner
Diff against target: 570 lines (+436/-6)
11 files modified
CMakeLists.txt (+7/-1)
debian/control (+23/-0)
debian/libcontent-hub-dev.install (+2/-2)
debian/libcontent-hub-glib-dev.install (+3/-0)
debian/libcontent-hub-glib0.install (+1/-0)
debian/libcontent-hub0.install (+1/-1)
libcontent-hub-glib.pc.in (+11/-0)
src/com/ubuntu/content/CMakeLists.txt (+62/-2)
tests/CMakeLists.txt (+1/-0)
tests/acceptance-tests/CMakeLists.txt (+11/-0)
tests/acceptance-tests/glib_test.cpp (+314/-0)
To merge this branch: bzr merge lp:~attente/content-hub/content-hub-glib-2
Reviewer Review Type Date Requested Status
Ken VanDine Pending
Review via email: mp+311443@code.launchpad.net

This proposal has been superseded by a proposal from 2016-11-23.

Commit message

Add GLib bindings (LP: #1624437)

Description of the change

Add GLib bindings (LP: #1624437)

There's a GTK branch (wip/attente/mir-content-hub) that needs this for copy-paste support.

To post a comment you must log in.
309. By William Hua

Merge lp:content-hub

310. By William Hua

Fix build failure on zesty due to googletest 1.8. Also refactored
tests/acceptance-tests/CMakeLists.txt to make adding tests less
cumbersome. (LP: #1644062)

311. By William Hua

Group the commands better

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2016-08-23 20:17:57 +0000
3+++ CMakeLists.txt 2016-11-23 14:51:34 +0000
4@@ -114,8 +114,14 @@
5 set(exec_prefix ${prefix}/bin)
6 set(libdir ${prefix}/${CMAKE_INSTALL_LIBDIR})
7 set(pkg-name "libcontent-hub")
8+set(glib-pkg-name "libcontent-hub-glib")
9 configure_file(libcontent-hub.pc.in libcontent-hub.pc @ONLY)
10-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libcontent-hub.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
11+configure_file(libcontent-hub-glib.pc.in libcontent-hub-glib.pc @ONLY)
12+install(FILES
13+ ${CMAKE_CURRENT_BINARY_DIR}/libcontent-hub.pc
14+ ${CMAKE_CURRENT_BINARY_DIR}/libcontent-hub-glib.pc
15+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
16+)
17
18 # There's no nice way to format this. Thanks CMake.
19 add_test(LGPL-required
20
21=== modified file 'debian/control'
22--- debian/control 2016-10-25 18:45:11 +0000
23+++ debian/control 2016-11-23 14:51:34 +0000
24@@ -59,6 +59,20 @@
25 securely and efficiently exchange content.
26 This package includes the content sharing libraries.
27
28+Package: libcontent-hub-glib0
29+Section: libs
30+Architecture: any
31+Multi-Arch: same
32+Pre-Depends: ${misc:Pre-Depends},
33+Depends: ${misc:Depends},
34+ ${shlibs:Depends},
35+Suggests: content-hub
36+Description: content sharing/picking library - GLib bindings
37+ Content sharing/picking infrastructure and service, designed to allow apps to
38+ securely and efficiently exchange content.
39+ .
40+ This package includes GLib bindings of the content sharing libraries.
41+
42 Package: libcontent-hub-dev
43 Section: libdevel
44 Architecture: any
45@@ -68,6 +82,15 @@
46 Description: content sharing development files
47 All the development headers and libraries for the content hub
48
49+Package: libcontent-hub-glib-dev
50+Section: libdevel
51+Architecture: any
52+Multi-Arch: same
53+Depends: libcontent-hub-glib0 (= ${binary:Version}),
54+ ${misc:Depends},
55+Description: content sharing development files - GLib bindings
56+ GLib bindings of the development headers and libraries for the content hub
57+
58 Package: qtdeclarative5-ubuntu-content1
59 Section: libs
60 Architecture: any
61
62=== modified file 'debian/libcontent-hub-dev.install'
63--- debian/libcontent-hub-dev.install 2013-09-30 21:28:46 +0000
64+++ debian/libcontent-hub-dev.install 2016-11-23 14:51:34 +0000
65@@ -1,3 +1,3 @@
66-usr/include
67+usr/include/com/ubuntu/content/*.h
68 usr/lib/*/libcontent-hub.so
69-usr/lib/*/pkgconfig
70+usr/lib/*/pkgconfig/libcontent-hub.pc
71
72=== added file 'debian/libcontent-hub-glib-dev.install'
73--- debian/libcontent-hub-glib-dev.install 1970-01-01 00:00:00 +0000
74+++ debian/libcontent-hub-glib-dev.install 2016-11-23 14:51:34 +0000
75@@ -0,0 +1,3 @@
76+usr/include/com/ubuntu/content/glib/*
77+usr/lib/*/libcontent-hub-glib.so
78+usr/lib/*/pkgconfig/libcontent-hub-glib.pc
79
80=== added file 'debian/libcontent-hub-glib0.install'
81--- debian/libcontent-hub-glib0.install 1970-01-01 00:00:00 +0000
82+++ debian/libcontent-hub-glib0.install 2016-11-23 14:51:34 +0000
83@@ -0,0 +1,1 @@
84+usr/lib/*/libcontent-hub-glib.so.*
85
86=== modified file 'debian/libcontent-hub0.install'
87--- debian/libcontent-hub0.install 2013-08-26 21:58:01 +0000
88+++ debian/libcontent-hub0.install 2016-11-23 14:51:34 +0000
89@@ -1,1 +1,1 @@
90-usr/lib/*/lib*.so.*
91+usr/lib/*/libcontent-hub.so.*
92
93=== added file 'libcontent-hub-glib.pc.in'
94--- libcontent-hub-glib.pc.in 1970-01-01 00:00:00 +0000
95+++ libcontent-hub-glib.pc.in 2016-11-23 14:51:34 +0000
96@@ -0,0 +1,11 @@
97+prefix=@prefix@
98+exec_prefix=@exec_prefix@
99+libdir=@libdir@
100+includedir=${prefix}/include
101+
102+Name: @glib-pkg-name@
103+Description: content sharing/picking library - GLib bindings
104+Version: @CONTENT_HUB_VERSION@
105+Libs: -L${libdir} -lcontent-hub-glib
106+Cflags: -I${includedir}
107+Requires: gio-2.0
108
109=== modified file 'src/com/ubuntu/content/CMakeLists.txt'
110--- src/com/ubuntu/content/CMakeLists.txt 2016-09-22 18:10:11 +0000
111+++ src/com/ubuntu/content/CMakeLists.txt 2016-11-23 14:51:34 +0000
112@@ -28,6 +28,8 @@
113 ${UBUNTU_DOWNLOAD_MANAGER_INCLUDE_DIRS}
114 ${NOTIFY_INCLUDE_DIRS}
115 ${APPARMOR_INCLUDE_DIRS}
116+ ${GLIB_INCLUDE_DIRS}
117+ ${GIO_INCLUDE_DIRS}
118 )
119
120 qt5_add_dbus_interface(
121@@ -120,8 +122,66 @@
122 ${APPARMOR_LDFLAGS}
123 )
124
125-install(
126- TARGETS content-hub
127+find_program(
128+ GDBUS_CODEGEN
129+ gdbus-codegen
130+)
131+
132+set(
133+ DBUS_XML
134+ ${CMAKE_CURRENT_SOURCE_DIR}/detail/com.ubuntu.content.Handler.xml
135+ ${CMAKE_CURRENT_SOURCE_DIR}/detail/com.ubuntu.content.Paste.xml
136+ ${CMAKE_CURRENT_SOURCE_DIR}/detail/com.ubuntu.content.Service.xml
137+ ${CMAKE_CURRENT_SOURCE_DIR}/detail/com.ubuntu.content.Transfer.xml
138+)
139+
140+set(
141+ DBUS_ANNOTATIONS
142+ --annotate com.ubuntu.content.dbus.Paste.Charge\(\)[mimeData] org.gtk.GDBus.C.ForceGVariant true
143+ --annotate com.ubuntu.content.dbus.Paste.MimeData\(\)[mimeData] org.gtk.GDBus.C.ForceGVariant true
144+ --annotate com.ubuntu.content.dbus.Service.CreatePaste\(\)[mimeData] org.gtk.GDBus.C.ForceGVariant true
145+ --annotate com.ubuntu.content.dbus.Service.GetLatestPasteData\(\)[mimeData] org.gtk.GDBus.C.ForceGVariant true
146+ --annotate com.ubuntu.content.dbus.Service.GetPasteData\(\)[mimeData] org.gtk.GDBus.C.ForceGVariant true
147+)
148+
149+add_custom_command(
150+ OUTPUT glib/content-hub-glib.h glib/content-hub-glib.c
151+ COMMAND ${CMAKE_COMMAND} -E make_directory glib
152+ COMMAND ${GDBUS_CODEGEN}
153+ --interface-prefix com.ubuntu.content.dbus
154+ --generate-c-code glib/content-hub-glib
155+ --c-namespace ContentHub
156+ ${DBUS_ANNOTATIONS}
157+ ${DBUS_XML}
158+ DEPENDS ${DBUS_XML}
159+ VERBATIM
160+)
161+
162+add_library(
163+ content-hub-glib SHARED
164+ glib/content-hub-glib.h
165+ glib/content-hub-glib.c
166+)
167+
168+target_link_libraries(
169+ content-hub-glib
170+ ${GIO_LIBRARIES}
171+)
172+
173+set_target_properties(
174+ content-hub-glib
175+ PROPERTIES
176+ VERSION ${CONTENT_HUB_VERSION_MAJOR}.${CONTENT_HUB_VERSION_MINOR}.${CONTENT_HUB_VERSION_PATCH}
177+ SOVERSION ${CONTENT_HUB_VERSION_MAJOR}
178+)
179+
180+install(
181+ FILES ${CMAKE_CURRENT_BINARY_DIR}/glib/content-hub-glib.h
182+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/com/ubuntu/content/glib
183+)
184+
185+install(
186+ TARGETS content-hub content-hub-glib
187 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
188 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
189 )
190
191=== modified file 'tests/CMakeLists.txt'
192--- tests/CMakeLists.txt 2015-09-23 14:45:09 +0000
193+++ tests/CMakeLists.txt 2016-11-23 14:51:34 +0000
194@@ -30,6 +30,7 @@
195 ${LIBERTINE_INCLUDE_DIRS}
196 ${UBUNTU_LAUNCH_INCLUDE_DIRS}
197 ${CMAKE_BINARY_DIR}/src
198+ ${CMAKE_BINARY_DIR}/src/com/ubuntu/content
199 ${GMOCK_INCLUDE_DIR}
200 ${GTEST_INCLUDE_DIR}
201 )
202
203=== modified file 'tests/acceptance-tests/CMakeLists.txt'
204--- tests/acceptance-tests/CMakeLists.txt 2016-11-23 14:27:28 +0000
205+++ tests/acceptance-tests/CMakeLists.txt 2016-11-23 14:51:34 +0000
206@@ -80,6 +80,12 @@
207 ${MOCS}
208 )
209
210+add_executable(
211+ glib_test
212+ glib_test.cpp
213+ ${MOCS}
214+)
215+
216 qt5_use_modules(app_hub_communication_default_source Core Gui DBus Test)
217 qt5_use_modules(app_hub_communication_known_sources Core Gui DBus Test)
218 qt5_use_modules(app_hub_communication_stores Core Gui DBus Test)
219@@ -89,6 +95,7 @@
220 qt5_use_modules(test_utils Core Test)
221 qt5_use_modules(test_hook Core Gui DBus Test)
222 qt5_use_modules(mimedata_test Core Test)
223+qt5_use_modules(glib_test Core Gui DBus Test)
224
225 target_link_libraries(app_hub_communication_stores content-hub gmock gtest gtest_main)
226 target_link_libraries(app_hub_communication_default_source content-hub gmock gtest gtest_main)
227@@ -101,6 +108,7 @@
228 target_link_libraries(test_types content-hub gmock gtest gtest_main)
229 target_link_libraries(test_hook content-hub gmock gtest gtest_main ${GSETTINGS_LDFLAGS})
230 target_link_libraries(mimedata_test content-hub gmock gtest gtest_main)
231+target_link_libraries(glib_test content-hub-glib content-hub gmock gtest gtest_main)
232
233 add_test(NAME app_hub_communication_default_source COMMAND dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/app_hub_communication_default_source)
234 add_test(NAME app_hub_communication_known_sources COMMAND dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/app_hub_communication_known_sources)
235@@ -112,6 +120,7 @@
236 add_test(NAME test_types COMMAND dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/test_types)
237 add_test(NAME test_hook COMMAND dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/test_hook)
238 add_test(NAME mimedata_test COMMAND mimedata_test)
239+add_test(NAME glib_test COMMAND dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/glib_test)
240
241 SET_TESTS_PROPERTIES(app_hub_communication_stores
242 PROPERTIES ENVIRONMENT "CONTENT_HUB_TESTING=1")
243@@ -133,6 +142,8 @@
244 PROPERTIES ENVIRONMENT "CONTENT_HUB_TESTING=1")
245 SET_TESTS_PROPERTIES(mimedata_test
246 PROPERTIES ENVIRONMENT "CONTENT_HUB_TESTING=1")
247+SET_TESTS_PROPERTIES(glib_test
248+ PROPERTIES ENVIRONMENT "CONTENT_HUB_TESTING=1")
249
250 set_target_properties(
251 test_hook
252
253=== added file 'tests/acceptance-tests/glib_test.cpp'
254--- tests/acceptance-tests/glib_test.cpp 1970-01-01 00:00:00 +0000
255+++ tests/acceptance-tests/glib_test.cpp 2016-11-23 14:51:34 +0000
256@@ -0,0 +1,314 @@
257+/*
258+ * Copyright © 2016 Canonical Ltd.
259+ *
260+ * This program is free software: you can redistribute it and/or modify
261+ * it under the terms of the GNU General Public License version 3 as
262+ * published by the Free Software Foundation.
263+ *
264+ * This program is distributed in the hope that it will be useful,
265+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
266+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
267+ * GNU Lesser General Public License for more details.
268+ *
269+ * You should have received a copy of the GNU Lesser General Public License
270+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
271+ *
272+ * Authored by: William Hua <william.hua@canonical.com>
273+ */
274+
275+/* modified from app_hub_communication_paste.cpp */
276+
277+#include "app_manager_mock.h"
278+#include "test_harness.h"
279+#include "../cross_process_sync.h"
280+#include "../fork_and_run.h"
281+
282+#include <com/ubuntu/content/hub.h>
283+#include <com/ubuntu/content/item.h>
284+#include <com/ubuntu/content/paste.h>
285+
286+#include "com/ubuntu/content/detail/peer_registry.h"
287+#include "com/ubuntu/content/detail/service.h"
288+#include "com/ubuntu/content/serviceadaptor.h"
289+
290+#include <gmock/gmock.h>
291+#include <gtest/gtest.h>
292+
293+#include <QCoreApplication>
294+#include <QtDBus/QDBusConnection>
295+#include <QStandardPaths>
296+#include <QTemporaryDir>
297+#include <QtTest/QTest>
298+
299+#include <thread>
300+
301+#include <cstring>
302+#include <gio/gio.h>
303+
304+#include "glib/content-hub-glib.h"
305+
306+namespace cua = com::ubuntu::ApplicationManager;
307+namespace cuc = com::ubuntu::content;
308+namespace cucd = com::ubuntu::content::detail;
309+
310+QString service_name{"com.ubuntu.content.dbus.Service"};
311+
312+struct MockedPeerRegistry : public cucd::PeerRegistry
313+{
314+ MockedPeerRegistry() : cucd::PeerRegistry()
315+ {
316+ using namespace ::testing;
317+
318+ ON_CALL(*this, default_source_for_type(_)).WillByDefault(Return(cuc::Peer::unknown()));
319+ ON_CALL(*this, install_default_source_for_type(_,_)).WillByDefault(Return(false));
320+ ON_CALL(*this, install_source_for_type(_,_)).WillByDefault(Return(false));
321+ }
322+
323+ MOCK_METHOD1(default_source_for_type, cuc::Peer(cuc::Type t));
324+ MOCK_METHOD1(enumerate_known_peers, void(const std::function<void(const cuc::Peer&)>&));
325+ MOCK_METHOD2(enumerate_known_sources_for_type, void(cuc::Type, const std::function<void(const cuc::Peer&)>&));
326+ MOCK_METHOD2(enumerate_known_destinations_for_type, void(cuc::Type, const std::function<void(const cuc::Peer&)>&));
327+ MOCK_METHOD2(enumerate_known_shares_for_type, void(cuc::Type, const std::function<void(const cuc::Peer&)>&));
328+ MOCK_METHOD2(install_default_source_for_type, bool(cuc::Type, cuc::Peer));
329+ MOCK_METHOD2(install_source_for_type, bool(cuc::Type, cuc::Peer));
330+ MOCK_METHOD2(install_destination_for_type, bool(cuc::Type, cuc::Peer));
331+ MOCK_METHOD2(install_share_for_type, bool(cuc::Type, cuc::Peer));
332+ MOCK_METHOD1(remove_peer, bool(cuc::Peer));
333+ MOCK_METHOD1(peer_is_legacy, bool(QString));
334+};
335+
336+static const gchar *SERVICE_NAME = "com.ubuntu.content.dbus.Service";
337+static const gchar *SERVICE_PATH = "/";
338+static const gchar *APPLICATION_ID = "com.ubuntu.content.glib_test";
339+static const gchar *HANDLER_PATH = "/com/ubuntu/content/handler";
340+static const gchar *SURFACE_ID = "01234567-0123-0123-0123-0123456789ab";
341+
342+static const gchar * const PASTE_FORMATS[] =
343+{
344+ "text/plain",
345+ "text/html",
346+ NULL
347+};
348+
349+static const gint N_PASTE_FORMATS = sizeof (PASTE_FORMATS) / sizeof (PASTE_FORMATS[0]) - 1;
350+
351+static const gchar PASTE_DATA[] =
352+ "text/plain"
353+ "plain text"
354+ "text/html"
355+ "<p>html text</p>";
356+
357+static const gint N_PASTE_DATA = sizeof (PASTE_DATA) / sizeof (PASTE_DATA[0]) - 1;
358+
359+static gboolean pasteboard_changed;
360+
361+static void
362+pasteboard_changed_cb (ContentHubService *service,
363+ gpointer user_data)
364+{
365+ GMainLoop *main_loop = (GMainLoop *) user_data;
366+
367+ pasteboard_changed = TRUE;
368+
369+ g_main_loop_quit (main_loop);
370+}
371+
372+static gboolean
373+timed_out_cb (gpointer user_data)
374+{
375+ GMainLoop *main_loop = (GMainLoop *) user_data;
376+
377+ g_main_loop_quit (main_loop);
378+
379+ return G_SOURCE_CONTINUE;
380+}
381+
382+static void
383+set_paste (ContentHubService *service)
384+{
385+ GMainLoop *main_loop;
386+ guint timeout_id;
387+
388+ g_assert_false (pasteboard_changed);
389+
390+ main_loop = g_main_loop_new (NULL, FALSE);
391+ timeout_id = g_timeout_add (1000, timed_out_cb, main_loop);
392+
393+ g_signal_connect (
394+ service,
395+ "pasteboard-changed",
396+ G_CALLBACK (pasteboard_changed_cb),
397+ main_loop);
398+
399+ g_assert_true (
400+ content_hub_service_call_create_paste_sync (
401+ service,
402+ APPLICATION_ID,
403+ SURFACE_ID,
404+ g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, PASTE_DATA, sizeof (PASTE_DATA) - 1, sizeof (guchar)),
405+ PASTE_FORMATS,
406+ NULL,
407+ NULL,
408+ NULL));
409+
410+ g_main_loop_run (main_loop);
411+ g_source_remove (timeout_id);
412+ g_clear_pointer (&main_loop, g_main_loop_unref);
413+
414+ g_assert_true (pasteboard_changed);
415+
416+ pasteboard_changed = FALSE;
417+}
418+
419+static void
420+get_paste (ContentHubService *service)
421+{
422+ gchar **formats;
423+ GVariant *variant;
424+ gconstpointer data;
425+ gsize size;
426+ gint i;
427+
428+ g_assert_true (
429+ content_hub_service_call_paste_formats_sync (
430+ service,
431+ &formats,
432+ NULL,
433+ NULL));
434+
435+ g_assert_cmpint (g_strv_length (formats), ==, N_PASTE_FORMATS);
436+
437+ for (i = 0; i < N_PASTE_FORMATS; i++)
438+ g_assert_cmpstr (formats[i], ==, PASTE_FORMATS[i]);
439+
440+ g_strfreev (formats);
441+
442+ g_assert_true (
443+ content_hub_service_call_get_latest_paste_data_sync (
444+ service,
445+ SURFACE_ID,
446+ &variant,
447+ NULL,
448+ NULL));
449+
450+ data = g_variant_get_fixed_array (variant, &size, sizeof (guchar));
451+
452+ g_assert_cmpint (size, ==, N_PASTE_DATA);
453+ g_assert_cmpint (memcmp (data, PASTE_DATA, N_PASTE_DATA), ==, 0);
454+}
455+
456+int
457+glib_test (int argc,
458+ char *argv[])
459+{
460+ GDBusConnection *session;
461+ ContentHubService *service;
462+ ContentHubHandler *handler;
463+
464+ session = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
465+
466+ service = content_hub_service_proxy_new_sync (
467+ session,
468+ G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES,
469+ SERVICE_NAME,
470+ SERVICE_PATH,
471+ NULL,
472+ NULL);
473+
474+ g_assert_nonnull (service);
475+
476+ handler = content_hub_handler_skeleton_new ();
477+
478+ g_assert_true (
479+ g_dbus_interface_skeleton_export (
480+ G_DBUS_INTERFACE_SKELETON (handler),
481+ session,
482+ HANDLER_PATH,
483+ NULL));
484+
485+ g_object_unref (session);
486+
487+ g_assert_true (
488+ content_hub_service_call_register_import_export_handler_sync (
489+ service,
490+ APPLICATION_ID,
491+ HANDLER_PATH,
492+ NULL,
493+ NULL));
494+
495+ g_assert_true (
496+ content_hub_service_call_handler_active_sync (
497+ service,
498+ APPLICATION_ID,
499+ NULL,
500+ NULL));
501+
502+ set_paste (service);
503+ get_paste (service);
504+
505+ g_assert_true (
506+ content_hub_service_call_quit_sync (
507+ service,
508+ NULL,
509+ NULL));
510+
511+ g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (handler));
512+ g_object_unref (handler);
513+ g_object_unref (service);
514+
515+ return 0;
516+}
517+
518+/* modified from app_hub_communication_paste.cpp */
519+
520+TEST(GLib, glib_test)
521+{
522+ using namespace ::testing;
523+
524+ test::CrossProcessSync sync;
525+
526+ auto parent = [&sync]()
527+ {
528+ int argc = 0;
529+ QCoreApplication app{argc, nullptr};
530+
531+ QDBusConnection connection = QDBusConnection::sessionBus();
532+
533+ auto mock = new ::testing::NiceMock<MockedPeerRegistry>{};
534+
535+ QSharedPointer<cucd::PeerRegistry> registry{mock};
536+ auto app_manager = QSharedPointer<cua::ApplicationManager>(new MockedAppManager());
537+ cucd::Service implementation(connection, registry, app_manager, &app);
538+ new ServiceAdaptor(std::addressof(implementation));
539+
540+ ASSERT_TRUE(connection.registerService(service_name));
541+ ASSERT_TRUE(connection.registerObject("/", std::addressof(implementation)));
542+
543+ sync.signal_ready();
544+
545+ app.exec();
546+
547+ connection.unregisterObject("/");
548+ connection.unregisterService(service_name);
549+ };
550+
551+ auto child = [&sync]()
552+ {
553+ int argc = 0;
554+ QCoreApplication app(argc, nullptr);
555+
556+ sync.wait_for_signal_ready();
557+
558+ test::TestHarness harness;
559+ harness.add_test_case([]()
560+ {
561+ char arg0[] = "glib_test";
562+ char *argv[] = { arg0 };
563+
564+ EXPECT_EQ(0, glib_test(1, argv));
565+ });
566+ EXPECT_EQ(0, QTest::qExec(std::addressof(harness)));
567+ };
568+
569+ EXPECT_EQ(EXIT_SUCCESS, test::fork_and_run(child, parent));
570+}

Subscribers

People subscribed via source and target branches