47
|
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: Unit Test for mpmediawallview.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <hbmainwindow.h>
|
|
19 |
#include <hbapplication.h>
|
|
20 |
#include <hbview.h>
|
|
21 |
#include <QSignalSpy>
|
|
22 |
|
|
23 |
#include "unittest_mpmediawallview.h"
|
|
24 |
#include "stub/inc/mpplaybackdata.h"
|
55
|
25 |
#include "stub/inc/mpengine.h"
|
|
26 |
#include "stub/inc/mpenginefactory.h"
|
|
27 |
#include "stub/inc/hbmessagebox.h"
|
|
28 |
|
47
|
29 |
|
|
30 |
// Do this so we can access all member variables.
|
|
31 |
#define private public
|
|
32 |
#include "mpmediawallview.h"
|
|
33 |
#undef private
|
|
34 |
|
|
35 |
// Do this so we can access all memeber functions
|
|
36 |
#include "../../src/mpmediawallview.cpp"
|
|
37 |
|
55
|
38 |
|
47
|
39 |
/*!
|
|
40 |
Make our test case a stand-alone executable that runs all the test functions.
|
|
41 |
*/
|
|
42 |
int main(int argc, char *argv[])
|
|
43 |
{
|
|
44 |
HbApplication app(argc, argv);
|
|
45 |
HbMainWindow window;
|
|
46 |
|
|
47 |
TestMpMediaWallView tv;
|
|
48 |
|
|
49 |
if ( argc > 1 ) {
|
|
50 |
return QTest::qExec( &tv, argc, argv);
|
|
51 |
}
|
|
52 |
else {
|
|
53 |
char *pass[3];
|
|
54 |
pass[0] = argv[0];
|
|
55 |
pass[1] = "-o";
|
|
56 |
pass[2] = "c:\\data\\unittest_mpmediawallview.txt";
|
|
57 |
|
|
58 |
return QTest::qExec(&tv, 3, pass);
|
|
59 |
}
|
|
60 |
}
|
|
61 |
|
|
62 |
//Constructor
|
|
63 |
TestMpMediaWallView::TestMpMediaWallView()
|
|
64 |
: mTest(0)
|
|
65 |
{
|
|
66 |
|
|
67 |
}
|
|
68 |
|
|
69 |
//Destructor
|
|
70 |
TestMpMediaWallView::~TestMpMediaWallView()
|
|
71 |
{
|
|
72 |
delete mTest;
|
|
73 |
}
|
|
74 |
|
|
75 |
/*!
|
|
76 |
Called before the first testfunction is executed.
|
|
77 |
*/
|
|
78 |
void TestMpMediaWallView::initTestCase()
|
|
79 |
{
|
|
80 |
|
|
81 |
}
|
|
82 |
|
|
83 |
/*!
|
|
84 |
Called after the last testfunction was executed.
|
|
85 |
*/
|
|
86 |
void TestMpMediaWallView::cleanupTestCase()
|
|
87 |
{
|
|
88 |
QCoreApplication::processEvents();
|
|
89 |
}
|
|
90 |
|
|
91 |
/*!
|
|
92 |
Called before each testfunction is executed.
|
|
93 |
*/
|
|
94 |
void TestMpMediaWallView::init()
|
|
95 |
{
|
|
96 |
mTest = new MpMediaWallView();
|
|
97 |
}
|
|
98 |
|
|
99 |
/*!
|
|
100 |
Called after every testfunction.
|
|
101 |
*/
|
|
102 |
void TestMpMediaWallView::cleanup()
|
|
103 |
{
|
|
104 |
delete mTest;
|
|
105 |
mTest = 0;
|
|
106 |
}
|
|
107 |
|
|
108 |
/*!
|
|
109 |
Test InitializeView
|
|
110 |
*/
|
|
111 |
void TestMpMediaWallView::testInitializeView()
|
|
112 |
{
|
|
113 |
|
|
114 |
QVERIFY(!mTest->mEngine);
|
|
115 |
QVERIFY(!mTest->mCollectionData);
|
|
116 |
QVERIFY(!mTest->mModel);
|
|
117 |
QVERIFY(!mTest->mAlbumCover);
|
|
118 |
QVERIFY(!mTest->mTrackList);
|
|
119 |
QVERIFY(!mTest->mPlaybackData);
|
|
120 |
|
|
121 |
//test member variables are initialized
|
|
122 |
mTest->initializeView();
|
|
123 |
QVERIFY(mTest->mEngine);
|
|
124 |
QVERIFY(mTest->mCollectionData);
|
|
125 |
QVERIFY(mTest->mModel);
|
|
126 |
QVERIFY(mTest->mAlbumCover);
|
|
127 |
QVERIFY(mTest->mTrackList);
|
|
128 |
QVERIFY(mTest->mPlaybackData);
|
|
129 |
|
|
130 |
}
|
|
131 |
|
|
132 |
/*!
|
|
133 |
Test DeActivateView
|
|
134 |
*/
|
|
135 |
void TestMpMediaWallView::testDeactivateView()
|
|
136 |
{
|
|
137 |
mTest->initializeView();
|
|
138 |
mTest->mShowingSongsList = true;
|
|
139 |
mTest->setUpListAnimation();
|
|
140 |
mTest->deactivateView();
|
|
141 |
QCOMPARE(mTest->mShowingSongsList, false);
|
|
142 |
|
|
143 |
}
|
|
144 |
|
|
145 |
/*!
|
|
146 |
Test ContextOpened
|
|
147 |
*/
|
|
148 |
/* test case fails because potential problem in docml
|
|
149 |
void TestMpMediaWallView::testContextOpened()
|
|
150 |
{
|
|
151 |
|
|
152 |
mTest->mCollectionData = new MpMpxCollectionData();
|
|
153 |
mTest->mDocumentLoader = new MpMediaWallDocumentLoader();
|
|
154 |
|
|
155 |
QVERIFY(mTest->mCollectionData->context() == QVariant(ECollectionContextUnknown));
|
|
156 |
mTest->contextOpened(ECollectionContextArtists);
|
|
157 |
QVERIFY(mTest->mCollectionData->context() == QVariant(ECollectionContextAlbumsMediaWall));
|
|
158 |
|
|
159 |
//test loading 'empty' section, docml loading fails because initialize not called
|
|
160 |
QVERIFY(!mTest->mNoMusic);
|
|
161 |
mTest->contextOpened(ECollectionContextAlbumsMediaWall);
|
|
162 |
QVERIFY(mTest->mNoMusic);
|
|
163 |
}
|
|
164 |
*/
|
|
165 |
|
|
166 |
/*!
|
|
167 |
Test ContextOpened
|
|
168 |
*/
|
|
169 |
void TestMpMediaWallView::testContextOpened()
|
|
170 |
{
|
|
171 |
//test loading 'empty'
|
|
172 |
mTest->initializeView();
|
|
173 |
mTest->contextOpened(ECollectionContextAlbumsMediaWall);
|
|
174 |
//test loading 'mediawall'
|
|
175 |
mTest->mCollectionData->setCount(3);
|
|
176 |
mTest->contextOpened(ECollectionContextAlbumsMediaWall);
|
|
177 |
}
|
|
178 |
|
|
179 |
/*!
|
|
180 |
Test ContainerContentsChanged
|
|
181 |
*/
|
|
182 |
void TestMpMediaWallView::testContainerContentsChanged()
|
|
183 |
{
|
|
184 |
//test containerContetstsChanged calls opencallection when library not updating
|
|
185 |
mTest->initializeView();
|
|
186 |
QVERIFY(mTest->mEngine->mOpenCollectionCalled == 1);
|
|
187 |
mTest->containerContentsChanged();
|
|
188 |
QVERIFY(mTest->mEngine->mOpenCollectionCalled == 2);
|
|
189 |
mTest->libraryAboutToUpdate();
|
|
190 |
mTest->containerContentsChanged();
|
|
191 |
QVERIFY(mTest->mEngine->mOpenCollectionCalled == 2);
|
|
192 |
}
|
|
193 |
|
|
194 |
/*!
|
|
195 |
Test LibraryUpdated
|
|
196 |
*/
|
|
197 |
void TestMpMediaWallView::testLibraryUpdated()
|
|
198 |
{
|
|
199 |
//test libraryupdated changes flag and calls opencallection
|
|
200 |
mTest->initializeView();
|
|
201 |
mTest->mEngine->mOpenCollectionCalled=0;
|
|
202 |
mTest->mLibraryUpdating=true;
|
|
203 |
mTest->libraryUpdated();
|
|
204 |
QVERIFY(mTest->mLibraryUpdating == false);
|
|
205 |
QVERIFY(mTest->mEngine->mOpenCollectionCalled == 1);
|
|
206 |
}
|
|
207 |
|
|
208 |
/*!
|
55
|
209 |
Test listItemActivated
|
47
|
210 |
*/
|
55
|
211 |
void TestMpMediaWallView::testListItemActivated()
|
47
|
212 |
{
|
|
213 |
|
55
|
214 |
if ( MpEngineFactory::instance()->mSharedEngine ) {
|
|
215 |
delete MpEngineFactory::instance()->mSharedEngine;
|
|
216 |
}
|
|
217 |
MpEngineFactory::instance()->mSharedEngine = new MpEngine();
|
|
218 |
mTest->initializeView();
|
|
219 |
|
|
220 |
//Test with corrupted song
|
|
221 |
mTest->mCollectionData->mAlbumSongProperty = true;
|
|
222 |
MpEngineFactory::sharedEngine()->mPlayPauseCount = 0;
|
|
223 |
MpEngineFactory::sharedEngine()->mPlayAlbumSongsCount = 0;
|
|
224 |
mTest->listItemActivated(QModelIndex());
|
|
225 |
QVERIFY(MpEngineFactory::sharedEngine()->mPlayPauseCount == 0);
|
|
226 |
QVERIFY(MpEngineFactory::sharedEngine()->mPlayAlbumSongsCount == 0);
|
47
|
227 |
|
55
|
228 |
//Test select nowplaying item that is playing.
|
|
229 |
mTest->mCollectionData->mAlbumSongProperty = false;
|
|
230 |
mTest->mPlaybackData->mPlaybackState = MpPlaybackData::Playing;
|
|
231 |
mTest->mPlaybackData->mSongId = 1234;
|
|
232 |
mTest->mCollectionData->mArbitraryAlbumSongId = 1234;
|
|
233 |
MpEngineFactory::sharedEngine()->mPlayPauseCount = 0;
|
|
234 |
MpEngineFactory::sharedEngine()->mPlayAlbumSongsCount = 0;
|
|
235 |
mTest->listItemActivated(QModelIndex());
|
|
236 |
QVERIFY(MpEngineFactory::sharedEngine()->mPlayPauseCount == 1);
|
|
237 |
QVERIFY(MpEngineFactory::sharedEngine()->mPlayAlbumSongsCount == 0);
|
47
|
238 |
|
55
|
239 |
//Test select nowplaying item that is not initialized.
|
|
240 |
mTest->mCollectionData->mAlbumSongProperty = false;
|
|
241 |
mTest->mPlaybackData->mPlaybackState = MpPlaybackData::NotPlaying;
|
|
242 |
MpEngineFactory::sharedEngine()->mPlayPauseCount = 0;
|
|
243 |
MpEngineFactory::sharedEngine()->mPlayAlbumSongsCount = 0;
|
|
244 |
mTest->listItemActivated(QModelIndex());
|
|
245 |
QVERIFY(MpEngineFactory::sharedEngine()->mPlayPauseCount == 0);
|
|
246 |
QVERIFY(MpEngineFactory::sharedEngine()->mPlayAlbumSongsCount == 1);
|
|
247 |
|
|
248 |
//Test select an item that is not playing.
|
|
249 |
mTest->mCollectionData->mAlbumSongProperty = false;
|
|
250 |
mTest->mCollectionData->mArbitraryAlbumSongId = 4321;
|
|
251 |
MpEngineFactory::sharedEngine()->mPlayPauseCount = 0;
|
|
252 |
MpEngineFactory::sharedEngine()->mPlayAlbumSongsCount = 0;
|
|
253 |
mTest->listItemActivated(QModelIndex());
|
|
254 |
QVERIFY(MpEngineFactory::sharedEngine()->mPlayPauseCount == 0);
|
|
255 |
QVERIFY(MpEngineFactory::sharedEngine()->mPlayAlbumSongsCount == 1);
|
47
|
256 |
}
|
55
|
257 |
|