mmshplugins/mmshaoplugin/tsrc/ut_aoplugin/src/ut_muscallmonitor.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_muscallmonitor.h"
       
    22 #include "muscallmonitor.h"
       
    23 
       
    24 
       
    25 //  SYSTEM INCLUDES
       
    26 #include <digia/eunit/eunitmacros.h>
       
    27 
       
    28 _LIT(KTelNo,"1234");
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 UT_CMusCallMonitor* UT_CMusCallMonitor::NewL()
       
    35     {
       
    36     UT_CMusCallMonitor* self = UT_CMusCallMonitor::NewLC();
       
    37     CleanupStack::Pop( self );
       
    38     return self;
       
    39     }
       
    40 
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 UT_CMusCallMonitor* UT_CMusCallMonitor::NewLC()
       
    47     {
       
    48     UT_CMusCallMonitor* self = new( ELeave ) UT_CMusCallMonitor();
       
    49     CleanupStack::PushL( self );
       
    50     self->ConstructL();
       
    51     return self;
       
    52     }
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // UT_CMusCallMonitor::NotifyCallStateChanged() 
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 void UT_CMusCallMonitor::NotifyCallStateChanged(
       
    59 									NMusSessionInformationApi::TMusCallEvent /*aVal*/,
       
    60 									TName& /*aCallName*/ )
       
    61     {          
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 UT_CMusCallMonitor::~UT_CMusCallMonitor()
       
    69     {
       
    70     }
       
    71 
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // Default constructor
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 UT_CMusCallMonitor::UT_CMusCallMonitor()
       
    78     {
       
    79     // NOP
       
    80     }
       
    81 
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // Second phase construct
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 void UT_CMusCallMonitor::ConstructL()
       
    88     {
       
    89     // The ConstructL from the base class CEUnitTestSuiteClass must be called.
       
    90     // It generates the test case table.
       
    91     CEUnitTestSuiteClass::ConstructL();
       
    92     }
       
    93     
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 //
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 void UT_CMusCallMonitor::SetupL()
       
   100     {    
       
   101     TName callName = KTelNo();
       
   102     TBool pttCallExist = EFalse;
       
   103     if ( RProperty::Set( NMusSessionInformationApi::KCategoryUid,
       
   104                      NMusSessionInformationApi::KMusCallCount,
       
   105                      0 ) != KErrNone )
       
   106         {
       
   107         User::Leave( KErrNoMemory );
       
   108         }
       
   109     iCallMonitor = CMusCallMonitor::NewL( callName, pttCallExist );
       
   110     }
       
   111 
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 void UT_CMusCallMonitor::Teardown()
       
   118     {
       
   119     delete iCallMonitor;
       
   120     iLine.Close(); 
       
   121     PropertyHelper::Close();
       
   122 
       
   123     }
       
   124 
       
   125 
       
   126 
       
   127 // TEST CASES
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 //
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 void UT_CMusCallMonitor::UT_CMusCallMonitor_StartMonitorLL()
       
   134     {
       
   135 
       
   136     EUNIT_ASSERT( !iCallMonitor->iCallStatusMonitor );
       
   137     EUNIT_ASSERT( !iCallMonitor->iCallEventMonitor );
       
   138     iCallMonitor->StartMonitorL( iLine, *this );
       
   139 
       
   140     EUNIT_ASSERT( iCallMonitor->iCallStatusMonitor );
       
   141     EUNIT_ASSERT( iCallMonitor->iCallEventMonitor );
       
   142 
       
   143     EUNIT_ASSERT_LEAVE( iCallMonitor->StartMonitorL( iLine, *this ) );
       
   144     }
       
   145 
       
   146 
       
   147 
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 // -----------------------------------------------------------------------------
       
   151 //
       
   152 void UT_CMusCallMonitor::UT_CMusCallMonitor_StopMonitorLL()
       
   153     {
       
   154     
       
   155     EUNIT_ASSERT( !iCallMonitor->iCallStatusMonitor );
       
   156     EUNIT_ASSERT( !iCallMonitor->iCallEventMonitor );
       
   157     iCallMonitor->StopMonitor();
       
   158     EUNIT_ASSERT( !iCallMonitor->iCallStatusMonitor );
       
   159     EUNIT_ASSERT( !iCallMonitor->iCallEventMonitor );
       
   160 
       
   161     iCallMonitor->StartMonitorL( iLine, *this );
       
   162 
       
   163     EUNIT_ASSERT( iCallMonitor->iCallStatusMonitor );
       
   164     EUNIT_ASSERT( iCallMonitor->iCallEventMonitor );
       
   165     iCallMonitor->StopMonitor();
       
   166     EUNIT_ASSERT( !iCallMonitor->iCallStatusMonitor );
       
   167     EUNIT_ASSERT( !iCallMonitor->iCallEventMonitor );
       
   168     
       
   169     }
       
   170 
       
   171 
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 // -----------------------------------------------------------------------------
       
   175 //
       
   176 void UT_CMusCallMonitor::UT_CMusCallMonitor_IsEqualL()
       
   177     {
       
   178     TName test = KNullDesC();
       
   179     
       
   180     EUNIT_ASSERT( !iCallMonitor->IsEqual( test ) );
       
   181 
       
   182     test = iCallMonitor->Name();
       
   183     EUNIT_ASSERT( iCallMonitor->IsEqual( test ) );
       
   184 
       
   185     }
       
   186 
       
   187 // -----------------------------------------------------------------------------
       
   188 //
       
   189 // -----------------------------------------------------------------------------
       
   190 //
       
   191 void UT_CMusCallMonitor::UT_CMusCallMonitor_IsMonitoredL()
       
   192     {
       
   193     
       
   194     EUNIT_ASSERT( !iCallMonitor->IsMonitored() );
       
   195     
       
   196     iCallMonitor->StartMonitorL( iLine, *this );
       
   197     EUNIT_ASSERT( iCallMonitor->IsMonitored() );
       
   198     
       
   199     
       
   200     }
       
   201 
       
   202 
       
   203    
       
   204 
       
   205 
       
   206 //  TEST TABLE
       
   207 
       
   208 EUNIT_BEGIN_TEST_TABLE(
       
   209     UT_CMusCallMonitor,
       
   210     "UT_CMusCallMonitor",
       
   211     "UNIT" )
       
   212 
       
   213 EUNIT_TEST(
       
   214     "StartMonitorL - test",
       
   215     "CMusCallStatusMonitor",
       
   216     "StartMonitorL",
       
   217     "FUNCTIONALITY",
       
   218     SetupL, UT_CMusCallMonitor_StartMonitorLL, Teardown)
       
   219 
       
   220 EUNIT_TEST(
       
   221     "StopMonitorL - test",
       
   222     "CMusCallStatusMonitor",
       
   223     "StopMonitorL",
       
   224     "FUNCTIONALITY",
       
   225     SetupL, UT_CMusCallMonitor_StopMonitorLL, Teardown)
       
   226 
       
   227 EUNIT_TEST(
       
   228     "IsEqual - test",
       
   229     "CMusCallStatusMonitor",
       
   230     "IsEqual",
       
   231     "FUNCTIONALITY",
       
   232     SetupL, UT_CMusCallMonitor_IsEqualL, Teardown)
       
   233 
       
   234 EUNIT_TEST(
       
   235     "IsMonitored - test",
       
   236     "CMusCallStatusMonitor",
       
   237     "IsMonitored",
       
   238     "FUNCTIONALITY",
       
   239     SetupL, UT_CMusCallMonitor_IsMonitoredL, Teardown)
       
   240 
       
   241 
       
   242 EUNIT_END_TEST_TABLE
       
   243 
       
   244 //  END OF FILE
       
   245 
       
   246