1 /*************************************************************************** 2 * Copyright (c) 2009 Sven Krohlas <sven@asbest-online.de> * 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; either version 2 of the License, or * 7 * (at your option) any later version. * 8 * * 9 * This program is distributed in the hope that it will be useful, * 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 * GNU General Public License for more details. * 13 * * 14 * You should have received a copy of the GNU General Public License * 15 * along with this program; if not, write to the * 16 * Free Software Foundation, Inc., * 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 18 ***************************************************************************/ 19 20 #ifndef TESTMETAMULTITRACK_H 21 #define TESTMETAMULTITRACK_H 22 23 #include "core/meta/Observer.h" 24 #include "core/playlists/Playlist.h" 25 26 #include <QObject> 27 28 namespace Meta { 29 class MultiTrack; 30 } 31 32 class TestMetaMultiTrack : public QObject, private Playlists::PlaylistObserver 33 { 34 Q_OBJECT 35 36 public: 37 TestMetaMultiTrack(); 38 39 void tracksLoaded( Playlists::PlaylistPtr playlist ) override; 40 41 Q_SIGNALS: 42 void tracksLoadedSignal( const Playlists::PlaylistPtr &playlist ); 43 44 private Q_SLOTS: 45 void initTestCase(); 46 void cleanupTestCase(); 47 48 void init(); 49 void cleanup(); 50 51 void testSources(); 52 void testSetSourceCurrentNextUrl(); 53 void testHasCapabilityInterface(); 54 55 private: 56 Playlists::PlaylistPtr m_playlist; 57 Meta::MultiTrack *m_testMultiTrack; 58 }; 59 60 /** 61 * A helper class that waits until all tracks have called notifyObservers at least once 62 * and then emits a signal done() 63 */ 64 class NotifyObserversWaiter : public QObject, private Meta::Observer 65 { 66 Q_OBJECT 67 68 public: 69 NotifyObserversWaiter( const QSet<Meta::TrackPtr> &tracks, QObject *parent = nullptr ); 70 71 Q_SIGNALS: 72 void done(); 73 74 private Q_SLOTS: 75 void slotFilterResolved(); 76 77 private: 78 using Observer::metadataChanged; // silence gcc warning 79 virtual void metadataChanged( Meta::TrackPtr track ); 80 81 QSet<Meta::TrackPtr> m_tracks; 82 QMutex m_mutex; 83 }; 84 85 #endif // TESTMETAMULTITRACK_H 86