Merge lp:~ted/url-dispatcher/bad-url-fixes into lp:url-dispatcher

Proposed by Ted Gould
Status: Merged
Approved by: dobey
Approved revision: 120
Merged at revision: 114
Proposed branch: lp:~ted/url-dispatcher/bad-url-fixes
Merge into: lp:url-dispatcher
Diff against target: 229 lines (+16/-144)
7 files modified
debian/control (+1/-1)
gui/url-dispatcher-gui.desktop.in (+1/-0)
gui/url-dispatcher-gui.svg (+1/-0)
service/bad-url/CMakeLists.txt (+1/-1)
service/bad-url/exec-tool.cpp (+12/-18)
tests/CMakeLists.txt (+0/-13)
tests/exec-tool-test.cc (+0/-111)
To merge this branch: bzr merge lp:~ted/url-dispatcher/bad-url-fixes
Reviewer Review Type Date Requested Status
dobey (community) Approve
unity-api-1-bot continuous-integration Needs Fixing
Review via email: mp+320100@code.launchpad.net

Commit message

Update bad-url exec tool to UAL C++ interface

Description of the change

This doesn't fix the bad url support but cleans up some cruft and removes a test that we don't want to port to systemd.

To post a comment you must log in.
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
dobey (dobey) :
review: Needs Information
lp:~ted/url-dispatcher/bad-url-fixes updated
118. By Ted Gould

Make return values clearer

Revision history for this message
Ted Gould (ted) wrote :

We don't need dbus anymore. The URLs are taken care of by UAL. But the return codes should be explicit. Fixed that in r118.

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
dobey (dobey) :
lp:~ted/url-dispatcher/bad-url-fixes updated
119. By Ted Gould

Turn UAL up to 11

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :
review: Needs Fixing (continuous-integration)
lp:~ted/url-dispatcher/bad-url-fixes updated
120. By Ted Gould

