File indexing completed on 2024-05-12 04:49:42
0001 /**************************************************************************************** 0002 * Copyright (c) 2012 Tatjana Gornak <t.gornak@gmail.com> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #ifndef TESTPLAYLISTOBSERVER_H 0018 #define TESTPLAYLISTOBSERVER_H 0019 0020 #include "core/playlists/Playlist.h" 0021 0022 #include <QObject> 0023 #include <QSharedPointer> 0024 #include <QString> 0025 0026 class Observer : public QObject, public Playlists::PlaylistObserver 0027 { 0028 Q_OBJECT 0029 0030 public: 0031 virtual void metadataChanged( Playlists::PlaylistPtr ) 0032 { 0033 Q_EMIT metadataChangedSignal(); 0034 } 0035 void tracksLoaded( Playlists::PlaylistPtr ) override 0036 { 0037 Q_EMIT tracksLoadedSignal(); 0038 } 0039 virtual void trackAdded( Playlists::PlaylistPtr, Meta::TrackPtr, int ) 0040 { 0041 Q_EMIT trackAddedSignal(); 0042 } 0043 virtual void trackRemoved( Playlists::PlaylistPtr, int ) 0044 { 0045 Q_EMIT trackRemovedSignal(); 0046 } 0047 0048 Q_SIGNALS: 0049 void metadataChangedSignal(); 0050 void tracksLoadedSignal(); 0051 void trackAddedSignal(); 0052 void trackRemovedSignal(); 0053 }; 0054 0055 class TestPlaylistObserver : public QObject 0056 { 0057 Q_OBJECT 0058 0059 public: 0060 TestPlaylistObserver(); 0061 0062 private Q_SLOTS: 0063 void initTestCase(); 0064 void cleanupTestCase(); 0065 0066 void init(); 0067 void cleanup(); 0068 0069 void testMetadataChanged(); 0070 void testTracksLoaded(); 0071 void testTrackAdded(); 0072 void testTrackRemoved(); 0073 0074 private: 0075 QString dataPath( const QString &relPath ); 0076 0077 Playlists::PlaylistPtr m_testPlaylist; 0078 Observer *m_observer; 0079 }; 0080 0081 #endif // TESTPLAYLISTOBSERVER_H