35
|
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 |
/*
|
|
7 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
8 |
* All rights reserved.
|
|
9 |
* This component and the accompanying materials are made available
|
|
10 |
* under the terms of "Eclipse Public License v1.0"
|
|
11 |
* which accompanies this distribution, and is available
|
|
12 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
13 |
*
|
|
14 |
* Initial Contributors:
|
|
15 |
* Nokia Corporation - initial contribution.
|
|
16 |
*
|
|
17 |
* Contributors:
|
|
18 |
*
|
|
19 |
* Description:
|
|
20 |
*
|
|
21 |
*/
|
|
22 |
|
|
23 |
#include "ut_psuidivertnotehandler.h"
|
|
24 |
#include "psuidivertnotehandler.h"
|
|
25 |
#include "psetcalldivertingwrapper.h"
|
|
26 |
#include "qtestmains60.h"
|
|
27 |
#include <smcmockclassincludes.h>
|
|
28 |
|
|
29 |
class CPsetContainer
|
|
30 |
{
|
|
31 |
public:
|
|
32 |
CPsetContainer(){};
|
|
33 |
~CPsetContainer(){};
|
|
34 |
};
|
|
35 |
|
|
36 |
/*QString hbTrId(const char *id, int n)
|
|
37 |
{
|
|
38 |
SMC_MOCK_METHOD2( QString, const char *, id, int, n )
|
|
39 |
}*/
|
|
40 |
|
|
41 |
|
|
42 |
/*!
|
|
43 |
UT_psuidivertnotehandler::UT_psuidivertnotehandler
|
|
44 |
*/
|
|
45 |
UT_psuidivertnotehandler::UT_psuidivertnotehandler()
|
|
46 |
{
|
|
47 |
|
|
48 |
}
|
|
49 |
|
|
50 |
/*!
|
|
51 |
UT_psuidivertnotehandler::~UT_psuidivertnotehandler
|
|
52 |
*/
|
|
53 |
UT_psuidivertnotehandler::~UT_psuidivertnotehandler()
|
|
54 |
{
|
|
55 |
|
|
56 |
}
|
|
57 |
|
|
58 |
/*!
|
|
59 |
UT_psuidivertnotehandler::init
|
|
60 |
*/
|
|
61 |
void UT_psuidivertnotehandler::init()
|
|
62 |
{
|
|
63 |
initialize();
|
|
64 |
}
|
|
65 |
|
|
66 |
/*!
|
|
67 |
UT_psuidivertnotehandler::cleanup
|
|
68 |
*/
|
|
69 |
void UT_psuidivertnotehandler::cleanup()
|
|
70 |
{
|
|
71 |
reset();
|
|
72 |
}
|
|
73 |
|
|
74 |
/*!
|
|
75 |
UT_psuidivertnotehandler::t_memleak
|
|
76 |
*/
|
|
77 |
void UT_psuidivertnotehandler::t_memleak()
|
|
78 |
{
|
|
79 |
|
|
80 |
}
|
|
81 |
|
|
82 |
/*!
|
|
83 |
UT_psuidivertnotehandler::t_construction
|
|
84 |
*/
|
|
85 |
void UT_psuidivertnotehandler::t_construction()
|
|
86 |
{
|
|
87 |
expect("QObject::connect").times(4);
|
|
88 |
CPsetContainer psetContainer;
|
|
89 |
PSetCallDivertingWrapper *mockDivertWrapper = new PSetCallDivertingWrapper(psetContainer,this);
|
|
90 |
PsUiDivertNoteHandler *divertHandler = new PsUiDivertNoteHandler(*mockDivertWrapper);
|
|
91 |
delete divertHandler;
|
|
92 |
delete mockDivertWrapper;
|
|
93 |
QVERIFY(verify());
|
|
94 |
}
|
|
95 |
|
|
96 |
void UT_psuidivertnotehandler::t_handleDivertingChanged()
|
|
97 |
{
|
|
98 |
CPsetContainer psetContainer;
|
|
99 |
PSetCallDivertingWrapper *mockDivertWrapper = new PSetCallDivertingWrapper(psetContainer,this);
|
|
100 |
PsUiDivertNoteHandler *divertHandler = new PsUiDivertNoteHandler(*mockDivertWrapper);
|
|
101 |
|
|
102 |
// Divert activated, plural false
|
|
103 |
PSCallDivertingCommand testCommand;
|
|
104 |
testCommand.iStatus = DivertingStatusActive;
|
|
105 |
expect("PsUiNotes::showGlobalNotificationDialog");
|
|
106 |
divertHandler->handleDivertingChanged(testCommand, false);
|
|
107 |
QVERIFY(verify());
|
|
108 |
|
|
109 |
// Divert activated, plural true
|
|
110 |
testCommand.iStatus = DivertingStatusActive;
|
|
111 |
expect("PsUiNotes::showGlobalNotificationDialog");
|
|
112 |
divertHandler->handleDivertingChanged(testCommand, true);
|
|
113 |
QVERIFY(verify());
|
|
114 |
|
|
115 |
// Divert deactivated, plural false
|
|
116 |
testCommand.iStatus = DivertingStatusInactive;
|
|
117 |
expect("PsUiNotes::showGlobalNotificationDialog");
|
|
118 |
divertHandler->handleDivertingChanged(testCommand, false);
|
|
119 |
QVERIFY(verify());
|
|
120 |
|
|
121 |
// Divert deactivated, plural true
|
|
122 |
testCommand.iStatus = DivertingStatusInactive;
|
|
123 |
expect("PsUiNotes::showGlobalNotificationDialog");
|
|
124 |
divertHandler->handleDivertingChanged(testCommand, true);
|
|
125 |
QVERIFY(verify());
|
|
126 |
|
|
127 |
// Divert status unknown
|
|
128 |
testCommand.iStatus = DivertingStatusUnknown;
|
|
129 |
expect("PsUiNotes::showGlobalNotificationDialog");
|
|
130 |
divertHandler->handleDivertingChanged(testCommand, true);
|
|
131 |
QVERIFY(verify());
|
|
132 |
|
|
133 |
delete divertHandler;
|
|
134 |
delete mockDivertWrapper;
|
|
135 |
}
|
|
136 |
|
|
137 |
void UT_psuidivertnotehandler::t_handleDivertingStatus()
|
|
138 |
{
|
|
139 |
CPsetContainer psetContainer;
|
|
140 |
PSetCallDivertingWrapper *mockDivertWrapper = new PSetCallDivertingWrapper(psetContainer,this);
|
|
141 |
PsUiDivertNoteHandler *divertHandler = new PsUiDivertNoteHandler(*mockDivertWrapper);
|
|
142 |
QList<PSCallDivertingStatus*> divertList;
|
|
143 |
|
|
144 |
expect("PsUiNotes::showCallDivertDetails").with(divertList);
|
|
145 |
divertHandler->handleDivertingStatus(divertList,false);
|
|
146 |
|
|
147 |
QVERIFY(verify());
|
|
148 |
delete divertHandler;
|
|
149 |
delete mockDivertWrapper;
|
|
150 |
}
|
|
151 |
|
|
152 |
void UT_psuidivertnotehandler::t_handleDivertingError()
|
|
153 |
{
|
|
154 |
CPsetContainer psetContainer;
|
|
155 |
PSetCallDivertingWrapper *mockDivertWrapper = new PSetCallDivertingWrapper(psetContainer,this);
|
|
156 |
PsUiDivertNoteHandler *divertHandler = new PsUiDivertNoteHandler(*mockDivertWrapper);
|
|
157 |
int errorCode = -1;
|
|
158 |
expect("PsUiNotes::cancelNote");
|
|
159 |
expect("PsUiNotes::showGlobalErrorNote");
|
|
160 |
divertHandler->handleDivertingError(errorCode);
|
|
161 |
|
|
162 |
QVERIFY(verify());
|
|
163 |
delete divertHandler;
|
|
164 |
delete mockDivertWrapper;
|
|
165 |
}
|
|
166 |
|
|
167 |
void UT_psuidivertnotehandler::t_handleCFRequesting()
|
|
168 |
{
|
|
169 |
CPsetContainer psetContainer;
|
|
170 |
PSetCallDivertingWrapper *mockDivertWrapper = new PSetCallDivertingWrapper(psetContainer,this);
|
|
171 |
PsUiDivertNoteHandler *divertHandler = new PsUiDivertNoteHandler(*mockDivertWrapper);
|
|
172 |
|
|
173 |
bool ongoing = true;
|
|
174 |
bool interrupted = false;
|
|
175 |
expect("PsUiNotes::showGlobalProgressNote");
|
|
176 |
divertHandler->handleCFRequesting(ongoing,interrupted);
|
|
177 |
QVERIFY(verify());
|
|
178 |
|
|
179 |
ongoing = false;
|
|
180 |
interrupted = true;
|
|
181 |
expect("PsUiNotes::cancelNote").times(2);
|
|
182 |
divertHandler->handleCFRequesting(ongoing,interrupted);
|
|
183 |
QVERIFY(verify());
|
|
184 |
|
|
185 |
ongoing = false;
|
|
186 |
interrupted = false;
|
|
187 |
expect("PsUiNotes::cancelNote");
|
|
188 |
divertHandler->handleCFRequesting(ongoing,interrupted);
|
|
189 |
QVERIFY(verify());
|
|
190 |
|
|
191 |
delete divertHandler;
|
|
192 |
delete mockDivertWrapper;
|
|
193 |
}
|
|
194 |
|
|
195 |
QTEST_MAIN_S60(UT_psuidivertnotehandler)
|