Merge lp:~dobey/indicator-sound/drop-greeeter into lp:indicator-sound

Proposed by dobey
Status: Approved
Approved by: dobey
Approved revision: 552
Proposed branch: lp:~dobey/indicator-sound/drop-greeeter
Merge into: lp:indicator-sound
Diff against target: 867 lines (+4/-697)
11 files modified
debian/control (+0/-1)
src/CMakeLists.txt (+2/-20)
src/accounts-service-user.vala (+0/-47)
src/greeter-broadcast.vala (+0/-34)
src/main.c (+2/-6)
src/media-player-list-greeter.vala (+0/-123)
src/media-player-user.vala (+0/-18)
src/service.vala (+0/-9)
tests/CMakeLists.txt (+0/-51)
tests/greeter-list.cc (+0/-68)
tests/media-player-user.cc (+0/-320)
To merge this branch: bzr merge lp:~dobey/indicator-sound/drop-greeeter
Reviewer Review Type Date Requested Status
unity-api-1-bot continuous-integration Approve
Charles Kerr (community) Approve
Review via email: mp+320858@code.launchpad.net

Commit message

Strip out the complicated non-working greeter support.

Description of the change

This removes the code which theoretically proxies the player controls out to the greeter screen, that doesn't work.

The Sound menu spec states that the player controls should NOT appear on the greeter screen:

https://wiki.ubuntu.com/Sound#Music_player_sections
"Whenever you are logged in (that is, not in the standalone installer session or at the login screen), any music player that advertises itself over http://mpris.org/ Mpris should have its own section in the sound menu."

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
Charles Kerr (charlesk) wrote :

So, first off, I'm not super happy with the tone of the MR, e.g. "theoretically". If the code needs fixing then that's something that should be addressed, but bugs happen and there's no need to be snide about it.

Secondly, I still disagree with the removal of this feature. Controlling play from the greeter is a worthwhile feature IMO.

But as per the discussion in the Indicator meeting today, I'm in the minority on this. If neither the coder doing the work, NOR the designer, want this feature, I'm not going to block the change. :P

review: Approve
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:552
https://jenkins.canonical.com/unity-api-1/job/lp-indicator-sound-ci/24/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/1892
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/1899
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1681
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1681/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1681
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1681/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1681
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1681/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1681
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1681/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1681
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1681/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1681
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1681/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-indicator-sound-ci/24/rebuild

review: Approve (continuous-integration)

Unmerged revisions

552. By dobey

