Merge lp:~xavi-garcia-mena/indicator-sound/bug-1213907-active-players-playback-control into lp:indicator-sound/15.10

Proposed by Xavi Garcia
Status: Merged
Approved by: Charles Kerr
Approved revision: 528
Merged at revision: 526
Proposed branch: lp:~xavi-garcia-mena/indicator-sound/bug-1213907-active-players-playback-control
Merge into: lp:indicator-sound/15.10
Diff against target: 1040 lines (+778/-47)
9 files modified
data/com.canonical.indicator.sound.gschema.xml (+11/-0)
src/service.vala (+11/-4)
src/sound-menu.vala (+78/-33)
tests/integration/indicator-sound-test-base.cpp (+40/-3)
tests/integration/indicator-sound-test-base.h (+9/-0)
tests/integration/test-indicator.cpp (+568/-1)
tests/service-mocks/media-player-mpris-mock/applications/testplayer2.desktop (+21/-0)
tests/service-mocks/media-player-mpris-mock/applications/testplayer3.desktop (+21/-0)
tests/sound-menu.cc (+19/-6)
To merge this branch: bzr merge lp:~xavi-garcia-mena/indicator-sound/bug-1213907-active-players-playback-control
Reviewer Review Type Date Requested Status
Sebastien Bacher Needs Fixing
PS Jenkins bot (community) continuous-integration Approve
Charles Kerr (community) Approve
Review via email: mp+284455@code.launchpad.net

Commit message

This branch modifies the sound indicator on the desktop to only show the playback controls for those players that are active or (if any is running) the last one being active.

Description of the change

This branch modifies the sound indicator on the desktop to only show the playback controls for those players that are active or (if any is running) the last one being active.

It includes integration tests to verify the code.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
526. By Xavi Garcia

fixed conflict

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

Questions inline.

review: Needs Information
Revision history for this message
Xavi Garcia (xavi-garcia-mena) wrote :

Thanks for the review, Charles!
Comments also inline

527. By Xavi Garcia

Added Charles suggestions

528. By Xavi Garcia

Fixed tabs

Revision history for this message
Charles Kerr (charlesk) wrote :

Thanks for the update Xavi!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

the "last used player" doesn't seem persistent, if the indicator restarts there are no control ... is that wanted?

the spec states "show playback controls only for those players that are currently playing, or if none are, the player that was playing most recently", it doesn't specify that it's restricted to the current session

review: Needs Fixing
Revision history for this message
Xavi Garcia (xavi-garcia-mena) wrote :

Confirmed with design. I'm working on storing the last used player to be persistent between sessions.

Revision history for this message
Sebastien Bacher (seb128) wrote :

thanks!

529. By Xavi Garcia

