mmshplugins/mmshaoplugin/tsrc/ut_aoplugin/src/ut_muscallconferenceeventmonitor.cpp
changeset 0 f0cf47e981f9
child 31 33a5d2bbf6fc
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 "ut_muscallconferenceeventmonitor.h"
       
    21 #include "muscallconferenceeventmonitor.h"
       
    22 #include "e32property.h"
       
    23 //#include "muscommonstubs.h" 
       
    24 
       
    25 //  SYSTEM INCLUDES
       
    26 #include <digia/eunit/eunitmacros.h>
       
    27 
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 UT_CMusCallConferenceEventMonitor* UT_CMusCallConferenceEventMonitor::NewL()
       
    34     {
       
    35     UT_CMusCallConferenceEventMonitor* self = UT_CMusCallConferenceEventMonitor::NewLC();
       
    36     CleanupStack::Pop( self );
       
    37     return self;
       
    38     }
       
    39 
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 UT_CMusCallConferenceEventMonitor* UT_CMusCallConferenceEventMonitor::NewLC()
       
    46     {
       
    47     UT_CMusCallConferenceEventMonitor* self = new( ELeave ) UT_CMusCallConferenceEventMonitor();
       
    48     CleanupStack::PushL( self );
       
    49     self->ConstructL();
       
    50     return self;
       
    51     }
       
    52 
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 UT_CMusCallConferenceEventMonitor::~UT_CMusCallConferenceEventMonitor()
       
    59     {
       
    60     // NOP
       
    61     }
       
    62 
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // Default constructor
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 UT_CMusCallConferenceEventMonitor::UT_CMusCallConferenceEventMonitor()
       
    69     {
       
    70     // NOP
       
    71     }
       
    72 
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // Second phase construct
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 void UT_CMusCallConferenceEventMonitor::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 // -----------------------------------------------------------------------------
       
    87 //
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 void UT_CMusCallConferenceEventMonitor::SetupL()
       
    91     {  
       
    92     
       
    93     //setup
       
    94     /*
       
    95     RProperty::Set( NMusSessionInformationApi::KCategoryUid,
       
    96                     NMusSessionInformationApi::KMusCallCount,
       
    97                     1 );
       
    98     */
       
    99     RProperty::Set( NMusSessionInformationApi::KCategoryUid,
       
   100                      NMusSessionInformationApi::KMusCallEvent,
       
   101                      0 );
       
   102     
       
   103     iConferenceCallEventMonitor = 
       
   104             CMusCallConferenceEventMonitor::NewL( iMobilePhone,
       
   105                                                   iLine ,
       
   106                                                   iCallMonitorArray );
       
   107     
       
   108     }
       
   109 
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 void UT_CMusCallConferenceEventMonitor::Teardown()
       
   116     {
       
   117     delete iConferenceCallEventMonitor;
       
   118     PropertyHelper::Close();
       
   119     iMobilePhone.Close();
       
   120     iLine.Close();
       
   121     iCallMonitorArray.ResetAndDestroy();
       
   122     
       
   123     
       
   124     }
       
   125 
       
   126 
       
   127 
       
   128 // TEST CASES
       
   129 
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 void UT_CMusCallConferenceEventMonitor::UT_CMusCallConferenceEventMonitor_NewLL()
       
   136     {
       
   137     EUNIT_ASSERT( iConferenceCallEventMonitor )
       
   138     }
       
   139 
       
   140  
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 // -----------------------------------------------------------------------------
       
   144 //
       
   145 void UT_CMusCallConferenceEventMonitor::UT_CMusCallConferenceEventMonitor_RunLL()
       
   146     {
       
   147     TInt val = RMobileConferenceCall::EConferenceCallRemoved ;
       
   148     EUNIT_ASSERT( iConferenceCallEventMonitor );
       
   149 
       
   150     RTelHelper::SetConfEvent( RMobileConferenceCall::EConferenceCallRemoved );
       
   151     iConferenceCallEventMonitor->SetStateL( NMusSessionInformationApi::ENoCall );                               
       
   152     iConferenceCallEventMonitor->Cancel(); // Cancel the active object            
       
   153     iConferenceCallEventMonitor->RunL();
       
   154     RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   155                      NMusSessionInformationApi::KMusCallEvent,
       
   156                      val );
       
   157     EUNIT_ASSERT( val==NMusSessionInformationApi::ENoCall);
       
   158 
       
   159     RTelHelper::SetConfEvent ( RMobileConferenceCall::EConferenceBuilt);
       
   160     iConferenceCallEventMonitor->Cancel(); // Cancel the active object    
       
   161     iConferenceCallEventMonitor->RunL();
       
   162     RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   163                      NMusSessionInformationApi::KMusCallEvent,
       
   164                      val );
       
   165     EUNIT_ASSERT( val==NMusSessionInformationApi::EConferenceCall);
       
   166 
       
   167     RTelHelper::SetConfEvent( RMobileConferenceCall::EConferenceTerminated );
       
   168     iConferenceCallEventMonitor->SetStateL( NMusSessionInformationApi::ENoCall );                               
       
   169     iConferenceCallEventMonitor->Cancel(); // Cancel the active object    
       
   170     iConferenceCallEventMonitor->RunL();
       
   171     RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   172                      NMusSessionInformationApi::KMusCallEvent,
       
   173                      val );
       
   174     EUNIT_ASSERT( val==NMusSessionInformationApi::ENoCall);
       
   175 
       
   176     RTelHelper::SetConfEvent( RMobileConferenceCall::EConferenceSwapped );
       
   177     iConferenceCallEventMonitor->SetStateL( NMusSessionInformationApi::ENoCall );                               
       
   178     iConferenceCallEventMonitor->Cancel(); // Cancel the active object    
       
   179     iConferenceCallEventMonitor->RunL();
       
   180     RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   181                      NMusSessionInformationApi::KMusCallEvent,
       
   182                      val );
       
   183     EUNIT_ASSERT( val==NMusSessionInformationApi::EConferenceCall);
       
   184 
       
   185     RTelHelper::SetConfEvent( RMobileConferenceCall::EConferenceSplit);
       
   186     iConferenceCallEventMonitor->SetStateL( NMusSessionInformationApi::ENoCall );                               
       
   187     iConferenceCallEventMonitor->Cancel(); // Cancel the active object    
       
   188     iConferenceCallEventMonitor->RunL();
       
   189     RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   190                      NMusSessionInformationApi::KMusCallEvent,
       
   191                      val );
       
   192     EUNIT_ASSERT( val==NMusSessionInformationApi::EConferenceCall );
       
   193     
       
   194     RTelHelper::SetConfEvent( (RMobileConferenceCall::TMobileConferenceEvent)152090 );
       
   195     iConferenceCallEventMonitor->SetStateL( NMusSessionInformationApi::ENoCall );                               
       
   196     iConferenceCallEventMonitor->SetStateL( NMusSessionInformationApi::ENoCall );                               
       
   197     iConferenceCallEventMonitor->Cancel(); // Cancel the active object    
       
   198     iConferenceCallEventMonitor->RunL();
       
   199     RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   200                      NMusSessionInformationApi::KMusCallEvent,
       
   201                      val );
       
   202     EUNIT_ASSERT( val==NMusSessionInformationApi::ENoCall );
       
   203     }
       
   204 
       
   205 
       
   206 // -----------------------------------------------------------------------------
       
   207 //
       
   208 // -----------------------------------------------------------------------------
       
   209 //
       
   210 void UT_CMusCallConferenceEventMonitor::UT_CMusCallConferenceEventMonitor_DoCancelL()
       
   211     {
       
   212     EUNIT_ASSERT( iConferenceCallEventMonitor );
       
   213     iConferenceCallEventMonitor->DoCancel();
       
   214     EUNIT_ASSERT( RTelHelper::GetCalledFunction() == 
       
   215                                         RTelSubSessionBase::ECancelAsyncRequest )
       
   216     }
       
   217 
       
   218 
       
   219 // -----------------------------------------------------------------------------
       
   220 //
       
   221 // -----------------------------------------------------------------------------
       
   222 //
       
   223 void UT_CMusCallConferenceEventMonitor::UT_CMusCallConferenceEventMonitor_RunErrorL()
       
   224     {
       
   225     EUNIT_ASSERT( iConferenceCallEventMonitor );
       
   226     TInt error = KErrNotFound;
       
   227     iConferenceCallEventMonitor->RunError(error);
       
   228     }
       
   229 
       
   230 // -----------------------------------------------------------------------------
       
   231 //
       
   232 // -----------------------------------------------------------------------------
       
   233 //
       
   234 void UT_CMusCallConferenceEventMonitor::UT_CMusCallConferenceEventMonitor_MonitorCallLL()
       
   235     {
       
   236     EUNIT_ASSERT( iConferenceCallEventMonitor );
       
   237     EUNIT_ASSERT( iConferenceCallEventMonitor->iCallMonitorArray.Count() == 0 );
       
   238     
       
   239     iConferenceCallEventMonitor->MonitorCallL();
       
   240     EUNIT_ASSERT( iConferenceCallEventMonitor->iCallMonitorArray.Count() == 0 );
       
   241     
       
   242     RTelHelper::SetCallStatus( RMobileCall::EStatusConnected );
       
   243     iConferenceCallEventMonitor->MonitorCallL();
       
   244     EUNIT_ASSERT( iConferenceCallEventMonitor->iCallMonitorArray.Count() == 0 );
       
   245     
       
   246     }
       
   247 
       
   248 
       
   249 
       
   250 
       
   251 //  TEST TABLE
       
   252 
       
   253 EUNIT_BEGIN_TEST_TABLE(
       
   254     UT_CMusCallConferenceEventMonitor,
       
   255     "UT_CMusCallConferenceEventMonitor",
       
   256     "UNIT" )
       
   257 
       
   258 EUNIT_TEST(
       
   259     "NewL - test ",
       
   260     "CMusCallConferenceEventMonitor",
       
   261     "NewL",
       
   262     "FUNCTIONALITY",
       
   263     SetupL, UT_CMusCallConferenceEventMonitor_NewLL, Teardown)
       
   264 
       
   265 EUNIT_TEST(
       
   266     "RunL - test ",
       
   267     "CMusCallConferenceEventMonitor",
       
   268     "RunL",
       
   269     "FUNCTIONALITY",
       
   270     SetupL, UT_CMusCallConferenceEventMonitor_RunLL, Teardown)
       
   271 
       
   272 EUNIT_TEST(
       
   273     "DoCancel - test ",
       
   274     "CMusCallConferenceEventMonitor",
       
   275     "DoCancel",
       
   276     "FUNCTIONALITY",
       
   277     SetupL, UT_CMusCallConferenceEventMonitor_DoCancelL, Teardown)
       
   278 
       
   279 EUNIT_TEST(
       
   280     "RunError - test ",
       
   281     "CMusCallConferenceEventMonitor",
       
   282     "RunError",
       
   283     "FUNCTIONALITY",
       
   284     SetupL, UT_CMusCallConferenceEventMonitor_RunErrorL, Teardown)
       
   285 
       
   286 EUNIT_TEST(
       
   287     "MonitorCallL - test ",
       
   288     "CMusCallConferenceEventMonitor",
       
   289     "MonitorCallL",
       
   290     "FUNCTIONALITY",
       
   291     SetupL, UT_CMusCallConferenceEventMonitor_MonitorCallLL, Teardown)
       
   292     
       
   293 EUNIT_END_TEST_TABLE
       
   294 
       
   295 //  END OF FILE
       
   296 
       
   297