phonesrv_plat/call_remote_party_information_api/tsrc/src/it_remotepartyinformation.cpp
changeset 0 ff3b6d0fd310
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     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 #include "IT_RemotePartyInformation.h"
       
    19 #include <EUnitMacros.h>
       
    20 #include <EUnitDecorators.h>
       
    21 
       
    22 #include <CCallInformation.h>
       
    23 #include <ccallinfoiter.h>
       
    24 #include <MCallInformationObserver.h>
       
    25 #include <CCallRemotePartyInformation.h>
       
    26 #include <MCallRemotePartyInfo.h>
       
    27 #include <ccallremotepartyinfoiter.h>
       
    28 
       
    29 #include "cdialer.h"
       
    30 
       
    31 //Speaking clock number when calling from NTN network.
       
    32 _LIT (KNumber, "99901");
       
    33 
       
    34 // - Construction -----------------------------------------------------------
       
    35 
       
    36 IT_RemotePartyInformation* IT_RemotePartyInformation::NewL()
       
    37     {
       
    38     IT_RemotePartyInformation* self = IT_RemotePartyInformation::NewLC();
       
    39     CleanupStack::Pop();
       
    40     return self;
       
    41     }
       
    42 
       
    43 IT_RemotePartyInformation* IT_RemotePartyInformation::NewLC()
       
    44     {
       
    45     IT_RemotePartyInformation* self = new( ELeave ) IT_RemotePartyInformation();
       
    46     CleanupStack::PushL( self );
       
    47     self->ConstructL();
       
    48     return self;
       
    49     }
       
    50 
       
    51 IT_RemotePartyInformation::~IT_RemotePartyInformation()
       
    52     {
       
    53     }
       
    54 
       
    55 IT_RemotePartyInformation::IT_RemotePartyInformation()
       
    56     {
       
    57     }
       
    58 
       
    59 void IT_RemotePartyInformation::ConstructL()
       
    60     {
       
    61     CEUnitTestSuiteClass::ConstructL();
       
    62     }
       
    63 
       
    64 // - Test methods -----------------------------------------------------------
       
    65 
       
    66 void IT_RemotePartyInformation::CallInformationChanged()
       
    67     {
       
    68     if( iWait->IsStarted() )
       
    69         {
       
    70         iWait->AsyncStop();
       
    71         }
       
    72     }
       
    73 
       
    74 void IT_RemotePartyInformation::CallRemotePartyInformationChanged()
       
    75     {
       
    76     if( iWait->IsStarted() )
       
    77         {
       
    78         iWait->AsyncStop();
       
    79         }
       
    80     }
       
    81 
       
    82 void IT_RemotePartyInformation::SetupL(  )
       
    83     {    
       
    84     EUNIT_PRINT( _L( "IT_RemotePartyInformation::SetupL in" ));
       
    85     User::LeaveIfError( iTelServer.Connect() );    
       
    86     iCallInfos = CCallInformation::NewL();
       
    87     iRemotePartyInfo = CCallRemotePartyInformation::NewL();
       
    88     iDialer = CDialer::NewL( iTelServer );
       
    89     iWait = new( ELeave )CActiveSchedulerWait();
       
    90     EUNIT_PRINT( _L( "IT_RemotePartyInformation::SetupL out" ));
       
    91     }
       
    92     
       
    93 
       
    94 void IT_RemotePartyInformation::Teardown(  )
       
    95     {
       
    96     EUNIT_PRINT( _L( "IT_RemotePartyInformation::Teardown in" ));
       
    97     delete iWait;    
       
    98     delete iDialer;
       
    99     delete iRemotePartyInfo;
       
   100     delete iCallInfos;
       
   101     iTelServer.Close();
       
   102     EUNIT_PRINT( _L( "IT_RemotePartyInformation::Teardown out" ));
       
   103     }
       
   104     
       
   105 
       
   106 void IT_RemotePartyInformation::TestNoCallsL(  )
       
   107     {    
       
   108     const MCallRemotePartyInfo* remoteInfo = iRemotePartyInfo->GetRemotePartyInformationL( 1 ); 
       
   109     EUNIT_ASSERT( remoteInfo == NULL );
       
   110     
       
   111     }
       
   112 
       
   113 void IT_RemotePartyInformation::TestSingleCallNoContactL(  )
       
   114     {
       
   115     // Listening notification from Call Info API for getting remote party info is not
       
   116     // good idea since remote party info readiness is not tied to a call state change.
       
   117     EUNIT_PRINT( _L( "IT_RemotePartyInformation::TestSingleCallNoContactL in" ));
       
   118     iRemotePartyInfo->NotifyChanges( *this );
       
   119     iDialer->Dial(KNumber);    
       
   120     iWait->Start(); // Wait for notification from Remote Party Info API.    
       
   121     iRemotePartyInfo->CancelNotification();        
       
   122         
       
   123     CCallInfoIter& infos( iCallInfos->GetCallsL() );
       
   124     EUNIT_PRINT( _L( "IT_RemotePartyInformation: GetCallsL" ));
       
   125     EUNIT_ASSERT_EQUALS( infos.Count(), 1 );
       
   126     EUNIT_PRINT( _L( "IT_RemotePartyInformation: Count" ));
       
   127     const MCall& call( infos.Current() );    
       
   128     EUNIT_PRINT( _L( "IT_RemotePartyInformation: Current" ));
       
   129     TInt callIndex = call.CallIndex();   
       
   130     EUNIT_PRINT( _L( "IT_RemotePartyInformation: CallIndex"));
       
   131         
       
   132     //check the data, option 1
       
   133     const MCallRemotePartyInfo* remoteInfo = iRemotePartyInfo->GetRemotePartyInformationL( callIndex );
       
   134     EUNIT_PRINT( _L( "IT_RemotePartyInformation: GetRemotePartyInformationL" ));
       
   135     EUNIT_ASSERT( remoteInfo != NULL );    
       
   136     const TDesC& number = remoteInfo->Address();     
       
   137     EUNIT_PRINT( _L( "IT_RemotePartyInformation: Address" ));
       
   138     EUNIT_ASSERT_EQUALS( number, KNumber );    
       
   139     EUNIT_ASSERT_EQUALS( remoteInfo->RemoteIdentity(), MCallRemotePartyInfo::ERemoteIdentityAvailable );
       
   140     EUNIT_ASSERT( remoteInfo->SATCall() == EFalse );
       
   141         
       
   142     //check the data, option 2    
       
   143     CCallRemotePartyInfoIter& iter = iRemotePartyInfo->GetRemotePartyInformationL( );
       
   144     EUNIT_PRINT( _L( "IT_RemotePartyInformation: GetRemotePartyInformationL" ));
       
   145     EUNIT_ASSERT_EQUALS( iter.Count(), 1 );   
       
   146     EUNIT_PRINT( _L( "IT_RemotePartyInformation: Count" ));
       
   147     const MCallRemotePartyInfo& duplicatedInfo = iter.Current();
       
   148     EUNIT_PRINT( _L( "IT_RemotePartyInformation: Current" ));
       
   149     EUNIT_ASSERT( (*remoteInfo == duplicatedInfo) == ETrue );    
       
   150         
       
   151     iDialer->Hangup();
       
   152     EUNIT_PRINT( _L( "IT_RemotePartyInformation::TestSingleCallNoContactL out" ));
       
   153     }
       
   154 
       
   155 
       
   156 
       
   157 // - EUnit test table -------------------------------------------------------
       
   158 
       
   159 EUNIT_BEGIN_TEST_TABLE(
       
   160     IT_RemotePartyInformation,
       
   161     "API tests for Remote party information api",
       
   162     "MODULE" )
       
   163 
       
   164 EUNIT_TEST(
       
   165     "No calls",
       
   166     "CCallRemotePartyInformation",
       
   167     "GetCallsL",
       
   168     "FUNCTIONALITY",
       
   169     SetupL, TestNoCallsL, Teardown)    
       
   170    
       
   171 EUNIT_TEST(
       
   172     "One call, no contact information found",
       
   173     "CCallRemotePartyInformation",
       
   174     "GetCallsL",
       
   175     "FUNCTIONALITY",
       
   176     SetupL, TestSingleCallNoContactL, Teardown)    
       
   177 
       
   178 EUNIT_END_TEST_TABLE