Added persistence for last running player

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/com.canonical.indicator.sound.gschema.xml'
2--- data/com.canonical.indicator.sound.gschema.xml 2015-08-11 17:33:34 +0000
3+++ data/com.canonical.indicator.sound.gschema.xml 2016-02-10 13:10:45 +0000
4@@ -102,5 +102,16 @@
5 </description>
6 </key>
7
8+ <key name="last-running-player" type="s">
9+ <default>""</default>
10+ <summary>Stores which was the last running music player.</summary>
11+ <description>
12+ To make the last running player persistent and be able to set its playback controls
13+ we store which was the last player running id.
14+
15+ The default value ("") corresponds to no player.
16+ </description>
17+ </key>
18+
19 </schema>
20 </schemalist>
21
22=== modified file 'src/service.vala'
23--- src/service.vala 2016-01-07 05:28:51 +0000
24+++ src/service.vala 2016-02-10 13:10:45 +0000
25@@ -91,11 +91,12 @@
26 this.actions.add_action (this.create_high_volume_action ());
27 this.actions.add_action (this.create_volume_sync_action ());
28
29+ string last_player = this.settings.get_string ("last-running-player");
30 this.menus = new HashTable<string, SoundMenu> (str_hash, str_equal);
31- this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS));
32- this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS));
33- this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE));
34- this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS));
35+ this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS, last_player));
36+ this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS, last_player));
37+ this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS_PLAY_CONTROLS | SoundMenu.DisplayFlags.ADD_PLAY_CONTROL_INACTIVE_PLAYER, last_player));
38+ this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS, last_player));
39
40 this.menus.@foreach ( (profile, menu) => {
41 this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE);
42@@ -109,6 +110,12 @@
43 this.volume_control.active_output_changed.connect (menu.update_volume_slider);
44 });
45
46+ this.menus.@foreach ( (profile, menu) => {
47+ menu.last_player_updated.connect ((player_id) => {
48+ this.settings.set_value ("last-running-player", player_id);
49+ });
50+ });
51+
52 this.sync_preferred_players ();
53 this.settings.changed["interested-media-players"].connect ( () => {
54 this.sync_preferred_players ();
55
56=== modified file 'src/sound-menu.vala'
57--- src/sound-menu.vala 2016-01-20 17:12:23 +0000
58+++ src/sound-menu.vala 2016-02-10 13:10:45 +0000
59@@ -25,10 +25,20 @@
60 HIDE_INACTIVE_PLAYERS = 2,
61 HIDE_PLAYERS = 4,
62 GREETER_PLAYERS = 8,
63- SHOW_SILENT_MODE = 16
64- }
65-
66- public SoundMenu (string? settings_action, DisplayFlags flags) {
67+ SHOW_SILENT_MODE = 16,
68+ HIDE_INACTIVE_PLAYERS_PLAY_CONTROLS = 32,
69+ ADD_PLAY_CONTROL_INACTIVE_PLAYER = 64
70+ }
71+
72+ public enum PlayerSectionPosition {
73+ LABEL = 0,
74+ PLAYER_CONTROLS = 1,
75+ PLAYLIST = 2
76+ }
77+
78+ const string PLAYBACK_ITEM_TYPE = "com.canonical.unity.playback-item";
79+
80+ public SoundMenu (string? settings_action, DisplayFlags flags, string default_player_id) {
81 /* A sound menu always has at least two sections: the volume section (this.volume_section)
82 * at the start of the menu, and the settings section at the end. Between those two,
83 * it has a dynamic amount of player sections, one for each registered player.
84@@ -68,10 +78,14 @@
85
86 this.hide_players = (flags & DisplayFlags.HIDE_PLAYERS) != 0;
87 this.hide_inactive = (flags & DisplayFlags.HIDE_INACTIVE_PLAYERS) != 0;
88+ this.hide_inactive_player_controls = (flags & DisplayFlags.HIDE_INACTIVE_PLAYERS_PLAY_CONTROLS) != 0;
89+ this.add_play_button_inactive_player = (flags & DisplayFlags.ADD_PLAY_CONTROL_INACTIVE_PLAYER) != 0;
90 this.notify_handlers = new HashTable<MediaPlayer, ulong> (direct_hash, direct_equal);
91
92 this.greeter_players = (flags & DisplayFlags.GREETER_PLAYERS) != 0;
93
94+ this.default_player = default_player_id;
95+
96 }
97
98 ~SoundMenu () {
99@@ -148,6 +162,15 @@
100 return -1;
101 }
102
103+ public void update_all_players_play_section() {
104+ foreach (var player_stored in notify_handlers.get_keys ()) {
105+ int index = this.find_player_section(player_stored);
106+ if (index != -1) {
107+ // just update to verify if we must hide the player controls
108+ update_player_section (player_stored, index);
109+ }
110+ }
111+ }
112
113 public void add_player (MediaPlayer player) {
114 if (this.notify_handlers.contains (player))
115@@ -158,21 +181,23 @@
116 this.update_playlists (player);
117
118 var handler_id = player.notify["is-running"].connect ( () => {
119+ int index = this.find_player_section(player);
120 if (player.is_running) {
121- int index = this.find_player_section(player);
122 if (index == -1) {
123 this.insert_player_section (player);
124 }
125- else {
126- update_player_section (player, index);
127- }
128+ number_of_running_players++;
129 }
130 else {
131+ number_of_running_players--;
132 if (this.hide_inactive)
133 this.remove_player_section (player);
134 }
135-
136 this.update_playlists (player);
137+
138+ // we need to update the rest of players, because we might have
139+ // a non running player still showing the playback controls
140+ update_all_players_play_section();
141 });
142 this.notify_handlers.insert (player, handler_id);
143
144@@ -239,8 +264,12 @@
145 bool high_volume_warning_shown = false;
146 bool hide_inactive;
147 bool hide_players = false;
148+ bool hide_inactive_player_controls = false;
149+ bool add_play_button_inactive_player = false;
150 HashTable<MediaPlayer, ulong> notify_handlers;
151 bool greeter_players = false;
152+ int number_of_running_players = 0;
153+ string default_player = "";
154
155 /* returns the position in this.menu of the section that's associated with @player */
156 int find_player_section (MediaPlayer player) {
157@@ -261,9 +290,21 @@
158 return -1;
159 }
160
161+ int find_player_playback_controls_section (Menu player_menu) {
162+ int n = player_menu.get_n_items ();
163+ for (int i = 0; i < n; i++) {
164+ string type;
165+ player_menu.get_item_attribute (i, "x-canonical-type", "s", out type);
166+ if (type == PLAYBACK_ITEM_TYPE)
167+ return i;
168+ }
169+
170+ return -1;
171+ }
172+
173 MenuItem create_playback_menu_item (MediaPlayer player) {
174 var playback_item = new MenuItem (null, null);
175- playback_item.set_attribute ("x-canonical-type", "s", "com.canonical.unity.playback-item");
176+ playback_item.set_attribute ("x-canonical-type", "s", PLAYBACK_ITEM_TYPE);
177 if (player.is_running) {
178 if (player.can_do_play) {
179 playback_item.set_attribute ("x-canonical-play-action", "s", "indicator.play." + player.id);
180@@ -274,6 +315,10 @@
181 if (player.can_do_prev) {
182 playback_item.set_attribute ("x-canonical-previous-action", "s", "indicator.previous." + player.id);
183 }
184+ } else {
185+ if (this.add_play_button_inactive_player) {
186+ playback_item.set_attribute ("x-canonical-play-action", "s", "indicator.play." + player.id);
187+ }
188 }
189 return playback_item;
190 }
191@@ -301,24 +346,10 @@
192 player_item.set_attribute_value ("icon", icon.serialize ());
193 section.append_item (player_item);
194
195- var playback_item = new MenuItem (null, null);
196- playback_item.set_attribute ("x-canonical-type", "s", "com.canonical.unity.playback-item");
197- playback_item.set_attribute ("x-canonical-play-action", "s", "indicator.play." + player.id + ".disabled");
198- playback_item.set_attribute ("x-canonical-next-action", "s", "indicator.next." + player.id + ".disabled");
199- playback_item.set_attribute ("x-canonical-previous-action", "s", "indicator.previous." + player.id + ".disabled");
200-
201- if (player.is_running) {
202- if (player.can_do_play) {
203- playback_item.set_attribute ("x-canonical-play-action", "s", "indicator.play." + player.id);
204- }
205- if (player.can_do_next) {
206- playback_item.set_attribute ("x-canonical-next-action", "s", "indicator.next." + player.id);
207- }
208- if (player.can_do_prev) {
209- playback_item.set_attribute ("x-canonical-previous-action", "s", "indicator.previous." + player.id);
210- }
211+ if (player.is_running|| !this.hide_inactive_player_controls || player.id == this.default_player) {
212+ var playback_item = create_playback_menu_item (player);
213+ section.insert_item (PlayerSectionPosition.PLAYER_CONTROLS, playback_item);
214 }
215- section.append_item (playback_item);
216
217 /* Add new players to the end of the player sections, just before the settings */
218 if (settings_shown) {
219@@ -339,13 +370,25 @@
220
221 void update_player_section (MediaPlayer player, int index) {
222 var player_section = this.menu.get_item_link(index, Menu.LINK_SECTION) as Menu;
223- if (player_section.get_n_items () == 2 || player_section.get_n_items () == 3) {
224- // we have 2 items, the second one is the playback item
225- // if we have 3 items, it means we also have the playlist item.
226- // remove the playbak item first
227- player_section.remove (1);
228+
229+ int play_control_index = find_player_playback_controls_section (player_section);
230+ if (player.is_running && number_of_running_players == 1) {
231+ // this is the first or the last player running...
232+ // store its id
233+ this.last_player_updated (player.id);
234+ }
235+ if (player.is_running || !this.hide_inactive_player_controls) {
236 MenuItem playback_item = create_playback_menu_item (player);
237- player_section.insert_item (1, playback_item);
238+ if (play_control_index != -1) {
239+ player_section.remove (PlayerSectionPosition.PLAYER_CONTROLS);
240+ }
241+ player_section.insert_item (PlayerSectionPosition.PLAYER_CONTROLS, playback_item);
242+ } else {
243+ if (play_control_index != -1 && number_of_running_players >= 1) {
244+ // remove both, playlist and play controls
245+ player_section.remove (PlayerSectionPosition.PLAYLIST);
246+ player_section.remove (PlayerSectionPosition.PLAYER_CONTROLS);
247+ }
248 }
249 }
250
251@@ -404,4 +447,6 @@
252
253 return slider;
254 }
255+
256+ public signal void last_player_updated (string player_id);
257 }
258
259=== modified file 'tests/integration/indicator-sound-test-base.cpp'
260--- tests/integration/indicator-sound-test-base.cpp 2016-01-07 05:28:51 +0000
261+++ tests/integration/indicator-sound-test-base.cpp 2016-02-10 13:10:45 +0000
262@@ -192,16 +192,53 @@
263
264 bool IndicatorSoundTestBase::startTestMprisPlayer(QString const& playerName)
265 {
266- testPlayer1.terminate();
267- testPlayer1.start(MEDIA_PLAYER_MPRIS_BIN, QStringList()
268+ if (!stopTestMprisPlayer(playerName))
269+ {
270+ return false;
271+ }
272+ TestPlayer player;
273+ player.name = playerName;
274+ player.process.reset(new QProcess());
275+ player.process->start(MEDIA_PLAYER_MPRIS_BIN, QStringList()
276 << playerName);
277- if (!testPlayer1.waitForStarted())
278+ if (!player.process->waitForStarted())
279+ {
280+ qWarning() << "ERROR STARTING PLAYER " << playerName;
281 return false;
282+ }
283
284+ testPlayers.push_back(player);
285
286 return true;
287 }
288
289+bool IndicatorSoundTestBase::stopTestMprisPlayer(QString const& playerName)
290+{
291+ bool terminateOK = true;
292+ int index = findRunningTestMprisPlayer(playerName);
293+ if (index != -1)
294+ {
295+ testPlayers[index].process->terminate();
296+ if (!testPlayers[index].process->waitForFinished())
297+ terminateOK = false;
298+ testPlayers.remove(index);
299+ }
300+
301+ return terminateOK;
302+}
303+
304+int IndicatorSoundTestBase::findRunningTestMprisPlayer(QString const& playerName)
305+{
306+ for (int i = 0; i < testPlayers.size(); i++)
307+ {
308+ if (testPlayers.at(i).name == playerName)
309+ {
310+ return i;
311+ }
312+ }
313+ return -1;
314+}
315+
316 bool IndicatorSoundTestBase::setTestMprisPlayerProperty(QString const &testPlayer, QString const &property, bool value)
317 {
318 QProcess setProperty;
319
320=== modified file 'tests/integration/indicator-sound-test-base.h'
321--- tests/integration/indicator-sound-test-base.h 2016-01-07 05:28:51 +0000
322+++ tests/integration/indicator-sound-test-base.h 2016-02-10 13:10:45 +0000
323@@ -81,6 +81,8 @@
324 bool runProcess(QProcess&);
325
326 bool startTestMprisPlayer(QString const& playerName);
327+ bool stopTestMprisPlayer(QString const& playerName);
328+ int findRunningTestMprisPlayer(QString const& playerName);
329
330 bool setTestMprisPlayerProperty(QString const &testPlayer, QString const &property, bool value);
331
332@@ -156,6 +158,13 @@
333
334 QProcess testPlayer1;
335
336+ struct TestPlayer
337+ {
338+ std::shared_ptr<QProcess> process;
339+ QString name;
340+ };
341+ QVector<TestPlayer> testPlayers;
342+
343 std::unique_ptr<MenusInterface> menu_interface_;
344
345 std::unique_ptr<DBusPropertiesInterface> accounts_interface_;
346
347=== modified file 'tests/integration/test-indicator.cpp'
348--- tests/integration/test-indicator.cpp 2016-01-13 18:36:19 +0000
349+++ tests/integration/test-indicator.cpp 2016-02-10 13:10:45 +0000
350@@ -367,6 +367,574 @@
351 .label("Sound Settings…")
352 )
353 ).match());
354+
355+ // stop the test player
356+ EXPECT_TRUE(stopTestMprisPlayer("testplayer1"));
357+
358+ EXPECT_MATCHRESULT(mh::MenuMatcher(desktopParameters())
359+ .item(mh::MenuItemMatcher()
360+ .action("indicator.root")
361+ .string_attribute("x-canonical-type", "com.canonical.indicator.root")
362+ .string_attribute("x-canonical-secondary-action", "indicator.mute")
363+ .mode(mh::MenuItemMatcher::Mode::all)
364+ .submenu()
365+ .item(mh::MenuItemMatcher()
366+ .section()
367+ .item(mh::MenuItemMatcher().checkbox()
368+ .label("Mute")
369+ )
370+ .item(volumeSlider(INITIAL_VOLUME, "Volume"))
371+ )
372+ .item(mh::MenuItemMatcher()
373+ .section()
374+ .item(mh::MenuItemMatcher()
375+ .action("indicator.testplayer1.desktop")
376+ .label("TestPlayer1")
377+ .themed_icon("icon", {"testplayer"})
378+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
379+ )
380+ .item(mh::MenuItemMatcher()
381+ .string_attribute("x-canonical-previous-action","indicator.previous.testplayer1.desktop")
382+ .string_attribute("x-canonical-play-action","indicator.play.testplayer1.desktop")
383+ .string_attribute("x-canonical-next-action","indicator.next.testplayer1.desktop")
384+ .string_attribute("x-canonical-type","com.canonical.unity.playback-item")
385+ )
386+ )
387+ .item(mh::MenuItemMatcher()
388+ .label("Sound Settings…")
389+ )
390+ ).match());
391+}
392+
393+TEST_F(TestIndicator, DesktopMprisPlayersPlaybackControls)
394+{
395+ double INITIAL_VOLUME = 0.0;
396+
397+ ASSERT_NO_THROW(startAccountsService());
398+ EXPECT_TRUE(clearGSettingsPlayers());
399+ ASSERT_NO_THROW(startPulseDesktop());
400+
401+ // initialize volumes in pulseaudio
402+ EXPECT_FALSE(setStreamRestoreVolume("alert", INITIAL_VOLUME));
403+ EXPECT_TRUE(setSinkVolume(INITIAL_VOLUME));
404+
405+ // start the test player
406+ EXPECT_TRUE(startTestMprisPlayer("testplayer1"));
407+
408+ // start now the indicator, so it picks the new volumes
409+ ASSERT_NO_THROW(startIndicator());
410+
411+ // check that the player is added
412+ EXPECT_MATCHRESULT(mh::MenuMatcher(desktopParameters())
413+ .item(mh::MenuItemMatcher()
414+ .action("indicator.root")
415+ .string_attribute("x-canonical-type", "com.canonical.indicator.root")
416+ .string_attribute("x-canonical-secondary-action", "indicator.mute")
417+ .mode(mh::MenuItemMatcher::Mode::all)
418+ .submenu()
419+ .item(mh::MenuItemMatcher()
420+ .section()
421+ .item(mh::MenuItemMatcher().checkbox()
422+ .label("Mute")
423+ )
424+ .item(volumeSlider(INITIAL_VOLUME, "Volume"))
425+ )
426+ .item(mh::MenuItemMatcher()
427+ .section()
428+ .item(mh::MenuItemMatcher()
429+ .action("indicator.testplayer1.desktop")
430+ .label("TestPlayer1")
431+ .themed_icon("icon", {"testplayer"})
432+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
433+ )
434+ .item(mh::MenuItemMatcher()
435+ .string_attribute("x-canonical-previous-action","indicator.previous.testplayer1.desktop")
436+ .string_attribute("x-canonical-play-action","indicator.play.testplayer1.desktop")
437+ .string_attribute("x-canonical-next-action","indicator.next.testplayer1.desktop")
438+ .string_attribute("x-canonical-type","com.canonical.unity.playback-item")
439+ )
440+ )
441+ .item(mh::MenuItemMatcher()
442+ .label("Sound Settings…")
443+ )
444+ ).match());
445+
446+ // start the second test player
447+ EXPECT_TRUE(startTestMprisPlayer("testplayer2"));
448+
449+ // check that the player is added
450+ EXPECT_MATCHRESULT(mh::MenuMatcher(desktopParameters())
451+ .item(mh::MenuItemMatcher()
452+ .action("indicator.root")
453+ .string_attribute("x-canonical-type", "com.canonical.indicator.root")
454+ .string_attribute("x-canonical-secondary-action", "indicator.mute")
455+ .mode(mh::MenuItemMatcher::Mode::all)
456+ .submenu()
457+ .item(mh::MenuItemMatcher()
458+ .section()
459+ .item(mh::MenuItemMatcher().checkbox()
460+ .label("Mute")
461+ )
462+ .item(volumeSlider(INITIAL_VOLUME, "Volume"))
463+ )
464+ .item(mh::MenuItemMatcher()
465+ .section()
466+ .item(mh::MenuItemMatcher()
467+ .action("indicator.testplayer1.desktop")
468+ .label("TestPlayer1")
469+ .themed_icon("icon", {"testplayer"})
470+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
471+ )
472+ .item(mh::MenuItemMatcher()
473+ .string_attribute("x-canonical-previous-action","indicator.previous.testplayer1.desktop")
474+ .string_attribute("x-canonical-play-action","indicator.play.testplayer1.desktop")
475+ .string_attribute("x-canonical-next-action","indicator.next.testplayer1.desktop")
476+ .string_attribute("x-canonical-type","com.canonical.unity.playback-item")
477+ )
478+ )
479+ .item(mh::MenuItemMatcher()
480+ .section()
481+ .item(mh::MenuItemMatcher()
482+ .action("indicator.testplayer2.desktop")
483+ .label("TestPlayer2")
484+ .themed_icon("icon", {"testplayer"})
485+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
486+ )
487+ .item(mh::MenuItemMatcher()
488+ .string_attribute("x-canonical-previous-action","indicator.previous.testplayer2.desktop")
489+ .string_attribute("x-canonical-play-action","indicator.play.testplayer2.desktop")
490+ .string_attribute("x-canonical-next-action","indicator.next.testplayer2.desktop")
491+ .string_attribute("x-canonical-type","com.canonical.unity.playback-item")
492+ )
493+ )
494+ .item(mh::MenuItemMatcher()
495+ .label("Sound Settings…")
496+ )
497+ ).match());
498+
499+ // start the third test player
500+ EXPECT_TRUE(startTestMprisPlayer("testplayer3"));
501+
502+ // check that the player is added
503+ EXPECT_MATCHRESULT(mh::MenuMatcher(desktopParameters())
504+ .item(mh::MenuItemMatcher()
505+ .action("indicator.root")
506+ .string_attribute("x-canonical-type", "com.canonical.indicator.root")
507+ .string_attribute("x-canonical-secondary-action", "indicator.mute")
508+ .mode(mh::MenuItemMatcher::Mode::all)
509+ .submenu()
510+ .item(mh::MenuItemMatcher()
511+ .section()
512+ .item(mh::MenuItemMatcher().checkbox()
513+ .label("Mute")
514+ )
515+ .item(volumeSlider(INITIAL_VOLUME, "Volume"))
516+ )
517+ .item(mh::MenuItemMatcher()
518+ .section()
519+ .item(mh::MenuItemMatcher()
520+ .action("indicator.testplayer1.desktop")
521+ .label("TestPlayer1")
522+ .themed_icon("icon", {"testplayer"})
523+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
524+ )
525+ .item(mh::MenuItemMatcher()
526+ .string_attribute("x-canonical-previous-action","indicator.previous.testplayer1.desktop")
527+ .string_attribute("x-canonical-play-action","indicator.play.testplayer1.desktop")
528+ .string_attribute("x-canonical-next-action","indicator.next.testplayer1.desktop")
529+ .string_attribute("x-canonical-type","com.canonical.unity.playback-item")
530+ )
531+ )
532+ .item(mh::MenuItemMatcher()
533+ .section()
534+ .item(mh::MenuItemMatcher()
535+ .action("indicator.testplayer2.desktop")
536+ .label("TestPlayer2")
537+ .themed_icon("icon", {"testplayer"})
538+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
539+ )
540+ .item(mh::MenuItemMatcher()
541+ .string_attribute("x-canonical-previous-action","indicator.previous.testplayer2.desktop")
542+ .string_attribute("x-canonical-play-action","indicator.play.testplayer2.desktop")
543+ .string_attribute("x-canonical-next-action","indicator.next.testplayer2.desktop")
544+ .string_attribute("x-canonical-type","com.canonical.unity.playback-item")
545+ )
546+ )
547+ .item(mh::MenuItemMatcher()
548+ .section()
549+ .item(mh::MenuItemMatcher()
550+ .action("indicator.testplayer3.desktop")
551+ .label("TestPlayer3")
552+ .themed_icon("icon", {"testplayer"})
553+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
554+ )
555+ .item(mh::MenuItemMatcher()
556+ .string_attribute("x-canonical-previous-action","indicator.previous.testplayer3.desktop")
557+ .string_attribute("x-canonical-play-action","indicator.play.testplayer3.desktop")
558+ .string_attribute("x-canonical-next-action","indicator.next.testplayer3.desktop")
559+ .string_attribute("x-canonical-type","com.canonical.unity.playback-item")
560+ )
561+ )
562+ .item(mh::MenuItemMatcher()
563+ .label("Sound Settings…")
564+ )
565+ ).match());
566+
567+ // stop the test player
568+ EXPECT_TRUE(stopTestMprisPlayer("testplayer3"));
569+
570+ // check that player 3 is present, but it has no playback controls
571+ EXPECT_MATCHRESULT(mh::MenuMatcher(desktopParameters())
572+ .item(mh::MenuItemMatcher()
573+ .action("indicator.root")
574+ .string_attribute("x-canonical-type", "com.canonical.indicator.root")
575+ .string_attribute("x-canonical-secondary-action", "indicator.mute")
576+ .mode(mh::MenuItemMatcher::Mode::all)
577+ .submenu()
578+ .item(mh::MenuItemMatcher()
579+ .section()
580+ .item(mh::MenuItemMatcher().checkbox()
581+ .label("Mute")
582+ )
583+ .item(volumeSlider(INITIAL_VOLUME, "Volume"))
584+ )
585+ .item(mh::MenuItemMatcher()
586+ .section()
587+ .item(mh::MenuItemMatcher()
588+ .action("indicator.testplayer1.desktop")
589+ .label("TestPlayer1")
590+ .themed_icon("icon", {"testplayer"})
591+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
592+ )
593+ .item(mh::MenuItemMatcher()
594+ .string_attribute("x-canonical-previous-action","indicator.previous.testplayer1.desktop")
595+ .string_attribute("x-canonical-play-action","indicator.play.testplayer1.desktop")
596+ .string_attribute("x-canonical-next-action","indicator.next.testplayer1.desktop")
597+ .string_attribute("x-canonical-type","com.canonical.unity.playback-item")
598+ )
599+ )
600+ .item(mh::MenuItemMatcher()
601+ .section()
602+ .item(mh::MenuItemMatcher()
603+ .action("indicator.testplayer2.desktop")
604+ .label("TestPlayer2")
605+ .themed_icon("icon", {"testplayer"})
606+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
607+ )
608+ .item(mh::MenuItemMatcher()
609+ .string_attribute("x-canonical-previous-action","indicator.previous.testplayer2.desktop")
610+ .string_attribute("x-canonical-play-action","indicator.play.testplayer2.desktop")
611+ .string_attribute("x-canonical-next-action","indicator.next.testplayer2.desktop")
612+ .string_attribute("x-canonical-type","com.canonical.unity.playback-item")
613+ )
614+ )
615+ .item(mh::MenuItemMatcher()
616+ .section()
617+ .item(mh::MenuItemMatcher()
618+ .action("indicator.testplayer3.desktop")
619+ .label("TestPlayer3")
620+ .themed_icon("icon", {"testplayer"})
621+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
622+ )
623+ )
624+ .item(mh::MenuItemMatcher()
625+ .label("Sound Settings…")
626+ )
627+ ).match());
628+
629+ EXPECT_TRUE(stopTestMprisPlayer("testplayer2"));
630+
631+ // check that player 2 is present, but it has no playback controls
632+ EXPECT_MATCHRESULT(mh::MenuMatcher(desktopParameters())
633+ .item(mh::MenuItemMatcher()
634+ .action("indicator.root")
635+ .string_attribute("x-canonical-type", "com.canonical.indicator.root")
636+ .string_attribute("x-canonical-secondary-action", "indicator.mute")
637+ .mode(mh::MenuItemMatcher::Mode::all)
638+ .submenu()
639+ .item(mh::MenuItemMatcher()
640+ .section()
641+ .item(mh::MenuItemMatcher().checkbox()
642+ .label("Mute")
643+ )
644+ .item(volumeSlider(INITIAL_VOLUME, "Volume"))
645+ )
646+ .item(mh::MenuItemMatcher()
647+ .section()
648+ .item(mh::MenuItemMatcher()
649+ .action("indicator.testplayer1.desktop")
650+ .label("TestPlayer1")
651+ .themed_icon("icon", {"testplayer"})
652+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
653+ )
654+ .item(mh::MenuItemMatcher()
655+ .string_attribute("x-canonical-previous-action","indicator.previous.testplayer1.desktop")
656+ .string_attribute("x-canonical-play-action","indicator.play.testplayer1.desktop")
657+ .string_attribute("x-canonical-next-action","indicator.next.testplayer1.desktop")
658+ .string_attribute("x-canonical-type","com.canonical.unity.playback-item")
659+ )
660+ )
661+ .item(mh::MenuItemMatcher()
662+ .section()
663+ .item(mh::MenuItemMatcher()
664+ .action("indicator.testplayer2.desktop")
665+ .label("TestPlayer2")
666+ .themed_icon("icon", {"testplayer"})
667+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
668+ )
669+ )
670+ .item(mh::MenuItemMatcher()
671+ .section()
672+ .item(mh::MenuItemMatcher()
673+ .action("indicator.testplayer3.desktop")
674+ .label("TestPlayer3")
675+ .themed_icon("icon", {"testplayer"})
676+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
677+ )
678+ )
679+ .item(mh::MenuItemMatcher()
680+ .label("Sound Settings…")
681+ )
682+ ).match());
683+
684+ EXPECT_TRUE(stopTestMprisPlayer("testplayer1"));
685+
686+ // check that player 1 is present, and it still has the playback controls
687+ // as it was the last one being executed
688+ EXPECT_MATCHRESULT(mh::MenuMatcher(desktopParameters())
689+ .item(mh::MenuItemMatcher()
690+ .action("indicator.root")
691+ .string_attribute("x-canonical-type", "com.canonical.indicator.root")
692+ .string_attribute("x-canonical-secondary-action", "indicator.mute")
693+ .mode(mh::MenuItemMatcher::Mode::all)
694+ .submenu()
695+ .item(mh::MenuItemMatcher()
696+ .section()
697+ .item(mh::MenuItemMatcher().checkbox()
698+ .label("Mute")
699+ )
700+ .item(volumeSlider(INITIAL_VOLUME, "Volume"))
701+ )
702+ .item(mh::MenuItemMatcher()
703+ .section()
704+ .item(mh::MenuItemMatcher()
705+ .action("indicator.testplayer1.desktop")
706+ .label("TestPlayer1")
707+ .themed_icon("icon", {"testplayer"})
708+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
709+ )
710+ .item(mh::MenuItemMatcher()
711+ .string_attribute("x-canonical-previous-action","indicator.previous.testplayer1.desktop")
712+ .string_attribute("x-canonical-play-action","indicator.play.testplayer1.desktop")
713+ .string_attribute("x-canonical-next-action","indicator.next.testplayer1.desktop")
714+ .string_attribute("x-canonical-type","com.canonical.unity.playback-item")
715+ )
716+ )
717+ .item(mh::MenuItemMatcher()
718+ .section()
719+ .item(mh::MenuItemMatcher()
720+ .action("indicator.testplayer2.desktop")
721+ .label("TestPlayer2")
722+ .themed_icon("icon", {"testplayer"})
723+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
724+ )
725+ )
726+ .item(mh::MenuItemMatcher()
727+ .section()
728+ .item(mh::MenuItemMatcher()
729+ .action("indicator.testplayer3.desktop")
730+ .label("TestPlayer3")
731+ .themed_icon("icon", {"testplayer"})
732+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
733+ )
734+ )
735+ .item(mh::MenuItemMatcher()
736+ .label("Sound Settings…")
737+ )
738+ ).match());
739+
740+ // start the third test player
741+ EXPECT_TRUE(startTestMprisPlayer("testplayer3"));
742+
743+ // check that player 3 is the only one with playback controls
744+ EXPECT_MATCHRESULT(mh::MenuMatcher(desktopParameters())
745+ .item(mh::MenuItemMatcher()
746+ .action("indicator.root")
747+ .string_attribute("x-canonical-type", "com.canonical.indicator.root")
748+ .string_attribute("x-canonical-secondary-action", "indicator.mute")
749+ .mode(mh::MenuItemMatcher::Mode::all)
750+ .submenu()
751+ .item(mh::MenuItemMatcher()
752+ .section()
753+ .item(mh::MenuItemMatcher().checkbox()
754+ .label("Mute")
755+ )
756+ .item(volumeSlider(INITIAL_VOLUME, "Volume"))
757+ )
758+ .item(mh::MenuItemMatcher()
759+ .section()
760+ .item(mh::MenuItemMatcher()
761+ .action("indicator.testplayer1.desktop")
762+ .label("TestPlayer1")
763+ .themed_icon("icon", {"testplayer"})
764+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
765+ )
766+ )
767+ .item(mh::MenuItemMatcher()
768+ .section()
769+ .item(mh::MenuItemMatcher()
770+ .action("indicator.testplayer2.desktop")
771+ .label("TestPlayer2")
772+ .themed_icon("icon", {"testplayer"})
773+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
774+ )
775+ )
776+ .item(mh::MenuItemMatcher()
777+ .section()
778+ .item(mh::MenuItemMatcher()
779+ .action("indicator.testplayer3.desktop")
780+ .label("TestPlayer3")
781+ .themed_icon("icon", {"testplayer"})
782+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
783+ )
784+ .item(mh::MenuItemMatcher()
785+ .string_attribute("x-canonical-previous-action","indicator.previous.testplayer3.desktop")
786+ .string_attribute("x-canonical-play-action","indicator.play.testplayer3.desktop")
787+ .string_attribute("x-canonical-next-action","indicator.next.testplayer3.desktop")
788+ .string_attribute("x-canonical-type","com.canonical.unity.playback-item")
789+ )
790+ )
791+ .item(mh::MenuItemMatcher()
792+ .label("Sound Settings…")
793+ )
794+ ).match());
795+
796+ // start the rest of players
797+ EXPECT_TRUE(startTestMprisPlayer("testplayer1"));
798+ EXPECT_TRUE(startTestMprisPlayer("testplayer2"));
799+
800+ EXPECT_MATCHRESULT(mh::MenuMatcher(desktopParameters())
801+ .item(mh::MenuItemMatcher()
802+ .action("indicator.root")
803+ .string_attribute("x-canonical-type", "com.canonical.indicator.root")
804+ .string_attribute("x-canonical-secondary-action", "indicator.mute")
805+ .mode(mh::MenuItemMatcher::Mode::all)
806+ .submenu()
807+ .item(mh::MenuItemMatcher()
808+ .section()
809+ .item(mh::MenuItemMatcher().checkbox()
810+ .label("Mute")
811+ )
812+ .item(volumeSlider(INITIAL_VOLUME, "Volume"))
813+ )
814+ .item(mh::MenuItemMatcher()
815+ .section()
816+ .item(mh::MenuItemMatcher()
817+ .action("indicator.testplayer1.desktop")
818+ .label("TestPlayer1")
819+ .themed_icon("icon", {"testplayer"})
820+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
821+ )
822+ .item(mh::MenuItemMatcher()
823+ .string_attribute("x-canonical-previous-action","indicator.previous.testplayer1.desktop")
824+ .string_attribute("x-canonical-play-action","indicator.play.testplayer1.desktop")
825+ .string_attribute("x-canonical-next-action","indicator.next.testplayer1.desktop")
826+ .string_attribute("x-canonical-type","com.canonical.unity.playback-item")
827+ )
828+ )
829+ .item(mh::MenuItemMatcher()
830+ .section()
831+ .item(mh::MenuItemMatcher()
832+ .action("indicator.testplayer2.desktop")
833+ .label("TestPlayer2")
834+ .themed_icon("icon", {"testplayer"})
835+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
836+ )
837+ .item(mh::MenuItemMatcher()
838+ .string_attribute("x-canonical-previous-action","indicator.previous.testplayer2.desktop")
839+ .string_attribute("x-canonical-play-action","indicator.play.testplayer2.desktop")
840+ .string_attribute("x-canonical-next-action","indicator.next.testplayer2.desktop")
841+ .string_attribute("x-canonical-type","com.canonical.unity.playback-item")
842+ )
843+ )
844+ .item(mh::MenuItemMatcher()
845+ .section()
846+ .item(mh::MenuItemMatcher()
847+ .action("indicator.testplayer3.desktop")
848+ .label("TestPlayer3")
849+ .themed_icon("icon", {"testplayer"})
850+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
851+ )
852+ .item(mh::MenuItemMatcher()
853+ .string_attribute("x-canonical-previous-action","indicator.previous.testplayer3.desktop")
854+ .string_attribute("x-canonical-play-action","indicator.play.testplayer3.desktop")
855+ .string_attribute("x-canonical-next-action","indicator.next.testplayer3.desktop")
856+ .string_attribute("x-canonical-type","com.canonical.unity.playback-item")
857+ )
858+ )
859+ .item(mh::MenuItemMatcher()
860+ .label("Sound Settings…")
861+ )
862+ ).match());
863+
864+ // stop all players
865+ EXPECT_TRUE(stopTestMprisPlayer("testplayer1"));
866+ EXPECT_TRUE(stopTestMprisPlayer("testplayer2"));
867+ EXPECT_TRUE(stopTestMprisPlayer("testplayer3"));
868+
869+ // check that player 3 is the only one with playback controls
870+ // as it was the last one being stopped
871+ EXPECT_MATCHRESULT(mh::MenuMatcher(desktopParameters())
872+ .item(mh::MenuItemMatcher()
873+ .action("indicator.root")
874+ .string_attribute("x-canonical-type", "com.canonical.indicator.root")
875+ .string_attribute("x-canonical-secondary-action", "indicator.mute")
876+ .mode(mh::MenuItemMatcher::Mode::all)
877+ .submenu()
878+ .item(mh::MenuItemMatcher()
879+ .section()
880+ .item(mh::MenuItemMatcher().checkbox()
881+ .label("Mute")
882+ )
883+ .item(volumeSlider(INITIAL_VOLUME, "Volume"))
884+ )
885+ .item(mh::MenuItemMatcher()
886+ .section()
887+ .item(mh::MenuItemMatcher()
888+ .action("indicator.testplayer1.desktop")
889+ .label("TestPlayer1")
890+ .themed_icon("icon", {"testplayer"})
891+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
892+ )
893+ )
894+ .item(mh::MenuItemMatcher()
895+ .section()
896+ .item(mh::MenuItemMatcher()
897+ .action("indicator.testplayer2.desktop")
898+ .label("TestPlayer2")
899+ .themed_icon("icon", {"testplayer"})
900+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
901+ )
902+ )
903+ .item(mh::MenuItemMatcher()
904+ .section()
905+ .item(mh::MenuItemMatcher()
906+ .action("indicator.testplayer3.desktop")
907+ .label("TestPlayer3")
908+ .themed_icon("icon", {"testplayer"})
909+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
910+ )
911+ .item(mh::MenuItemMatcher()
912+ .string_attribute("x-canonical-previous-action","indicator.previous.testplayer3.desktop")
913+ .string_attribute("x-canonical-play-action","indicator.play.testplayer3.desktop")
914+ .string_attribute("x-canonical-next-action","indicator.next.testplayer3.desktop")
915+ .string_attribute("x-canonical-type","com.canonical.unity.playback-item")
916+ )
917+ )
918+ .item(mh::MenuItemMatcher()
919+ .label("Sound Settings…")
920+ )
921+ ).match());
922 }
923
924 TEST_F(TestIndicator, DesktopMprisPlayerButtonsState)
925@@ -817,7 +1385,6 @@
926 // try again...
927 notificationsSpy.clear();
928
929- qWarning() << "-----------------------------------------------------------";
930 // change volume to 1.0... warning should be emitted
931 setActionValue("volume", QVariant::fromValue(1.0));
932 EXPECT_TRUE(waitVolumeChangedInIndicator());
933
934=== added file 'tests/service-mocks/media-player-mpris-mock/applications/testplayer2.desktop'
935--- tests/service-mocks/media-player-mpris-mock/applications/testplayer2.desktop 1970-01-01 00:00:00 +0000
936+++ tests/service-mocks/media-player-mpris-mock/applications/testplayer2.desktop 2016-02-10 13:10:45 +0000
937@@ -0,0 +1,21 @@
938+[Desktop Entry]
939+Name=TestPlayer2
940+GenericName=Test Player 2
941+X-GNOME-FullName=Test Player 2
942+Comment=Play and organize your music collection
943+Keywords=Audio;Song;MP3;CD;Podcast;MTP;iPod;Playlist;Last.fm;UPnP;DLNA;Radio;
944+Exec=echo %U
945+Terminal=false
946+Type=Application
947+Icon=testplayer
948+X-GNOME-DocPath=testplayer/testplayer.xml
949+Categories=GNOME;GTK;AudioVideo;Audio;Player;
950+MimeType=application/x-ogg;application/ogg;audio/x-vorbis+ogg;audio/x-scpls;audio/x-mp3;audio/x-mpeg;audio/mpeg;audio/x-mpegurl;audio/x-flac;audio/mp4;x-scheme-handler/itms;x-scheme-handler/itmss;
951+StartupNotify=true
952+X-GNOME-Bugzilla-Bugzilla=GNOME
953+X-GNOME-Bugzilla-Product=testplayer
954+X-GNOME-Bugzilla-Component=general
955+X-GNOME-Bugzilla-OtherBinaries=rhythmbox-client;rhythmbox-metadata;
956+X-GNOME-Bugzilla-Version=3.1
957+X-GNOME-UsesNotifications=true
958+
959
960=== added file 'tests/service-mocks/media-player-mpris-mock/applications/testplayer3.desktop'
961--- tests/service-mocks/media-player-mpris-mock/applications/testplayer3.desktop 1970-01-01 00:00:00 +0000
962+++ tests/service-mocks/media-player-mpris-mock/applications/testplayer3.desktop 2016-02-10 13:10:45 +0000
963@@ -0,0 +1,21 @@
964+[Desktop Entry]
965+Name=TestPlayer3
966+GenericName=Test Player 3
967+X-GNOME-FullName=Test Player 3
968+Comment=Play and organize your music collection
969+Keywords=Audio;Song;MP3;CD;Podcast;MTP;iPod;Playlist;Last.fm;UPnP;DLNA;Radio;
970+Exec=echo %U
971+Terminal=false
972+Type=Application
973+Icon=testplayer
974+X-GNOME-DocPath=testplayer/testplayer.xml
975+Categories=GNOME;GTK;AudioVideo;Audio;Player;
976+MimeType=application/x-ogg;application/ogg;audio/x-vorbis+ogg;audio/x-scpls;audio/x-mp3;audio/x-mpeg;audio/mpeg;audio/x-mpegurl;audio/x-flac;audio/mp4;x-scheme-handler/itms;x-scheme-handler/itmss;
977+StartupNotify=true
978+X-GNOME-Bugzilla-Bugzilla=GNOME
979+X-GNOME-Bugzilla-Product=testplayer
980+X-GNOME-Bugzilla-Component=general
981+X-GNOME-Bugzilla-OtherBinaries=rhythmbox-client;rhythmbox-metadata;
982+X-GNOME-Bugzilla-Version=3.1
983+X-GNOME-UsesNotifications=true
984+
985
986=== modified file 'tests/sound-menu.cc'
987--- tests/sound-menu.cc 2015-09-16 16:18:46 +0000
988+++ tests/sound-menu.cc 2016-02-10 13:10:45 +0000
989@@ -62,7 +62,7 @@
990
991 void check_player_control_buttons(bool canPlay, bool canNext, bool canPrev)
992 {
993- SoundMenu * menu = sound_menu_new (nullptr, SOUND_MENU_DISPLAY_FLAGS_NONE);
994+ SoundMenu * menu = sound_menu_new (nullptr, SOUND_MENU_DISPLAY_FLAGS_NONE, "");
995
996 MediaPlayerTrack * track = media_player_track_new("Artist", "Title", "Album", "http://art.url");
997
998@@ -96,9 +96,22 @@
999
1000 /* Player control */
1001 verify_item_attribute(section, 1, "x-canonical-type", g_variant_new_string("com.canonical.unity.playback-item"));
1002- verify_item_attribute(section, 1, "x-canonical-play-action", g_variant_new_string(canPlay ? "indicator.play.player-id" : "indicator.play.player-id.disabled"));
1003- verify_item_attribute(section, 1, "x-canonical-next-action", g_variant_new_string(canNext ? "indicator.next.player-id" : "indicator.next.player-id.disabled"));
1004- verify_item_attribute(section, 1, "x-canonical-previous-action", g_variant_new_string(canPrev ? "indicator.previous.player-id" : "indicator.previous.player-id.disabled"));
1005+ //verify_item_attribute(section, 1, "x-canonical-play-action", g_variant_new_string(""));
1006+ if (!canPlay) {
1007+ verify_item_attribute_is_not_set(section, 1, "x-canonical-play-action", G_VARIANT_TYPE_STRING);
1008+ } else {
1009+ verify_item_attribute(section, 1, "x-canonical-play-action", g_variant_new_string("indicator.play.player-id"));
1010+ }
1011+ if (!canNext) {
1012+ verify_item_attribute_is_not_set(section, 1, "x-canonical-next-action", G_VARIANT_TYPE_STRING);
1013+ } else {
1014+ verify_item_attribute(section, 1, "x-canonical-next-action", g_variant_new_string("indicator.next.player-id"));
1015+ }
1016+ if (!canPrev) {
1017+ verify_item_attribute_is_not_set(section, 1, "x-canonical-previous-action", G_VARIANT_TYPE_STRING);
1018+ } else {
1019+ verify_item_attribute(section, 1, "x-canonical-previous-action", g_variant_new_string("indicator.previous.player-id"));
1020+ }
1021
1022 g_clear_object(&section);
1023
1024@@ -112,7 +125,7 @@
1025 };
1026
1027 TEST_F(SoundMenuTest, BasicObject) {
1028- SoundMenu * menu = sound_menu_new (nullptr, SOUND_MENU_DISPLAY_FLAGS_NONE);
1029+ SoundMenu * menu = sound_menu_new (nullptr, SOUND_MENU_DISPLAY_FLAGS_NONE, "");
1030
1031 ASSERT_NE(nullptr, menu);
1032
1033@@ -121,7 +134,7 @@
1034 }
1035
1036 TEST_F(SoundMenuTest, AddRemovePlayer) {
1037- SoundMenu * menu = sound_menu_new (nullptr, SOUND_MENU_DISPLAY_FLAGS_NONE);
1038+ SoundMenu * menu = sound_menu_new (nullptr, SOUND_MENU_DISPLAY_FLAGS_NONE, "");
1039
1040 MediaPlayerTrack * track = media_player_track_new("Artist", "Title", "Album", "http://art.url");
1041

Subscribers

People subscribed via source and target branches