172 * called before the first testfunction is executed |
175 * called before the first testfunction is executed |
173 */ |
176 */ |
174 void TestRadioUiEngine::initTestCase() |
177 void TestRadioUiEngine::initTestCase() |
175 { |
178 { |
176 FUNC_LOG; |
179 FUNC_LOG; |
177 #ifdef UNIT_TESTS_FOR_10_1 |
180 // Workaround for the below panic, occured after porting to 10.1 |
178 // Workaround for the below panic, occured after porting to 10.1 |
181 // Main Panic E32USER-CBase 44 |
179 // Main Panic E32USER-CBase 44 |
182 // Create and install the active scheduler |
180 // Create and install the active scheduler |
183 mScheduler = new(ELeave) CActiveScheduler; |
181 CActiveScheduler* scheduler = new(ELeave) CActiveScheduler; |
184 CActiveScheduler::Install( mScheduler ); |
182 CleanupStack::PushL(scheduler); |
185 TInt err( KErrNone); |
183 CActiveScheduler::Install(scheduler); |
186 TRAP( err, mSchedulerTimer = CSchedulerStopAndStartTimer::NewL( *this ) ); |
184 #endif |
187 QVERIFY2( KErrNone == err, "CSchedulerStopAndStartTimer not constructed!" ); |
185 RadioEngineUtils::InitializeL(); |
188 mSchedulerTimer->StartTimer( 1000000, CSchedulerStopAndStartTimer::ETimerIdCreateMUT ); |
186 mUiEngine = new RadioUiEngine; |
189 } |
187 mUiEngine->init(); |
190 |
188 |
191 /*! |
189 mEngineWrapper.reset( new RadioEngineWrapper( mUiEngine->stationModel().stationHandlerIf() ) ); |
192 * called after the last testfunction was executed |
190 mEngineWrapper->init(); |
193 */ |
191 mPresetStorage.reset( new RadioPresetStorage() ); |
194 void TestRadioUiEngine::cleanupTestCase() |
192 mUiEngine->stationModel().initialize( mPresetStorage.data(), mEngineWrapper.data() ); |
195 { |
193 |
196 FUNC_LOG; |
194 //TODO:: Check why ASSERT fails when mModel->rowCount() == 0 |
197 Radio::disconnect( &mUiEngine->stationModel(), SIGNAL(dataChanged(const QModelIndex, const QModelIndex)), |
195 if(mUiEngine->stationModel().rowCount()>0) |
|
196 { |
|
197 mUiEngine->stationModel().removeAll(); //ASSERT: \"last >= first\" in file qabstractitemmodel.cpp, line 2110 |
|
198 } |
|
199 |
|
200 Radio::connect( &mUiEngine->stationModel(), SIGNAL(dataChanged(const QModelIndex, const QModelIndex)), |
|
201 this, SLOT(dataChanged(const QModelIndex, const QModelIndex)) ); |
198 this, SLOT(dataChanged(const QModelIndex, const QModelIndex)) ); |
202 |
199 |
203 Radio::connect( &mUiEngine->stationModel(), SIGNAL(stationDataChanged(RadioStation)), |
200 Radio::disconnect( &mUiEngine->stationModel(), SIGNAL(stationDataChanged(RadioStation)), |
204 this, SLOT(stationDataChanged(RadioStation)) ); |
201 this, SLOT(stationDataChanged(RadioStation)) ); |
205 |
202 |
206 Radio::connect( &mUiEngine->stationModel(), SIGNAL(favoriteChanged(RadioStation)), |
203 Radio::disconnect( &mUiEngine->stationModel(), SIGNAL(favoriteChanged(RadioStation)), |
207 this, SLOT(favoriteChanged(RadioStation)) ); |
204 this, SLOT(favoriteChanged(RadioStation)) ); |
208 |
205 |
209 Radio::connect( &mUiEngine->historyModel(), SIGNAL(itemAdded()), |
206 Radio::disconnect( &mUiEngine->historyModel(), SIGNAL(itemAdded()), |
210 this, SLOT(itemAdded()) ); |
207 this, SLOT(itemAdded()) ); |
211 } |
208 mSchedulerTimer->StartTimer( 1000000, CSchedulerStopAndStartTimer::ETimerIdDeleteMUT ); |
212 |
|
213 /*! |
|
214 * called after the last testfunction was executed |
|
215 */ |
|
216 void TestRadioUiEngine::cleanupTestCase() |
|
217 { |
|
218 FUNC_LOG; |
|
219 delete &mUiEngine->stationModel(); |
|
220 delete mUiEngine; |
|
221 } |
209 } |
222 |
210 |
223 /*! |
211 /*! |
224 * |
212 * |
225 */ |
213 */ |
949 QStringList stringList = mUiEngine->historyModel().data( index, Qt::DisplayRole ).value<QStringList>(); |
936 QStringList stringList = mUiEngine->historyModel().data( index, Qt::DisplayRole ).value<QStringList>(); |
950 QString artistTitle = stringList.at(0); |
937 QString artistTitle = stringList.at(0); |
951 QVERIFY2(!(artistTitle.compare(KTestArtist1+" - "+KTestTitle1)), "API:RadioHistoryModel addItem() 3"); |
938 QVERIFY2(!(artistTitle.compare(KTestArtist1+" - "+KTestTitle1)), "API:RadioHistoryModel addItem() 3"); |
952 |
939 |
953 |
940 |
954 expectedHistoryItemCount = mUiEngine->historyModel().rowCount(); |
941 expectedHistoryItemCount = mUiEngine->historyModel().rowCount() + 1; |
955 // trying to add an item that allready exists must not increase the item count |
942 // trying to add an item that allready exists must increase the item count |
956 mUiEngine->historyModel().addItem( KTestArtist1, KTestTitle1, station ); |
943 mUiEngine->historyModel().addItem( KTestArtist1, KTestTitle1, station ); |
|
944 INFO_1( "mUiEngine->historyModel().rowCount()== %i", mUiEngine->historyModel().rowCount() ); |
957 QVERIFY2((mUiEngine->historyModel().rowCount()==expectedHistoryItemCount), "API:RadioHistoryModel addItem() 4"); |
945 QVERIFY2((mUiEngine->historyModel().rowCount()==expectedHistoryItemCount), "API:RadioHistoryModel addItem() 4"); |
958 } |
946 } |
959 |
947 |
960 /*! |
948 /*! |
961 * |
949 * |
993 item->reset(); |
981 item->reset(); |
994 QVERIFY2(!item->isValid(), "API:testHistoryModelItem isValid() 2"); |
982 QVERIFY2(!item->isValid(), "API:testHistoryModelItem isValid() 2"); |
995 delete item; |
983 delete item; |
996 item = NULL; |
984 item = NULL; |
997 } |
985 } |
|
986 |
|
987 void TestRadioUiEngine::Timeout( TUint aTimerId ) |
|
988 { |
|
989 FUNC_LOG; |
|
990 if ( CSchedulerStopAndStartTimer::ETimerIdCreateMUT == aTimerId ) |
|
991 { |
|
992 INFO("ETimerIdCreateMUT elapsed"); |
|
993 } |
|
994 else if ( CSchedulerStopAndStartTimer::ETimerIdDeleteMUT == aTimerId ) |
|
995 { |
|
996 INFO("ETimerIdDeleteMUT elapsed"); |
|
997 } |
|
998 else if ( CSchedulerStopAndStartTimer::ETimerIdRunMUT == aTimerId ) |
|
999 { |
|
1000 INFO("ETimerIdRunMUT elapsed"); |
|
1001 } |
|
1002 else |
|
1003 { |
|
1004 INFO("Unknown timer elapsed"); |
|
1005 } |
|
1006 } |
|
1007 |
|
1008 void TestRadioUiEngine::CreateMUT() |
|
1009 { |
|
1010 FUNC_LOG; |
|
1011 RadioEngineUtils::InitializeL(); |
|
1012 mUiEngine = new RadioUiEngine; |
|
1013 mUiEngine->init(); |
|
1014 |
|
1015 mEngineWrapper.reset( new RadioEngineWrapper( mUiEngine->stationModel().stationHandlerIf() ) ); |
|
1016 mEngineWrapper->init(); |
|
1017 mPresetStorage.reset( new RadioPresetStorage() ); |
|
1018 mUiEngine->stationModel().initialize( mPresetStorage.data(), mEngineWrapper.data() ); |
|
1019 |
|
1020 //TODO:: Check why ASSERT fails when mModel->rowCount() == 0 |
|
1021 if(mUiEngine->stationModel().rowCount()>0) |
|
1022 { |
|
1023 mUiEngine->stationModel().removeAll(); //ASSERT: \"last >= first\" in file qabstractitemmodel.cpp, line 2110 |
|
1024 } |
|
1025 |
|
1026 Radio::connect( &mUiEngine->stationModel(), SIGNAL(dataChanged(const QModelIndex, const QModelIndex)), |
|
1027 this, SLOT(dataChanged(const QModelIndex, const QModelIndex)) ); |
|
1028 |
|
1029 Radio::connect( &mUiEngine->stationModel(), SIGNAL(stationDataChanged(RadioStation)), |
|
1030 this, SLOT(stationDataChanged(RadioStation)) ); |
|
1031 |
|
1032 Radio::connect( &mUiEngine->stationModel(), SIGNAL(favoriteChanged(RadioStation)), |
|
1033 this, SLOT(favoriteChanged(RadioStation)) ); |
|
1034 |
|
1035 Radio::connect( &mUiEngine->historyModel(), SIGNAL(itemAdded()), |
|
1036 this, SLOT(itemAdded()) ); |
|
1037 mSchedulerTimer->StartTimer( 1000000, CSchedulerStopAndStartTimer::ETimerIdRunMUT ); |
|
1038 } |
|
1039 |
|
1040 void TestRadioUiEngine::DeleteMUT() |
|
1041 { |
|
1042 FUNC_LOG; |
|
1043 if ( NULL != mUiEngine ) |
|
1044 { |
|
1045 delete mUiEngine; |
|
1046 mUiEngine = NULL; |
|
1047 } |
|
1048 } |