Strip out the complicated non-working greeter support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2017-02-07 22:04:35 +0000
+++ debian/control 2017-03-23 19:32:45 +0000
@@ -56,7 +56,6 @@
56 indicator-common,56 indicator-common,
57Recommends: unity-control-center | gnome-control-center | ubuntu-system-settings | pavucontrol | mate-media,57Recommends: unity-control-center | gnome-control-center | ubuntu-system-settings | pavucontrol | mate-media,
58 accountsservice,58 accountsservice,
59Suggests: unity-greeter-session-broadcast,
60Description: System sound indicator.59Description: System sound indicator.
61 System sound indicator which provides easy control of the PulseAudio sound 60 System sound indicator which provides easy control of the PulseAudio sound
62 daemon.61 daemon.
6362
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2017-02-07 21:50:25 +0000
+++ src/CMakeLists.txt 2017-03-23 19:32:45 +0000
@@ -134,13 +134,6 @@
134 mpris2-interfaces134 mpris2-interfaces
135)135)
136vala_add(indicator-sound-service136vala_add(indicator-sound-service
137 media-player-user.vala
138 DEPENDS
139 media-player
140 accounts-service-sound-settings
141 greeter-broadcast
142)
143vala_add(indicator-sound-service
144 media-player-list.vala137 media-player-list.vala
145 DEPENDS138 DEPENDS
146 media-player139 media-player
@@ -154,13 +147,6 @@
154 mpris2-interfaces147 mpris2-interfaces
155)148)
156vala_add(indicator-sound-service149vala_add(indicator-sound-service
157 media-player-list-greeter.vala
158 DEPENDS
159 media-player-list
160 media-player-user
161 media-player
162)
163vala_add(indicator-sound-service
164 mpris2-interfaces.vala150 mpris2-interfaces.vala
165)151)
166vala_add(indicator-sound-service152vala_add(indicator-sound-service
@@ -183,7 +169,6 @@
183 accounts-service-sound-settings169 accounts-service-sound-settings
184 accounts-service-privacy-settings170 accounts-service-privacy-settings
185 accounts-service-system-sound-settings171 accounts-service-system-sound-settings
186 greeter-broadcast
187)172)
188vala_add(indicator-sound-service173vala_add(indicator-sound-service
189 accounts-service-sound-settings.vala174 accounts-service-sound-settings.vala
@@ -194,9 +179,6 @@
194vala_add(indicator-sound-service179vala_add(indicator-sound-service
195 accounts-service-system-sound-settings.vala180 accounts-service-system-sound-settings.vala
196)181)
197vala_add(indicator-sound-service
198 greeter-broadcast.vala
199)
200182
201vala_finish(indicator-sound-service183vala_finish(indicator-sound-service
202 SOURCES184 SOURCES
@@ -235,8 +217,8 @@
235)217)
236218
237add_library(219add_library(
238 indicator-sound-service-lib STATIC220 indicator-sound-service-lib STATIC
239 ${INDICATOR_SOUND_SOURCES}221 ${INDICATOR_SOUND_SOURCES}
240)222)
241223
242target_link_libraries(224target_link_libraries(
243225
=== modified file 'src/accounts-service-user.vala'
--- src/accounts-service-user.vala 2015-12-31 20:49:42 +0000
+++ src/accounts-service-user.vala 2017-03-23 19:32:45 +0000
@@ -25,9 +25,6 @@
25 AccountsServiceSystemSoundSettings? syssoundproxy = null;25 AccountsServiceSystemSoundSettings? syssoundproxy = null;
26 uint timer = 0;26 uint timer = 0;
27 MediaPlayer? _player = null;27 MediaPlayer? _player = null;
28 GreeterBroadcast? greeter = null;
29
30 public bool showDataOnGreeter { get; set; }
3128
32 bool _silentMode = false;29 bool _silentMode = false;
33 public bool silentMode {30 public bool silentMode {
@@ -118,14 +115,6 @@
118 user = accounts_manager.get_user(GLib.Environment.get_user_name());115 user = accounts_manager.get_user(GLib.Environment.get_user_name());
119 user.notify["is-loaded"].connect(() => user_loaded_changed());116 user.notify["is-loaded"].connect(() => user_loaded_changed());
120 user_loaded_changed();117 user_loaded_changed();
121
122 Bus.get_proxy.begin<GreeterBroadcast> (
123 BusType.SYSTEM,
124 "com.canonical.Unity.Greeter.Broadcast",
125 "/com/canonical/Unity/Greeter/Broadcast",
126 DBusProxyFlags.NONE,
127 null,
128 greeter_proxy_new);
129 }118 }
130119
131 void user_loaded_changed () {120 void user_loaded_changed () {
@@ -188,11 +177,8 @@
188 var welcomeval = changed.lookup_value("MessagesWelcomeScreen", VariantType.BOOLEAN);177 var welcomeval = changed.lookup_value("MessagesWelcomeScreen", VariantType.BOOLEAN);
189 if (welcomeval != null) {178 if (welcomeval != null) {
190 debug("Messages on welcome screen changed");179 debug("Messages on welcome screen changed");
191 this.showDataOnGreeter = welcomeval.get_boolean();
192 }180 }
193 });181 });
194
195 this.showDataOnGreeter = this.privacyproxy.messages_welcome_screen;
196 } catch (Error e) {182 } catch (Error e) {
197 this.privacyproxy = null;183 this.privacyproxy = null;
198 warning("Unable to get proxy to user privacy settings: %s", e.message);184 warning("Unable to get proxy to user privacy settings: %s", e.message);
@@ -219,37 +205,4 @@
219 warning("Unable to get proxy to system sound settings: %s", e.message);205 warning("Unable to get proxy to system sound settings: %s", e.message);
220 }206 }
221 }207 }
222
223 void greeter_proxy_new (GLib.Object? obj, AsyncResult res) {
224 try {
225 this.greeter = Bus.get_proxy.end (res);
226
227 this.greeter.SoundPlayPause.connect((username) => {
228 if (username != GLib.Environment.get_user_name())
229 return;
230 if (this._player == null)
231 return;
232 this._player.play_pause();
233 });
234
235 this.greeter.SoundNext.connect((username) => {
236 if (username != GLib.Environment.get_user_name())
237 return;
238 if (this._player == null)
239 return;
240 this._player.next();
241 });
242
243 this.greeter.SoundPrev.connect((username) => {
244 if (username != GLib.Environment.get_user_name())
245 return;
246 if (this._player == null)
247 return;
248 this._player.previous();
249 });
250 } catch (Error e) {
251 this.greeter = null;
252 warning("Unable to get greeter proxy: %s", e.message);
253 }
254 }
255}208}
256209
=== removed file 'src/greeter-broadcast.vala'
--- src/greeter-broadcast.vala 2014-03-13 18:38:55 +0000
+++ src/greeter-broadcast.vala 1970-01-01 00:00:00 +0000
@@ -1,34 +0,0 @@
1/*
2 * Copyright 2014 © Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Ted Gould <ted@canonical.com>
18 */
19
20[DBus (name = "com.canonical.Unity.Greeter.Broadcast")]
21public interface GreeterBroadcast : Object {
22 // methods
23 // unused public abstract async void RequestApplicationStart(string name, string appid) throws IOError;
24 // unused public abstract async void RequestHomeShown(string name) throws IOError;
25 public abstract async void RequestSoundPlayPause(string name) throws IOError;
26 public abstract async void RequestSoundNext(string name) throws IOError;
27 public abstract async void RequestSoundPrev(string name) throws IOError;
28 // signals
29 // unused public signal void StartApplication(string username, string appid);
30 // unused public signal void ShowHome(string username);
31 public signal void SoundPlayPause(string username);
32 public signal void SoundNext(string username);
33 public signal void SoundPrev(string username);
34}
350
=== modified file 'src/main.c'
--- src/main.c 2016-02-23 12:48:46 +0000
+++ src/main.c 2017-03-23 19:32:45 +0000
@@ -54,12 +54,8 @@
54 AccountsServiceAccess * accounts_service_access = NULL;54 AccountsServiceAccess * accounts_service_access = NULL;
5555
5656
57 if (g_strcmp0("lightdm", g_get_user_name()) == 0) {57 playerlist = MEDIA_PLAYER_LIST(media_player_list_mpris_new());
58 playerlist = MEDIA_PLAYER_LIST(media_player_list_greeter_new());58 accounts = accounts_service_user_new();
59 } else {
60 playerlist = MEDIA_PLAYER_LIST(media_player_list_mpris_new());
61 accounts = accounts_service_user_new();
62 }
6359
64 pgloop = pa_glib_mainloop_new(NULL);60 pgloop = pa_glib_mainloop_new(NULL);
65 options = indicator_sound_options_gsettings_new();61 options = indicator_sound_options_gsettings_new();
6662
=== removed file 'src/media-player-list-greeter.vala'
--- src/media-player-list-greeter.vala 2014-04-01 23:20:56 +0000
+++ src/media-player-list-greeter.vala 1970-01-01 00:00:00 +0000
@@ -1,123 +0,0 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Ted Gould <ted@canonical.com>
18 */
19
20[DBus (name="com.canonical.UnityGreeter.List")]
21public interface UnityGreeterList : Object {
22 public abstract async string get_active_entry () throws IOError;
23 public signal void entry_selected (string entry_name);
24}
25
26public class MediaPlayerListGreeter : MediaPlayerList {
27 string? selected_user = null;
28 UnityGreeterList? proxy = null;
29 HashTable<string, MediaPlayerUser> players = new HashTable<string, MediaPlayerUser>(str_hash, str_equal);
30
31 public MediaPlayerListGreeter () {
32 Bus.get_proxy.begin<UnityGreeterList> (
33 BusType.SESSION,
34 "com.canonical.UnityGreeter",
35 "/list",
36 DBusProxyFlags.NONE,
37 null,
38 new_proxy);
39 }
40
41 void new_proxy (GLib.Object? obj, AsyncResult res) {
42 try {
43 this.proxy = Bus.get_proxy.end(res);
44
45 this.proxy.entry_selected.connect(active_user_changed);
46 this.proxy.get_active_entry.begin ((obj, res) => {
47 try {
48 var value = (obj as UnityGreeterList).get_active_entry.end(res);
49 active_user_changed(value);
50 } catch (Error e) {
51 warning("Unable to get active entry: %s", e.message);
52 }
53 });
54 } catch (Error e) {
55 this.proxy = null;
56 warning("Unable to create proxy to the greeter: %s", e.message);
57 }
58 }
59
60 void active_user_changed (string active_user) {
61 /* No change, move along */
62 if (selected_user == active_user) {
63 return;
64 }
65
66 debug(@"Active user changed to: $active_user");
67
68 var old_user = selected_user;
69
70 /* Protect against a null user */
71 if (active_user != "" && active_user[0] != '*') {
72 selected_user = active_user;
73 } else {
74 debug(@"Blocking active user change for '$active_user'");
75 selected_user = null;
76 }
77
78 if (selected_user != null && !players.contains(selected_user)) {
79 players.insert(selected_user, new MediaPlayerUser(selected_user));
80 }
81
82 if (old_user != null) {
83 var old_player = players.lookup(old_user);
84 debug("Removing player for user: %s", old_user);
85 player_removed(old_player);
86 }
87
88 if (selected_user != null) {
89 var new_player = players.lookup(selected_user);
90
91 if (new_player != null) {
92 debug("Adding player for user: %s", selected_user);
93 player_added(new_player);
94 }
95 }
96 }
97
98 /* We need to have an iterator for the interface, but eh, we can
99 only ever have one player for the current user */
100 public class Iterator : MediaPlayerList.Iterator {
101 int i = 0;
102 MediaPlayerListGreeter list;
103
104 public Iterator (MediaPlayerListGreeter in_list) {
105 list = in_list;
106 }
107
108 public override MediaPlayer? next_value () {
109 MediaPlayer? retval = null;
110
111 if (i == 0 && list.selected_user != null) {
112 retval = list.players.lookup(list.selected_user);
113 }
114 i++;
115
116 return retval;
117 }
118 }
119
120 public override MediaPlayerList.Iterator iterator() {
121 return new Iterator(this) as MediaPlayerList.Iterator;
122 }
123}
1240
=== modified file 'src/media-player-user.vala'
--- src/media-player-user.vala 2015-12-29 17:05:16 +0000
+++ src/media-player-user.vala 2017-03-23 19:32:45 +0000
@@ -22,7 +22,6 @@
22 string username;22 string username;
23 Act.User? actuser = null;23 Act.User? actuser = null;
24 AccountsServiceSoundSettings? proxy = null;24 AccountsServiceSoundSettings? proxy = null;
25 GreeterBroadcast? greeter = null;
2625
27 HashTable<string, bool> properties_queued = new HashTable<string, bool>(str_hash, str_equal);26 HashTable<string, bool> properties_queued = new HashTable<string, bool>(str_hash, str_equal);
28 uint properties_timeout = 0;27 uint properties_timeout = 0;
@@ -46,14 +45,6 @@
46 null,45 null,
47 new_proxy);46 new_proxy);
48 });47 });
49
50 Bus.get_proxy.begin<GreeterBroadcast> (
51 BusType.SYSTEM,
52 "com.canonical.Unity.Greeter.Broadcast",
53 "/com/canonical/Unity/Greeter/Broadcast",
54 DBusProxyFlags.NONE,
55 null,
56 greeter_proxy_new);
57 }48 }
5849
59 ~MediaPlayerUser () {50 ~MediaPlayerUser () {
@@ -219,15 +210,6 @@
219 set { }210 set { }
220 }211 }
221212
222 void greeter_proxy_new (GLib.Object? obj, AsyncResult res) {
223 try {
224 this.greeter = Bus.get_proxy.end (res);
225 } catch (Error e) {
226 this.greeter = null;
227 warning("Unable to get greeter proxy: %s", e.message);
228 }
229 }
230
231 /* Control functions through unity-greeter-session-broadcast */213 /* Control functions through unity-greeter-session-broadcast */
232 public override void activate () {214 public override void activate () {
233 /* TODO: */215 /* TODO: */
234216
=== modified file 'src/service.vala'
--- src/service.vala 2016-04-15 09:55:49 +0000
+++ src/service.vala 2017-03-23 19:32:45 +0000
@@ -73,15 +73,6 @@
73 });73 });
7474
75 this.accounts_service = accounts;75 this.accounts_service = accounts;
76 /* If we're on the greeter, don't export */
77 if (this.accounts_service != null) {
78 this.accounts_service.notify["showDataOnGreeter"].connect(() => {
79 this.export_to_accounts_service = this.accounts_service.showDataOnGreeter;
80 eventually_update_player_actions();
81 });
82
83 this.export_to_accounts_service = this.accounts_service.showDataOnGreeter;
84 }
8576
86 this.players = playerlist;77 this.players = playerlist;
87 this.players.player_added.connect (this.player_added);78 this.players.player_added.connect (this.player_added);
8879
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2017-02-07 21:50:25 +0000
+++ tests/CMakeLists.txt 2017-03-23 19:32:45 +0000
@@ -212,55 +212,6 @@
212add_test(notifications-test notifications-test)212add_test(notifications-test notifications-test)
213213
214###########################214###########################
215# Accounts Service User
216###########################
217
218include_directories(${CMAKE_SOURCE_DIR}/src)
219add_executable (media-player-user-test media-player-user.cc)
220target_link_libraries (
221 media-player-user-test
222 indicator-sound-service-lib
223 vala-mocks-lib
224 ${SOUNDSERVICE_LIBRARIES}
225 ${TEST_LIBRARIES}
226 ${GMOCK_LIBRARIES}
227)
228
229# Split tests to work around libaccountservice sucking
230add_test(media-player-user-test-basic
231 media-player-user-test --gtest_filter=MediaPlayerUserTest.BasicObject
232)
233add_test(media-player-user-test-dataset
234 media-player-user-test --gtest_filter=MediaPlayerUserTest.DataSet
235)
236add_test(media-player-user-test-timeout
237 media-player-user-test --gtest_filter=MediaPlayerUserTest.TimeoutTest
238)
239
240###########################
241# Greeter List
242###########################
243
244include_directories(${CMAKE_SOURCE_DIR}/src)
245add_executable (greeter-list-test greeter-list.cc)
246target_link_libraries (
247 greeter-list-test
248 indicator-sound-service-lib
249 vala-mocks-lib
250 ${SOUNDSERVICE_LIBRARIES}
251 ${TEST_LIBRARIES}
252 ${GMOCK_LIBRARIES}
253)
254
255# Split tests to work around libaccountservice sucking
256add_test(greeter-list-test-basic
257 greeter-list-test --gtest_filter=GreeterListTest.BasicObject
258)
259add_test(greeter-list-test-iterator
260 greeter-list-test --gtest_filter=GreeterListTest.BasicIterator
261)
262
263###########################
264# Indicator Test215# Indicator Test
265###########################216###########################
266217
@@ -293,8 +244,6 @@
293 volume-control-test244 volume-control-test
294 sound-menu-test245 sound-menu-test
295 notifications-test246 notifications-test
296 media-player-user-test
297 greeter-list-test
298 indicator-test247 indicator-test
299 PARENT_SCOPE248 PARENT_SCOPE
300)249)
301250
=== removed file 'tests/greeter-list.cc'
--- tests/greeter-list.cc 2014-03-25 13:52:31 +0000
+++ tests/greeter-list.cc 1970-01-01 00:00:00 +0000
@@ -1,68 +0,0 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Ted Gould <ted@canonical.com>
18 */
19
20#include <gtest/gtest.h>
21#include <gio/gio.h>
22
23extern "C" {
24#include "indicator-sound-service.h"
25#include "vala-mocks.h"
26}
27
28class GreeterListTest : public ::testing::Test
29{
30 protected:
31 GTestDBus * bus = nullptr;
32
33 virtual void SetUp() {
34 bus = g_test_dbus_new(G_TEST_DBUS_NONE);
35 g_test_dbus_up(bus);
36 }
37
38 virtual void TearDown() {
39 g_test_dbus_down(bus);
40 g_clear_object(&bus);
41 }
42
43};
44
45TEST_F(GreeterListTest, BasicObject) {
46 MediaPlayerListGreeter * list = media_player_list_greeter_new();
47
48 ASSERT_NE(nullptr, list);
49
50 g_clear_object(&list);
51 return;
52}
53
54TEST_F(GreeterListTest, BasicIterator) {
55 MediaPlayerListGreeter * list = media_player_list_greeter_new();
56 ASSERT_NE(nullptr, list);
57
58 MediaPlayerListGreeterIterator * iter = media_player_list_greeter_iterator_new(list);
59 ASSERT_NE(nullptr, iter);
60
61 MediaPlayer * player = media_player_list_iterator_next_value (MEDIA_PLAYER_LIST_ITERATOR(iter));
62 ASSERT_EQ(nullptr, player);
63
64 g_clear_object(&iter);
65 g_clear_object(&list);
66 return;
67}
68
690
=== removed file 'tests/media-player-user.cc'
--- tests/media-player-user.cc 2015-08-12 00:13:59 +0000
+++ tests/media-player-user.cc 1970-01-01 00:00:00 +0000
@@ -1,320 +0,0 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Ted Gould <ted@canonical.com>
18 */
19
20#include <chrono>
21#include <future>
22
23#include <gtest/gtest.h>
24#include <gio/gio.h>
25#include <libdbustest/dbus-test.h>
26
27#include "accounts-service-mock.h"
28
29extern "C" {
30#include "indicator-sound-service.h"
31}
32
33class MediaPlayerUserTest : public ::testing::Test
34{
35
36 protected:
37 DbusTestService * testsystem = NULL;
38 AccountsServiceMock service_mock;
39
40 DbusTestService * testsession = NULL;
41
42 DbusTestProcess * systemmonitor = nullptr;
43 DbusTestProcess * sessionmonitor = nullptr;
44
45 GDBusConnection * system = NULL;
46 GDBusConnection * session = NULL;
47 GDBusProxy * proxy = NULL;
48
49 std::chrono::milliseconds _eventuallyTime = std::chrono::seconds{5};
50
51 virtual void SetUp() {
52 /* System Bus */
53 testsystem = dbus_test_service_new(NULL);
54 dbus_test_service_set_bus(testsystem, DBUS_TEST_SERVICE_BUS_SYSTEM);
55
56 systemmonitor = dbus_test_process_new("dbus-monitor");
57 dbus_test_process_append_param(systemmonitor, "--system");
58 dbus_test_task_set_name(DBUS_TEST_TASK(systemmonitor), "System");
59 dbus_test_service_add_task(testsystem, DBUS_TEST_TASK(systemmonitor));
60
61 dbus_test_service_add_task(testsystem, (DbusTestTask*)service_mock);
62 dbus_test_service_start_tasks(testsystem);
63
64 system = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
65 ASSERT_NE(nullptr, system);
66 g_dbus_connection_set_exit_on_close(system, FALSE);
67 g_object_add_weak_pointer(G_OBJECT(system), (gpointer *)&system);
68
69 /* Session Bus */
70 testsession = dbus_test_service_new(NULL);
71 dbus_test_service_set_bus(testsession, DBUS_TEST_SERVICE_BUS_SESSION);
72
73 sessionmonitor = dbus_test_process_new("dbus-monitor");
74 dbus_test_process_append_param(sessionmonitor, "--session");
75 dbus_test_task_set_name(DBUS_TEST_TASK(sessionmonitor), "Session");
76 dbus_test_service_add_task(testsession, DBUS_TEST_TASK(sessionmonitor));
77
78 dbus_test_service_start_tasks(testsession);
79
80 session = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
81 ASSERT_NE(nullptr, session);
82 g_dbus_connection_set_exit_on_close(session, FALSE);
83 g_object_add_weak_pointer(G_OBJECT(session), (gpointer *)&session);
84
85 /* Setup proxy */
86 proxy = g_dbus_proxy_new_sync(system,
87 G_DBUS_PROXY_FLAGS_NONE,
88 NULL,
89 "org.freedesktop.Accounts",
90 "/user",
91 "org.freedesktop.DBus.Properties",
92 NULL, NULL);
93 ASSERT_NE(nullptr, proxy);
94 }
95
96 virtual void TearDown() {
97 g_clear_object(&sessionmonitor);
98 g_clear_object(&systemmonitor);
99
100 g_clear_object(&proxy);
101 g_clear_object(&testsystem);
102 g_clear_object(&testsession);
103
104 g_object_unref(system);
105 g_object_unref(session);
106
107 #if 0
108 /* Accounts Service keeps a bunch of references around so we
109 have to split the tests and can't check this :-( */
110 unsigned int cleartry = 0;
111 while ((session != NULL || system != NULL) && cleartry < 100) {
112 loop(100);
113 cleartry++;
114 }
115
116 ASSERT_EQ(nullptr, session);
117 ASSERT_EQ(nullptr, system);
118 #endif
119 }
120
121 static gboolean timeout_cb (gpointer user_data) {
122 GMainLoop * loop = static_cast<GMainLoop *>(user_data);
123 g_main_loop_quit(loop);
124 return G_SOURCE_REMOVE;
125 }
126
127 void loop (unsigned int ms) {
128 GMainLoop * loop = g_main_loop_new(NULL, FALSE);
129 g_timeout_add(ms, timeout_cb, loop);
130 g_main_loop_run(loop);
131 g_main_loop_unref(loop);
132 }
133
134 void set_property (const gchar * name, GVariant * value) {
135 dbus_test_dbus_mock_object_update_property((DbusTestDbusMock *)service_mock, service_mock.get_sound(), name, value, NULL);
136 }
137
138 testing::AssertionResult expectEventually (std::function<testing::AssertionResult(void)> &testfunc) {
139 auto loop = std::shared_ptr<GMainLoop>(g_main_loop_new(nullptr, FALSE), [](GMainLoop * loop) { if (loop != nullptr) g_main_loop_unref(loop); });
140
141 std::promise<testing::AssertionResult> retpromise;
142 auto retfuture = retpromise.get_future();
143 auto start = std::chrono::steady_clock::now();
144
145 /* The core of the idle function as an object so we can use the C++-isms
146 of attaching the variables and make this code reasonably readable */
147 std::function<void(void)> idlefunc = [&loop, &retpromise, &testfunc, &start, this]() -> void {
148 auto result = testfunc();
149
150 if (result == false && _eventuallyTime > (std::chrono::steady_clock::now() - start)) {
151 return;
152 }
153
154 retpromise.set_value(result);
155 g_main_loop_quit(loop.get());
156 };
157
158 auto idlesrc = g_idle_add([](gpointer data) -> gboolean {
159 auto func = reinterpret_cast<std::function<void(void)> *>(data);
160 (*func)();
161 return G_SOURCE_CONTINUE;
162 }, &idlefunc);
163
164 g_main_loop_run(loop.get());
165 g_source_remove(idlesrc);
166
167 return retfuture.get();
168 }
169
170 /* Eventually Helpers */
171 #define _EVENTUALLY_HELPER(oper) \
172 template <typename... Args> testing::AssertionResult expectEventually##oper (Args&& ... args) { \
173 std::function<testing::AssertionResult(void)> func = [&]() { \
174 return testing::internal::CmpHelper##oper(std::forward<Args>(args)...); \
175 }; \
176 return expectEventually(func); \
177 }
178
179 _EVENTUALLY_HELPER(EQ);
180 _EVENTUALLY_HELPER(NE);
181 _EVENTUALLY_HELPER(LT);
182 _EVENTUALLY_HELPER(GT);
183 _EVENTUALLY_HELPER(STREQ);
184 _EVENTUALLY_HELPER(STRNE);
185
186 #undef _EVENTUALLY_HELPER
187};
188
189/* Helpers */
190#define EXPECT_EVENTUALLY_EQ(expected, actual) \
191 EXPECT_PRED_FORMAT2(MediaPlayerUserTest::expectEventuallyEQ, expected, actual)
192
193#define EXPECT_EVENTUALLY_NE(expected, actual) \
194 EXPECT_PRED_FORMAT2(MediaPlayerUserTest::expectEventuallyNE, expected, actual)
195
196#define EXPECT_EVENTUALLY_LT(expected, actual) \
197 EXPECT_PRED_FORMAT2(MediaPlayerUserTest::expectEventuallyLT, expected, actual)
198
199#define EXPECT_EVENTUALLY_GT(expected, actual) \
200 EXPECT_PRED_FORMAT2(MediaPlayerUserTest::expectEventuallyGT, expected, actual)
201
202#define EXPECT_EVENTUALLY_STREQ(expected, actual) \
203 EXPECT_PRED_FORMAT2(MediaPlayerUserTest::expectEventuallySTREQ, expected, actual)
204
205#define EXPECT_EVENTUALLY_STRNE(expected, actual) \
206 EXPECT_PRED_FORMAT2(MediaPlayerUserTest::expectEventuallySTRNE, expected, actual)
207
208
209TEST_F(MediaPlayerUserTest, BasicObject) {
210 MediaPlayerUser * player = media_player_user_new("user");
211 ASSERT_NE(nullptr, player);
212
213 /* Protected, but no useful data */
214 EXPECT_FALSE(media_player_get_is_running(MEDIA_PLAYER(player)));
215 EXPECT_TRUE(media_player_get_can_raise(MEDIA_PLAYER(player)));
216 EXPECT_STREQ("user", media_player_get_id(MEDIA_PLAYER(player)));
217 EXPECT_STREQ("", media_player_get_name(MEDIA_PLAYER(player)));
218 EXPECT_STREQ("", media_player_get_state(MEDIA_PLAYER(player)));
219 EXPECT_EQ(nullptr, media_player_get_icon(MEDIA_PLAYER(player)));
220 EXPECT_EQ(nullptr, media_player_get_current_track(MEDIA_PLAYER(player)));
221
222 /* Get the proxy -- but no good data */
223 loop(100);
224
225 /* Ensure even with the proxy we don't have anything */
226 EXPECT_FALSE(media_player_get_is_running(MEDIA_PLAYER(player)));
227 EXPECT_TRUE(media_player_get_can_raise(MEDIA_PLAYER(player)));
228 EXPECT_STREQ("user", media_player_get_id(MEDIA_PLAYER(player)));
229 EXPECT_STREQ("", media_player_get_name(MEDIA_PLAYER(player)));
230 EXPECT_STREQ("", media_player_get_state(MEDIA_PLAYER(player)));
231 EXPECT_EQ(nullptr, media_player_get_icon(MEDIA_PLAYER(player)));
232 EXPECT_EQ(nullptr, media_player_get_current_track(MEDIA_PLAYER(player)));
233
234 g_clear_object(&player);
235}
236
237void
238running_update (GObject * obj, GParamSpec * pspec, bool * running) {
239 *running = media_player_get_is_running(MEDIA_PLAYER(obj)) == TRUE;
240};
241
242TEST_F(MediaPlayerUserTest, DISABLED_DataSet) {
243 /* Put data into Acts */
244 set_property("Timestamp", g_variant_new_uint64(g_get_monotonic_time()));
245 set_property("PlayerName", g_variant_new_string("The Player Formerly Known as Prince"));
246 GIcon * in_icon = g_themed_icon_new_with_default_fallbacks("foo-bar-fallback");
247 set_property("PlayerIcon", g_variant_new_variant(g_icon_serialize(in_icon)));
248 set_property("State", g_variant_new_string("Chillin'"));
249 set_property("Title", g_variant_new_string("Dictator"));
250 set_property("Artist", g_variant_new_string("Bansky"));
251 set_property("Album", g_variant_new_string("Vinyl is dead"));
252 set_property("ArtUrl", g_variant_new_string("http://art.url"));
253
254 /* Build our media player */
255 MediaPlayerUser * player = media_player_user_new("user");
256 ASSERT_NE(nullptr, player);
257
258 /* Ensure even with the proxy we don't have anything */
259 bool running = false;
260 g_signal_connect(G_OBJECT(player), "notify::is-running", G_CALLBACK(running_update), &running);
261 running_update(G_OBJECT(player), nullptr, &running);
262 EXPECT_EVENTUALLY_EQ(true, running);
263 EXPECT_TRUE(media_player_get_can_raise(MEDIA_PLAYER(player)));
264 EXPECT_STREQ("user", media_player_get_id(MEDIA_PLAYER(player)));
265 EXPECT_STREQ("The Player Formerly Known as Prince", media_player_get_name(MEDIA_PLAYER(player)));
266 EXPECT_STREQ("Chillin'", media_player_get_state(MEDIA_PLAYER(player)));
267
268 GIcon * out_icon = media_player_get_icon(MEDIA_PLAYER(player));
269 EXPECT_NE(nullptr, out_icon);
270 EXPECT_TRUE(g_icon_equal(in_icon, out_icon));
271 // NOTE: No reference in 'out_icon' returned
272
273 MediaPlayerTrack * track = media_player_get_current_track(MEDIA_PLAYER(player));
274 EXPECT_NE(nullptr, track);
275 EXPECT_STREQ("Dictator", media_player_track_get_title(track));
276 EXPECT_STREQ("Bansky", media_player_track_get_artist(track));
277 EXPECT_STREQ("Vinyl is dead", media_player_track_get_album(track));
278 EXPECT_STREQ("http://art.url", media_player_track_get_art_url(track));
279 // NOTE: No reference in 'track' returned
280
281 g_clear_object(&in_icon);
282 g_clear_object(&player);
283}
284
285TEST_F(MediaPlayerUserTest, DISABLED_TimeoutTest) {
286 /* Put data into Acts -- but 15 minutes ago */
287 set_property("Timestamp", g_variant_new_uint64(g_get_monotonic_time() - 15 * 60 * 1000 * 1000));
288 set_property("PlayerName", g_variant_new_string("The Player Formerly Known as Prince"));
289 GIcon * in_icon = g_themed_icon_new_with_default_fallbacks("foo-bar-fallback");
290 set_property("PlayerIcon", g_variant_new_variant(g_icon_serialize(in_icon)));
291 set_property("State", g_variant_new_string("Chillin'"));
292 set_property("Title", g_variant_new_string("Dictator"));
293 set_property("Artist", g_variant_new_string("Bansky"));
294 set_property("Album", g_variant_new_string("Vinyl is dead"));
295 set_property("ArtUrl", g_variant_new_string("http://art.url"));
296
297 /* Build our media player */
298 MediaPlayerUser * player = media_player_user_new("user");
299 ASSERT_NE(nullptr, player);
300
301 bool running = false;
302 g_signal_connect(G_OBJECT(player), "notify::is-running", G_CALLBACK(running_update), &running);
303 running_update(G_OBJECT(player), nullptr, &running);
304
305 /* Ensure that we show up as not running */
306 EXPECT_EVENTUALLY_EQ(false, running);
307
308 /* Update to make running */
309 set_property("Timestamp", g_variant_new_uint64(g_get_monotonic_time()));
310
311 EXPECT_EVENTUALLY_EQ(true, running);
312
313 /* Clear to not run */
314 set_property("Timestamp", g_variant_new_uint64(1));
315
316 EXPECT_EVENTUALLY_EQ(false, running);
317
318 g_clear_object(&in_icon);
319 g_clear_object(&player);
320}

Subscribers

People subscribed via source and target branches