mmshplugins/mmshaoplugin/tsrc/ut_aoplugin/src/ut_muscalleventmonitor.cpp
changeset 0 f0cf47e981f9
child 32 73a1feb507fb
equal deleted inserted replaced
-1:000000000000 0:f0cf47e981f9
       
     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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  INTERNAL INCLUDES
       
    20 #include "e32property.h"
       
    21 #include "ut_muscalleventmonitor.h"
       
    22 #include "muscalleventmonitor.h"
       
    23 
       
    24 
       
    25 //  SYSTEM INCLUDES
       
    26 #include <digia/eunit/eunitmacros.h>
       
    27 
       
    28 _LIT(KTelNo,"1234");
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 UT_CMusCallEventMonitor* UT_CMusCallEventMonitor::NewL()
       
    35     {
       
    36     UT_CMusCallEventMonitor* self = UT_CMusCallEventMonitor::NewLC();
       
    37     CleanupStack::Pop( self );
       
    38     return self;
       
    39     }
       
    40 
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 UT_CMusCallEventMonitor* UT_CMusCallEventMonitor::NewLC()
       
    47     {
       
    48     UT_CMusCallEventMonitor* self = new( ELeave ) UT_CMusCallEventMonitor();
       
    49     CleanupStack::PushL( self );
       
    50     self->ConstructL();
       
    51     return self;
       
    52     }
       
    53 
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 UT_CMusCallEventMonitor::~UT_CMusCallEventMonitor()
       
    60     {
       
    61     }
       
    62 
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // Default constructor
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 UT_CMusCallEventMonitor::UT_CMusCallEventMonitor()
       
    69     {
       
    70     // NOP
       
    71     }
       
    72 
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // Second phase construct
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 void UT_CMusCallEventMonitor::ConstructL()
       
    79     {
       
    80     // The ConstructL from the base class CEUnitTestSuiteClass must be called.
       
    81     // It generates the test case table.
       
    82     CEUnitTestSuiteClass::ConstructL();
       
    83     }
       
    84     
       
    85 // -----------------------------------------------------------------------------
       
    86 // UT_CMusCallEventMonitor::NotifyCallStateChanged() 
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 void UT_CMusCallEventMonitor::NotifyCallStateChanged(
       
    90 									NMusSessionInformationApi::TMusCallEvent /*aVal*/,
       
    91 									TName& /*aCallName*/ )
       
    92     {          
       
    93     }
       
    94     
       
    95     
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 void UT_CMusCallEventMonitor::SetupL()
       
   102     {    
       
   103     
       
   104     //setup
       
   105     /*
       
   106     RProperty::Set( NMusSessionInformationApi::KCategoryUid,
       
   107                     NMusSessionInformationApi::KMusCallCount,
       
   108                     1 );
       
   109     */
       
   110     RProperty::Set( NMusSessionInformationApi::KCategoryUid,
       
   111                      NMusSessionInformationApi::KMusCallEvent,
       
   112                      0 );
       
   113     
       
   114     iCallEventMonitor = CMusCallEventMonitor::NewL( iCall, *this );
       
   115     
       
   116     }
       
   117 
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 void UT_CMusCallEventMonitor::Teardown()
       
   124     {
       
   125     delete iCallEventMonitor;    
       
   126     PropertyHelper::Close();
       
   127     iCall.Close();
       
   128     }
       
   129 
       
   130 
       
   131 
       
   132 // TEST CASES
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 void UT_CMusCallEventMonitor::UT_CMusCallEventMonitor_RunLL()
       
   139     {
       
   140     /* Test configurations */
       
   141     iCallEventMonitor->iRemoteCallEvent = RMobileCall::ERemoteResume;
       
   142     iCallEventMonitor->iLocalCallEvent = RMobileCall::ELocalResume;
       
   143     
       
   144     // Test : Local is on hold
       
   145     TInt val = RMobileCall::EStatusUnknown;
       
   146     EUNIT_ASSERT( iCallEventMonitor );
       
   147     iCallEventMonitor->Cancel();
       
   148     RTelHelper::SetCallEvent( RMobileCall::ELocalHold );
       
   149     if ( RProperty::Set( NMusSessionInformationApi::KCategoryUid,
       
   150                      NMusSessionInformationApi::KMusCallCount,
       
   151                      1 ) != KErrNone )
       
   152         {
       
   153         User::Leave( KErrNoMemory );
       
   154         }
       
   155     
       
   156     iCallEventMonitor->RunL();
       
   157     RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   158                      NMusSessionInformationApi::KMusCallEvent,
       
   159                      val );
       
   160     EUNIT_ASSERT( val==NMusSessionInformationApi::ECallHold);
       
   161 
       
   162 	// Test : Local resumed from hold
       
   163     iCallEventMonitor->Cancel();
       
   164     RTelHelper::SetCallEvent( RMobileCall::ELocalResume );
       
   165     iCallEventMonitor->RunL();
       
   166     RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   167                      NMusSessionInformationApi::KMusCallEvent,
       
   168                      val );
       
   169     EUNIT_ASSERT( val==NMusSessionInformationApi::ECallConnected);
       
   170 
       
   171 	// Test : Local Transfered. Means no call.
       
   172     iCallEventMonitor->Cancel();
       
   173     RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   174                     NMusSessionInformationApi::KMusCallEvent,
       
   175                     val );
       
   176     TInt callEnt = val;
       
   177     RTelHelper::SetCallEvent( RMobileCall::ELocalTransfer );    
       
   178     iCallEventMonitor->RunL();
       
   179     RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   180                      NMusSessionInformationApi::KMusCallEvent,
       
   181                      val );
       
   182                      
       
   183     EUNIT_ASSERT( callEnt==val );
       
   184     
       
   185 	// Test : Remote is on hold
       
   186     iCallEventMonitor->Cancel();
       
   187     RTelHelper::SetCallEvent( RMobileCall::ERemoteHold );
       
   188     iCallEventMonitor->RunL();
       
   189     RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   190                      NMusSessionInformationApi::KMusCallEvent,
       
   191                      val );
       
   192     EUNIT_ASSERT( val==NMusSessionInformationApi::ECallHold);
       
   193 
       
   194     // Test : Remote resumed
       
   195     iCallEventMonitor->Cancel();
       
   196     RTelHelper::SetCallEvent( RMobileCall::ERemoteResume );
       
   197     iCallEventMonitor->RunL();
       
   198     RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   199                      NMusSessionInformationApi::KMusCallEvent,
       
   200                      val );
       
   201     EUNIT_ASSERT( val==NMusSessionInformationApi::ECallConnected);
       
   202 
       
   203     /*. When call goes to Nocall state , call info not needed to
       
   204         to be checked.Bug exist in both 5.0 and MCL . Should be fixed in
       
   205         both the branches. Else this unit case will fail 19.12.2008
       
   206      
       
   207 	 //Test : Remote terminated
       
   208     iCallEventMonitor->Cancel();
       
   209     RTelHelper::SetCallEvent( RMobileCall::ERemoteTerminated );
       
   210     iCallEventMonitor->RunL();
       
   211     RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   212                      NMusSessionInformationApi::KMusCallEvent,
       
   213                      val );
       
   214     EUNIT_ASSERT( val==NMusSessionInformationApi::ENoCall);
       
   215      */   
       
   216     
       
   217 	// Test : Remote is on conference
       
   218     iCallEventMonitor->Cancel();
       
   219     RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   220                     NMusSessionInformationApi::KMusCallEvent,
       
   221                     val );
       
   222     callEnt = val;
       
   223     RTelHelper::SetCallEvent( RMobileCall::ERemoteConferenceCreate );
       
   224     iCallEventMonitor->RunL();
       
   225     RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   226                      NMusSessionInformationApi::KMusCallEvent,
       
   227                      val );
       
   228     EUNIT_ASSERT( callEnt==val );
       
   229 
       
   230 	// Test : Remote conference transfer
       
   231     iCallEventMonitor->Cancel();
       
   232     RTelHelper::SetCallEvent( RMobileCall::ERemoteTransferring );
       
   233     iCallEventMonitor->RunL();
       
   234     RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   235                      NMusSessionInformationApi::KMusCallEvent,
       
   236                      val );
       
   237     EUNIT_ASSERT( val==callEnt );
       
   238 
       
   239     // remote is connected state and local resume
       
   240     iCallEventMonitor->Cancel();
       
   241     RTelHelper::SetCallEvent( RMobileCall::ELocalResume );
       
   242     iCallEventMonitor->iRemoteCallEvent = RMobileCall::ERemoteResume;
       
   243     iCallEventMonitor->RunL();
       
   244     RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   245                      NMusSessionInformationApi::KMusCallEvent,
       
   246                      val );
       
   247     EUNIT_ASSERT( val==NMusSessionInformationApi::ECallConnected);  
       
   248 
       
   249     // remote is in hold state and local resume.
       
   250     iCallEventMonitor->Cancel();
       
   251     RTelHelper::SetCallEvent( RMobileCall::ELocalResume );
       
   252     iCallEventMonitor->iRemoteCallEvent = RMobileCall::ERemoteResume;
       
   253     iCallEventMonitor->RunL();
       
   254     RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   255                      NMusSessionInformationApi::KMusCallEvent,
       
   256                      val );
       
   257     EUNIT_ASSERT( val==NMusSessionInformationApi::ECallConnected );
       
   258 
       
   259     //local hold state and remote resumed
       
   260     iCallEventMonitor->Cancel();
       
   261     RTelHelper::SetCallEvent( RMobileCall::ERemoteResume );
       
   262     iCallEventMonitor->iLocalCallEvent = RMobileCall::ELocalHold;
       
   263     iCallEventMonitor->RunL();
       
   264     RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   265                      NMusSessionInformationApi::KMusCallEvent,
       
   266                      val );
       
   267     EUNIT_ASSERT( val==NMusSessionInformationApi::ECallHold);
       
   268 
       
   269      //local connected state and remote resumed
       
   270     iCallEventMonitor->Cancel();
       
   271     RTelHelper::SetCallEvent( RMobileCall::ERemoteResume );
       
   272     iCallEventMonitor->iLocalCallEvent = RMobileCall::ELocalResume;
       
   273     iCallEventMonitor->RunL();
       
   274     RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   275                      NMusSessionInformationApi::KMusCallEvent,
       
   276                      val );
       
   277     EUNIT_ASSERT( val==NMusSessionInformationApi::ECallConnected);
       
   278     }
       
   279 
       
   280 
       
   281 
       
   282 // -----------------------------------------------------------------------------
       
   283 //
       
   284 // -----------------------------------------------------------------------------
       
   285 //
       
   286 void UT_CMusCallEventMonitor::UT_CMusCallEventMonitor_DoCancelL()
       
   287     {
       
   288     EUNIT_ASSERT( iCallEventMonitor );
       
   289     iCallEventMonitor->DoCancel();
       
   290     EUNIT_ASSERT( RTelHelper::GetCalledFunction() == 
       
   291                                         RTelSubSessionBase::ECancelAsyncRequest )
       
   292     }
       
   293 
       
   294 
       
   295 // -----------------------------------------------------------------------------
       
   296 //
       
   297 // -----------------------------------------------------------------------------
       
   298 //
       
   299 void UT_CMusCallEventMonitor::UT_CMusCallEventMonitor_RunErrorL()
       
   300     {
       
   301     EUNIT_ASSERT( iCallEventMonitor );
       
   302     TInt error = KErrNotFound;
       
   303     EUNIT_ASSERT_EQUALS(iCallEventMonitor->RunError(error), KErrNone);
       
   304     EUNIT_ASSERT_EQUALS(iCallEventMonitor->RunError(KErrNone), KErrNone);
       
   305     }
       
   306 
       
   307 
       
   308    
       
   309 
       
   310 
       
   311 //  TEST TABLE
       
   312 
       
   313 EUNIT_BEGIN_TEST_TABLE(
       
   314     UT_CMusCallEventMonitor,
       
   315     "UT_CMusCallEventMonitor",
       
   316     "UNIT" )
       
   317 
       
   318 EUNIT_TEST(
       
   319     "RunL - test",
       
   320     "CMusCallStatusMonitor",
       
   321     "RunL",
       
   322     "FUNCTIONALITY",
       
   323     SetupL, UT_CMusCallEventMonitor_RunLL, Teardown)
       
   324 
       
   325 EUNIT_TEST(
       
   326     "DoCancel - test",
       
   327     "CMusCallStatusMonitor",
       
   328     "RunL",
       
   329     "FUNCTIONALITY",
       
   330     SetupL, UT_CMusCallEventMonitor_DoCancelL, Teardown)
       
   331 
       
   332 EUNIT_TEST(
       
   333     "RunError - test",
       
   334     "CMusCallStatusMonitor",
       
   335     "RunErrorL",
       
   336     "FUNCTIONALITY",
       
   337     SetupL, UT_CMusCallEventMonitor_RunErrorL, Teardown)
       
   338 
       
   339 EUNIT_END_TEST_TABLE
       
   340 
       
   341 //  END OF FILE
       
   342 
       
   343