File indexing completed on 2024-04-28 04:48:12
0001 /**************************************************************************************** 0002 * Copyright (c) 2013 Konrad Zemek <konrad.zemek@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 IMPORTER_MOCKS_H 0018 #define IMPORTER_MOCKS_H 0019 0020 #include "importers/ImporterManager.h" 0021 #include "importers/ImporterProvider.h" 0022 #include "statsyncing/Controller.h" 0023 0024 #include <gmock/gmock.h> 0025 0026 class EngineController; 0027 namespace StatSyncing 0028 { 0029 class Controller; 0030 } 0031 0032 class MockProvider : public StatSyncing::ImporterProvider 0033 { 0034 public: 0035 MockProvider( const QVariantMap &config, StatSyncing::ImporterManager *manager ); 0036 QVariantMap config() const; 0037 StatSyncing::ImporterManager *manager() const; 0038 0039 MOCK_CONST_METHOD0( reliableTrackMetaData, qint64() ); 0040 MOCK_CONST_METHOD0( writableTrackStatsData, qint64() ); 0041 MOCK_METHOD0( artists, QSet<QString>() ); 0042 MOCK_METHOD1( artistTracks, StatSyncing::TrackList(const QString&) ); 0043 }; 0044 0045 class MockManager : public StatSyncing::ImporterManager 0046 { 0047 public: 0048 MockManager(); 0049 0050 StatSyncing::ProviderPtrMap providers(); 0051 StatSyncing::ImporterProviderPtr concreteNewInstance( const QVariantMap &cfg ); 0052 void providerForgottenProxy( const QString &providerId ); 0053 0054 using StatSyncing::ImporterManager::managerConfig; 0055 using StatSyncing::ImporterManager::providerConfig; 0056 0057 MOCK_CONST_METHOD0( type, QString() ); 0058 MOCK_CONST_METHOD0( description, QString() ); 0059 MOCK_CONST_METHOD0( prettyName, QString() ); 0060 MOCK_CONST_METHOD0( icon, QIcon() ); 0061 MOCK_METHOD1( configWidget, StatSyncing::ProviderConfigWidget*(const QVariantMap&) ); 0062 MOCK_CONST_METHOD0( pluginInfo, KPluginInfo() ); 0063 MOCK_METHOD1( newInstance, StatSyncing::ImporterProviderPtr(const QVariantMap&) ); 0064 }; 0065 0066 class MockController : public StatSyncing::Controller 0067 { 0068 public: 0069 MockController( QObject *parent = nullptr ); 0070 0071 MOCK_METHOD1( registerProvider, void(const StatSyncing::ProviderPtr&) ); 0072 MOCK_METHOD1( unregisterProvider, void(const StatSyncing::ProviderPtr&) ); 0073 }; 0074 0075 class ImporterMocks : public QObject 0076 { 0077 Q_OBJECT 0078 0079 protected: 0080 EngineController *m_engineController; 0081 MockController *m_mockController; 0082 MockManager *m_mockManager; 0083 MockProvider *m_mockProvider; 0084 0085 private Q_SLOTS: 0086 void initTestCase(); 0087 void init(); 0088 void cleanup(); 0089 void cleanupTestCase(); 0090 }; 0091 0092 #endif // IMPORTER_MOCKS_H