diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/indicator-sound-test-base.cpp | 33 | ||||
-rw-r--r-- | tests/integration/indicator-sound-test-base.h | 4 | ||||
-rw-r--r-- | tests/sound-menu.cc | 32 |
3 files changed, 50 insertions, 19 deletions
diff --git a/tests/integration/indicator-sound-test-base.cpp b/tests/integration/indicator-sound-test-base.cpp index f61857e..8242fb6 100644 --- a/tests/integration/indicator-sound-test-base.cpp +++ b/tests/integration/indicator-sound-test-base.cpp @@ -448,13 +448,40 @@ bool IndicatorSoundTestBase::initializeMenuChangedSignal() return true; } -bool IndicatorSoundTestBase::waitVolumeChangedInIndicator() +QVariant IndicatorSoundTestBase::waitPropertyChanged(QString property) { + QVariant ret_val; if (signal_spy_volume_changed_) { - return signal_spy_volume_changed_->wait(); + signal_spy_volume_changed_->wait(); + if (signal_spy_volume_changed_->count()) + { + QList<QVariant> arguments = signal_spy_volume_changed_->takeFirst(); + if (arguments.size() == 3 && static_cast<QMetaType::Type>(arguments.at(1).type()) == QMetaType::QVariantMap) + { + QVariantMap map = arguments.at(1).toMap(); + QMapIterator<QString, QVariant> iter(map); + while (iter.hasNext()) { + iter.next(); + if (iter.key() == property) + { + return iter.value(); + } + } + } + } } - return false; + return ret_val; +} +bool IndicatorSoundTestBase::waitVolumeChangedInIndicator() +{ + QVariant val = waitPropertyChanged("Volume"); + return !val.isNull(); +} + +QVariant IndicatorSoundTestBase::waitLastRunningPlayerChanged() +{ + return waitPropertyChanged("LastRunningPlayer"); } void IndicatorSoundTestBase::initializeAccountsInterface() diff --git a/tests/integration/indicator-sound-test-base.h b/tests/integration/indicator-sound-test-base.h index 969fd69..ecdbd7d 100644 --- a/tests/integration/indicator-sound-test-base.h +++ b/tests/integration/indicator-sound-test-base.h @@ -144,6 +144,10 @@ protected: float getVolumeValue(bool *isValid = nullptr); + QVariant waitPropertyChanged(QString property); + + QVariant waitLastRunningPlayerChanged(); + QtDBusTest::DBusTestRunner dbusTestRunner; QtDBusMock::DBusMock dbusMock; diff --git a/tests/sound-menu.cc b/tests/sound-menu.cc index 2576d19..79ae703 100644 --- a/tests/sound-menu.cc +++ b/tests/sound-menu.cc @@ -62,7 +62,7 @@ class SoundMenuTest : public ::testing::Test void check_player_control_buttons(bool canPlay, bool canNext, bool canPrev) { - SoundMenu * menu = sound_menu_new (nullptr, SOUND_MENU_DISPLAY_FLAGS_NONE, ""); + SoundMenu * menu = sound_menu_new (nullptr, SOUND_MENU_DISPLAY_FLAGS_NONE); MediaPlayerTrack * track = media_player_track_new("Artist", "Title", "Album", "http://art.url"); @@ -96,22 +96,22 @@ class SoundMenuTest : public ::testing::Test /* Player control */ verify_item_attribute(section, 1, "x-canonical-type", g_variant_new_string("com.canonical.unity.playback-item")); - //verify_item_attribute(section, 1, "x-canonical-play-action", g_variant_new_string("")); - if (!canPlay) { + //verify_item_attribute(section, 1, "x-canonical-play-action", g_variant_new_string("")); + if (!canPlay) { verify_item_attribute_is_not_set(section, 1, "x-canonical-play-action", G_VARIANT_TYPE_STRING); - } else { - verify_item_attribute(section, 1, "x-canonical-play-action", g_variant_new_string("indicator.play.player-id")); - } - if (!canNext) { + } else { + verify_item_attribute(section, 1, "x-canonical-play-action", g_variant_new_string("indicator.play.player-id")); + } + if (!canNext) { verify_item_attribute_is_not_set(section, 1, "x-canonical-next-action", G_VARIANT_TYPE_STRING); - } else { - verify_item_attribute(section, 1, "x-canonical-next-action", g_variant_new_string("indicator.next.player-id")); - } - if (!canPrev) { + } else { + verify_item_attribute(section, 1, "x-canonical-next-action", g_variant_new_string("indicator.next.player-id")); + } + if (!canPrev) { verify_item_attribute_is_not_set(section, 1, "x-canonical-previous-action", G_VARIANT_TYPE_STRING); - } else { - verify_item_attribute(section, 1, "x-canonical-previous-action", g_variant_new_string("indicator.previous.player-id")); - } + } else { + verify_item_attribute(section, 1, "x-canonical-previous-action", g_variant_new_string("indicator.previous.player-id")); + } g_clear_object(§ion); @@ -125,7 +125,7 @@ class SoundMenuTest : public ::testing::Test }; TEST_F(SoundMenuTest, BasicObject) { - SoundMenu * menu = sound_menu_new (nullptr, SOUND_MENU_DISPLAY_FLAGS_NONE, ""); + SoundMenu * menu = sound_menu_new (nullptr, SOUND_MENU_DISPLAY_FLAGS_NONE); ASSERT_NE(nullptr, menu); @@ -134,7 +134,7 @@ TEST_F(SoundMenuTest, BasicObject) { } TEST_F(SoundMenuTest, AddRemovePlayer) { - SoundMenu * menu = sound_menu_new (nullptr, SOUND_MENU_DISPLAY_FLAGS_NONE, ""); + SoundMenu * menu = sound_menu_new (nullptr, SOUND_MENU_DISPLAY_FLAGS_NONE); MediaPlayerTrack * track = media_player_track_new("Artist", "Title", "Album", "http://art.url"); |