diff --git a/src/playlist/PlaylistCWrapper.cpp b/src/playlist/PlaylistCWrapper.cpp index 384c0aff2..a4f4c5e68 100644 --- a/src/playlist/PlaylistCWrapper.cpp +++ b/src/playlist/PlaylistCWrapper.cpp @@ -380,6 +380,13 @@ uint32_t projectm_playlist_remove_presets(projectm_playlist_handle instance, uin } +bool projectm_playlist_get_shuffle(projectm_playlist_handle instance) +{ + auto* playlist = playlist_handle_to_instance(instance); + return playlist->Shuffle(); +} + + void projectm_playlist_set_shuffle(projectm_playlist_handle instance, bool shuffle) { auto* playlist = playlist_handle_to_instance(instance); diff --git a/src/playlist/playlist.h b/src/playlist/playlist.h index f5c2264c9..ac94ee25a 100644 --- a/src/playlist/playlist.h +++ b/src/playlist/playlist.h @@ -331,6 +331,13 @@ bool projectm_playlist_remove_preset(projectm_playlist_handle instance, uint32_t uint32_t projectm_playlist_remove_presets(projectm_playlist_handle instance, uint32_t index, uint32_t count); +/** + * @brief Retrieves the current state of shuffle mode. + * @param instance The playlist manager instance. + * @return True if shuffle mode is enabled, false otherwise. + */ +bool projectm_playlist_get_shuffle(projectm_playlist_handle instance); + /** * @brief Enable or disable shuffle mode. * @param instance The playlist manager instance. diff --git a/tests/playlist/APITest.cpp b/tests/playlist/APITest.cpp index 49ee96b0b..6ef65afe3 100644 --- a/tests/playlist/APITest.cpp +++ b/tests/playlist/APITest.cpp @@ -270,6 +270,18 @@ TEST(projectMPlaylistAPI, RemovePresets) } +TEST(projectMPlaylistAPI, GetShuffle) +{ + PlaylistCWrapperMock mockPlaylist; + + EXPECT_CALL(mockPlaylist, Shuffle()) + .Times(1) + .WillOnce(Return(true)); + + EXPECT_TRUE(projectm_playlist_get_shuffle(reinterpret_cast(&mockPlaylist))); +} + + TEST(projectMPlaylistAPI, SetShuffle) { PlaylistCWrapperMock mockPlaylist; diff --git a/tests/playlist/PlaylistCWrapperMock.h b/tests/playlist/PlaylistCWrapperMock.h index 69f19175a..d1b4068a3 100644 --- a/tests/playlist/PlaylistCWrapperMock.h +++ b/tests/playlist/PlaylistCWrapperMock.h @@ -21,6 +21,7 @@ public: MOCK_METHOD(bool, AddItem, (const std::string&, uint32_t, bool) ); MOCK_METHOD(uint32_t, AddPath, (const std::string&, uint32_t, bool, bool) ); MOCK_METHOD(bool, RemoveItem, (uint32_t)); + MOCK_METHOD(bool, Shuffle, (), (const)); MOCK_METHOD(void, SetShuffle, (bool) ); MOCK_METHOD(void, Sort, (uint32_t, uint32_t, SortPredicate, SortOrder)); MOCK_METHOD(uint32_t, RetryCount, ());