author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 00:17:30 +0300 | |
changeset 53 | bb6ed1806599 |
parent 50 | c44f9bb56771 |
permissions | -rw-r--r-- |
24 | 1 |
/* |
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: radiostation test implementation |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include <e32base.h> |
|
19 |
#include <eikenv.h> |
|
20 |
#include "t_radiostation.h" |
|
21 |
#include "radiopresetstorage.h" |
|
22 |
#include "radiostation.h" |
|
23 |
#include "radiostationmodel.h" |
|
24 |
#include "radiohistorymodel.h" |
|
25 |
#include "radioenginewrapper.h" |
|
26 |
#include "radiouiengine.h" |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
27 |
#include "radioengineutils.h" |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
28 |
#include "radiologger.h" //Radio::connect |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
29 |
#include "trace.h" |
24 | 30 |
|
31 |
// Constants |
|
32 |
const uint KTestFrequency1 = 89000000; |
|
33 |
const uint KTestFrequency2 = 89500000; |
|
34 |
const uint KTestFrequency3 = 90000000; |
|
35 |
const uint KTestFrequency4 = 90500000; |
|
36 |
const uint KTestFrequency5 = 91000000; |
|
37 |
const uint KTestFrequency6 = 91500000; |
|
38 |
const uint KTestGenre1 = 1; |
|
39 |
const uint KTestGenre2 = 2; |
|
40 |
const QString KTestStationName1 = "Radio Noice"; |
|
41 |
const QString KTestStationName2 = "RN RENAMED"; |
|
42 |
const QString KTestUrl1 = "http://qt.nokia.com"; |
|
43 |
const QString KTestUrl2 = "http://www.radionoice.com"; |
|
44 |
const QString KTestFrequencyString1 = "89000000"; |
|
45 |
const QString KTestFrequencyString2 = "89500000"; |
|
46 |
const QString KTestFrequencyString3 = "90000000"; |
|
47 |
const QString KTestFrequencyString6 = "91500000"; |
|
48 |
const QString KTestArtist1 = "Eläkeläiset"; |
|
49 |
const QString KTestArtist2 = "Jope"; |
|
50 |
const QString KTestArtist3 = "Motorhead"; |
|
51 |
const QString KTestTitle1 = "Humppa^2"; |
|
52 |
const QString KTestTitle2 = "´åäö´ ^&%¤^"; |
|
53 |
const QString KTestTitle3 = "Dancing queen"; |
|
54 |
const QString KTestRadioTextRadioText = "NOW! Metallica - Enter sandman in MusicStore for free"; |
|
55 |
const QString KTestRadioTextPlusArtist = "Metallica"; |
|
56 |
const QString KTestRadioTextPlusTitle = "Enter sandman"; |
|
57 |
const QString KTestRadioTextPlusUrl = "www.metallica.com"; |
|
58 |
const QString KTestRadioTextPlusUnsupportedTag = "*#*#*#"; |
|
59 |
const QString KTestDynamicPSText = "MAKKARAA"; |
|
60 |
||
61 |
/*! |
|
62 |
* |
|
63 |
*/ |
|
64 |
int main(int /* argc*/, char *argv[]) |
|
65 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
66 |
FUNC_LOG; |
53
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
67 |
TestRadioUiEngine* tv = new TestRadioUiEngine(); |
24 | 68 |
|
69 |
char *pass[3]; |
|
70 |
pass[0] = argv[0]; |
|
71 |
pass[1] = "-o"; |
|
72 |
pass[2] = "c:\\data\\testradiouiengine.txt"; |
|
73 |
||
53
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
74 |
int res = QTest::qExec(tv, 3, pass); |
24 | 75 |
|
53
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
76 |
INFO_1( "Main, result value %i", res ); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
77 |
delete tv; |
24 | 78 |
return res; |
79 |
} |
|
80 |
||
81 |
||
82 |
TestRadioUiEngine::TestRadioUiEngine() |
|
83 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
84 |
FUNC_LOG; |
24 | 85 |
} |
86 |
||
87 |
||
88 |
void TestRadioUiEngine::tunedToFrequency( uint /* frequency */, int /* commandSender */) |
|
89 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
90 |
FUNC_LOG; |
24 | 91 |
} |
92 |
||
93 |
||
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
94 |
void TestRadioUiEngine::seekingStarted( Seek::Direction /* direction */) |
24 | 95 |
{ |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
96 |
FUNC_LOG; |
24 | 97 |
} |
98 |
||
99 |
void TestRadioUiEngine::radioStatusChanged( bool /* radioIsOn */) |
|
100 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
101 |
FUNC_LOG; |
24 | 102 |
} |
103 |
||
104 |
void TestRadioUiEngine::rdsAvailabilityChanged( bool /* available */) |
|
105 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
106 |
FUNC_LOG; |
24 | 107 |
} |
108 |
||
109 |
void TestRadioUiEngine::volumeChanged( int /* volume */) |
|
110 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
111 |
FUNC_LOG; |
24 | 112 |
} |
113 |
||
114 |
void TestRadioUiEngine::muteChanged( bool /* muted */) |
|
115 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
116 |
FUNC_LOG; |
24 | 117 |
} |
118 |
||
119 |
void TestRadioUiEngine::audioRouteChanged( bool /* loudspeaker */) |
|
120 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
121 |
FUNC_LOG; |
24 | 122 |
} |
123 |
||
124 |
void TestRadioUiEngine::scanAndSaveFinished() |
|
125 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
126 |
FUNC_LOG; |
24 | 127 |
} |
128 |
||
129 |
||
130 |
void TestRadioUiEngine::headsetStatusChanged( bool /* connected */) |
|
131 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
132 |
FUNC_LOG; |
24 | 133 |
} |
134 |
||
135 |
void TestRadioUiEngine::skipPrevious() |
|
136 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
137 |
FUNC_LOG; |
24 | 138 |
} |
139 |
||
140 |
void TestRadioUiEngine::skipNext() |
|
141 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
142 |
FUNC_LOG; |
24 | 143 |
} |
144 |
||
145 |
/*! |
|
146 |
* Destructor |
|
147 |
*/ |
|
148 |
TestRadioUiEngine::~TestRadioUiEngine() |
|
149 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
150 |
FUNC_LOG; |
53
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
151 |
mEngineWrapper.reset( NULL ); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
152 |
mPresetStorage.reset( NULL ); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
153 |
delete mSchedulerTimer; |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
154 |
delete mScheduler; |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
155 |
RadioEngineUtils::Release(); |
24 | 156 |
} |
157 |
||
158 |
/*! |
|
159 |
* called before each testfunction is executed |
|
160 |
*/ |
|
161 |
void TestRadioUiEngine::init() |
|
162 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
163 |
FUNC_LOG; |
24 | 164 |
} |
165 |
||
166 |
/*! |
|
167 |
* called after every testfunction |
|
168 |
*/ |
|
169 |
void TestRadioUiEngine::cleanup() |
|
170 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
171 |
FUNC_LOG; |
24 | 172 |
} |
173 |
||
174 |
/*! |
|
175 |
* called before the first testfunction is executed |
|
176 |
*/ |
|
177 |
void TestRadioUiEngine::initTestCase() |
|
178 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
179 |
FUNC_LOG; |
53
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
180 |
// Workaround for the below panic, occured after porting to 10.1 |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
181 |
// Main Panic E32USER-CBase 44 |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
182 |
// Create and install the active scheduler |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
183 |
mScheduler = new(ELeave) CActiveScheduler; |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
184 |
CActiveScheduler::Install( mScheduler ); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
185 |
TInt err( KErrNone); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
186 |
TRAP( err, mSchedulerTimer = CSchedulerStopAndStartTimer::NewL( *this ) ); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
187 |
QVERIFY2( KErrNone == err, "CSchedulerStopAndStartTimer not constructed!" ); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
188 |
mSchedulerTimer->StartTimer( 1000000, CSchedulerStopAndStartTimer::ETimerIdCreateMUT ); |
24 | 189 |
} |
190 |
||
191 |
/*! |
|
192 |
* called after the last testfunction was executed |
|
193 |
*/ |
|
194 |
void TestRadioUiEngine::cleanupTestCase() |
|
195 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
196 |
FUNC_LOG; |
53
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
197 |
Radio::disconnect( &mUiEngine->stationModel(), SIGNAL(dataChanged(const QModelIndex, const QModelIndex)), |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
198 |
this, SLOT(dataChanged(const QModelIndex, const QModelIndex)) ); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
199 |
|
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
200 |
Radio::disconnect( &mUiEngine->stationModel(), SIGNAL(stationDataChanged(RadioStation)), |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
201 |
this, SLOT(stationDataChanged(RadioStation)) ); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
202 |
|
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
203 |
Radio::disconnect( &mUiEngine->stationModel(), SIGNAL(favoriteChanged(RadioStation)), |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
204 |
this, SLOT(favoriteChanged(RadioStation)) ); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
205 |
|
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
206 |
Radio::disconnect( &mUiEngine->historyModel(), SIGNAL(itemAdded()), |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
207 |
this, SLOT(itemAdded()) ); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
208 |
mSchedulerTimer->StartTimer( 1000000, CSchedulerStopAndStartTimer::ETimerIdDeleteMUT ); |
24 | 209 |
} |
210 |
||
211 |
/*! |
|
212 |
* |
|
213 |
*/ |
|
214 |
void TestRadioUiEngine::dataChanged(const QModelIndex /* topLeft */, const QModelIndex /* bottomRight */) |
|
215 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
216 |
FUNC_LOG; |
24 | 217 |
mEnteredSlots |= DataChanged; |
218 |
} |
|
219 |
||
220 |
/*! |
|
221 |
* |
|
222 |
*/ |
|
223 |
void TestRadioUiEngine::stationDataChanged( RadioStation /* addedStation */ ) |
|
224 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
225 |
FUNC_LOG; |
24 | 226 |
mEnteredSlots |= StationDataChanged; |
227 |
} |
|
228 |
||
229 |
/*! |
|
230 |
* |
|
231 |
*/ |
|
232 |
void TestRadioUiEngine::favoriteChanged( RadioStation /* addedStation */) |
|
233 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
234 |
FUNC_LOG; |
24 | 235 |
mEnteredSlots |= FavoriteChanged; |
236 |
} |
|
237 |
||
238 |
/*! |
|
239 |
* |
|
240 |
*/ |
|
241 |
void TestRadioUiEngine::itemAdded() |
|
242 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
243 |
FUNC_LOG; |
24 | 244 |
mEnteredSlots |= ItemAdded; |
245 |
} |
|
246 |
||
247 |
||
248 |
/*! |
|
249 |
* Testing of implicit sharing a.k.a. copy-on-write |
|
250 |
*/ |
|
251 |
void TestRadioUiEngine::testImplicitSharing() |
|
252 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
253 |
FUNC_LOG; |
24 | 254 |
RadioStation t_RadioStation_1; |
255 |
||
256 |
int originalPresetIndex = t_RadioStation_1.presetIndex(); |
|
257 |
// before any values assigned into any data field |
|
258 |
QVERIFY2(( originalPresetIndex == RadioStation::SharedNull ), "API:Radiostation init failed 1"); |
|
259 |
t_RadioStation_1.setName("Noice"); |
|
260 |
originalPresetIndex = t_RadioStation_1.presetIndex(); |
|
261 |
// once some value assigned into some other data field |
|
262 |
QVERIFY2(( originalPresetIndex == RadioStation::Invalid ), "API:Radiostation init failed 2"); |
|
263 |
||
264 |
t_RadioStation_1.setFrequency( KTestFrequency1 ); |
|
265 |
//const int newIndex = mModel->findUnusedPresetIndex(); |
|
266 |
t_RadioStation_1.setPresetIndex( 2 ); |
|
267 |
t_RadioStation_1.setGenre(1); |
|
268 |
t_RadioStation_1.setUrl("http://qt.nokia.com"); |
|
269 |
||
270 |
RadioStation* t_RadioStation_2 = new RadioStation(t_RadioStation_1); |
|
271 |
// test that changing the content of copied data doesn't cause |
|
272 |
// detach in the copying data structure |
|
273 |
uint originalFrequency = t_RadioStation_1.frequency(); |
|
274 |
t_RadioStation_1.setFrequency( originalFrequency + 1 ); |
|
275 |
// should be detached |
|
276 |
bool detached = t_RadioStation_2->isDetached(); |
|
277 |
QVERIFY2(detached, "API:Radiostation Implicit sharing/ freq 1"); |
|
278 |
||
279 |
// test that changing the content of data sets detach true |
|
280 |
originalFrequency = t_RadioStation_2->frequency(); |
|
281 |
t_RadioStation_2->setFrequency( originalFrequency + 1 ); |
|
282 |
// should be detached |
|
283 |
detached = t_RadioStation_2->isDetached(); |
|
284 |
QVERIFY2(detached, "API:Radiostation Implicit sharing/ freq 2"); |
|
285 |
delete t_RadioStation_2; |
|
286 |
t_RadioStation_2 = NULL; |
|
287 |
||
288 |
//------------------------------------------------------------------------- |
|
289 |
// test that changing the content of copied data doesn't cause |
|
290 |
// detach in the copying data structure |
|
291 |
t_RadioStation_2 = new RadioStation(t_RadioStation_1); |
|
292 |
// should not be detached |
|
293 |
detached = t_RadioStation_2->isDetached(); |
|
294 |
QVERIFY2(!detached, "API:Radiostation Implicit sharing/ preset index 1"); |
|
295 |
originalPresetIndex = t_RadioStation_1.presetIndex(); |
|
296 |
t_RadioStation_1.setPresetIndex( originalPresetIndex + 1 ); |
|
297 |
// should be detached |
|
298 |
detached = t_RadioStation_2->isDetached(); |
|
299 |
QVERIFY2(detached, "API:Radiostation Implicit sharing/ preset index 2"); |
|
300 |
||
301 |
// test that changing the content of data sets detach true |
|
302 |
originalPresetIndex = t_RadioStation_2->presetIndex(); |
|
303 |
//newIndex = mModel->findUnusedPresetIndex(); |
|
304 |
t_RadioStation_2->setPresetIndex( originalPresetIndex + 1 ); |
|
305 |
// should be detached |
|
306 |
detached = t_RadioStation_2->isDetached(); |
|
307 |
QVERIFY2(detached, "API:Radiostation Implicit sharing/ preset index 3"); |
|
308 |
delete t_RadioStation_2; |
|
309 |
t_RadioStation_2 = NULL; |
|
310 |
||
311 |
// test that changing the content of copied data doesn't cause |
|
312 |
// detach in the copying data structure |
|
313 |
t_RadioStation_2 = new RadioStation(t_RadioStation_1); |
|
314 |
// should not be detached |
|
315 |
detached = t_RadioStation_2->isDetached(); |
|
316 |
QVERIFY2(!detached, "API:Radiostation Implicit sharing/ name 1"); |
|
317 |
//QString originalName = t_RadioStation_1.name(); |
|
318 |
t_RadioStation_1.setName("RadioOne"); |
|
319 |
// should be detached |
|
320 |
detached = t_RadioStation_2->isDetached(); |
|
321 |
QVERIFY2(detached, "API:Radiostation Implicit sharing/ name 2"); |
|
322 |
// test that changing the content of data sets detach true |
|
323 |
t_RadioStation_2->setName("RadioTwo"); |
|
324 |
// should be detached |
|
325 |
detached = t_RadioStation_2->isDetached(); |
|
326 |
QVERIFY2(detached, "API:Radiostation Implicit sharing/ name 3"); |
|
327 |
} |
|
328 |
||
329 |
/*! |
|
330 |
* Testing of change flags set by RadioStation class |
|
331 |
*/ |
|
332 |
void TestRadioUiEngine::testChangeFlags() |
|
333 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
334 |
FUNC_LOG; |
24 | 335 |
RadioStation t_RadioStation; |
336 |
||
337 |
QVERIFY2(!t_RadioStation.isValid(), "API:Radiostation Init failure"); |
|
338 |
t_RadioStation.setUserDefinedName(""); |
|
339 |
t_RadioStation.setUserDefinedName("Radio Noice"); |
|
340 |
t_RadioStation.setFrequency( KTestFrequency1 ); |
|
341 |
//const int newIndex = mModel->findUnusedPresetIndex(); |
|
342 |
t_RadioStation.setPresetIndex( 2 ); |
|
343 |
t_RadioStation.setGenre( KTestGenre1 ); |
|
344 |
t_RadioStation.setUrl( KTestUrl1 ); |
|
345 |
||
346 |
t_RadioStation.resetChangeFlags(); |
|
347 |
bool persistentDataChanged = t_RadioStation.hasDataChanged( RadioStation::PersistentDataChanged ); |
|
348 |
QVERIFY2(!persistentDataChanged, "API:Radiostation Change flags/ PersistentDataChanged 1"); |
|
349 |
t_RadioStation.setUserDefinedName("Radio Noice+"); |
|
350 |
bool nameChanged = t_RadioStation.hasDataChanged( RadioStation::NameChanged ); |
|
351 |
QVERIFY2(nameChanged, "API:Radiostation Change flags/ NameChanged"); |
|
352 |
persistentDataChanged = t_RadioStation.hasDataChanged( RadioStation::PersistentDataChanged ); |
|
353 |
QVERIFY2(persistentDataChanged, "API:Radiostation Change flags/ PersistentDataChanged 2"); |
|
354 |
t_RadioStation.resetChangeFlags(); |
|
355 |
||
356 |
uint originalGenre = t_RadioStation.genre(); |
|
357 |
t_RadioStation.setGenre( originalGenre + 1 ); |
|
358 |
bool genreChanged = t_RadioStation.hasDataChanged( RadioStation::GenreChanged ); |
|
359 |
QVERIFY2(genreChanged, "API:Radiostation Change flags/ GenreChanged"); |
|
360 |
persistentDataChanged = t_RadioStation.hasDataChanged( RadioStation::PersistentDataChanged ); |
|
361 |
QVERIFY2(persistentDataChanged, "API:Radiostation Change flags/ PersistentDataChanged 3"); |
|
362 |
t_RadioStation.resetChangeFlags(); |
|
363 |
||
364 |
QString originalUrl = t_RadioStation.url(); |
|
365 |
t_RadioStation.setUrl(originalUrl); |
|
366 |
// previous url set so no url or persistent data change flags should be set |
|
367 |
bool urlChanged = t_RadioStation.hasDataChanged( RadioStation::UrlChanged ); |
|
368 |
QVERIFY2(!urlChanged, "API:Radiostation Change flags/ UrlChanged"); |
|
369 |
persistentDataChanged = t_RadioStation.hasDataChanged( RadioStation::PersistentDataChanged ); |
|
370 |
QVERIFY2(!persistentDataChanged, "API:Radiostation Change flags/ PersistentDataChanged 4"); |
|
371 |
t_RadioStation.resetChangeFlags(); |
|
372 |
||
373 |
QString originalRadioText = t_RadioStation.radioText(); |
|
374 |
t_RadioStation.setRadioText( originalRadioText + "buy sausage" ); |
|
375 |
bool radioTextChanged = t_RadioStation.hasDataChanged( RadioStation::RadioTextChanged ); |
|
376 |
QVERIFY2(radioTextChanged, "API:Radiostation Change flags/ RadioTextChanged"); |
|
377 |
// radio text not stored into cenrep |
|
378 |
persistentDataChanged = t_RadioStation.hasDataChanged( RadioStation::PersistentDataChanged ); |
|
379 |
QVERIFY2(!persistentDataChanged, "API:Radiostation Change flags/ PersistentDataChanged 5"); |
|
380 |
t_RadioStation.resetChangeFlags(); |
|
381 |
t_RadioStation.setRadioText( t_RadioStation.radioText() ); |
|
382 |
// because current radio text is reset change flags must not be affected |
|
383 |
radioTextChanged = t_RadioStation.hasDataChanged( RadioStation::RadioTextChanged ); |
|
384 |
QVERIFY2(!radioTextChanged, "API:Radiostation Change flags/ RadioTextChanged"); |
|
385 |
t_RadioStation.resetChangeFlags(); |
|
386 |
||
387 |
QVERIFY2((t_RadioStation.psType()==RadioStation::Unknown), "API:Radiostation PS type check"); |
|
388 |
t_RadioStation.setPsType( RadioStation::Dynamic ); |
|
389 |
bool psTypeChanged = t_RadioStation.hasDataChanged( RadioStation::PsTypeChanged ); |
|
390 |
QVERIFY2(psTypeChanged, "API:Radiostation Change flags/ PsTypeChanged"); |
|
391 |
persistentDataChanged = t_RadioStation.hasDataChanged( RadioStation::PersistentDataChanged ); |
|
392 |
// PS type not stored as persistent data |
|
393 |
QVERIFY2(!persistentDataChanged, "API:Radiostation Change flags/ PersistentDataChanged 6"); |
|
394 |
t_RadioStation.resetChangeFlags(); |
|
395 |
||
396 |
t_RadioStation.setFavorite(t_RadioStation.isFavorite()); |
|
397 |
bool favouriteChanged = t_RadioStation.hasDataChanged( RadioStation::FavoriteChanged ); |
|
398 |
QVERIFY2(!favouriteChanged, "API:Radiostation Change flags/ FavoriteChanged"); |
|
399 |
persistentDataChanged = t_RadioStation.hasDataChanged( RadioStation::PersistentDataChanged ); |
|
400 |
QVERIFY2(!persistentDataChanged, "API:Radiostation Change flags/ PersistentDataChanged 7"); |
|
401 |
t_RadioStation.resetChangeFlags(); |
|
402 |
||
403 |
// initially there should not be PI code defined |
|
404 |
QVERIFY2(!t_RadioStation.hasPiCode(), "API:Radiostation Pi code check"); |
|
405 |
// non-clear channel |
|
406 |
t_RadioStation.setPiCode(0xC004, RadioRegion::Default); //88.1 CBEE-FM - Chatham, ON |
|
407 |
bool piCodeChanged = t_RadioStation.hasDataChanged( RadioStation::PiCodeChanged ); |
|
408 |
QVERIFY2(piCodeChanged, "API:Radiostation Change flags/ PiCodeChanged"); |
|
409 |
persistentDataChanged = t_RadioStation.hasDataChanged( RadioStation::PersistentDataChanged ); |
|
410 |
QVERIFY2(persistentDataChanged, "API:Radiostation Change flags/ PersistentDataChanged 8"); |
|
411 |
} |
|
412 |
||
413 |
/*! |
|
414 |
* Testing of call sign integer to char conversion |
|
415 |
*/ |
|
416 |
void TestRadioUiEngine::TestCallSignChar() |
|
417 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
418 |
FUNC_LOG; |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
419 |
/* |
24 | 420 |
for(uint i = 0; i < KLastCallSignCharCode; i++) |
421 |
{ |
|
422 |
RadioStation t_RadioStation; |
|
423 |
bool passed = t_RadioStation.callSignChar(i) == static_cast<char>( 'A' + i ); |
|
424 |
QVERIFY2(passed, "API:Radiostation TestCallSignChar 1"); |
|
425 |
} |
|
426 |
RadioStation t_RadioStation; |
|
427 |
bool passed = t_RadioStation.callSignChar(KLastCallSignCharCode + 1) == static_cast<char>( '?' ); |
|
428 |
QVERIFY2(passed, "API:Radiostation TestCallSignChar 2"); |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
429 |
*/ |
24 | 430 |
} |
431 |
||
432 |
/*! |
|
433 |
* Testing of PI code to call sign conversion |
|
434 |
*/ |
|
435 |
void TestRadioUiEngine::testPICodeToCallSign() |
|
436 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
437 |
FUNC_LOG; |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
438 |
/* |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
439 |
RadioStation t_RadioStation; |
24 | 440 |
|
441 |
// boundary values, two typical values and three chars call sign case |
|
442 |
QString callSign = t_RadioStation.piCodeToCallSign( KKxxxCallSignPiFirst - 1 ); |
|
443 |
QVERIFY2((callSign==""), "API:Radiostation Call sign <"); |
|
444 |
callSign = t_RadioStation.piCodeToCallSign( KKxxxCallSignPiFirst ); |
|
445 |
QVERIFY2((callSign=="KAAA"), "API:Radiostation Call sign KAAA"); |
|
446 |
callSign = t_RadioStation.piCodeToCallSign( 0x243F ); |
|
447 |
QVERIFY2((callSign=="KHRJ"), "API:Radiostation Call sign KHRJ"); |
|
448 |
callSign = t_RadioStation.piCodeToCallSign( KWxxxCallSignPiFirst - 1 ); |
|
449 |
QVERIFY2((callSign=="KZZZ"), "API:Radiostation Call sign KZZZ"); |
|
450 |
callSign = t_RadioStation.piCodeToCallSign( KWxxxCallSignPiFirst ); |
|
451 |
QVERIFY2((callSign=="WAAA"), "API:Radiostation Call sign WAAA"); |
|
452 |
callSign = t_RadioStation.piCodeToCallSign( 0x74B9 ); |
|
453 |
QVERIFY2((callSign=="WMDT"), "API:Radiostation Call sign WMDT"); |
|
454 |
callSign = t_RadioStation.piCodeToCallSign( KWxxxCallSignPiLast ); |
|
455 |
QVERIFY2((callSign=="WZZZ"), "API:Radiostation Call sign WZZZ"); |
|
456 |
callSign = t_RadioStation.piCodeToCallSign( KWxxxCallSignPiLast + 1 ); |
|
457 |
QVERIFY2((callSign=="KEX"), "API:Radiostation Call sign KEX"); |
|
458 |
callSign = t_RadioStation.piCodeToCallSign( 0x99B5 ); |
|
459 |
QVERIFY2((callSign=="WJZ"), "API:Radiostation Call sign WJZ"); |
|
460 |
callSign = t_RadioStation.piCodeToCallSign( 0x99C0 ); |
|
461 |
QVERIFY2((callSign==""), "API:Radiostation Call sign ????"); |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
462 |
*/ |
24 | 463 |
} |
464 |
||
465 |
/*! |
|
466 |
* Testing of RadioStationModel initial state |
|
467 |
*/ |
|
468 |
void TestRadioUiEngine::testRadioStationModelInit() |
|
469 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
470 |
FUNC_LOG; |
24 | 471 |
//TODO:: Check why ASSERT fails when mModel->rowCount() == 0 |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
472 |
if( mUiEngine->stationModel().rowCount()>0 ) |
24 | 473 |
{ |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
474 |
mUiEngine->stationModel().removeAll(); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
475 |
QVERIFY2((mUiEngine->stationModel().rowCount()==0), "API:RadioStationModel removeAll()"); |
24 | 476 |
} |
477 |
||
478 |
RadioStation foundStation; |
|
479 |
// no stations in the model in this phase |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
480 |
QVERIFY2(!(mUiEngine->stationModel().findFrequency( KTestFrequency1, foundStation )), |
24 | 481 |
"API:RadioStationModel findFrequency 1"); |
482 |
} |
|
483 |
||
484 |
/*! |
|
485 |
* Testing of RadioStationModel addStation method and resulting RadioStationModel signals |
|
486 |
*/ |
|
487 |
void TestRadioUiEngine::testAddStation1() |
|
488 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
489 |
FUNC_LOG; |
24 | 490 |
RadioStation station; |
491 |
station.setFrequency( KTestFrequency1 ); |
|
492 |
station.setFrequency( KTestFrequency1 ); |
|
493 |
station.setGenre( KTestGenre1 ); |
|
494 |
station.setGenre( KTestGenre1 ); |
|
495 |
station.setUrl( KTestUrl1 ); |
|
496 |
station.setType( RadioStation::LocalStation ); |
|
497 |
station.setType( RadioStation::LocalStation ); |
|
498 |
station.setName(""); |
|
499 |
station.setName( KTestStationName1 ); |
|
500 |
station.setDynamicPsText( KTestDynamicPSText ); |
|
501 |
station.setPiCode( 0xC004, RadioRegion::America ); //88.1 CBEE-FM - Chatham, ON |
|
502 |
QVERIFY2(!(station.dynamicPsText().compare(KTestDynamicPSText)), "API:RadioStationModel addStation 1"); |
|
503 |
station.setDynamicPsText( KTestDynamicPSText ); |
|
504 |
// check that adding station increases model row count |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
505 |
mExpectedStationCount = mUiEngine->stationModel().rowCount() + 1; |
24 | 506 |
mStationToBeAdded = station.name(); |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
507 |
mUiEngine->stationModel().addStation( station ); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
508 |
QVERIFY2((mUiEngine->stationModel().rowCount()==mExpectedStationCount), "API:RadioStationModel addStation 2"); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
509 |
bool correctSignalsReceived = mEnteredSlots.testFlag( DataChanged ); |
24 | 510 |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
511 |
bool frequencyUpdated = station.frequency() == KTestFrequency1; |
24 | 512 |
QVERIFY2(frequencyUpdated, "API:RadioStationModel addStation 1"); |
513 |
// check that correct signals received |
|
514 |
QVERIFY2(correctSignalsReceived, "API:RadioStationModel addStation 3"); |
|
515 |
mEnteredSlots = NoSlotsEntered; |
|
516 |
||
517 |
// check that added station can be found by frequency |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
518 |
int index( KErrNotFound ); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
519 |
index = mUiEngine->stationModel().indexFromFrequency( KTestFrequency1 ); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
520 |
QVERIFY2(index != KErrNotFound, "Added station not found from model!"); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
521 |
|
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
522 |
RadioStation readStation ( mUiEngine->stationModel().stationAt( index ) ); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
523 |
QVERIFY2( !readStation.name().compare(KTestStationName1), "Added station's name not found from model!"); |
24 | 524 |
} |
525 |
||
526 |
/*! |
|
527 |
* Testing of RadioStationModel saveStation method and resulting RadioStationModel signals |
|
528 |
*/ |
|
529 |
void TestRadioUiEngine::testSaveStation1() |
|
530 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
531 |
FUNC_LOG; |
24 | 532 |
RadioStation newStation1; |
533 |
// check that find by frequency works |
|
534 |
// this is needed for preset index to be updated into newStation1 |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
535 |
QVERIFY2((mUiEngine->stationModel().findFrequency( KTestFrequency1, newStation1 )), |
24 | 536 |
"API:RadioStationModel findFrequency 2"); |
537 |
newStation1.setType( RadioStation::Favorite ); |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
538 |
mEnteredSlots = NoSlotsEntered; |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
539 |
mUiEngine->stationModel().saveStation( newStation1 ); |
24 | 540 |
bool correctSignalsReceived = mEnteredSlots.testFlag( StationDataChanged ) && |
541 |
mEnteredSlots.testFlag( FavoriteChanged ) && mEnteredSlots.testFlag( DataChanged );; |
|
542 |
QVERIFY2(correctSignalsReceived, "API:RadioStationModel saveStation 1"); |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
543 |
mEnteredSlots = NoSlotsEntered; |
24 | 544 |
|
545 |
newStation1.setGenre(newStation1.genre()+1); |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
546 |
mUiEngine->stationModel().saveStation( newStation1 ); |
24 | 547 |
correctSignalsReceived = mEnteredSlots.testFlag( StationDataChanged ) && mEnteredSlots.testFlag( DataChanged ); |
548 |
// check that correct signals received |
|
549 |
QVERIFY2(correctSignalsReceived, "API:RadioStationModel saveStation 2"); |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
550 |
mEnteredSlots = NoSlotsEntered; |
24 | 551 |
} |
552 |
||
553 |
/*! |
|
554 |
* Testing of RadioStationModel addStation method and rowCount methods |
|
555 |
*/ |
|
556 |
void TestRadioUiEngine::testAddStation2() |
|
557 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
558 |
FUNC_LOG; |
24 | 559 |
RadioStation newStation2; |
560 |
newStation2.setFrequency( KTestFrequency2 ); |
|
561 |
newStation2.setGenre( KTestGenre2 ); |
|
562 |
newStation2.setUrl( KTestUrl2 ); |
|
563 |
newStation2.setType( RadioStation::LocalStation | RadioStation::Favorite ); |
|
564 |
newStation2.setName("Radio ice"); |
|
565 |
// check that adding station increases model row count |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
566 |
mExpectedStationCount = mUiEngine->stationModel().rowCount()+1; |
24 | 567 |
mStationToBeAdded = newStation2.name(); |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
568 |
mUiEngine->stationModel().addStation( newStation2 ); |
24 | 569 |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
570 |
QVERIFY2((mUiEngine->stationModel().rowCount()==mExpectedStationCount), "API:RadioStationModel addStation 3"); |
24 | 571 |
mEnteredSlots = NoSlotsEntered; |
572 |
} |
|
573 |
||
574 |
/*! |
|
575 |
* Testing of RadioStationModel saveStation method special cases |
|
576 |
*/ |
|
577 |
void TestRadioUiEngine::testSaveStation2() |
|
578 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
579 |
FUNC_LOG; |
24 | 580 |
RadioStation newStation1; |
581 |
// this is needed for preset index to be updated into newStation1 |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
582 |
QVERIFY2((mUiEngine->stationModel().findFrequency( KTestFrequency1, newStation1 )), |
24 | 583 |
"API:RadioStationModel findFrequency 2"); |
584 |
||
585 |
newStation1.setFrequency( KTestFrequency2 ); |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
586 |
mExpectedStationCount = mUiEngine->stationModel().rowCount(); |
24 | 587 |
// updating existing station data must not increase station count |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
588 |
mUiEngine->stationModel().saveStation( newStation1 ); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
589 |
QVERIFY2((mUiEngine->stationModel().rowCount()==mExpectedStationCount), "API:RadioStationModel saveStation 1"); |
24 | 590 |
// because frequency tried to be updated no signals should be received either |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
591 |
bool correctSignalsReceived = mEnteredSlots.testFlag( DataChanged ); |
24 | 592 |
QVERIFY2(correctSignalsReceived, "API:RadioStationModel saveStation 2"); |
593 |
mEnteredSlots = NoSlotsEntered; |
|
594 |
||
595 |
// original frequency resumed |
|
596 |
newStation1.setFrequency( KTestFrequency1 ); |
|
597 |
newStation1.setGenre(newStation1.genre()+1); |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
598 |
mExpectedStationCount = mUiEngine->stationModel().rowCount(); |
24 | 599 |
// now that frequency resumed signal should be received also |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
600 |
mUiEngine->stationModel().saveStation( newStation1 ); |
24 | 601 |
correctSignalsReceived = mEnteredSlots.testFlag( StationDataChanged ) && mEnteredSlots.testFlag( DataChanged ); |
602 |
QVERIFY2(correctSignalsReceived, "API:RadioStationModel saveStation 3"); |
|
603 |
// updating existing station data must not increase station count |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
604 |
QVERIFY2((mUiEngine->stationModel().rowCount()==mExpectedStationCount), "API:RadioStationModel saveStation 2"); |
24 | 605 |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
606 |
mExpectedStationCount = mUiEngine->stationModel().rowCount(); |
24 | 607 |
mStationToBeAdded = newStation1.name(); |
608 |
// adding station must fail because the frequency is the same as previously used frequency |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
609 |
mUiEngine->stationModel().addStation( newStation1 ); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
610 |
QVERIFY2((mUiEngine->stationModel().rowCount()==mExpectedStationCount), "API:RadioStationModel addStation 3"); |
24 | 611 |
} |
612 |
||
613 |
/*! |
|
614 |
* Testing of RadioStationModel addStation method special cases |
|
615 |
*/ |
|
616 |
void TestRadioUiEngine::testAddStation3() |
|
617 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
618 |
FUNC_LOG; |
24 | 619 |
RadioStation newStation3; |
620 |
newStation3.setFrequency( KTestFrequency2 ); |
|
621 |
newStation3.setGenre(3); |
|
622 |
newStation3.setUrl("http://www.radio4noice.com"); |
|
623 |
newStation3.setType( RadioStation::LocalStation | RadioStation::Favorite ); |
|
624 |
newStation3.setName("Radio e"); |
|
625 |
// adding station must fail because frequency is the same as previously used frequency |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
626 |
mExpectedStationCount = mUiEngine->stationModel().rowCount(); |
24 | 627 |
mStationToBeAdded = newStation3.name(); |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
628 |
mUiEngine->stationModel().addStation( newStation3 ); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
629 |
QVERIFY2((mUiEngine->stationModel().rowCount()==mExpectedStationCount), "API:RadioStationModel addStation 4"); |
24 | 630 |
// adding station must success because the station frequency is different now |
631 |
newStation3.setFrequency( KTestFrequency2 + 1 ); |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
632 |
mExpectedStationCount = mUiEngine->stationModel().rowCount() + 1; |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
633 |
mUiEngine->stationModel().addStation( newStation3 ); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
634 |
QVERIFY2((mUiEngine->stationModel().rowCount()==mExpectedStationCount), "API:RadioStationModel addStation 5"); |
24 | 635 |
// test that station can be found by frequency range |
636 |
QList<RadioStation> stations; |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
637 |
stations = mUiEngine->stationModel().stationsInRange( KTestFrequency1, KTestFrequency3 ); |
24 | 638 |
QVERIFY2((stations.count()==3), "API:RadioStationModel stationsInRange"); |
639 |
} |
|
640 |
||
641 |
/*! |
|
642 |
* Testing of RadioStationModel saveStation method special cases |
|
643 |
*/ |
|
644 |
void TestRadioUiEngine::testSaveStation3() |
|
645 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
646 |
FUNC_LOG; |
24 | 647 |
RadioStation newStation3; |
648 |
RadioStation foundStation; |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
649 |
QVERIFY2(mUiEngine->stationModel().findFrequency( KTestFrequency2 + 1, newStation3 ), |
24 | 650 |
"API:RadioStationModel findFrequency 4"); |
651 |
||
652 |
newStation3.setFrequency( KTestFrequency3 ); |
|
653 |
// because frequency or preset index don't have change flag the frequency must not be updated |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
654 |
mUiEngine->stationModel().saveStation( newStation3 ); |
24 | 655 |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
656 |
QVERIFY2(!(mUiEngine->stationModel().findFrequency( KTestFrequency3, foundStation )), |
24 | 657 |
"API:RadioStationModel findFrequency 3"); |
658 |
||
659 |
newStation3.setGenre( newStation3.genre() + 1 ); |
|
660 |
// allthough genre changed so the frequency update must not become effective |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
661 |
mUiEngine->stationModel().saveStation( newStation3 ); |
24 | 662 |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
663 |
QVERIFY2(!(mUiEngine->stationModel().findFrequency( KTestFrequency3, foundStation )), |
24 | 664 |
"API:RadioStationModel findFrequency 4"); |
665 |
||
666 |
||
667 |
mEnteredSlots = NoSlotsEntered; |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
668 |
foreach( const RadioStation& station, mUiEngine->stationModel().list() ) |
24 | 669 |
{ |
670 |
if ( station.frequency() == KTestFrequency2 ) |
|
671 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
672 |
mUiEngine->stationModel().setFavoriteByFrequency( KTestFrequency2, !station.isFavorite() ); |
24 | 673 |
} |
674 |
} |
|
675 |
bool correctSignalsReceived = mEnteredSlots.testFlag( StationDataChanged ) && |
|
676 |
mEnteredSlots.testFlag( FavoriteChanged ) && mEnteredSlots.testFlag( DataChanged ); |
|
677 |
QVERIFY2(correctSignalsReceived, "API:RadioStationModel findFrequency 5"); |
|
678 |
} |
|
679 |
||
680 |
||
681 |
||
682 |
/*! |
|
683 |
* Test that stations are stored into RadioStationModel in ascending frequency order |
|
684 |
*/ |
|
685 |
void TestRadioUiEngine::testSortByFrequency() |
|
686 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
687 |
FUNC_LOG; |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
688 |
int role = RadioRole::RadioStationRole; |
24 | 689 |
int previousFrequency(0); // int not initialized zero as default |
690 |
||
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
691 |
for (int i = 0; i< mUiEngine->stationModel().rowCount(); i++ ) |
24 | 692 |
{ |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
693 |
QModelIndex index = mUiEngine->stationModel().index( i, 0 ); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
694 |
QVariant stationData = mUiEngine->stationModel().data( index, role ); |
24 | 695 |
RadioStation station = stationData.value<RadioStation>(); |
696 |
// stations must be obtainded at ascending frequency order |
|
697 |
QVERIFY2((station.frequency()>previousFrequency), "API:RadioStationModel testSortByFrequency"); |
|
698 |
previousFrequency = station.frequency(); |
|
699 |
} |
|
700 |
} |
|
701 |
||
702 |
/*! |
|
703 |
* Test that preset indexes match |
|
704 |
*/ |
|
705 |
void TestRadioUiEngine::testFindPresetIndex() |
|
706 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
707 |
FUNC_LOG; |
24 | 708 |
RadioStation station; |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
709 |
for (int i = 0; i< mUiEngine->stationModel().rowCount(); i++ ) |
24 | 710 |
{ |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
711 |
QVERIFY2((mUiEngine->stationModel().findPresetIndex(i) != RadioStation::NotFound), |
24 | 712 |
"API:RadioStationModel testFindPresetIndex 1"); |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
713 |
QVERIFY2((mUiEngine->stationModel().findPresetIndex( i, station ) != RadioStation::NotFound), |
24 | 714 |
"API:RadioStationModel testFindPresetIndex 2"); |
715 |
QVERIFY2((station.presetIndex() == i), "API:RadioStationModel testFindPresetIndex 3"); |
|
716 |
} |
|
717 |
} |
|
718 |
||
719 |
/*! |
|
720 |
* Test that preset can be removed from model by frequency |
|
721 |
*/ |
|
722 |
void TestRadioUiEngine::testRemoveByFrequency() |
|
723 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
724 |
FUNC_LOG; |
24 | 725 |
RadioStation station; |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
726 |
int initialStationCount( mUiEngine->stationModel().rowCount() ); |
24 | 727 |
int presetIndex(0); |
728 |
||
729 |
// find valid preset index |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
730 |
for(int i = 0; i<mUiEngine->stationModel().rowCount(); i++) |
24 | 731 |
{ |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
732 |
presetIndex = mUiEngine->stationModel().findPresetIndex( i, station ); |
24 | 733 |
if(presetIndex!=RadioStation::NotFound) |
734 |
break; |
|
735 |
} |
|
736 |
QVERIFY2((presetIndex != RadioStation::NotFound), "API:RadioStationModel testRemoveByFrequency 1"); |
|
737 |
||
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
738 |
mUiEngine->stationModel().removeByFrequency( station.frequency() ); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
739 |
QVERIFY2((mUiEngine->stationModel().rowCount()==(initialStationCount-1)), "API:RadioStationModel testRemoveByFrequency 2"); |
24 | 740 |
} |
741 |
||
742 |
/*! |
|
743 |
* Test that station can be removed from model by preset index |
|
744 |
*/ |
|
745 |
void TestRadioUiEngine::testRemoveByPresetIndex() |
|
746 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
747 |
FUNC_LOG; |
24 | 748 |
RadioStation station; |
749 |
station.setFrequency( KTestFrequency4 ); |
|
750 |
mStationToBeAdded = ""; |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
751 |
mExpectedStationCount = mUiEngine->stationModel().rowCount() + 1; |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
752 |
mUiEngine->stationModel().addStation( station ); |
24 | 753 |
// for updating station preset index |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
754 |
QVERIFY2((mUiEngine->stationModel().findFrequency( KTestFrequency4, station )), |
24 | 755 |
"API:RadioStationModel testRemoveByPresetIndex 1"); |
756 |
||
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
757 |
int initialStationCount( mUiEngine->stationModel().rowCount() ); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
758 |
mUiEngine->stationModel().removeByPresetIndex( station.presetIndex() ); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
759 |
QVERIFY2((mUiEngine->stationModel().rowCount()==(initialStationCount-1)), "API:RadioStationModel testRemoveByPresetIndex 2"); |
24 | 760 |
} |
761 |
||
762 |
/*! |
|
763 |
* Test RadioStationModel method removeStation |
|
764 |
*/ |
|
765 |
void TestRadioUiEngine::testRemoveStation() |
|
766 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
767 |
FUNC_LOG; |
24 | 768 |
RadioStation station; |
769 |
station.setFrequency( KTestFrequency5 ); |
|
770 |
mStationToBeAdded = ""; |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
771 |
mExpectedStationCount = mUiEngine->stationModel().rowCount() + 1; |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
772 |
mUiEngine->stationModel().addStation( station ); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
773 |
int initialStationCount( mUiEngine->stationModel().rowCount() ); |
24 | 774 |
// for updating station preset index |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
775 |
QVERIFY2(mUiEngine->stationModel().findFrequency( KTestFrequency5, station ), |
24 | 776 |
"API:RadioStationModel testRemoveStation"); |
777 |
||
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
778 |
mUiEngine->stationModel().removeStation( station ); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
779 |
QVERIFY2((mUiEngine->stationModel().rowCount()==(initialStationCount-1)), "API:RadioStationModel testRemoveStation"); |
24 | 780 |
} |
781 |
||
782 |
||
783 |
/*! |
|
784 |
* Test setting and unsetting station type favourite |
|
785 |
*/ |
|
786 |
void TestRadioUiEngine::testSetFavorite() |
|
787 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
788 |
FUNC_LOG; |
24 | 789 |
RadioStation station; |
790 |
station.setFrequency( KTestFrequency6 ); |
|
791 |
station.setType( RadioStation::Favorite ); |
|
792 |
QVERIFY2(station.isFavorite(), "API:RadioStationModel testSetFavorite 1"); |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
793 |
mUiEngine->stationModel().addStation( station ); |
24 | 794 |
mEnteredSlots = NoSlotsEntered; |
795 |
||
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
796 |
mUiEngine->stationModel().setFavoriteByFrequency( KTestFrequency6, false ); |
24 | 797 |
bool correctSignalsReceived = mEnteredSlots.testFlag( StationDataChanged ) && |
798 |
mEnteredSlots.testFlag( FavoriteChanged ) && mEnteredSlots.testFlag( DataChanged ); |
|
799 |
QVERIFY2(correctSignalsReceived, "API:RadioStationModel testSetFavorite 2"); |
|
800 |
||
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
801 |
mUiEngine->stationModel().findFrequency( KTestFrequency6, station ); |
24 | 802 |
QVERIFY2(!station.isFavorite(), "API:RadioStationModel testSetFavorite 3"); |
803 |
mEnteredSlots = NoSlotsEntered; |
|
804 |
||
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
805 |
mUiEngine->stationModel().setFavoriteByPreset( station.presetIndex(), true ); |
24 | 806 |
correctSignalsReceived = mEnteredSlots.testFlag( StationDataChanged ) && |
807 |
mEnteredSlots.testFlag( FavoriteChanged ) && mEnteredSlots.testFlag( DataChanged ); |
|
808 |
QVERIFY2(correctSignalsReceived, "API:RadioStationModel testSetFavorite 4"); |
|
809 |
||
810 |
// test toggling the favorite |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
811 |
int index = mUiEngine->stationModel().indexFromFrequency( KTestFrequency6 ); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
812 |
mUiEngine->stationModel().setFavoriteByFrequency( KTestFrequency6, ETrue ); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
813 |
RadioStation station1 = mUiEngine->stationModel().stationAt( index ); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
814 |
QVERIFY2(station1.isFavorite(), "API:RadioStationModel testToggleFavourite"); |
24 | 815 |
|
816 |
} |
|
817 |
||
818 |
/*! |
|
819 |
* Test renaming station |
|
820 |
*/ |
|
821 |
void TestRadioUiEngine::testRenameStation() |
|
822 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
823 |
FUNC_LOG; |
24 | 824 |
RadioStation station; |
825 |
int presetIndex(0); |
|
826 |
// find valid preset index |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
827 |
for( int i = 0; i<mUiEngine->stationModel().rowCount(); i++ ) |
24 | 828 |
{ |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
829 |
if( mUiEngine->stationModel().findPresetIndex( i, station ) != RadioStation::NotFound ) |
24 | 830 |
{ |
831 |
presetIndex = i; |
|
832 |
break; |
|
833 |
} |
|
834 |
} |
|
835 |
QString initialStationName( station.name() ); |
|
836 |
mEnteredSlots = NoSlotsEntered; |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
837 |
mUiEngine->stationModel().renameStation( presetIndex, initialStationName + "Renamed" ); |
24 | 838 |
bool correctSignalsReceived = mEnteredSlots.testFlag( StationDataChanged ) && |
839 |
mEnteredSlots.testFlag( DataChanged ); |
|
840 |
QVERIFY2(correctSignalsReceived, "API:RadioStationModel testRenameStation 1"); |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
841 |
QVERIFY2(initialStationName!=mUiEngine->stationModel().stationAt(presetIndex).name(), "API:RadioStationModel testRenameStation 2"); |
24 | 842 |
|
843 |
station.setUserDefinedName( KTestStationName2 ); |
|
844 |
QVERIFY2(station.isRenamed(), "API:RadioStationModel testRenameStation 1"); |
|
845 |
||
846 |
} |
|
847 |
||
848 |
/*! |
|
849 |
* Test setting radio text |
|
850 |
*/ |
|
851 |
void TestRadioUiEngine::testSetRadioTextPlus() |
|
852 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
853 |
FUNC_LOG; |
24 | 854 |
RadioStation station; |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
855 |
mUiEngine->stationModel().findFrequency( KTestFrequency6, station ); |
24 | 856 |
station.setRadioText( "" ); |
857 |
station.setRadioText( KTestRadioTextRadioText ); |
|
858 |
station.setRadioText( KTestRadioTextRadioText ); |
|
859 |
station.setRadioTextPlus( RtPlus::Artist, KTestRadioTextPlusArtist ); |
|
860 |
station.setRadioTextPlus( RtPlus::Title, KTestRadioTextPlusTitle ); |
|
861 |
station.setRadioTextPlus( RtPlus::Homepage, KTestRadioTextPlusUrl ); |
|
862 |
station.setRadioTextPlus( RtPlus::Homepage + 1, KTestRadioTextPlusUnsupportedTag ); |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
863 |
mUiEngine->stationModel().saveStation( station ); |
24 | 864 |
bool effective = station.radioText().contains( KTestRadioTextPlusArtist, Qt::CaseSensitive ); |
865 |
QVERIFY2(effective, "API:RadioStationModel testSetRadioTextPlus 1"); |
|
866 |
effective = station.radioText().contains( KTestRadioTextPlusTitle, Qt::CaseSensitive ); |
|
867 |
QVERIFY2(effective, "API:RadioStationModel testSetRadioTextPlus 2"); |
|
868 |
effective = !station.url().compare( KTestRadioTextPlusUrl ); |
|
869 |
QVERIFY2(effective, "API:RadioStationModel testSetRadioTextPlus 3"); |
|
870 |
} |
|
871 |
||
872 |
/*! |
|
873 |
* Test RadioStationModel API |
|
874 |
*/ |
|
875 |
void TestRadioUiEngine::testRadioStationModel() |
|
876 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
877 |
FUNC_LOG; |
24 | 878 |
testRadioStationModelInit(); |
879 |
testAddStation1(); |
|
880 |
testSaveStation1(); |
|
881 |
testAddStation2(); |
|
882 |
testSaveStation2(); |
|
883 |
testAddStation3(); |
|
884 |
testSaveStation3(); |
|
885 |
testSortByFrequency(); |
|
886 |
testFindPresetIndex(); |
|
887 |
testRemoveByFrequency(); |
|
888 |
testRemoveByPresetIndex(); |
|
889 |
testRemoveStation(); |
|
890 |
testSetFavorite(); |
|
891 |
testRenameStation(); |
|
892 |
testSetRadioTextPlus(); |
|
893 |
} |
|
894 |
/*! |
|
895 |
* Test RadioHistoryModel API |
|
896 |
*/ |
|
897 |
void TestRadioUiEngine::testhistoryModel() |
|
898 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
899 |
FUNC_LOG; |
24 | 900 |
testHistoryModelInit(); |
901 |
testHistoryModelAddItem(); |
|
902 |
testAddRadioTextPlus(); |
|
903 |
testClearRadioTextPlus(); |
|
904 |
} |
|
905 |
||
906 |
/*! |
|
907 |
* Testing of RadioHistoryModel initial state |
|
908 |
*/ |
|
909 |
void TestRadioUiEngine::testHistoryModelInit() |
|
910 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
911 |
FUNC_LOG; |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
912 |
//TODO:: Check why ASSERT fails when mUiEngine->historyModel().rowCount() == 0 |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
913 |
if( mUiEngine->historyModel().rowCount()>0 ) |
24 | 914 |
{ |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
915 |
mUiEngine->historyModel().removeAll( EFalse ); |
24 | 916 |
} |
53
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
917 |
QVERIFY2((mUiEngine->historyModel().rowCount()==0), "API:RadioHistoryModel removeAll()"); |
24 | 918 |
} |
919 |
||
920 |
/*! |
|
921 |
* |
|
922 |
*/ |
|
923 |
void TestRadioUiEngine::testHistoryModelAddItem() |
|
924 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
925 |
FUNC_LOG; |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
926 |
RadioStation station; |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
927 |
mUiEngine->stationModel().findFrequency( KTestFrequency6, station ); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
928 |
int expectedHistoryItemCount( mUiEngine->historyModel().rowCount() + 1 ); |
24 | 929 |
mEnteredSlots = NoSlotsEntered; |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
930 |
mUiEngine->historyModel().addItem( KTestArtist1, KTestTitle1, station ); |
24 | 931 |
// check that item count increases |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
932 |
QVERIFY2((mUiEngine->historyModel().rowCount()==expectedHistoryItemCount), "API:RadioHistoryModel addItem() 2"); |
24 | 933 |
|
934 |
// check that artist/title stored into the model conforms to the one read from the model |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
935 |
QModelIndex index = mUiEngine->historyModel().index( 0, 0 ); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
936 |
QStringList stringList = mUiEngine->historyModel().data( index, Qt::DisplayRole ).value<QStringList>(); |
24 | 937 |
QString artistTitle = stringList.at(0); |
938 |
QVERIFY2(!(artistTitle.compare(KTestArtist1+" - "+KTestTitle1)), "API:RadioHistoryModel addItem() 3"); |
|
939 |
||
940 |
||
53
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
941 |
expectedHistoryItemCount = mUiEngine->historyModel().rowCount() + 1; |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
942 |
// trying to add an item that allready exists must increase the item count |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
943 |
mUiEngine->historyModel().addItem( KTestArtist1, KTestTitle1, station ); |
53
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
944 |
INFO_1( "mUiEngine->historyModel().rowCount()== %i", mUiEngine->historyModel().rowCount() ); |
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
945 |
QVERIFY2((mUiEngine->historyModel().rowCount()==expectedHistoryItemCount), "API:RadioHistoryModel addItem() 4"); |
24 | 946 |
} |
947 |
||
948 |
/*! |
|
949 |
* |
|
950 |
*/ |
|
951 |
void TestRadioUiEngine::testAddRadioTextPlus() |
|
952 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
953 |
FUNC_LOG; |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
954 |
RadioStation station; |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
955 |
mUiEngine->stationModel().findFrequency( KTestFrequency6, station ); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
956 |
mUiEngine->historyModel().addRadioTextPlus( RtPlus::Artist, KTestArtist1, station ); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
957 |
mUiEngine->historyModel().addRadioTextPlus( RtPlus::Title, KTestTitle1, station ); |
24 | 958 |
} |
959 |
||
960 |
/*! |
|
961 |
* |
|
962 |
*/ |
|
963 |
void TestRadioUiEngine::testClearRadioTextPlus() |
|
964 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
965 |
FUNC_LOG; |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
966 |
mUiEngine->historyModel().clearRadioTextPlus(); |
24 | 967 |
} |
968 |
||
969 |
/*! |
|
970 |
* Test RadioHistoryModelItem API |
|
971 |
*/ |
|
972 |
void TestRadioUiEngine::testHistoryModelItem() |
|
973 |
{ |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
974 |
FUNC_LOG; |
24 | 975 |
RadioHistoryItem* item = new RadioHistoryItem( KTestArtist3, KTestTitle3 ); |
976 |
item->setArtist( KTestArtist3 ); |
|
977 |
QVERIFY2(!(item->artist().compare(KTestArtist3)), "API:testHistoryModelItem setArtist()"); |
|
978 |
item->setTitle( KTestTitle3 ); |
|
979 |
QVERIFY2(!(item->title().compare(KTestTitle3)), "API:testHistoryModelItem setTitle()"); |
|
50
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
980 |
QVERIFY2( item->isValid(), "API:testHistoryModelItem isValid() 1"); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
981 |
item->reset(); |
c44f9bb56771
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
982 |
QVERIFY2(!item->isValid(), "API:testHistoryModelItem isValid() 2"); |
24 | 983 |
delete item; |
984 |
item = NULL; |
|
985 |
} |
|
53
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
986 |
|
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
987 |
void TestRadioUiEngine::Timeout( TUint aTimerId ) |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
988 |
{ |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
989 |
FUNC_LOG; |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
990 |
if ( CSchedulerStopAndStartTimer::ETimerIdCreateMUT == aTimerId ) |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
991 |
{ |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
992 |
INFO("ETimerIdCreateMUT elapsed"); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
993 |
} |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
994 |
else if ( CSchedulerStopAndStartTimer::ETimerIdDeleteMUT == aTimerId ) |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
995 |
{ |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
996 |
INFO("ETimerIdDeleteMUT elapsed"); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
997 |
} |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
998 |
else if ( CSchedulerStopAndStartTimer::ETimerIdRunMUT == aTimerId ) |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
999 |
{ |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1000 |
INFO("ETimerIdRunMUT elapsed"); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1001 |
} |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1002 |
else |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1003 |
{ |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1004 |
INFO("Unknown timer elapsed"); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1005 |
} |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1006 |
} |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1007 |
|
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1008 |
void TestRadioUiEngine::CreateMUT() |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1009 |
{ |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1010 |
FUNC_LOG; |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1011 |
RadioEngineUtils::InitializeL(); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1012 |
mUiEngine = new RadioUiEngine; |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1013 |
mUiEngine->init(); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1014 |
|
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1015 |
mEngineWrapper.reset( new RadioEngineWrapper( mUiEngine->stationModel().stationHandlerIf() ) ); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1016 |
mEngineWrapper->init(); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1017 |
mPresetStorage.reset( new RadioPresetStorage() ); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1018 |
mUiEngine->stationModel().initialize( mPresetStorage.data(), mEngineWrapper.data() ); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1019 |
|
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1020 |
//TODO:: Check why ASSERT fails when mModel->rowCount() == 0 |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1021 |
if(mUiEngine->stationModel().rowCount()>0) |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1022 |
{ |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1023 |
mUiEngine->stationModel().removeAll(); //ASSERT: \"last >= first\" in file qabstractitemmodel.cpp, line 2110 |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1024 |
} |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1025 |
|
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1026 |
Radio::connect( &mUiEngine->stationModel(), SIGNAL(dataChanged(const QModelIndex, const QModelIndex)), |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1027 |
this, SLOT(dataChanged(const QModelIndex, const QModelIndex)) ); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1028 |
|
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1029 |
Radio::connect( &mUiEngine->stationModel(), SIGNAL(stationDataChanged(RadioStation)), |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1030 |
this, SLOT(stationDataChanged(RadioStation)) ); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1031 |
|
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1032 |
Radio::connect( &mUiEngine->stationModel(), SIGNAL(favoriteChanged(RadioStation)), |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1033 |
this, SLOT(favoriteChanged(RadioStation)) ); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1034 |
|
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1035 |
Radio::connect( &mUiEngine->historyModel(), SIGNAL(itemAdded()), |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1036 |
this, SLOT(itemAdded()) ); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1037 |
mSchedulerTimer->StartTimer( 1000000, CSchedulerStopAndStartTimer::ETimerIdRunMUT ); |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1038 |
} |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1039 |
|
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1040 |
void TestRadioUiEngine::DeleteMUT() |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1041 |
{ |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1042 |
FUNC_LOG; |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1043 |
if ( NULL != mUiEngine ) |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1044 |
{ |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1045 |
delete mUiEngine; |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1046 |
mUiEngine = NULL; |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1047 |
} |
bb6ed1806599
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
50
diff
changeset
|
1048 |
} |