mmshplugins/mmshaoplugin/tsrc/ut_aoplugin/src/ut_musaocalleventmonitor.cpp
changeset 22 496ad160a278
equal deleted inserted replaced
15:ccd8e69b5392 22:496ad160a278
       
     1 /*
       
     2 * Copyright (c) 2005-2006 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:  Monitor that observes the status of the current CS call
       
    15 *
       
    16 */
       
    17 
       
    18 #include "ut_musaocalleventmonitor.h"
       
    19 #include "musaocalleventmonitor.h"
       
    20 #include "mussesseioninformationapi.h"
       
    21 
       
    22 /*
       
    23 #include "muscallmonitor.h"
       
    24 #include "muscalleventmonitor.h"
       
    25 #include "musaoplugin.h"
       
    26 #include "ut_muscalleventmonitor.h"
       
    27 #include "mussesseioninformationapi.h"
       
    28 */
       
    29 
       
    30 #include <etelmm.h>
       
    31 #include <etel.h>
       
    32 #include <digia/eunit/eunitmacros.h>
       
    33 #include <e32property.h>
       
    34 
       
    35 
       
    36 #pragma warn_illtokenpasting off
       
    37 
       
    38 _LIT( KEmptyTelNumber, "");
       
    39 
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // Symbian two-phase constructor.
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 UT_CMusAoCallEventMonitor* UT_CMusAoCallEventMonitor::NewLC()
       
    46     {    
       
    47     UT_CMusAoCallEventMonitor* self = new (ELeave) UT_CMusAoCallEventMonitor();
       
    48     CleanupStack::PushL( self );
       
    49     self->ConstructL();    
       
    50     return self;
       
    51     }
       
    52 
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // Symbian second-phase constructor.
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 void UT_CMusAoCallEventMonitor::ConstructL()
       
    59     {
       
    60     CEUnitTestSuiteClass::ConstructL();
       
    61     }
       
    62 
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 void UT_CMusAoCallEventMonitor::CallConnectedL( const TDesC& /*aTelNumber*/,
       
    69 												TBool /*aIsSipUri*/ )
       
    70     {
       
    71     iCallConnected = ETrue;
       
    72     }
       
    73     
       
    74     
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 void UT_CMusAoCallEventMonitor::CallHoldL( const TDesC& /*aTelNumber*/,
       
    80 										   TBool /*aIsSipUri*/ )
       
    81     {
       
    82     iCallHold = ETrue;
       
    83     }
       
    84     
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 void UT_CMusAoCallEventMonitor::ConferenceCallL()
       
    91     {
       
    92     iConferenceCall = ETrue;
       
    93     }
       
    94     
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 void UT_CMusAoCallEventMonitor::NoActiveCallL()
       
   101     {
       
   102     iNoActiveCall = ETrue;
       
   103     }
       
   104 
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // C++ constructor.
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 UT_CMusAoCallEventMonitor::UT_CMusAoCallEventMonitor() 
       
   111     : CEUnitTestSuiteClass()
       
   112     {
       
   113     // nothing
       
   114     }
       
   115 
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // C++ destructor.
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 UT_CMusAoCallEventMonitor::~UT_CMusAoCallEventMonitor()
       
   122     {
       
   123     }
       
   124 
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 void UT_CMusAoCallEventMonitor::UT_ConnectedCallCountLL()
       
   131     {
       
   132     iMonitor->iCallCount = 2;
       
   133     iMonitor->ConnectedCallCountL();
       
   134     EUNIT_ASSERT_EQUALS( iMonitor->ConnectedCallCountL(), 2);
       
   135     }
       
   136     
       
   137     
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 // -----------------------------------------------------------------------------
       
   141 //
       
   142 void UT_CMusAoCallEventMonitor::UT_RunLL()
       
   143     {    
       
   144     ResetObserverFlags();
       
   145     iMonitor->RunL();
       
   146     iMonitor->Cancel();
       
   147     EUNIT_ASSERT( iNoActiveCall );
       
   148     }
       
   149 
       
   150 
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 void UT_CMusAoCallEventMonitor::UT_ExamineEventLL()
       
   156     {
       
   157 
       
   158     ResetObserverFlags();
       
   159     iMonitor->ExamineEventL( NMusSessionInformationApi::ENoCall );
       
   160     EUNIT_ASSERT( iNoActiveCall )
       
   161 
       
   162     ResetObserverFlags();
       
   163     iMonitor->ExamineEventL( NMusSessionInformationApi::EConferenceCall );
       
   164     EUNIT_ASSERT( iConferenceCall )
       
   165 
       
   166    // Without telephony number
       
   167     ResetObserverFlags();
       
   168     iMonitor->ExamineEventL( NMusSessionInformationApi::ECallConnected );
       
   169     EUNIT_ASSERT( iNoActiveCall )
       
   170 
       
   171     ResetObserverFlags();
       
   172     iMonitor->ExamineEventL( NMusSessionInformationApi::ECallHold );
       
   173     EUNIT_ASSERT( iNoActiveCall )
       
   174 
       
   175 
       
   176     // 6. telephone number
       
   177     RProperty::Define( NMusSessionInformationApi::KCategoryUid,
       
   178                        NMusSessionInformationApi::KMusTelNumber,
       
   179                        RProperty::EText,
       
   180                        0 );
       
   181     User::LeaveIfError( RProperty::Set(
       
   182                         NMusSessionInformationApi::KCategoryUid,
       
   183                         NMusSessionInformationApi::KMusTelNumber,
       
   184                         KEmptyTelNumber ) );
       
   185 
       
   186 
       
   187     // With telephony number
       
   188     ResetObserverFlags();
       
   189     iMonitor->ExamineEventL( NMusSessionInformationApi::ECallConnected );
       
   190     EUNIT_ASSERT( iCallConnected )
       
   191 
       
   192     ResetObserverFlags();
       
   193     iMonitor->ExamineEventL( NMusSessionInformationApi::ECallHold );
       
   194     EUNIT_ASSERT( iCallHold )
       
   195 
       
   196     // 6. telephone number
       
   197     RProperty::Delete( NMusSessionInformationApi::KCategoryUid,
       
   198                        NMusSessionInformationApi::KMusTelNumber );
       
   199 
       
   200     RProperty::Delete( NMusSessionInformationApi::KCategoryUid,
       
   201                        NMusSessionInformationApi::KMusCallCount );
       
   202      
       
   203 
       
   204     // 7. call count
       
   205     RProperty::Define( NMusSessionInformationApi::KCategoryUid,
       
   206                        NMusSessionInformationApi::KMusCallCount,
       
   207                        RProperty::EInt,
       
   208                        0 );
       
   209     ResetObserverFlags();
       
   210     iMonitor->ExamineEventL( KErrNotFound );
       
   211     EUNIT_ASSERT( iNoActiveCall ); 
       
   212 
       
   213     // 7. call count
       
   214     RProperty::Delete( NMusSessionInformationApi::KCategoryUid,
       
   215                        NMusSessionInformationApi::KMusCallCount );
       
   216     
       
   217     }
       
   218 
       
   219 
       
   220 // -----------------------------------------------------------------------------
       
   221 //
       
   222 // -----------------------------------------------------------------------------
       
   223 //
       
   224 void UT_CMusAoCallEventMonitor::SetupL()
       
   225     {    
       
   226     RMobilePhone phone;
       
   227     iMonitor = CMusAoCallEventMonitor::NewL( *this );
       
   228     iMonitor->Cancel();
       
   229 
       
   230     
       
   231     }
       
   232 
       
   233 
       
   234 // -----------------------------------------------------------------------------
       
   235 //
       
   236 // -----------------------------------------------------------------------------
       
   237 //
       
   238 void UT_CMusAoCallEventMonitor::Teardown()
       
   239     {    
       
   240     delete iMonitor;    
       
   241     }
       
   242 
       
   243 
       
   244 // -----------------------------------------------------------------------------
       
   245 //
       
   246 // -----------------------------------------------------------------------------
       
   247 //
       
   248 void UT_CMusAoCallEventMonitor::ResetObserverFlags()
       
   249     {
       
   250     iCallConnected = EFalse; 
       
   251     iCallHold = EFalse; 
       
   252     iConferenceCall = EFalse; 
       
   253     iNoActiveCall = EFalse; 
       
   254     }
       
   255 
       
   256 
       
   257 // test table
       
   258 
       
   259 EUNIT_BEGIN_TEST_TABLE(
       
   260     UT_CMusAoCallEventMonitor,
       
   261     "UT_CMusAoCallEventMonitor",
       
   262     "UNIT" )
       
   263 
       
   264 EUNIT_TEST(
       
   265     "UT_ConnectedCallCountL",
       
   266     "CMusCallEventMonitor",
       
   267     "ConnectedCallCountL",
       
   268     "FUNCTIONALITY",
       
   269     SetupL, UT_ConnectedCallCountLL, Teardown)
       
   270 
       
   271 EUNIT_TEST(
       
   272     "UT_RunL",
       
   273     "CMusCallEventMonitor",
       
   274     "RunL",
       
   275     "FUNCTIONALITY",
       
   276     SetupL, UT_RunLL, Teardown)
       
   277 
       
   278 EUNIT_TEST(
       
   279     "UT_ExamineEventL",
       
   280     "CMusCallEventMonitor",
       
   281     "ExamineEventL",
       
   282     "FUNCTIONALITY",
       
   283     SetupL, UT_ExamineEventLL, Teardown)
       
   284 
       
   285 
       
   286 EUNIT_END_TEST_TABLE