35
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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: Unit test for mpsongdata
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include <QSignalSpy>
|
|
18 |
#include <hbapplication.h>
|
|
19 |
#include <hbmainwindow.h>
|
|
20 |
#include <hbicon.h>
|
43
|
21 |
#include <mpxmedia.h>
|
35
|
22 |
|
43
|
23 |
#include "unittest_mpsongdata.h"
|
35
|
24 |
#include "stub/inc/thumbnailmanager_qt.h"
|
|
25 |
|
|
26 |
// Do this so we can access all member variables.
|
|
27 |
#define private public
|
|
28 |
#include "mpsongdata.h"
|
43
|
29 |
#include "mpsongdata_p.h"
|
35
|
30 |
#undef private
|
|
31 |
|
43
|
32 |
// This so we can test private functions
|
|
33 |
#include "mpsongdata_p.cpp"
|
35
|
34 |
|
|
35 |
/*!
|
|
36 |
Make our test case a stand-alone executable that runs all the test functions.
|
|
37 |
*/
|
|
38 |
int main(int argc, char *argv[])
|
|
39 |
{
|
|
40 |
HbApplication app(argc, argv);
|
|
41 |
HbMainWindow window;
|
|
42 |
|
|
43 |
TestMpSongData tv;
|
|
44 |
|
|
45 |
if ( argc > 1 ) {
|
|
46 |
return QTest::qExec( &tv, argc, argv);
|
|
47 |
}
|
|
48 |
else {
|
|
49 |
char *pass[3];
|
|
50 |
pass[0] = argv[0];
|
|
51 |
pass[1] = "-o";
|
|
52 |
pass[2] = "c:\\data\\unittest_mpsongdata.txt";
|
|
53 |
|
|
54 |
return QTest::qExec(&tv, 3, pass);
|
43
|
55 |
}
|
35
|
56 |
}
|
|
57 |
|
|
58 |
//Constructor
|
|
59 |
TestMpSongData::TestMpSongData()
|
|
60 |
: mTest(0)
|
|
61 |
{
|
|
62 |
|
|
63 |
}
|
|
64 |
|
|
65 |
//Destructor
|
|
66 |
TestMpSongData::~TestMpSongData()
|
|
67 |
{
|
|
68 |
delete mTest;
|
|
69 |
}
|
|
70 |
|
|
71 |
/*!
|
|
72 |
Called before the first testfunction is executed.
|
|
73 |
*/
|
|
74 |
void TestMpSongData::initTestCase()
|
|
75 |
{
|
43
|
76 |
|
35
|
77 |
}
|
|
78 |
|
|
79 |
/*!
|
|
80 |
Called after the last testfunction was executed.
|
|
81 |
*/
|
|
82 |
void TestMpSongData::cleanupTestCase()
|
|
83 |
{
|
|
84 |
}
|
|
85 |
|
|
86 |
/*!
|
|
87 |
Called before each testfunction is executed.
|
|
88 |
*/
|
|
89 |
void TestMpSongData::init()
|
|
90 |
{
|
|
91 |
mTest = new MpSongData();
|
43
|
92 |
mTestPrivate = mTest->d_ptr;
|
35
|
93 |
}
|
|
94 |
|
|
95 |
/*!
|
|
96 |
Called after every testfunction.
|
|
97 |
*/
|
|
98 |
void TestMpSongData::cleanup()
|
|
99 |
{
|
|
100 |
delete mTest;
|
|
101 |
mTest = 0;
|
|
102 |
}
|
|
103 |
|
|
104 |
/*!
|
|
105 |
Test correct cleanup of member variables.
|
|
106 |
*/
|
|
107 |
void TestMpSongData::testMemberCleanup()
|
|
108 |
{
|
|
109 |
cleanup();
|
|
110 |
ThumbnailManager::resetInitCounter();
|
|
111 |
init();
|
|
112 |
cleanup();
|
|
113 |
QCOMPARE( ThumbnailManager::getInitCounter(), 0 );
|
|
114 |
}
|
|
115 |
|
|
116 |
|
|
117 |
/*!
|
43
|
118 |
Test title()
|
35
|
119 |
*/
|
|
120 |
void TestMpSongData::testTitle()
|
|
121 |
{
|
43
|
122 |
mTestPrivate->mTitle = QString();
|
|
123 |
QVERIFY( mTest->title().isNull() == true );
|
|
124 |
|
35
|
125 |
QString title( "title" );
|
43
|
126 |
mTestPrivate->mTitle = title;
|
35
|
127 |
QVERIFY( mTest->title().isNull() == false );
|
|
128 |
QCOMPARE( mTest->title(), title );
|
|
129 |
}
|
|
130 |
|
|
131 |
/*!
|
43
|
132 |
Test album()
|
35
|
133 |
*/
|
|
134 |
void TestMpSongData::testAlbum()
|
|
135 |
{
|
43
|
136 |
mTestPrivate->mAlbum = QString();
|
35
|
137 |
QVERIFY( mTest->album().isNull() == true );
|
43
|
138 |
|
35
|
139 |
QString album( "album" );
|
43
|
140 |
mTestPrivate->mAlbum = album;
|
35
|
141 |
QVERIFY( mTest->album().isNull() == false );
|
|
142 |
QCOMPARE( mTest->album(), album );
|
|
143 |
}
|
|
144 |
|
|
145 |
/*!
|
43
|
146 |
Test artist()
|
35
|
147 |
*/
|
|
148 |
void TestMpSongData::testArtist()
|
|
149 |
{
|
43
|
150 |
mTestPrivate->mArtist = QString();
|
35
|
151 |
QVERIFY( mTest->artist().isNull() == true );
|
43
|
152 |
|
35
|
153 |
QString artist( "artist");
|
43
|
154 |
mTestPrivate->mArtist = artist;
|
35
|
155 |
QVERIFY( mTest->artist().isNull() == false );
|
|
156 |
QCOMPARE( mTest->artist(), artist );
|
|
157 |
}
|
|
158 |
|
|
159 |
/*!
|
43
|
160 |
Test comment()
|
35
|
161 |
*/
|
|
162 |
void TestMpSongData::testComment()
|
|
163 |
{
|
43
|
164 |
mTestPrivate->mComment = QString();
|
35
|
165 |
QVERIFY( mTest->comment().isNull() == true );
|
43
|
166 |
|
35
|
167 |
QString comment( "This is a nice song" );
|
43
|
168 |
mTestPrivate->mComment = comment;
|
35
|
169 |
QVERIFY( mTest->comment().isNull() == false );
|
|
170 |
QCOMPARE( mTest->comment(), comment );
|
|
171 |
}
|
|
172 |
|
|
173 |
/*!
|
43
|
174 |
Test albumArt()
|
35
|
175 |
*/
|
|
176 |
void TestMpSongData::testAlbumArt()
|
|
177 |
{
|
|
178 |
HbIcon dummyAlbumArt;
|
43
|
179 |
mTestPrivate->albumArt( dummyAlbumArt );
|
35
|
180 |
QVERIFY( dummyAlbumArt.isNull() == true );
|
43
|
181 |
|
35
|
182 |
HbIcon dummyAlbumArtTwo;
|
43
|
183 |
mTestPrivate->mAlbumArt = new HbIcon( ":/playbackviewicons/someAlbumArt.png" );
|
35
|
184 |
mTest->albumArt( dummyAlbumArtTwo );
|
|
185 |
QVERIFY( dummyAlbumArtTwo.isNull() == false );
|
|
186 |
}
|
|
187 |
|
|
188 |
/*!
|
43
|
189 |
Test year()
|
35
|
190 |
*/
|
|
191 |
void TestMpSongData::testYear()
|
|
192 |
{
|
43
|
193 |
mTestPrivate->mYear = QString();
|
35
|
194 |
QVERIFY( mTest->year().isNull() == true );
|
43
|
195 |
|
35
|
196 |
QString year("2000");
|
43
|
197 |
mTestPrivate->mYear = year;
|
35
|
198 |
QVERIFY( mTest->year().isNull() == false );
|
|
199 |
QCOMPARE( mTest->year(), year );
|
|
200 |
}
|
|
201 |
|
|
202 |
/*!
|
43
|
203 |
Test genre()
|
35
|
204 |
*/
|
|
205 |
void TestMpSongData::testGenre()
|
|
206 |
{
|
43
|
207 |
mTestPrivate->mGenre = QString();
|
35
|
208 |
QVERIFY( mTest->genre().isNull() == true );
|
|
209 |
|
43
|
210 |
QString genre( "pop" );
|
|
211 |
mTestPrivate->mGenre = genre;
|
35
|
212 |
QVERIFY( mTest->genre().isNull() == false );
|
|
213 |
QCOMPARE( mTest->genre(), genre );
|
|
214 |
}
|
|
215 |
|
|
216 |
/*!
|
43
|
217 |
Test composer()
|
35
|
218 |
*/
|
|
219 |
void TestMpSongData::testComposer()
|
|
220 |
{
|
43
|
221 |
mTestPrivate->mComposer = QString();
|
35
|
222 |
QVERIFY( mTest->composer().isNull() == true );
|
43
|
223 |
|
35
|
224 |
QString composer( "composer ");
|
43
|
225 |
mTestPrivate->mComposer = composer;
|
35
|
226 |
QVERIFY( mTest->composer().isNull() == false );
|
|
227 |
QCOMPARE( mTest->composer(), composer );
|
|
228 |
}
|
|
229 |
|
|
230 |
|
|
231 |
/*!
|
43
|
232 |
Test albumTrack()
|
35
|
233 |
*/
|
|
234 |
void TestMpSongData::testAlbumtrack()
|
|
235 |
{
|
43
|
236 |
mTestPrivate->mAlbumTrack = QString();
|
35
|
237 |
QVERIFY( mTest->albumTrack().isNull() == true );
|
43
|
238 |
|
35
|
239 |
QString albumTrack("2");
|
43
|
240 |
mTestPrivate->mAlbumTrack = albumTrack;
|
|
241 |
QVERIFY( mTest->albumTrack().isNull() == false );
|
35
|
242 |
QCOMPARE( mTest->albumTrack(), albumTrack );
|
|
243 |
}
|
|
244 |
|
|
245 |
/*!
|
43
|
246 |
Test link()
|
35
|
247 |
*/
|
|
248 |
void TestMpSongData::testLink()
|
|
249 |
{
|
43
|
250 |
mTestPrivate->mLink = QString();
|
35
|
251 |
QVERIFY( mTest->link().isNull() == true );
|
43
|
252 |
|
35
|
253 |
QString link( "www.nokia.com" );
|
43
|
254 |
mTestPrivate->mLink = link;
|
35
|
255 |
QVERIFY( mTest->link().isNull() == false );
|
|
256 |
QCOMPARE( mTest->link(), link );
|
|
257 |
}
|
|
258 |
|
|
259 |
/*!
|
|
260 |
Test fileName()
|
|
261 |
*/
|
|
262 |
void TestMpSongData::testFileName()
|
|
263 |
{
|
43
|
264 |
mTestPrivate->mFileName = QString();
|
35
|
265 |
QVERIFY( mTest->fileName().isNull() == true );
|
43
|
266 |
|
35
|
267 |
QString fileName( "test.mp3" );
|
43
|
268 |
mTestPrivate->mFileName = fileName;
|
35
|
269 |
QVERIFY( mTest->fileName().isNull() == false );
|
|
270 |
QCOMPARE( mTest->fileName(), fileName );
|
|
271 |
}
|
|
272 |
|
|
273 |
/*!
|
|
274 |
Test fileName()
|
|
275 |
*/
|
|
276 |
void TestMpSongData::testMimeType()
|
|
277 |
{
|
43
|
278 |
mTestPrivate->mMimeType = QString();
|
35
|
279 |
QVERIFY( mTest->mimeType().isNull() == true );
|
43
|
280 |
|
35
|
281 |
QString mimeType( "mp3" );
|
43
|
282 |
mTestPrivate->mMimeType = mimeType;
|
35
|
283 |
QVERIFY( mTest->mimeType().isNull() == false );
|
|
284 |
QCOMPARE( mTest->mimeType(), mimeType );
|
|
285 |
}
|
|
286 |
|
|
287 |
/*!
|
|
288 |
Test fileName()
|
|
289 |
*/
|
|
290 |
void TestMpSongData::testDuration()
|
|
291 |
{
|
43
|
292 |
mTestPrivate->mDuration = QString();
|
35
|
293 |
QVERIFY( mTest->duration().isNull() == true );
|
43
|
294 |
|
35
|
295 |
QString duration( "04:16" );
|
43
|
296 |
mTestPrivate->mDuration = duration;
|
35
|
297 |
QVERIFY( mTest->duration().isNull() == false );
|
|
298 |
QCOMPARE( mTest->duration(), duration );
|
|
299 |
}
|
|
300 |
|
|
301 |
/*!
|
|
302 |
Test bitRate()
|
|
303 |
*/
|
|
304 |
void TestMpSongData::testBitRate()
|
|
305 |
{
|
43
|
306 |
mTestPrivate->mBitRate = QString();
|
35
|
307 |
QVERIFY( mTest->bitRate().isNull() == true );
|
43
|
308 |
|
35
|
309 |
QString bitRate( "320 Kbps" );
|
43
|
310 |
mTestPrivate->mBitRate = bitRate;
|
35
|
311 |
QVERIFY( mTest->bitRate().isNull() == false );
|
|
312 |
QCOMPARE( mTest->bitRate(), bitRate );
|
|
313 |
}
|
|
314 |
|
|
315 |
/*!
|
|
316 |
Test sampleRate()
|
|
317 |
*/
|
|
318 |
void TestMpSongData::testSampleRate()
|
|
319 |
{
|
43
|
320 |
mTestPrivate->mSampleRate = QString();
|
35
|
321 |
QVERIFY( mTest->sampleRate().isNull() == true );
|
43
|
322 |
|
35
|
323 |
QString sampleRate( "44100 hz" );
|
43
|
324 |
mTestPrivate->mSampleRate = sampleRate;
|
35
|
325 |
QVERIFY( mTest->sampleRate().isNull() == false );
|
|
326 |
QCOMPARE( mTest->sampleRate(), sampleRate );
|
|
327 |
}
|
|
328 |
|
|
329 |
/*!
|
|
330 |
Test size()
|
|
331 |
*/
|
|
332 |
void TestMpSongData::testSize()
|
|
333 |
{
|
43
|
334 |
mTestPrivate->mSize = QString();
|
35
|
335 |
QVERIFY( mTest->size().isNull() == true );
|
43
|
336 |
|
35
|
337 |
QString size( "4.3MB" );
|
43
|
338 |
mTestPrivate->mSize = size;
|
35
|
339 |
QVERIFY( mTest->size().isNull() == false );
|
|
340 |
QCOMPARE( mTest->size(), size );
|
|
341 |
}
|
|
342 |
|
|
343 |
/*!
|
|
344 |
Test modified()
|
|
345 |
*/
|
|
346 |
void TestMpSongData::testModified()
|
|
347 |
{
|
43
|
348 |
mTestPrivate->mModified = QString();
|
35
|
349 |
QVERIFY( mTest->modified().isNull() == true );
|
43
|
350 |
|
35
|
351 |
QString modified( "5.7.2010 14:35:08" );
|
43
|
352 |
mTestPrivate->mModified = modified;
|
35
|
353 |
QVERIFY( mTest->modified().isNull() == false );
|
|
354 |
QCOMPARE( mTest->modified(), modified );
|
|
355 |
}
|
|
356 |
|
|
357 |
/*!
|
|
358 |
Test copyright()
|
|
359 |
*/
|
|
360 |
void TestMpSongData::testCopyright()
|
|
361 |
{
|
43
|
362 |
mTestPrivate->mCopyright = QString();
|
35
|
363 |
QVERIFY( mTest->copyright().isNull() == true );
|
43
|
364 |
|
35
|
365 |
QString copyright( "Copyright holder" );
|
43
|
366 |
mTestPrivate->mCopyright = copyright;
|
35
|
367 |
QVERIFY( mTest->copyright().isNull() == false );
|
|
368 |
QCOMPARE( mTest->copyright(), copyright );
|
|
369 |
}
|
|
370 |
|
|
371 |
/*!
|
|
372 |
Test musicURL()
|
|
373 |
*/
|
|
374 |
void TestMpSongData::testMusicURL()
|
|
375 |
{
|
43
|
376 |
mTestPrivate->mMusicURL = QString();
|
35
|
377 |
QVERIFY( mTest->musicURL().isNull() == true );
|
43
|
378 |
|
35
|
379 |
QString musicURL( "www.nokia.com" );
|
43
|
380 |
mTestPrivate->mMusicURL = musicURL;
|
35
|
381 |
QVERIFY( mTest->musicURL().isNull() == false );
|
|
382 |
QCOMPARE( mTest->musicURL(), musicURL );
|
|
383 |
}
|
|
384 |
|
|
385 |
/*!
|
|
386 |
Test isDrmProtected()
|
|
387 |
*/
|
|
388 |
void TestMpSongData::testIsDrmProtected()
|
|
389 |
{
|
43
|
390 |
mTestPrivate->mDrmProtected = true;
|
35
|
391 |
QVERIFY( mTest->isDrmProtected() == true );
|
43
|
392 |
|
|
393 |
mTestPrivate->mDrmProtected = false;
|
35
|
394 |
QVERIFY( mTest->isDrmProtected() == false );
|
|
395 |
}
|
|
396 |
|
|
397 |
/*!
|
43
|
398 |
Test setMpxMedia()
|
35
|
399 |
*/
|
43
|
400 |
void TestMpSongData::testSetMpxMedia()
|
35
|
401 |
{
|
43
|
402 |
RArray<TInt> supportedIds;
|
|
403 |
CleanupClosePushL( supportedIds );
|
|
404 |
supportedIds.AppendL( KMPXMediaIdMusic );
|
|
405 |
supportedIds.AppendL( KMPXMediaIdGeneral );
|
|
406 |
CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array());
|
|
407 |
CleanupStack::PopAndDestroy(&supportedIds);
|
|
408 |
CleanupStack::PushL(entries);
|
|
409 |
|
|
410 |
entries->SetTObjectValueL<TInt>(KMPXMediaGeneralId, 1);
|
|
411 |
entries->SetTObjectValueL<TInt>(KMPXMediaMusicAlbumId, 2);
|
|
412 |
entries->SetTextValueL(KMPXMediaGeneralTitle, TPtrC(reinterpret_cast<const TUint16*>(L"Title")));
|
|
413 |
entries->SetTextValueL(KMPXMediaMusicArtist, TPtrC(reinterpret_cast<const TUint16*>(L"Artist")));
|
|
414 |
entries->SetTextValueL(KMPXMediaMusicAlbum, TPtrC(reinterpret_cast<const TUint16*>(L"Album")));
|
|
415 |
entries->SetTextValueL(KMPXMediaMusicAlbumArtFileName, TPtrC(reinterpret_cast<const TUint16*>(L"AlbumArtFileName")));
|
|
416 |
entries->SetTextValueL(KMPXMediaMusicComposer, TPtrC(reinterpret_cast<const TUint16*>(L"Composer")));
|
|
417 |
entries->SetTObjectValueL<TInt64> (KMPXMediaMusicYear, 63241257600000000);
|
|
418 |
entries->SetTextValueL(KMPXMediaMusicAlbumTrack, TPtrC(reinterpret_cast<const TUint16*>(L"1")));
|
|
419 |
entries->SetTextValueL(KMPXMediaMusicGenre, TPtrC(reinterpret_cast<const TUint16*>(L"Genre")));
|
|
420 |
entries->SetTextValueL(KMPXMediaGeneralMimeType, TPtrC(reinterpret_cast<const TUint16*>(L"audio/mp3")));
|
|
421 |
entries->SetTObjectValueL<TInt>(KMPXMediaGeneralDuration, 205907);
|
|
422 |
entries->SetTObjectValueL<TUint32>(KMPXMediaAudioBitrate, 128000);
|
|
423 |
entries->SetTObjectValueL<TUint32>(KMPXMediaAudioSamplerate, 44100);
|
|
424 |
entries->SetTextValueL(KMPXMediaGeneralCopyright, TPtrC(reinterpret_cast<const TUint16*>(L"Copyright")));
|
|
425 |
entries->SetTextValueL(KMPXMediaMusicURL, TPtrC(reinterpret_cast<const TUint16*>(L"MusicURL")));
|
|
426 |
|
|
427 |
CMPXMedia* mediaTestData = CMPXMedia::NewL(*entries);
|
|
428 |
CleanupStack::PushL(mediaTestData);
|
|
429 |
|
|
430 |
QSignalSpy spy1( mTest, SIGNAL( playbackInfoChanged() ) );
|
|
431 |
QSignalSpy spy2( mTest, SIGNAL( songDetailInfoChanged() ) );
|
|
432 |
|
|
433 |
mTest->setMpxMedia( *mediaTestData );
|
|
434 |
|
|
435 |
QCOMPARE( spy1.count(), 1 );
|
|
436 |
QCOMPARE( spy2.count(), 1 );
|
|
437 |
|
|
438 |
QCOMPARE( mTest->title(), QString("Title") );
|
|
439 |
QCOMPARE( mTest->artist(), QString("Artist") );
|
|
440 |
QCOMPARE( mTest->album(), QString("Album") );
|
|
441 |
QCOMPARE( mTest->year(), QString("2004") );
|
|
442 |
QCOMPARE( mTest->genre(), QString("Genre") );
|
|
443 |
QCOMPARE( mTest->composer(), QString("Composer") );
|
|
444 |
QCOMPARE( mTest->albumTrack(), QString("1") );
|
|
445 |
QCOMPARE( mTest->fileName().isNull(), true );
|
|
446 |
QCOMPARE( mTest->mimeType(), QString("MP3") );
|
|
447 |
QCOMPARE( mTest->duration(), QString("03:25") );
|
|
448 |
QCOMPARE( mTest->bitRate(), QString("128") );
|
|
449 |
QCOMPARE( mTest->sampleRate(), QString("44100") );
|
|
450 |
QCOMPARE( mTest->copyright(), QString("Copyright") );
|
|
451 |
QCOMPARE( mTest->musicURL(), QString("MusicURL") );
|
|
452 |
QCOMPARE( mTest->isDrmProtected(), false );
|
|
453 |
|
|
454 |
CleanupStack::PopAndDestroy(mediaTestData);
|
|
455 |
CleanupStack::PopAndDestroy(entries);
|
35
|
456 |
}
|
|
457 |
|
|
458 |
/*!
|
43
|
459 |
Test setTitle()
|
|
460 |
*/
|
|
461 |
void TestMpSongData::testSetTitle()
|
|
462 |
{
|
|
463 |
bool result;
|
|
464 |
QString title( "title" );
|
|
465 |
mTestPrivate->mTitle = QString();
|
|
466 |
result = mTestPrivate->setTitle( title );
|
|
467 |
QCOMPARE( result, true );
|
|
468 |
QCOMPARE( mTest->title(), title );
|
|
469 |
|
|
470 |
result = false;
|
|
471 |
title = QString( "title" );
|
|
472 |
mTestPrivate->mTitle = QString( "titleTwo" );
|
|
473 |
result = mTestPrivate->setTitle( title );
|
|
474 |
QCOMPARE( result, true );
|
|
475 |
QCOMPARE( mTest->title(), title );
|
|
476 |
|
|
477 |
result = false;
|
|
478 |
title = QString();
|
|
479 |
mTestPrivate->mTitle = QString();
|
|
480 |
result = mTestPrivate->setTitle( title );
|
|
481 |
QCOMPARE( result, false );
|
|
482 |
QCOMPARE( mTest->title().isNull(), true );
|
|
483 |
|
|
484 |
result = false;
|
|
485 |
title = QString();
|
|
486 |
mTestPrivate->mTitle = QString( "titleTwo" );
|
|
487 |
result = mTestPrivate->setTitle( title );
|
|
488 |
QCOMPARE( result, true );
|
|
489 |
QCOMPARE( mTest->title().isNull(), true );
|
|
490 |
}
|
|
491 |
|
|
492 |
/*!
|
|
493 |
Test SetAlbum()
|
35
|
494 |
*/
|
|
495 |
void TestMpSongData::TestMpSongData::testSetAlbum()
|
|
496 |
{
|
43
|
497 |
bool result;
|
35
|
498 |
QString album( "album" );
|
43
|
499 |
mTestPrivate->mAlbum = QString();
|
|
500 |
result = mTestPrivate->setAlbum( album );
|
35
|
501 |
QCOMPARE( result, true );
|
43
|
502 |
QCOMPARE( mTest->album(), album );
|
|
503 |
|
35
|
504 |
result = false;
|
|
505 |
album = QString( "album" );
|
43
|
506 |
mTestPrivate->mAlbum = QString( "albumTwo" );
|
|
507 |
result = mTestPrivate->setAlbum( album );
|
35
|
508 |
QCOMPARE( result, true );
|
43
|
509 |
QCOMPARE( mTest->album(), album );
|
|
510 |
|
35
|
511 |
result = false;
|
|
512 |
album = QString();
|
43
|
513 |
mTestPrivate->mAlbum = QString();
|
|
514 |
result = mTestPrivate->setAlbum( album );
|
35
|
515 |
QCOMPARE( result, false );
|
43
|
516 |
QCOMPARE( mTest->album().isNull(), true );
|
|
517 |
|
35
|
518 |
result = false;
|
|
519 |
album = QString();
|
43
|
520 |
mTestPrivate->mAlbum = QString( "albumTwo" );
|
|
521 |
result = mTestPrivate->setAlbum( album );
|
35
|
522 |
QCOMPARE( result, true );
|
43
|
523 |
QCOMPARE( mTest->album().isNull(), true );
|
35
|
524 |
}
|
|
525 |
|
|
526 |
/*!
|
43
|
527 |
Test SetArtist()
|
35
|
528 |
*/
|
|
529 |
void TestMpSongData::testSetArtist()
|
|
530 |
{
|
43
|
531 |
bool result;
|
35
|
532 |
QString artist( "artist" );
|
43
|
533 |
mTestPrivate->mArtist = QString();
|
|
534 |
result = mTestPrivate->setArtist( artist );
|
35
|
535 |
QCOMPARE( result, true );
|
43
|
536 |
QCOMPARE( mTest->artist(), artist );
|
|
537 |
|
35
|
538 |
result = false;
|
|
539 |
artist = QString( "artist" );
|
43
|
540 |
mTestPrivate->mArtist = QString( "artistTwo" );
|
|
541 |
result = mTestPrivate->setArtist( artist );
|
35
|
542 |
QCOMPARE( result, true );
|
43
|
543 |
QCOMPARE( mTest->artist(), artist );
|
|
544 |
|
35
|
545 |
result = false;
|
|
546 |
artist = QString();
|
43
|
547 |
mTestPrivate->mArtist = QString();
|
|
548 |
result = mTestPrivate->setArtist( artist );
|
35
|
549 |
QCOMPARE( result, false );
|
43
|
550 |
QCOMPARE( mTest->artist().isNull(), true );
|
|
551 |
|
35
|
552 |
result = false;
|
|
553 |
artist = QString();
|
43
|
554 |
mTestPrivate->mArtist = QString( "artistTwo" );
|
|
555 |
result = mTestPrivate->setArtist( artist );
|
35
|
556 |
QCOMPARE( result, true );
|
43
|
557 |
QCOMPARE( mTest->artist().isNull(), true );
|
35
|
558 |
}
|
|
559 |
|
|
560 |
/*!
|
43
|
561 |
Test SetComment()
|
35
|
562 |
*/
|
|
563 |
void TestMpSongData::testSetComment()
|
|
564 |
{
|
43
|
565 |
bool result;
|
35
|
566 |
QString comment( "comment" );
|
43
|
567 |
mTestPrivate->mComment = QString();
|
|
568 |
result = mTestPrivate->setComment( comment );
|
35
|
569 |
QCOMPARE( result, true );
|
43
|
570 |
QCOMPARE( mTest->comment(), comment );
|
|
571 |
|
35
|
572 |
result = false;
|
|
573 |
comment = QString( "comment" );
|
43
|
574 |
mTestPrivate->mComment = QString( "commentTwo" );
|
|
575 |
result = mTestPrivate->setComment( comment );
|
35
|
576 |
QCOMPARE( result, true );
|
43
|
577 |
QCOMPARE( mTest->comment(), comment );
|
|
578 |
|
35
|
579 |
result = false;
|
|
580 |
comment = QString();
|
43
|
581 |
mTestPrivate->mComment = QString();
|
|
582 |
result = mTestPrivate->setComment( comment );
|
35
|
583 |
QCOMPARE( result, false );
|
43
|
584 |
QCOMPARE( mTest->comment().isNull(), true );
|
|
585 |
|
35
|
586 |
result = false;
|
|
587 |
comment = QString();
|
43
|
588 |
mTestPrivate->mComment = QString( "commentTwo" );
|
|
589 |
result = mTestPrivate->setComment( comment );
|
35
|
590 |
QCOMPARE( result, true );
|
43
|
591 |
QCOMPARE( mTest->comment().isNull(), true );
|
35
|
592 |
}
|
|
593 |
|
|
594 |
/*!
|
43
|
595 |
Test SetYear()
|
35
|
596 |
*/
|
|
597 |
void TestMpSongData::testSetYear()
|
|
598 |
{
|
43
|
599 |
bool result;
|
35
|
600 |
int year = 2010;
|
43
|
601 |
mTestPrivate->mYear = QString();
|
|
602 |
result = mTestPrivate->setYear( year );
|
35
|
603 |
QCOMPARE( result, true );
|
43
|
604 |
QCOMPARE( mTest->year(), QString::number( year ) );
|
|
605 |
|
35
|
606 |
result = false;
|
|
607 |
year = 2010;
|
43
|
608 |
mTestPrivate->mYear = QString::number( 2011 );
|
|
609 |
result = mTestPrivate->setYear( year );
|
35
|
610 |
QCOMPARE( result, true );
|
43
|
611 |
QCOMPARE( mTest->year(), QString::number( year ) );
|
|
612 |
|
35
|
613 |
result = false;
|
|
614 |
year = -1;
|
43
|
615 |
mTestPrivate->mYear = QString();
|
|
616 |
result = mTestPrivate->setYear( year );
|
35
|
617 |
QCOMPARE( result, true );
|
43
|
618 |
QCOMPARE( mTest->year().isNull(), true );
|
|
619 |
|
35
|
620 |
result = false;
|
|
621 |
year = -1;
|
43
|
622 |
mTestPrivate->mYear = QString::number( 2011 );
|
|
623 |
result = mTestPrivate->setYear( year );
|
35
|
624 |
QCOMPARE( result, true );
|
43
|
625 |
QCOMPARE( mTest->year().isNull(), true );
|
35
|
626 |
}
|
|
627 |
|
|
628 |
/*!
|
43
|
629 |
Test setGenre()
|
35
|
630 |
*/
|
|
631 |
void TestMpSongData::testSetGenre()
|
|
632 |
{
|
43
|
633 |
bool result;
|
35
|
634 |
QString genre( "genre" );
|
43
|
635 |
mTestPrivate->mGenre = QString();
|
|
636 |
result = mTestPrivate->setGenre( genre );
|
35
|
637 |
QCOMPARE( result, true );
|
43
|
638 |
QCOMPARE( mTest->genre(), genre );
|
|
639 |
|
35
|
640 |
result = false;
|
|
641 |
genre = QString( "genre" );
|
43
|
642 |
mTestPrivate->mGenre = QString( "genreTwo" );
|
|
643 |
result = mTestPrivate->setGenre( genre );
|
35
|
644 |
QCOMPARE( result, true );
|
43
|
645 |
QCOMPARE( mTest->genre(), genre );
|
|
646 |
|
35
|
647 |
result = false;
|
|
648 |
genre = QString();
|
43
|
649 |
mTestPrivate->mGenre = QString();
|
|
650 |
result = mTestPrivate->setGenre( genre );
|
35
|
651 |
QCOMPARE( result, false );
|
43
|
652 |
QCOMPARE( mTest->genre().isNull(), true );
|
|
653 |
|
35
|
654 |
result = false;
|
|
655 |
genre = QString();
|
43
|
656 |
mTestPrivate->mGenre = QString( "genreTwo" );
|
|
657 |
result = mTestPrivate->setGenre( genre );
|
35
|
658 |
QCOMPARE( result, true );
|
43
|
659 |
QCOMPARE( mTest->genre().isNull(), true );
|
35
|
660 |
}
|
|
661 |
|
|
662 |
/*!
|
43
|
663 |
Test setComposer()
|
35
|
664 |
*/
|
|
665 |
void TestMpSongData::testSetComposer()
|
|
666 |
{
|
43
|
667 |
bool result;
|
35
|
668 |
QString composer( "composer" );
|
43
|
669 |
mTestPrivate->mComposer = QString();
|
|
670 |
result = mTestPrivate->setComposer( composer );
|
35
|
671 |
QCOMPARE( result, true );
|
43
|
672 |
QCOMPARE( mTest->composer(), composer );
|
|
673 |
|
35
|
674 |
result = false;
|
|
675 |
composer = QString( "composer" );
|
43
|
676 |
mTestPrivate->mComposer = QString( "composerTwo" );
|
|
677 |
result = mTestPrivate->setComposer( composer );
|
35
|
678 |
QCOMPARE( result, true );
|
43
|
679 |
QCOMPARE( mTest->composer(), composer );
|
|
680 |
|
35
|
681 |
result = false;
|
|
682 |
composer = QString();
|
43
|
683 |
mTestPrivate->mComposer = QString();
|
|
684 |
result = mTestPrivate->setComposer( composer );
|
35
|
685 |
QCOMPARE( result, false );
|
43
|
686 |
QCOMPARE( mTest->composer().isNull(), true );
|
|
687 |
|
35
|
688 |
result = false;
|
|
689 |
composer = QString();
|
43
|
690 |
mTestPrivate->mComposer = QString( "composerTwo" );
|
|
691 |
result = mTestPrivate->setComposer( composer );
|
35
|
692 |
QCOMPARE( result, true );
|
43
|
693 |
QCOMPARE( mTest->composer().isNull(), true );
|
35
|
694 |
}
|
|
695 |
|
|
696 |
/*!
|
43
|
697 |
Test setAlbumTrack()
|
35
|
698 |
*/
|
|
699 |
void TestMpSongData::testSetAlbumTrack()
|
|
700 |
{
|
43
|
701 |
bool result;
|
35
|
702 |
QString albumTrack( "2" );
|
43
|
703 |
mTestPrivate->mAlbumTrack = QString();
|
|
704 |
result = mTestPrivate->setAlbumTrack( albumTrack );
|
35
|
705 |
QCOMPARE( result, true );
|
43
|
706 |
QCOMPARE( mTest->albumTrack(), albumTrack );
|
|
707 |
|
35
|
708 |
result = false;
|
|
709 |
albumTrack = QString( "2" );
|
43
|
710 |
mTestPrivate->mAlbumTrack = QString( "3" );
|
|
711 |
result = mTestPrivate->setAlbumTrack( albumTrack );
|
35
|
712 |
QCOMPARE( result, true );
|
43
|
713 |
QCOMPARE( mTest->albumTrack(), albumTrack );
|
|
714 |
|
35
|
715 |
result = false;
|
|
716 |
albumTrack = QString();
|
43
|
717 |
mTestPrivate->mAlbumTrack = QString();
|
|
718 |
result = mTestPrivate->setAlbumTrack( albumTrack );
|
35
|
719 |
QCOMPARE( result, false );
|
43
|
720 |
QCOMPARE( mTest->albumTrack().isNull(), true );
|
|
721 |
|
35
|
722 |
result = false;
|
|
723 |
albumTrack = QString();
|
43
|
724 |
mTestPrivate->mAlbumTrack = QString( "3" );
|
|
725 |
result = mTestPrivate->setAlbumTrack( albumTrack );
|
35
|
726 |
QCOMPARE( result, true );
|
43
|
727 |
QCOMPARE( mTest->albumTrack().isNull(), true );
|
35
|
728 |
}
|
|
729 |
|
|
730 |
/*!
|
43
|
731 |
Test setLink()
|
35
|
732 |
*/
|
|
733 |
void TestMpSongData::testSetLink()
|
43
|
734 |
{
|
35
|
735 |
QString link( "www.nokia.com" );
|
43
|
736 |
mTestPrivate->mLink = QString();
|
|
737 |
mTestPrivate->setLink( link );
|
|
738 |
QCOMPARE( mTest->link(), link );
|
|
739 |
|
35
|
740 |
link = QString( "www.nokia.com" );
|
43
|
741 |
mTestPrivate->mLink = QString( "www.nokia.fi" );
|
|
742 |
mTestPrivate->setLink( link );
|
|
743 |
QCOMPARE( mTest->link(), link );
|
|
744 |
|
35
|
745 |
link = QString();
|
43
|
746 |
mTestPrivate->mLink = QString();
|
|
747 |
mTestPrivate->setLink( link );
|
|
748 |
QCOMPARE( mTest->link().isNull(), true );
|
|
749 |
|
35
|
750 |
link = QString();
|
43
|
751 |
mTestPrivate->mLink = QString( "www.nokia.fi" );
|
|
752 |
mTestPrivate->setLink( link );
|
|
753 |
QCOMPARE( mTest->link().isNull(), true );
|
35
|
754 |
}
|
|
755 |
|
|
756 |
/*!
|
43
|
757 |
Test setFileName()
|
35
|
758 |
*/
|
|
759 |
void TestMpSongData::testSetFileName()
|
|
760 |
{
|
43
|
761 |
bool result;
|
35
|
762 |
QString fileName( "fileName" );
|
43
|
763 |
mTestPrivate->mFileName = QString();
|
|
764 |
result = mTestPrivate->setFileName( fileName );
|
35
|
765 |
QCOMPARE( result, true );
|
43
|
766 |
QCOMPARE( mTest->fileName(), fileName );
|
|
767 |
|
35
|
768 |
result = false;
|
|
769 |
fileName = QString( "fileName" );
|
43
|
770 |
mTestPrivate->mFileName = QString( "fileNameTwo" );
|
|
771 |
result = mTestPrivate->setFileName( fileName );
|
35
|
772 |
QCOMPARE( result, true );
|
43
|
773 |
QCOMPARE( mTest->fileName(), fileName );
|
|
774 |
|
35
|
775 |
result = false;
|
|
776 |
fileName = QString();
|
43
|
777 |
mTestPrivate->mFileName = QString();
|
|
778 |
result = mTestPrivate->setFileName( fileName );
|
35
|
779 |
QCOMPARE( result, false );
|
43
|
780 |
QCOMPARE( mTest->fileName().isNull(), true );
|
|
781 |
|
35
|
782 |
result = false;
|
|
783 |
fileName = QString();
|
43
|
784 |
mTestPrivate->mFileName = QString( "fileNameTwo" );
|
|
785 |
result = mTestPrivate->setFileName( fileName );
|
35
|
786 |
QCOMPARE( result, true );
|
43
|
787 |
QCOMPARE( mTest->fileName().isNull(), true );
|
35
|
788 |
}
|
|
789 |
|
|
790 |
/*!
|
43
|
791 |
Test setMimeType()
|
35
|
792 |
*/
|
|
793 |
void TestMpSongData::testSetMimeType()
|
|
794 |
{
|
43
|
795 |
bool result;
|
35
|
796 |
QString mimeType( "mimeType" );
|
43
|
797 |
mTestPrivate->mMimeType = QString();
|
|
798 |
result = mTestPrivate->setMimeType( mimeType );
|
35
|
799 |
QCOMPARE( result, true );
|
43
|
800 |
QCOMPARE( mTest->mimeType(), mimeType );
|
|
801 |
|
35
|
802 |
result = false;
|
|
803 |
mimeType = QString( "mimeType" );
|
43
|
804 |
mTestPrivate->mMimeType = QString( "mimeTypeTwo" );
|
|
805 |
result = mTestPrivate->setMimeType( mimeType );
|
35
|
806 |
QCOMPARE( result, true );
|
43
|
807 |
QCOMPARE( mTest->mimeType(), mimeType );
|
|
808 |
|
35
|
809 |
result = false;
|
|
810 |
mimeType = QString();
|
43
|
811 |
mTestPrivate->mMimeType = QString();
|
|
812 |
result = mTestPrivate->setMimeType( mimeType );
|
35
|
813 |
QCOMPARE( result, false );
|
43
|
814 |
QCOMPARE( mTest->mimeType().isNull(), true );
|
|
815 |
|
35
|
816 |
result = false;
|
|
817 |
mimeType = QString();
|
43
|
818 |
mTestPrivate->mMimeType = QString( "mimeTypeTwo" );
|
|
819 |
result = mTestPrivate->setMimeType( mimeType );
|
35
|
820 |
QCOMPARE( result, true );
|
43
|
821 |
QCOMPARE( mTest->mimeType().isNull(), true );
|
35
|
822 |
}
|
|
823 |
|
|
824 |
/*!
|
|
825 |
Test setDuration() // TODO: more cases to add here for different time interval
|
|
826 |
*/
|
|
827 |
void TestMpSongData::testSetDuration()
|
|
828 |
{
|
43
|
829 |
bool result;
|
35
|
830 |
int duration = 100;
|
43
|
831 |
mTestPrivate->mDuration = QString();
|
|
832 |
result = mTestPrivate->setDuration( duration );
|
35
|
833 |
QCOMPARE( result, true );
|
43
|
834 |
QCOMPARE( mTest->duration(), QString("01:40") );
|
|
835 |
|
35
|
836 |
result = false;
|
|
837 |
duration = 100;
|
43
|
838 |
mTestPrivate->mDuration = QString( "02:00" );
|
|
839 |
result = mTestPrivate->setDuration( duration );
|
35
|
840 |
QCOMPARE( result, true );
|
43
|
841 |
QCOMPARE( mTest->duration(), QString("01:40") );
|
|
842 |
|
35
|
843 |
result = false;
|
|
844 |
duration = -1;
|
43
|
845 |
mTestPrivate->mDuration = QString();
|
|
846 |
result = mTestPrivate->setDuration( duration );
|
35
|
847 |
QCOMPARE( result, true );
|
43
|
848 |
QCOMPARE( mTest->duration().isNull(), true );
|
|
849 |
|
35
|
850 |
result = false;
|
|
851 |
duration = -1;
|
43
|
852 |
mTestPrivate->mDuration = QString( "02:00" );
|
|
853 |
result = mTestPrivate->setDuration( duration );
|
35
|
854 |
QCOMPARE( result, true );
|
43
|
855 |
QCOMPARE( mTest->duration().isNull(), true );
|
35
|
856 |
}
|
|
857 |
|
|
858 |
/*!
|
43
|
859 |
Test setBitRate()
|
35
|
860 |
*/
|
|
861 |
void TestMpSongData::testSetBitRate()
|
|
862 |
{
|
43
|
863 |
bool result;
|
35
|
864 |
int bitRate = 302000;
|
43
|
865 |
mTestPrivate->mBitRate = QString();
|
|
866 |
result = mTestPrivate->setBitRate( bitRate );
|
35
|
867 |
QCOMPARE( result, true );
|
43
|
868 |
QCOMPARE( mTest->bitRate(), QString::number( bitRate / 1000 ) );
|
|
869 |
|
35
|
870 |
result = false;
|
|
871 |
bitRate = 302000;
|
43
|
872 |
mTestPrivate->mBitRate = QString::number( 412 );
|
|
873 |
result = mTestPrivate->setBitRate( bitRate );
|
35
|
874 |
QCOMPARE( result, true );
|
43
|
875 |
QCOMPARE( mTest->bitRate(), QString::number( bitRate / 1000 ) );
|
|
876 |
|
35
|
877 |
result = false;
|
|
878 |
bitRate = -1;
|
43
|
879 |
mTestPrivate->mBitRate = QString();
|
|
880 |
result = mTestPrivate->setBitRate( bitRate );
|
35
|
881 |
QCOMPARE( result, true );
|
43
|
882 |
QCOMPARE( mTest->bitRate().isNull(), true );
|
|
883 |
|
35
|
884 |
result = false;
|
|
885 |
bitRate = -1;
|
43
|
886 |
mTestPrivate->mBitRate = QString::number( 412 );
|
|
887 |
result = mTestPrivate->setBitRate( bitRate );
|
35
|
888 |
QCOMPARE( result, true );
|
43
|
889 |
QCOMPARE( mTest->bitRate().isNull(), true );
|
35
|
890 |
}
|
|
891 |
|
|
892 |
/*!
|
|
893 |
Test setSampleRate
|
|
894 |
*/
|
|
895 |
void TestMpSongData::testSetSampleRate()
|
|
896 |
{
|
43
|
897 |
bool result;
|
35
|
898 |
int sampleRate = 44100;
|
43
|
899 |
mTestPrivate->mSampleRate = QString();
|
|
900 |
result = mTestPrivate->setSampleRate( sampleRate );
|
35
|
901 |
QCOMPARE( result, true );
|
43
|
902 |
QCOMPARE( mTest->sampleRate(), QString::number( sampleRate ) );
|
|
903 |
|
35
|
904 |
result = false;
|
|
905 |
sampleRate = 44100;
|
43
|
906 |
mTestPrivate->mSampleRate = QString::number( 55000 );
|
|
907 |
result = mTestPrivate->setSampleRate( sampleRate );
|
35
|
908 |
QCOMPARE( result, true );
|
43
|
909 |
QCOMPARE( mTest->sampleRate(), QString::number( sampleRate ) );
|
|
910 |
|
35
|
911 |
result = false;
|
|
912 |
sampleRate = -1;
|
43
|
913 |
mTestPrivate->mSampleRate = QString();
|
|
914 |
result = mTestPrivate->setSampleRate( sampleRate );
|
35
|
915 |
QCOMPARE( result, true );
|
43
|
916 |
QCOMPARE( mTest->sampleRate().isNull(), true );
|
|
917 |
|
35
|
918 |
result = false;
|
|
919 |
sampleRate = -1;
|
43
|
920 |
mTestPrivate->mSampleRate = QString::number( 55000 );
|
|
921 |
result = mTestPrivate->setSampleRate( sampleRate );
|
35
|
922 |
QCOMPARE( result, true );
|
43
|
923 |
QCOMPARE( mTest->sampleRate().isNull(), true );
|
35
|
924 |
}
|
|
925 |
|
|
926 |
/*!
|
|
927 |
Test setSize
|
|
928 |
*/
|
|
929 |
void TestMpSongData::testSetSize()
|
|
930 |
{
|
43
|
931 |
bool result;
|
35
|
932 |
int size = 4300;
|
43
|
933 |
mTestPrivate->mSize = QString();
|
|
934 |
result = mTestPrivate->setSize( size );
|
35
|
935 |
QCOMPARE( result, true );
|
45
|
936 |
QCOMPARE( mTest->size(), QString::number( size ) );
|
43
|
937 |
|
35
|
938 |
result = false;
|
|
939 |
size = 4300;
|
43
|
940 |
mTestPrivate->mSize = QString( "5" );
|
|
941 |
result = mTestPrivate->setSize( size );
|
35
|
942 |
QCOMPARE( result, true );
|
45
|
943 |
QCOMPARE( mTest->size(), QString::number( size ) );
|
35
|
944 |
}
|
|
945 |
|
|
946 |
/*!
|
|
947 |
Test setModified
|
|
948 |
*/
|
|
949 |
void TestMpSongData::testSetModified()
|
|
950 |
{
|
43
|
951 |
bool result;
|
35
|
952 |
QString modified( "5.7.2010 14:35:08" );
|
43
|
953 |
mTestPrivate->mModified = QString();
|
|
954 |
result = mTestPrivate->setModified( modified );
|
35
|
955 |
QCOMPARE( result, true );
|
43
|
956 |
QCOMPARE( mTest->modified(), modified );
|
|
957 |
|
35
|
958 |
result = false;
|
|
959 |
modified = QString( "5.7.2010 14:35:08" );
|
43
|
960 |
mTestPrivate->mModified = QString( "9.7.2010 16:35:08" );
|
|
961 |
result = mTestPrivate->setModified( modified );
|
35
|
962 |
QCOMPARE( result, true );
|
43
|
963 |
QCOMPARE( mTest->modified(), modified );
|
|
964 |
|
35
|
965 |
result = false;
|
|
966 |
modified = QString();
|
43
|
967 |
mTestPrivate->mModified = QString();
|
|
968 |
result = mTestPrivate->setModified( modified );
|
35
|
969 |
QCOMPARE( result, false );
|
43
|
970 |
QCOMPARE( mTest->modified().isNull(), true );
|
|
971 |
|
35
|
972 |
result = false;
|
|
973 |
modified = QString();
|
43
|
974 |
mTestPrivate->mModified = QString( "9.7.2010 16:35:08" );
|
|
975 |
result = mTestPrivate->setModified( modified );
|
35
|
976 |
QCOMPARE( result, true );
|
43
|
977 |
QCOMPARE( mTest->modified().isNull(), true );
|
35
|
978 |
}
|
|
979 |
|
|
980 |
/*!
|
|
981 |
Test setCopyright
|
|
982 |
*/
|
|
983 |
void TestMpSongData::testSetCopyright()
|
|
984 |
{
|
43
|
985 |
bool result;
|
35
|
986 |
QString copyright( "copyright" );
|
43
|
987 |
mTestPrivate->mCopyright = QString();
|
|
988 |
result = mTestPrivate->setCopyright( copyright );
|
35
|
989 |
QCOMPARE( result, true );
|
43
|
990 |
QCOMPARE( mTest->copyright(), copyright );
|
|
991 |
|
35
|
992 |
result = false;
|
|
993 |
copyright = QString( "copyright" );
|
43
|
994 |
mTestPrivate->mCopyright = QString( "copyrightTwo" );
|
|
995 |
result = mTestPrivate->setCopyright( copyright );
|
35
|
996 |
QCOMPARE( result, true );
|
43
|
997 |
QCOMPARE( mTest->copyright(), copyright );
|
|
998 |
|
35
|
999 |
result = false;
|
|
1000 |
copyright = QString();
|
43
|
1001 |
mTestPrivate->mCopyright = QString();
|
|
1002 |
result = mTestPrivate->setCopyright( copyright );
|
35
|
1003 |
QCOMPARE( result, false );
|
43
|
1004 |
QCOMPARE( mTest->copyright().isNull(), true );
|
|
1005 |
|
35
|
1006 |
result = false;
|
|
1007 |
copyright = QString();
|
43
|
1008 |
mTestPrivate->mCopyright = QString( "copyrightTwo" );
|
|
1009 |
result = mTestPrivate->setCopyright( copyright );
|
35
|
1010 |
QCOMPARE( result, true );
|
43
|
1011 |
QCOMPARE( mTest->copyright().isNull(), true );
|
35
|
1012 |
}
|
|
1013 |
|
|
1014 |
/*!
|
|
1015 |
Test setMusicURL
|
|
1016 |
*/
|
|
1017 |
void TestMpSongData::testSetMusicURL()
|
|
1018 |
{
|
43
|
1019 |
bool result;
|
35
|
1020 |
QString musicURL( "musicURL" );
|
43
|
1021 |
mTestPrivate->mMusicURL = QString();
|
|
1022 |
result = mTestPrivate->setMusicURL( musicURL );
|
35
|
1023 |
QCOMPARE( result, true );
|
43
|
1024 |
QCOMPARE( mTest->musicURL(), musicURL );
|
|
1025 |
|
35
|
1026 |
result = false;
|
|
1027 |
musicURL = QString( "musicURL" );
|
43
|
1028 |
mTestPrivate->mMusicURL = QString( "musicURLTwo" );
|
|
1029 |
result = mTestPrivate->setMusicURL( musicURL );
|
35
|
1030 |
QCOMPARE( result, true );
|
43
|
1031 |
QCOMPARE( mTest->musicURL(), musicURL );
|
|
1032 |
|
35
|
1033 |
result = false;
|
|
1034 |
musicURL = QString();
|
43
|
1035 |
mTestPrivate->mMusicURL = QString();
|
|
1036 |
result = mTestPrivate->setMusicURL( musicURL );
|
35
|
1037 |
QCOMPARE( result, false );
|
43
|
1038 |
QCOMPARE( mTest->musicURL().isNull(), true );
|
|
1039 |
|
35
|
1040 |
result = false;
|
|
1041 |
musicURL = QString();
|
43
|
1042 |
mTestPrivate->mMusicURL = QString( "musicURLTwo" );
|
|
1043 |
result = mTestPrivate->setMusicURL( musicURL );
|
35
|
1044 |
QCOMPARE( result, true );
|
43
|
1045 |
QCOMPARE( mTest->musicURL().isNull(), true );
|
35
|
1046 |
}
|
|
1047 |
|
|
1048 |
/*!
|
|
1049 |
Test setDrmProtected
|
|
1050 |
*/
|
|
1051 |
void TestMpSongData::testSetDrmProtected()
|
|
1052 |
{
|
43
|
1053 |
bool result;
|
35
|
1054 |
bool drmProtected = false;
|
43
|
1055 |
mTestPrivate->mDrmProtected = true;
|
|
1056 |
result = mTestPrivate->setDrmProtected( drmProtected );
|
35
|
1057 |
QCOMPARE( result, true );
|
43
|
1058 |
QCOMPARE( mTest->isDrmProtected(), false );
|
|
1059 |
|
35
|
1060 |
result = false;
|
|
1061 |
drmProtected = false;
|
43
|
1062 |
mTestPrivate->mDrmProtected = false;
|
|
1063 |
result = mTestPrivate->setDrmProtected( drmProtected );
|
35
|
1064 |
QCOMPARE( result, false );
|
43
|
1065 |
QCOMPARE( mTest->isDrmProtected(), false );
|
|
1066 |
|
35
|
1067 |
result = false;
|
|
1068 |
drmProtected = true;
|
43
|
1069 |
mTestPrivate->mDrmProtected = true;
|
|
1070 |
result = mTestPrivate->setDrmProtected( drmProtected);
|
35
|
1071 |
QCOMPARE( result, false );
|
43
|
1072 |
QCOMPARE( mTest->isDrmProtected(), true );
|
|
1073 |
|
35
|
1074 |
result = false;
|
|
1075 |
drmProtected = true;
|
43
|
1076 |
mTestPrivate->mDrmProtected = false;
|
|
1077 |
result = mTestPrivate->setDrmProtected( drmProtected );
|
35
|
1078 |
QCOMPARE( result, true );
|
43
|
1079 |
QCOMPARE( mTest->isDrmProtected(), true );
|
35
|
1080 |
}
|
|
1081 |
|
|
1082 |
|
|
1083 |
/*!
|
43
|
1084 |
Test setAlbumArtUri()
|
35
|
1085 |
*/
|
43
|
1086 |
void TestMpSongData::testSetAlbumArtUri()
|
35
|
1087 |
{
|
|
1088 |
const QString albumArtUri( "AlbumArt" );
|
|
1089 |
const QString albumArtUriEmpty( "" );
|
43
|
1090 |
|
35
|
1091 |
QSignalSpy spy( mTest, SIGNAL( albumArtReady() ) );
|
43
|
1092 |
|
35
|
1093 |
QVERIFY( spy.isValid() );
|
|
1094 |
QCOMPARE( spy.count(), 0 );
|
43
|
1095 |
|
|
1096 |
mTestPrivate->setAlbumArtUri( albumArtUri );
|
35
|
1097 |
QCOMPARE( spy.count(), 0 );
|
43
|
1098 |
|
|
1099 |
mTestPrivate->mThumbnailManager->mGetThumbFails = true;
|
|
1100 |
mTestPrivate->setAlbumArtUri( albumArtUri );
|
35
|
1101 |
QCOMPARE( spy.count(), 1 );
|
43
|
1102 |
QCOMPARE( mTestPrivate->mAlbumArt, mTestPrivate->mDefaultAlbumArt );
|
|
1103 |
|
|
1104 |
mTestPrivate->setAlbumArtUri( albumArtUriEmpty );
|
35
|
1105 |
QCOMPARE( spy.count(), 2 );
|
43
|
1106 |
QCOMPARE( mTestPrivate->mAlbumArt, mTestPrivate->mDefaultAlbumArt );
|
35
|
1107 |
}
|
|
1108 |
|
|
1109 |
/*!
|
43
|
1110 |
Test thumbnailReady()
|
35
|
1111 |
*/
|
|
1112 |
void TestMpSongData::testThumbnailReady()
|
|
1113 |
{
|
|
1114 |
connect( this, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
|
43
|
1115 |
mTest->mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)) );
|
35
|
1116 |
|
|
1117 |
QSignalSpy spy(mTest, SIGNAL(albumArtReady()));
|
|
1118 |
QVERIFY( spy.isValid() );
|
|
1119 |
QCOMPARE( spy.count(), 0 );
|
43
|
1120 |
|
35
|
1121 |
QPixmap dummyAlbumArt(":/playbackviewicons/someAlbumArt.png" );
|
43
|
1122 |
|
35
|
1123 |
emit thumbnailReady(dummyAlbumArt, 0, -1, 0);
|
|
1124 |
QCOMPARE( spy.count(), 1 );
|
|
1125 |
HbIcon dummyAlbumArtCompare;
|
|
1126 |
mTest->albumArt(dummyAlbumArtCompare);
|
|
1127 |
QCOMPARE( dummyAlbumArtCompare.isNull(), false );
|
43
|
1128 |
|
35
|
1129 |
emit thumbnailReady(dummyAlbumArt, 0, -1 , 1);
|
|
1130 |
QCOMPARE( spy.count(), 2 );
|
|
1131 |
mTest->albumArt(dummyAlbumArtCompare);
|
|
1132 |
QCOMPARE( dummyAlbumArtCompare.isNull(), false );
|
43
|
1133 |
|
35
|
1134 |
}
|
|
1135 |
|