File indexing completed on 2024-06-16 04:32:38

0001 /***************************************************************************
0002  *   Copyright (c) 2009 Sven Krohlas <sven@asbest-online.de>               *
0003  *                                                                         *
0004  *   This program is free software; you can redistribute it and/or modify  *
0005  *   it under the terms of the GNU General Public License as published by  *
0006  *   the Free Software Foundation; either version 2 of the License, or     *
0007  *   (at your option) any later version.                                   *
0008  *                                                                         *
0009  *   This program is distributed in the hope that it will be useful,       *
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0012  *   GNU General Public License for more details.                          *
0013  *                                                                         *
0014  *   You should have received a copy of the GNU General Public License     *
0015  *   along with this program; if not, write to the                         *
0016  *   Free Software Foundation, Inc.,                                       *
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
0018  ***************************************************************************/
0019 
0020 #ifndef TESTMETAMULTITRACK_H
0021 #define TESTMETAMULTITRACK_H
0022 
0023 #include "core/meta/Observer.h"
0024 #include "core/playlists/Playlist.h"
0025 
0026 #include <QObject>
0027 
0028 namespace Meta {
0029     class MultiTrack;
0030 }
0031 
0032 class TestMetaMultiTrack : public QObject, private Playlists::PlaylistObserver
0033 {
0034 Q_OBJECT
0035 
0036 public:
0037     TestMetaMultiTrack();
0038 
0039     void tracksLoaded( Playlists::PlaylistPtr playlist ) override;
0040 
0041 Q_SIGNALS:
0042     void tracksLoadedSignal( const Playlists::PlaylistPtr &playlist );
0043 
0044 private Q_SLOTS:
0045     void initTestCase();
0046     void cleanupTestCase();
0047 
0048     void init();
0049     void cleanup();
0050 
0051     void testSources();
0052     void testSetSourceCurrentNextUrl();
0053     void testHasCapabilityInterface();
0054 
0055 private:
0056     Playlists::PlaylistPtr m_playlist;
0057     Meta::MultiTrack *m_testMultiTrack;
0058 };
0059 
0060 /**
0061  * A helper class that waits until all tracks have called notifyObservers at least once
0062  * and then emits a signal done()
0063  */
0064 class NotifyObserversWaiter : public QObject, private Meta::Observer
0065 {
0066     Q_OBJECT
0067 
0068     public:
0069         NotifyObserversWaiter( const QSet<Meta::TrackPtr> &tracks, QObject *parent = nullptr );
0070 
0071     Q_SIGNALS:
0072         void done();
0073 
0074     private Q_SLOTS:
0075         void slotFilterResolved();
0076 
0077     private:
0078         using Observer::metadataChanged; // silence gcc warning
0079         virtual void metadataChanged( Meta::TrackPtr track );
0080 
0081         QSet<Meta::TrackPtr> m_tracks;
0082         QMutex m_mutex;
0083 };
0084 
0085 #endif // TESTMETAMULTITRACK_H