Remove tabs for dobey

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2017-03-14 14:34:06 +0000
3+++ debian/control 2017-03-17 15:13:13 +0000
4@@ -19,7 +19,7 @@
5 libglib2.0-dev,
6 libjson-glib-dev,
7 libsqlite3-dev,
8- libubuntu-app-launch3-dev (>= 0.5),
9+ libubuntu-app-launch3-dev (>= 0.11),
10 libunity-scopes-dev,
11 python3:any,
12 python3-dbusmock <!cross>,
13
14=== modified file 'gui/url-dispatcher-gui.desktop.in'
15--- gui/url-dispatcher-gui.desktop.in 2016-08-17 22:13:32 +0000
16+++ gui/url-dispatcher-gui.desktop.in 2017-03-17 15:13:13 +0000
17@@ -4,3 +4,4 @@
18 Type=Application
19 Exec=qmlscene @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/url-dispatcher/gui/url-dispatcher-gui.qml
20 X-Ubuntu-Touch=true
21+X-Ubuntu-Single-Instance=true
22
23=== modified file 'gui/url-dispatcher-gui.svg'
24--- gui/url-dispatcher-gui.svg 2016-08-17 22:00:22 +0000
25+++ gui/url-dispatcher-gui.svg 2017-03-17 15:13:13 +0000
26@@ -51,6 +51,7 @@
27 </cc:Work>
28 </rdf:RDF>
29 </metadata>
30+ <rect x="0" y="0" width="100%" height="100%" style="fill:#ffffff;fill-opacity:1;stroke:none" />
31 <g
32 inkscape:label="Layer 1"
33 inkscape:groupmode="layer"
34
35=== modified file 'service/bad-url/CMakeLists.txt'
36--- service/bad-url/CMakeLists.txt 2015-06-19 22:02:33 +0000
37+++ service/bad-url/CMakeLists.txt 2017-03-17 15:13:13 +0000
38@@ -3,7 +3,7 @@
39 ###########################
40
41 add_definitions( -DQML_BAD_URL="${CMAKE_INSTALL_FULL_DATADIR}/url-dispatcher/bad-url.qml" )
42-add_executable(bad-url-exec-tool exec-tool.c)
43+add_executable(bad-url-exec-tool exec-tool.cpp)
44 set_target_properties(bad-url-exec-tool PROPERTIES OUTPUT_NAME "exec-tool")
45 target_link_libraries(bad-url-exec-tool ${GIO2_LIBRARIES} ${UBUNTU_APP_LAUNCH_LIBRARIES})
46
47
48=== renamed file 'service/bad-url/exec-tool.c' => 'service/bad-url/exec-tool.cpp'
49--- service/bad-url/exec-tool.c 2015-06-19 22:02:33 +0000
50+++ service/bad-url/exec-tool.cpp 2017-03-17 15:13:13 +0000
51@@ -17,26 +17,20 @@
52 * Ted Gould <ted.gould@canonical.com>
53 */
54
55-#include <gio/gio.h>
56-#include <ubuntu-app-launch.h>
57+#include <ubuntu-app-launch/helper.h>
58+#include <glib.h>
59
60 int
61 main (int argc, char * argv[])
62 {
63- GDBusConnection * bus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
64- g_return_val_if_fail(bus != NULL, -1);
65-
66- gchar * exec = g_strdup_printf("qmlscene %s %s", QML_BAD_URL, g_getenv("APP_URIS"));
67-
68- gboolean sended = ubuntu_app_launch_helper_set_exec(exec, NULL);
69- g_free(exec);
70-
71- /* Ensuring the messages get on the bus before we quit */
72- g_dbus_connection_flush_sync(bus, NULL, NULL);
73- g_clear_object(&bus);
74-
75- if (sended)
76- return 0;
77- else
78- return -1;
79+ try {
80+ ubuntu::app_launch::Helper::setExec({"qmlscene", QML_BAD_URL});
81+ return EXIT_SUCCESS;
82+ } catch (std::runtime_error &e) {
83+ g_warning("Unable to set helper: %s", e.what());
84+ return EXIT_FAILURE;
85+ } catch (...) {
86+ g_warning("Unknown failure setting exec line");
87+ return EXIT_FAILURE;
88+ }
89 }
90
91=== modified file 'tests/CMakeLists.txt'
92--- tests/CMakeLists.txt 2017-03-14 14:31:35 +0000
93+++ tests/CMakeLists.txt 2017-03-17 15:13:13 +0000
94@@ -118,19 +118,6 @@
95 add_subdirectory(url_dispatcher_testability)
96
97 ###########################
98-# exec tool test
99-###########################
100-
101-add_executable (exec-tool-test exec-tool-test.cc)
102-target_link_libraries (exec-tool-test
103- gtest
104- ${GMOCK_LIBRARIES}
105- ${GIO2_LIBRARIES}
106- ${DBUSTEST_LIBRARIES})
107-
108-add_test (exec-tool-test exec-tool-test)
109-
110-###########################
111 # overlay tracker test
112 ###########################
113
114
115=== removed file 'tests/exec-tool-test.cc'
116--- tests/exec-tool-test.cc 2017-03-10 23:54:46 +0000
117+++ tests/exec-tool-test.cc 1970-01-01 00:00:00 +0000
118@@ -1,111 +0,0 @@
119-/**
120- * Copyright © 2013-2015 Canonical, Ltd.
121- *
122- * This program is free software: you can redistribute it and/or modify it under
123- * the terms of the GNU Lesser General Public License version 3, as published by
124- * the Free Software Foundation.
125- *
126- * This program is distributed in the hope that it will be useful, but WITHOUT
127- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
128- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
129- * Lesser General Public License for more details.
130- *
131- * You should have received a copy of the GNU Lesser General Public License
132- * along with this program. If not, see <http://www.gnu.org/licenses/>.
133- *
134- */
135-
136-#include "test-config.h"
137-
138-#include <gio/gio.h>
139-#include <gtest/gtest.h>
140-#include <libdbustest/dbus-test.h>
141-
142-class ExecToolTest : public ::testing::Test
143-{
144- protected:
145- DbusTestService * service = nullptr;
146- DbusTestDbusMock * mock = nullptr;
147- DbusTestDbusMockObject * obj = nullptr;
148- GDBusConnection * bus = nullptr;
149-
150- virtual void SetUp() {
151- g_setenv("URL_DISPATCHER_DISABLE_RECOVERABLE_ERROR", "1", TRUE);
152- g_setenv("URL_DISPATCHER_OVERLAY_DIR", OVERLAY_TEST_DIR, TRUE);
153-
154- service = dbus_test_service_new(nullptr);
155-
156- /* Upstart Mock */
157- mock = dbus_test_dbus_mock_new("com.ubuntu.Upstart");
158- obj = dbus_test_dbus_mock_get_object(mock, "/com/ubuntu/Upstart", "com.ubuntu.Upstart0_6", nullptr);
159-
160- dbus_test_dbus_mock_object_add_method(mock, obj,
161- "SetEnv",
162- G_VARIANT_TYPE("(assb)"),
163- NULL,
164- "",
165- NULL);
166-
167- dbus_test_task_set_name(DBUS_TEST_TASK(mock), "Upstart");
168- dbus_test_service_add_task(service, DBUS_TEST_TASK(mock));
169-
170- /* Start your engines! */
171- dbus_test_service_start_tasks(service);
172-
173- bus = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, nullptr);
174- g_dbus_connection_set_exit_on_close(bus, FALSE);
175- g_object_add_weak_pointer(G_OBJECT(bus), (gpointer *)&bus);
176- return;
177- }
178-
179- virtual void TearDown() {
180- /* dbustest should probably do this, not sure */
181-
182- g_clear_object(&mock);
183- g_clear_object(&service);
184-
185- g_object_unref(bus);
186-
187- unsigned int cleartry = 0;
188- while (bus != nullptr && cleartry < 100) {
189- pause(100);
190- cleartry++;
191- }
192-
193- return;
194- }
195-
196- static gboolean quit_loop (gpointer ploop) {
197- g_main_loop_quit((GMainLoop *)ploop);
198- return FALSE;
199- }
200-
201- void pause (int time) {
202- GMainLoop * loop = g_main_loop_new(nullptr, FALSE);
203- g_timeout_add(time, quit_loop, loop);
204- g_main_loop_run(loop);
205- g_main_loop_unref(loop);
206- }
207-};
208-
209-TEST_F(ExecToolTest, SetOverlay)
210-{
211- g_unsetenv("APP_ID");
212- gint retval = 0;
213- EXPECT_TRUE(g_spawn_command_line_sync(EXEC_TOOL, nullptr, nullptr, &retval, nullptr));
214- EXPECT_NE(0, retval);
215-
216- g_setenv("APP_ID", "com.test.good_application_1.2.3", TRUE);
217- g_setenv("UPSTART_JOB", "fubar", TRUE);
218- EXPECT_TRUE(g_spawn_command_line_sync(EXEC_TOOL, nullptr, nullptr, &retval, nullptr));
219- EXPECT_EQ(0, retval);
220-
221- guint len = 0;
222- const DbusTestDbusMockCall * calls = dbus_test_dbus_mock_object_get_method_calls(mock, obj, "SetEnv", &len, NULL);
223- ASSERT_NE(nullptr, calls);
224- ASSERT_EQ(1, len);
225-
226- GVariant * appexecenv = g_variant_get_child_value(calls[0].params, 1);
227- EXPECT_STREQ("APP_EXEC=foobar", g_variant_get_string(appexecenv, nullptr));
228- g_variant_unref(appexecenv);
229-}

Subscribers

People subscribed via source and target branches