74
|
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 tests for PhoneResourceAdapter.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <QtTest/QtTest>
|
|
19 |
#include <QtGui>
|
|
20 |
#include <hbapplication.h>
|
|
21 |
#include <QSignalSpy>
|
|
22 |
#include <QVariant>
|
|
23 |
#include <mockservice.h>
|
|
24 |
#include <cpeengineinfo.h>
|
|
25 |
#include <pevirtualengine.h>
|
76
|
26 |
#include "phoneconstants.h"
|
|
27 |
#include "phonetestmain.h"
|
74
|
28 |
#include "phonecallheadermanager.h"
|
|
29 |
#include "phoneuiqtviewif_stub.h"
|
|
30 |
#include "bubblemanagerif_stub.h"
|
|
31 |
#include "phonebubblewrapper.h"
|
|
32 |
#include "phonecallheaderutil.h"
|
|
33 |
|
|
34 |
class TestPhoneCallHeaderManager : public QObject, MockService
|
|
35 |
{
|
|
36 |
Q_OBJECT
|
|
37 |
public:
|
|
38 |
TestPhoneCallHeaderManager();
|
|
39 |
virtual ~TestPhoneCallHeaderManager();
|
|
40 |
|
|
41 |
public slots:
|
|
42 |
void initTestCase();
|
|
43 |
void cleanupTestCase();
|
|
44 |
void init();
|
|
45 |
void cleanup();
|
|
46 |
|
|
47 |
private slots:
|
|
48 |
void testCreateCallHeader();
|
|
49 |
void testCreateEmergencyCallHeader();
|
|
50 |
void testRemoveCallHeader();
|
76
|
51 |
void testUpdateCallHeader();
|
74
|
52 |
void testHandleCipheringInfoChange();
|
|
53 |
void testConferenceBubble();
|
|
54 |
void testExpandedConferenceCallHeader();
|
|
55 |
void testRemoveAllCallHeaders();
|
76
|
56 |
void testIsVoiceCall();
|
74
|
57 |
|
|
58 |
private:
|
|
59 |
|
|
60 |
private:
|
|
61 |
BubbleManagerIFStub *mBubbleManagerIFStub;
|
|
62 |
PhoneUIQtViewIFStub *mPhoneUIQtViewIFStub;
|
|
63 |
PhoneBubbleWrapper *mPhoneBubbleWrapper;
|
|
64 |
CPEEngineInfo *iEngineInfo;
|
|
65 |
PhoneCallHeaderManager *mCallHeaderManager; // class under test
|
|
66 |
};
|
|
67 |
|
|
68 |
TestPhoneCallHeaderManager::TestPhoneCallHeaderManager ()
|
|
69 |
{
|
|
70 |
}
|
|
71 |
|
|
72 |
TestPhoneCallHeaderManager::~TestPhoneCallHeaderManager ()
|
|
73 |
{
|
|
74 |
}
|
|
75 |
|
|
76 |
void TestPhoneCallHeaderManager::initTestCase ()
|
|
77 |
{
|
|
78 |
mBubbleManagerIFStub = new BubbleManagerIFStub();
|
|
79 |
mPhoneUIQtViewIFStub = new PhoneUIQtViewIFStub(*mBubbleManagerIFStub);
|
|
80 |
TRAP_IGNORE( iEngineInfo = CPEEngineInfo::NewL());
|
|
81 |
mPhoneBubbleWrapper = new PhoneBubbleWrapper(*mBubbleManagerIFStub);
|
|
82 |
mCallHeaderManager = new PhoneCallHeaderManager(
|
|
83 |
*mPhoneBubbleWrapper, *mPhoneUIQtViewIFStub);
|
|
84 |
|
|
85 |
mCallHeaderManager->setEngineInfo(iEngineInfo);
|
|
86 |
}
|
|
87 |
|
|
88 |
void TestPhoneCallHeaderManager::cleanupTestCase ()
|
|
89 |
{
|
|
90 |
delete mCallHeaderManager;
|
|
91 |
delete mPhoneUIQtViewIFStub;
|
|
92 |
delete mBubbleManagerIFStub;
|
|
93 |
delete mPhoneBubbleWrapper;
|
|
94 |
delete iEngineInfo;
|
|
95 |
}
|
|
96 |
|
|
97 |
void TestPhoneCallHeaderManager::init ()
|
|
98 |
{
|
|
99 |
initialize();
|
|
100 |
}
|
|
101 |
|
|
102 |
void TestPhoneCallHeaderManager::cleanup ()
|
|
103 |
{
|
|
104 |
reset();
|
|
105 |
}
|
|
106 |
|
|
107 |
void TestPhoneCallHeaderManager::testCreateCallHeader ()
|
|
108 |
{
|
|
109 |
int callId = 1;
|
|
110 |
iEngineInfo->SetCallState(EPEStateRinging, callId );
|
|
111 |
|
|
112 |
EXPECT( PhoneBubbleWrapper, createCallHeader);
|
|
113 |
mCallHeaderManager->createCallHeader(callId);
|
|
114 |
QVERIFY(verify());
|
|
115 |
|
|
116 |
iEngineInfo->SetCallState(EPEStateConnecting, callId );
|
|
117 |
mIsConferenceExpanded = true;
|
|
118 |
mSetExpandedConferenceCalled = false;
|
|
119 |
|
|
120 |
mCallHeaderManager->createCallHeader(callId);
|
|
121 |
QVERIFY(verify());
|
|
122 |
QVERIFY(mSetExpandedConferenceCalled);
|
|
123 |
|
|
124 |
mSetExpandedConferenceCalled = false;
|
|
125 |
mIsConferenceExpanded = false;
|
|
126 |
}
|
|
127 |
|
|
128 |
void TestPhoneCallHeaderManager::testCreateEmergencyCallHeader()
|
|
129 |
{
|
|
130 |
int callId = 1;
|
|
131 |
|
|
132 |
EXPECT( PhoneBubbleWrapper, createCallHeader);
|
|
133 |
EXPECT( PhoneBubbleWrapper, setLabel);
|
|
134 |
EXPECT( PhoneBubbleWrapper, setCli);
|
|
135 |
EXPECT( PhoneBubbleWrapper, setCiphering);
|
|
136 |
mCallHeaderManager->createEmergencyCallHeader(callId);
|
|
137 |
QVERIFY(verify());
|
|
138 |
}
|
|
139 |
|
|
140 |
void TestPhoneCallHeaderManager::testRemoveCallHeader()
|
|
141 |
{
|
|
142 |
int callId = 1;
|
|
143 |
int bubbleId = 1;
|
|
144 |
QMap<int,int> bubbleMap;
|
|
145 |
EXPECT( PhoneBubbleWrapper, bubbles).returns(bubbleMap);
|
|
146 |
EXPECT( PhoneBubbleWrapper, removeCallHeader).times(0);
|
|
147 |
mCallHeaderManager->removeCallHeader(callId);
|
|
148 |
QVERIFY(verify());
|
|
149 |
reset();
|
|
150 |
|
|
151 |
bubbleMap.insert(callId, bubbleId);
|
|
152 |
|
|
153 |
EXPECT( PhoneBubbleWrapper, bubbles).returns(bubbleMap);
|
|
154 |
EXPECT( PhoneBubbleWrapper, removeCallHeader).with(callId);
|
|
155 |
mCallHeaderManager->removeCallHeader(callId);
|
|
156 |
QVERIFY(verify());
|
|
157 |
reset();
|
|
158 |
}
|
|
159 |
|
76
|
160 |
void TestPhoneCallHeaderManager::testUpdateCallHeader()
|
74
|
161 |
{
|
|
162 |
int callId = 1;
|
|
163 |
int bubbleId = -1;
|
|
164 |
EXPECT( PhoneBubbleWrapper, bubbleId).returns(bubbleId);
|
|
165 |
EXPECT( PhoneBubbleWrapper, setState).times(0);
|
76
|
166 |
mCallHeaderManager->updateCallHeader(callId);
|
74
|
167 |
QVERIFY(verify());
|
|
168 |
reset();
|
|
169 |
|
|
170 |
bubbleId = 1;
|
|
171 |
|
|
172 |
EXPECT( PhoneBubbleWrapper, bubbleId).returns(bubbleId);
|
|
173 |
EXPECT( PhoneBubbleWrapper, setState).times(1);
|
76
|
174 |
mCallHeaderManager->updateCallHeader(callId);
|
74
|
175 |
QVERIFY(verify());
|
|
176 |
reset();
|
|
177 |
}
|
|
178 |
|
|
179 |
void TestPhoneCallHeaderManager::testHandleCipheringInfoChange()
|
|
180 |
{
|
|
181 |
iEngineInfo->SetCallSecureStatus( ETrue, 0 );
|
|
182 |
iEngineInfo->SetCallSecureStatus( EFalse, 1 );
|
|
183 |
int callId = KPEConferenceCallID;
|
|
184 |
int bubbleId = -1;
|
|
185 |
QList<int> conferenceList;
|
|
186 |
conferenceList.append(0);
|
|
187 |
conferenceList.append(1);
|
|
188 |
EXPECT( PhoneBubbleWrapper, conferenceCallList).returns(conferenceList);
|
|
189 |
EXPECT( PhoneBubbleWrapper, conferenceCallList).returns(conferenceList);
|
|
190 |
EXPECT( PhoneBubbleWrapper, conferenceCallList).returns(conferenceList);
|
|
191 |
EXPECT( PhoneBubbleWrapper, conferenceCallList).returns(conferenceList);
|
|
192 |
EXPECT( PhoneBubbleWrapper, setCiphering);
|
|
193 |
mCallHeaderManager->handleCipheringInfoChange(callId);
|
|
194 |
QVERIFY(verify());
|
|
195 |
reset();
|
|
196 |
|
|
197 |
callId = 1;
|
|
198 |
|
|
199 |
EXPECT( PhoneBubbleWrapper, bubbleId).returns(bubbleId);
|
|
200 |
EXPECT( PhoneBubbleWrapper, setCiphering).times(0);
|
|
201 |
mCallHeaderManager->handleCipheringInfoChange(callId);
|
|
202 |
QVERIFY(verify());
|
|
203 |
reset();
|
|
204 |
|
|
205 |
bubbleId = 1;
|
|
206 |
|
|
207 |
EXPECT( PhoneBubbleWrapper, bubbleId).returns(bubbleId);
|
|
208 |
EXPECT( PhoneBubbleWrapper, setCiphering);
|
|
209 |
mCallHeaderManager->handleCipheringInfoChange(callId);
|
|
210 |
QVERIFY(verify());
|
|
211 |
reset();
|
|
212 |
}
|
|
213 |
|
|
214 |
void TestPhoneCallHeaderManager::testConferenceBubble()
|
|
215 |
{
|
|
216 |
int callId = 7;
|
|
217 |
EXPECT( PhoneBubbleWrapper, createConferenceBubble);
|
|
218 |
mCallHeaderManager->createConferenceBubble(callId);
|
|
219 |
QVERIFY(verify());
|
|
220 |
reset();
|
|
221 |
|
|
222 |
EXPECT( PhoneBubbleWrapper, removeConferenceBubble);
|
|
223 |
mCallHeaderManager->removeConferenceBubble();
|
|
224 |
QVERIFY(verify());
|
|
225 |
reset();
|
|
226 |
|
|
227 |
QMap<int,int> bubbleMap;
|
|
228 |
EXPECT( PhoneBubbleWrapper, bubbles).returns(bubbleMap);
|
|
229 |
EXPECT( PhoneBubbleWrapper, removeCallHeader).with(callId);
|
|
230 |
mCallHeaderManager->removeCallFromConference(callId);
|
|
231 |
QVERIFY(verify());
|
|
232 |
reset();
|
|
233 |
|
|
234 |
EXPECT( PhoneBubbleWrapper, removeCallFromConference).with(callId);
|
|
235 |
EXPECT( PhoneBubbleWrapper, bubbles).returns(bubbleMap);
|
|
236 |
mCallHeaderManager->setPrivateFromConference(callId);
|
|
237 |
QVERIFY(verify());
|
|
238 |
reset();
|
|
239 |
}
|
|
240 |
|
|
241 |
void TestPhoneCallHeaderManager::testExpandedConferenceCallHeader()
|
|
242 |
{
|
|
243 |
|
|
244 |
QMap<int,int> bubbleMap;
|
|
245 |
EXPECT( PhoneBubbleWrapper, bubbles).returns(bubbleMap).times(2);
|
|
246 |
mCallHeaderManager->setExpandedConferenceCallHeader();
|
|
247 |
QVERIFY(verify());
|
|
248 |
QVERIFY(false == mIsExpandedConference);
|
|
249 |
reset();
|
|
250 |
|
|
251 |
bubbleMap.insert(1, 2);
|
|
252 |
EXPECT( PhoneBubbleWrapper, bubbles).returns(bubbleMap);
|
|
253 |
EXPECT( PhoneBubbleWrapper, callIdByBubbleId).returns(KConferenceCallId);
|
|
254 |
mCallHeaderManager->setExpandedConferenceCallHeader();
|
|
255 |
QVERIFY(verify());
|
|
256 |
QVERIFY(true == mIsExpandedConference);
|
|
257 |
reset();
|
|
258 |
}
|
|
259 |
|
|
260 |
void TestPhoneCallHeaderManager::testRemoveAllCallHeaders()
|
|
261 |
{
|
|
262 |
|
|
263 |
QList<int> conferenceListMap;
|
|
264 |
QMap<int,int> bubbleMap;
|
|
265 |
EXPECT( PhoneBubbleWrapper, conferenceCallList).returns(conferenceListMap);
|
|
266 |
EXPECT( PhoneBubbleWrapper, bubbles).returns(bubbleMap);
|
|
267 |
mCallHeaderManager->removeAllCallHeaders();
|
|
268 |
QVERIFY(verify());
|
|
269 |
reset();
|
|
270 |
|
|
271 |
conferenceListMap.append(1);
|
|
272 |
bubbleMap.insert(1,1);
|
|
273 |
bubbleMap.insert(KEmergencyCallId, KEmergencyCallId);
|
|
274 |
|
|
275 |
EXPECT( PhoneBubbleWrapper, conferenceCallList).returns(conferenceListMap);
|
|
276 |
EXPECT( PhoneBubbleWrapper, removeConferenceBubble);
|
|
277 |
EXPECT( PhoneBubbleWrapper, bubbles).returns(bubbleMap).times(2);
|
|
278 |
EXPECT( PhoneBubbleWrapper, removeCallHeader).with(1);
|
|
279 |
mCallHeaderManager->removeAllCallHeaders();
|
|
280 |
QVERIFY(verify());
|
|
281 |
reset();
|
|
282 |
}
|
|
283 |
|
76
|
284 |
void TestPhoneCallHeaderManager::testIsVoiceCall()
|
74
|
285 |
{
|
76
|
286 |
EXPECT( PhoneCallHeaderUtil, IsVoiceCall).returns(true);
|
|
287 |
QVERIFY(mCallHeaderManager->isVoiceCall( 1 ));
|
|
288 |
QVERIFY(verify());
|
|
289 |
reset();
|
74
|
290 |
}
|
|
291 |
|
76
|
292 |
PHONE_TEST_MAIN(TestPhoneCallHeaderManager)
|
74
|
293 |
#include "unit_tests.moc"
|