File indexing completed on 2024-04-28 04:48:14
0001 /**************************************************************************************** 0002 * Copyright (c) 2012 Jasneet Singh Bhatti <jazneetbhatti@gmail.com> * 0003 * This program is free software; you can redistribute it and/or modify it under * 0004 * the terms of the GNU General Public License as published by the Free Software * 0005 * Foundation; either version 2 of the License, or (at your option) any later * 0006 * version. * 0007 * * 0008 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0009 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0010 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0011 * * 0012 * You should have received a copy of the GNU General Public License along with * 0013 * this program. If not, see <http://www.gnu.org/licenses/>. * 0014 ****************************************************************************************/ 0015 0016 #ifndef COLLECTIONS_MOCKQUERYMAKER 0017 #define COLLECTIONS_MOCKQUERYMAKER 0018 0019 #include "core/collections/QueryMaker.h" 0020 0021 using namespace Collections; 0022 0023 /** 0024 * Ad-hoc mock to test the QueryMaker class 0025 */ 0026 class MockQueryMaker : public QueryMaker 0027 { 0028 Q_OBJECT 0029 0030 public: 0031 /** 0032 * For the vtable generated by the compiler 0033 */ 0034 ~MockQueryMaker() override; 0035 0036 /** 0037 * To prevent QueryMaker::addMatch( const Meta::LabelPtr& ) from being hidden 0038 */ 0039 using QueryMaker::addMatch; 0040 0041 /** 0042 * Mock implementations of pure virtual methods of class Collections::QueryMaker 0043 * to enable creation of an instance of this mock class 0044 * 0045 * NOT TO BE USED ANYWHERE IN THE TEST 0046 */ 0047 void run() override 0048 { 0049 Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); 0050 } 0051 0052 void abortQuery() override 0053 { 0054 Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); 0055 } 0056 0057 QueryMaker *setQueryType( QueryType ) override 0058 { 0059 Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); 0060 return nullptr; 0061 } 0062 0063 QueryMaker *addReturnValue( qint64 ) override 0064 { 0065 Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); 0066 return nullptr; 0067 } 0068 0069 QueryMaker *addReturnFunction( ReturnFunction, qint64 ) override 0070 { 0071 Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); 0072 return nullptr; 0073 } 0074 0075 QueryMaker *orderBy( qint64, bool ) override 0076 { 0077 Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); 0078 return nullptr; 0079 } 0080 0081 QueryMaker *addMatch( const Meta::TrackPtr& ) override 0082 { 0083 Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); 0084 return nullptr; 0085 } 0086 0087 QueryMaker *addMatch( const Meta::ArtistPtr& , ArtistMatchBehaviour ) override 0088 { 0089 Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); 0090 return nullptr; 0091 } 0092 0093 QueryMaker *addMatch( const Meta::AlbumPtr& ) override 0094 { 0095 Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); 0096 return nullptr; 0097 } 0098 0099 QueryMaker *addMatch( const Meta::ComposerPtr& ) override 0100 { 0101 Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); 0102 return nullptr; 0103 } 0104 0105 QueryMaker *addMatch( const Meta::GenrePtr& ) override 0106 { 0107 Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); 0108 return nullptr; 0109 } 0110 0111 QueryMaker *addMatch( const Meta::YearPtr& ) override 0112 { 0113 Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); 0114 return nullptr; 0115 } 0116 0117 QueryMaker *addFilter( qint64, const QString&, bool, bool ) override 0118 { 0119 Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); 0120 return nullptr; 0121 } 0122 0123 QueryMaker *excludeFilter( qint64, const QString&, bool, bool ) override 0124 { 0125 Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); 0126 return nullptr; 0127 } 0128 0129 QueryMaker *addNumberFilter( qint64, qint64, NumberComparison ) override 0130 { 0131 Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); 0132 return nullptr; 0133 } 0134 0135 QueryMaker *excludeNumberFilter( qint64, qint64, NumberComparison ) override 0136 { 0137 Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); 0138 return nullptr; 0139 } 0140 0141 QueryMaker *limitMaxResultSize( int ) override 0142 { 0143 Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); 0144 return nullptr; 0145 } 0146 0147 QueryMaker *beginAnd() override 0148 { 0149 Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); 0150 return nullptr; 0151 } 0152 0153 QueryMaker *beginOr() override 0154 { 0155 Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); 0156 return nullptr; 0157 } 0158 0159 QueryMaker *endAndOr() override 0160 { 0161 Q_ASSERT_X( false, __PRETTY_FUNCTION__, "should not be called"); 0162 return nullptr; 0163 } 0164 0165 /** 0166 * This method helps to determine if queryDone() has been connected/disconnected 0167 * with slot deleteLater() 0168 */ 0169 virtual void emitQueryDone() 0170 { 0171 Q_EMIT queryDone(); 0172 } 0173 0174 public Q_SLOTS: 0175 /** 0176 * Overrides the default deleteLater() slot provided by QObject since the default 0177 * slot implements a deferred delete of the object and is not easily testable 0178 * We only need to test if the slot is triggered or not 0179 */ 0180 virtual void deleteLater() 0181 { 0182 Q_EMIT destroyed(); 0183 } 0184 }; 0185 0186 #endif // COLLECTIONS_MOCKQUERYMAKER_H