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