phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/tsrc/ut_commlaunchercontacthandler/src/t_commlaunchercontacthandlerCases.cpp
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2002 - 2007 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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // [INCLUDE FILES] - do not remove
       
    21 #include <e32math.h>
       
    22 
       
    23 #define __COMMLAUNCHERPLUGINUNITTESTMODE
       
    24 #include "t_commlaunchercontacthandler.h"
       
    25 #include "t_testsingleton.h"
       
    26 
       
    27 #include "ccappcommlauncherheaders.h"
       
    28 
       
    29 
       
    30 // ============================ MEMBER FUNCTIONS ===============================
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // T_CCCAppCommLauncherContactHandler::Case
       
    34 // Returns a test case by number.
       
    35 //
       
    36 // This function contains an array of all available test cases 
       
    37 // i.e pair of case name and test function. If case specified by parameter
       
    38 // aCaseNumber is found from array, then that item is returned.
       
    39 // 
       
    40 // The reason for this rather complicated function is to specify all the
       
    41 // test cases only in one place. It is not necessary to understand how
       
    42 // function pointers to class member functions works when adding new test
       
    43 // cases. See function body for instructions how to add new test case.
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 const TCaseInfo T_CCCAppCommLauncherContactHandler::Case ( 
       
    47     const TInt aCaseNumber ) const 
       
    48      {
       
    49 
       
    50     /**
       
    51     * To add new test cases, implement new test case function and add new 
       
    52     * line to KCases array specify the name of the case and the function 
       
    53     * doing the test case
       
    54     * In practice, do following
       
    55     * 1) Make copy of existing test case function and change its name
       
    56     *    and functionality. Note that the function must be added to 
       
    57     *    t_commlaunchercontacthandler.cpp file and to t_commlaunchercontacthandler.h 
       
    58     *    header file.
       
    59     *
       
    60     * 2) Add entry to following KCases array either by using:
       
    61     *
       
    62     * 2.1: FUNCENTRY or ENTRY macro
       
    63     * ENTRY macro takes two parameters: test case name and test case 
       
    64     * function name.
       
    65     *
       
    66     * FUNCENTRY macro takes only test case function name as a parameter and
       
    67     * uses that as a test case name and test case function name.
       
    68     *
       
    69     * Or
       
    70     *
       
    71     * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used
       
    72     * only with OOM (Out-Of-Memory) testing!
       
    73     *
       
    74     * OOM_ENTRY macro takes five parameters: test case name, test case 
       
    75     * function name, TBool which specifies is method supposed to be run using
       
    76     * OOM conditions, TInt value for first heap memory allocation failure and 
       
    77     * TInt value for last heap memory allocation failure.
       
    78     * 
       
    79     * OOM_FUNCENTRY macro takes test case function name as a parameter and uses
       
    80     * that as a test case name, TBool which specifies is method supposed to be
       
    81     * run using OOM conditions, TInt value for first heap memory allocation 
       
    82     * failure and TInt value for last heap memory allocation failure. 
       
    83     */ 
       
    84 
       
    85     static TCaseInfoInternal const KCases[] =
       
    86         {
       
    87         // [test cases entries] - do not remove
       
    88         
       
    89         // NOTE: When compiled to GCCE, there must be Classname::
       
    90         // declaration in front of the method name, e.g. 
       
    91         // T_CCCAppCommLauncherContactHandler::PrintTest. Otherwise the compiler
       
    92         // gives errors.
       
    93         
       
    94         FUNCENTRY( T_CCCAppCommLauncherContactHandler::PrintTest ),
       
    95         ENTRY( "Loop test", T_CCCAppCommLauncherContactHandler::LoopTest ),
       
    96         ENTRY( "CreateAndDelete", T_CCCAppCommLauncherContactHandler::TestNewL ),
       
    97         ENTRY( "RequestContactDataL", 
       
    98                 T_CCCAppCommLauncherContactHandler::TestRequestContactDataL ),
       
    99         ENTRY( "ContactFieldDataObserverNotifyL", 
       
   100                 TestContactFieldDataObserverNotifyL ),
       
   101         // Seems to be not valid any more
       
   102         ENTRY( "CalculationAndGetters", 
       
   103                 T_CCCAppCommLauncherContactHandler::TestCalculationAndGettersL ),
       
   104         // Seems to be not valid any more
       
   105         ENTRY( "Updates", 
       
   106                 T_CCCAppCommLauncherContactHandler::TestUpdatesL ),
       
   107         ENTRY( "DefaultAttributes", TestDefaultAttributesL ),
       
   108         ENTRY( "TestContactStoreApiL", TestContactStoreApiL ),
       
   109         // Example how to use OOM functionality
       
   110         //OOM_ENTRY( "Loop test with OOM", 
       
   111         //        T_CCCAppCommLauncherContactHandler::LoopTest, ETrue, 2, 3),
       
   112         //OOM_FUNCENTRY( T_CCCAppCommLauncherContactHandler::PrintTest, ETrue, 1, 3 ),
       
   113         };
       
   114 
       
   115     // Verify that case number is valid  
       
   116     if( (TUint) aCaseNumber >= sizeof( KCases ) / 
       
   117                                sizeof( TCaseInfoInternal ) )
       
   118         {
       
   119         // Invalid case, construct empty object
       
   120         TCaseInfo null( (const TText*) L"" );
       
   121         null.iMethod = NULL;
       
   122         null.iIsOOMTest = EFalse;
       
   123         null.iFirstMemoryAllocation = 0;
       
   124         null.iLastMemoryAllocation = 0;
       
   125         return null;
       
   126         } 
       
   127 
       
   128     // Construct TCaseInfo object and return it
       
   129     TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName );
       
   130     tmp.iMethod = KCases[ aCaseNumber ].iMethod;
       
   131     tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest;
       
   132     tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation;
       
   133     tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation;
       
   134     return tmp;
       
   135 
       
   136     }
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 // T_CCCAppCommLauncherContactHandler::
       
   140 //
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 TInt T_CCCAppCommLauncherContactHandler::TestRequestContactDataL( 
       
   144         TTestResult& aResult )
       
   145     {
       
   146     
       
   147     CCCAppCommLauncherPlugin* plugin =
       
   148                 new (ELeave) CCCAppCommLauncherPlugin;
       
   149     CleanupStack::PushL( plugin );
       
   150     CCCAppCommLauncherView* view = CCCAppCommLauncherView::NewL();
       
   151     CleanupStack::PushL( view );
       
   152     CCCAppCommLauncherContactHandler* handler = 
       
   153             CCCAppCommLauncherContactHandler::NewL( *view, *plugin );
       
   154     CleanupStack::PushL( handler );
       
   155     
       
   156     T_CTestSingleton* singleton = T_CTestSingleton::InstanceL();
       
   157     singleton->SetValue( KTestContactInfoNull );
       
   158 
       
   159     view->ResetVariables();
       
   160     handler->RequestContactDataL();
       
   161     TL( EFalse == view->ContactChangedNotifyCalled() );
       
   162     
       
   163     view->ResetVariables();
       
   164     singleton->SetValue( KTestNormal );
       
   165     handler->RequestContactDataL();
       
   166     TL( view->ContactChangedNotifyCalled() );
       
   167     
       
   168     singleton->Release();
       
   169     singleton = NULL;
       
   170     
       
   171     CleanupStack::PopAndDestroy( 3 );
       
   172 
       
   173     _LIT( KDescription, "TestRequestContactDataL passed" );
       
   174     aResult.SetResult( KErrNone, KDescription );
       
   175 
       
   176     // Case was executed
       
   177     return KErrNone;
       
   178     }
       
   179 
       
   180 // -----------------------------------------------------------------------------
       
   181 // T_CCCAppCommLauncherContactHandler::TestContactFieldDataObserverNotifyL
       
   182 //
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 TInt T_CCCAppCommLauncherContactHandler::TestContactFieldDataObserverNotifyL ( 
       
   186         TTestResult& aResult )
       
   187     {
       
   188     CCCAppCommLauncherPlugin* plugin =
       
   189                 new (ELeave) CCCAppCommLauncherPlugin;
       
   190     CleanupStack::PushL( plugin );
       
   191     CCCAppCommLauncherView* view = CCCAppCommLauncherView::NewL();
       
   192     CleanupStack::PushL( view );
       
   193     CCCAppCommLauncherContactHandler* handler = 
       
   194             CCCAppCommLauncherContactHandler::NewL( *view, *plugin );
       
   195     CleanupStack::PushL( handler );
       
   196    
       
   197     CCmsContactFieldInfo* contactInfo = CCmsContactFieldInfo::NewL();
       
   198     CleanupStack::PushL( contactInfo );
       
   199     CCmsContactField* contactField = new (ELeave) CCmsContactField ( VOIP );
       
   200     CleanupStack::PushL( contactField );
       
   201    
       
   202     MCCAppContactFieldDataObserver::TParameter param = 
       
   203             MCCAppContactFieldDataObserver::TParameter();
       
   204     handler->ContactFieldDataObserverNotifyL( param );
       
   205 
       
   206     view->ResetVariables();
       
   207     param.iType = 
       
   208             MCCAppContactFieldDataObserver::TParameter::EContactInfoAvailable;
       
   209     handler->ContactFieldDataObserverNotifyL( param );
       
   210     TL( EFalse == view->ContactEnabledFieldsChangedNotifyCalled() );
       
   211     
       
   212     view->ResetVariables();
       
   213     param.iContactInfo = contactInfo;
       
   214     handler->ContactFieldDataObserverNotifyL( param );
       
   215     TL( view->ContactEnabledFieldsChangedNotifyCalled() );
       
   216     
       
   217     view->ResetVariables();
       
   218     param.iType = 
       
   219         MCCAppContactFieldDataObserver::TParameter::EContactDataFieldAvailable;
       
   220     handler->ContactFieldDataObserverNotifyL( param );
       
   221     TL( EFalse == view->ContactChangedNotifyCalled() );
       
   222     
       
   223     view->ResetVariables();
       
   224     param.iContactField = contactField;
       
   225     handler->ContactFieldDataObserverNotifyL( param );
       
   226     TL( view->ContactChangedNotifyCalled() );
       
   227     
       
   228     CleanupStack::PopAndDestroy( 5 ); 
       
   229         
       
   230     _LIT( KDescription, "TestContactFieldDataObserverNotifyL passed" );
       
   231     aResult.SetResult( KErrNone, KDescription );
       
   232 
       
   233     // Case was executed
       
   234     return KErrNone;
       
   235     }
       
   236     
       
   237     
       
   238 // -----------------------------------------------------------------------------
       
   239 // T_CCCAppCommLauncherContactHandler::PrintTest
       
   240 // Simple printing to UI test.
       
   241 // -----------------------------------------------------------------------------
       
   242 //
       
   243 TInt T_CCCAppCommLauncherContactHandler::PrintTest( 
       
   244     TTestResult& aResult )
       
   245     {
       
   246      /* Simple print test */
       
   247     _LIT( KPrintTest, "PrintTest" );
       
   248     _LIT( KEnter, "Enter" );
       
   249     _LIT( KOnGoing, "On-going" );
       
   250     _LIT( KExit, "Exit" );
       
   251 
       
   252     TestModuleIf().Printf( 0, KPrintTest, KEnter );
       
   253            
       
   254     TestModuleIf().Printf( 1, KPrintTest, KOnGoing );
       
   255     
       
   256     TestModuleIf().Printf( 0, KPrintTest, KExit );
       
   257 
       
   258     // Test case passed
       
   259 
       
   260     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   261     _LIT( KDescription, "PrintTest passed" );
       
   262     aResult.SetResult( KErrNone, KDescription );
       
   263 
       
   264     // Case was executed
       
   265     return KErrNone;
       
   266 
       
   267     }
       
   268 
       
   269 // -----------------------------------------------------------------------------
       
   270 // T_CCCAppCommLauncherContactHandler::LoopTest
       
   271 // Another printing to UI test.
       
   272 // -----------------------------------------------------------------------------
       
   273 //
       
   274 TInt T_CCCAppCommLauncherContactHandler::LoopTest( TTestResult& aResult )
       
   275     {
       
   276 
       
   277     /* Simple print and wait loop */
       
   278     _LIT( KState, "State" );
       
   279     _LIT( KLooping, "Looping" );
       
   280 
       
   281     TestModuleIf().Printf( 0, KState, KLooping );
       
   282 
       
   283     _LIT( KRunning, "Running" );
       
   284     _LIT( KLoop, "%d" );
       
   285     for( TInt i=0; i<10; i++)
       
   286         {
       
   287         TestModuleIf().Printf( 1, KRunning, KLoop, i);
       
   288         User::After( 1000000 );
       
   289         }
       
   290 
       
   291     _LIT( KFinished, "Finished" );
       
   292     TestModuleIf().Printf( 0, KState, KFinished );
       
   293 
       
   294     // Test case passed
       
   295 
       
   296     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   297     _LIT( KDescription, "LoopTest passed" );
       
   298     aResult.SetResult( KErrNone, KDescription );
       
   299 
       
   300     // Case was executed
       
   301     return KErrNone;
       
   302 
       
   303     }
       
   304 
       
   305 // -----------------------------------------------------------------------------
       
   306 // T_CCCAppCommLauncherContactHandler::TestNewL
       
   307 //
       
   308 // -----------------------------------------------------------------------------
       
   309 //
       
   310 TInt T_CCCAppCommLauncherContactHandler::TestNewL( TTestResult& aResult )
       
   311     {    
       
   312     __UHEAP_MARK;
       
   313     CCCAppCommLauncherPlugin* plugin =
       
   314                 new (ELeave) CCCAppCommLauncherPlugin;
       
   315     CleanupStack::PushL( plugin );
       
   316     CCCAppCommLauncherView* view = CCCAppCommLauncherView::NewL();
       
   317     CleanupStack::PushL( view );
       
   318     CCCAppCommLauncherContactHandler* handler = 
       
   319             CCCAppCommLauncherContactHandler::NewL( *view, *plugin );
       
   320     CleanupStack::PushL( handler );
       
   321     CleanupStack::PopAndDestroy( 3 );
       
   322     __UHEAP_MARKEND;
       
   323     
       
   324     
       
   325     __UHEAP_MARK;
       
   326     CCCAppCommLauncherPlugin* plugin1 =
       
   327                 new (ELeave) CCCAppCommLauncherPlugin;
       
   328     CleanupStack::PushL( plugin1 );
       
   329     CCCAppCommLauncherView* view2 = CCCAppCommLauncherView::NewL();
       
   330     CleanupStack::PushL( view2 );
       
   331     CCCAppCommLauncherContactHandler* handler2 = 
       
   332             CCCAppCommLauncherContactHandler::NewL( *view2, *plugin1 );
       
   333     CleanupStack::PushL( handler2 );
       
   334     CleanupStack::Pop( 3 );
       
   335     delete view2;
       
   336     delete handler2;
       
   337     delete plugin1;
       
   338     __UHEAP_MARKEND;
       
   339     
       
   340     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   341     _LIT( KDescription, "NewL test passed" );
       
   342     aResult.SetResult( KErrNone, KDescription );
       
   343 
       
   344     // Case was executed
       
   345     return KErrNone;
       
   346     }
       
   347   
       
   348 
       
   349 // -----------------------------------------------------------------------------
       
   350 // T_CCCAppCommLauncherContactHandler::TestCalculationAndGettersL
       
   351 //
       
   352 // -----------------------------------------------------------------------------
       
   353 //
       
   354 TInt T_CCCAppCommLauncherContactHandler::TestCalculationAndGettersL( 
       
   355         TTestResult& aResult )
       
   356     {
       
   357     CCCAppCommLauncherView* view = CCCAppCommLauncherView::NewL();
       
   358     CleanupStack::PushL( view );
       
   359     CCCAppCommLauncherPlugin *plugin = CCCAppCommLauncherPlugin::NewL();
       
   360     CleanupStack::PushL( plugin );
       
   361     CCCAppCommLauncherContactHandler* handler = 
       
   362             CCCAppCommLauncherContactHandler::NewL( *view, *plugin );
       
   363     CleanupStack::PushL( handler );
       
   364     
       
   365     handler->ContactFieldDataObserverHandleErrorL( 1, -3 );
       
   366     
       
   367     T1L( 1, handler->AddressAmount( 
       
   368             VPbkFieldTypeSelectorFactory::EVoiceCallSelector ));
       
   369     T1L( 1, handler->AddressAmount( 
       
   370             VPbkFieldTypeSelectorFactory::EEmailEditorSelector ));
       
   371     T1L( 1, handler->AddressAmount( 
       
   372             VPbkFieldTypeSelectorFactory::EVOIPCallSelector ));
       
   373     T1L( 1, handler->AddressAmount( 
       
   374             VPbkFieldTypeSelectorFactory::EUniEditorSelector ));
       
   375     T1L( 1, handler->AddressAmount( 
       
   376             VPbkFieldTypeSelectorFactory::EVoiceCallSelector ));
       
   377     T1L( 1, handler->AddressAmount( 
       
   378             VPbkFieldTypeSelectorFactory::EEmailEditorSelector ));
       
   379     T1L( 1, handler->AddressAmount( 
       
   380             VPbkFieldTypeSelectorFactory::EVOIPCallSelector ));
       
   381     T1L( 1, handler->AddressAmount( 
       
   382             VPbkFieldTypeSelectorFactory::EUniEditorSelector ));
       
   383     T1L( 1, handler->AddressAmount( 
       
   384             VPbkFieldTypeSelectorFactory::EInstantMessagingSelector ));
       
   385     T1L( 1, handler->AddressAmount( 
       
   386             VPbkFieldTypeSelectorFactory::EURLSelector ));
       
   387     
       
   388     RPointerArray<CCmsContactField> array = handler->ContactFieldDataArray();
       
   389     T1L( 1, array.Count( ) );
       
   390     
       
   391     HBufC8* test = handler->ContactIdentifierLC();
       
   392     T1L( 0, test->Compare( KTestString ) );
       
   393     CleanupStack::PopAndDestroy( test );
       
   394     
       
   395     CleanupStack::PopAndDestroy( 3 );
       
   396 
       
   397     _LIT( KDescription, "TestCalculationAndGettersL passed" );
       
   398     aResult.SetResult( KErrNone, KDescription );
       
   399 
       
   400     // Case was executed
       
   401     return KErrNone;
       
   402     }  
       
   403 
       
   404 // -----------------------------------------------------------------------------
       
   405 // T_CCCAppCommLauncherContactHandler::TestUpdatesL
       
   406 //
       
   407 // -----------------------------------------------------------------------------
       
   408 //
       
   409 TInt T_CCCAppCommLauncherContactHandler::TestUpdatesL( TTestResult& aResult )
       
   410     {
       
   411 
       
   412     CCCAppCommLauncherView* view = CCCAppCommLauncherView::NewL();
       
   413     CleanupStack::PushL( view );
       
   414     CCCAppCommLauncherPlugin *plugin = CCCAppCommLauncherPlugin::NewL();
       
   415     CleanupStack::PushL( plugin );
       
   416     CCCAppCommLauncherContactHandler* handler = 
       
   417             CCCAppCommLauncherContactHandler::NewL( *view, *plugin );
       
   418     CleanupStack::PushL( handler );
       
   419 
       
   420     T1L( 1, handler->AddressAmount( 
       
   421             VPbkFieldTypeSelectorFactory::EVoiceCallSelector ));
       
   422     T1L( 1, handler->AddressAmount( 
       
   423             VPbkFieldTypeSelectorFactory::EEmailEditorSelector ));
       
   424     T1L( 1, handler->AddressAmount( 
       
   425             VPbkFieldTypeSelectorFactory::EVOIPCallSelector ));
       
   426 
       
   427     T1L( 1, handler->AddressAmount( 
       
   428             VPbkFieldTypeSelectorFactory::EVoiceCallSelector ));
       
   429     T1L( 1, handler->AddressAmount( 
       
   430             VPbkFieldTypeSelectorFactory::EEmailEditorSelector ));
       
   431     T1L( 1, handler->AddressAmount( 
       
   432             VPbkFieldTypeSelectorFactory::EVOIPCallSelector ));
       
   433     
       
   434     T1L( 1, handler->AddressAmount( 
       
   435             VPbkFieldTypeSelectorFactory::EVoiceCallSelector ));
       
   436     T1L( 1, handler->AddressAmount( 
       
   437             VPbkFieldTypeSelectorFactory::EEmailEditorSelector ));
       
   438     T1L( 1, handler->AddressAmount( 
       
   439             VPbkFieldTypeSelectorFactory::EVOIPCallSelector ));
       
   440 
       
   441     T1L( 1, handler->AddressAmount( 
       
   442             VPbkFieldTypeSelectorFactory::EVoiceCallSelector ));
       
   443     T1L( 1, handler->AddressAmount( 
       
   444             VPbkFieldTypeSelectorFactory::EEmailEditorSelector ));
       
   445     T1L( 1, handler->AddressAmount(
       
   446             VPbkFieldTypeSelectorFactory::EVOIPCallSelector ));
       
   447 
       
   448     T1L( 1, handler->AddressAmount( 
       
   449             VPbkFieldTypeSelectorFactory::EVoiceCallSelector ));
       
   450     T1L( 1, handler->AddressAmount( 
       
   451             VPbkFieldTypeSelectorFactory::EEmailEditorSelector ));
       
   452     T1L( 1, handler->AddressAmount( 
       
   453             VPbkFieldTypeSelectorFactory::EVOIPCallSelector ));
       
   454     
       
   455     T1L( 1, handler->AddressAmount( 
       
   456             VPbkFieldTypeSelectorFactory::EVoiceCallSelector ));
       
   457     T1L( 1, handler->AddressAmount( 
       
   458             VPbkFieldTypeSelectorFactory::EEmailEditorSelector ));
       
   459     T1L( 1, handler->AddressAmount( 
       
   460             VPbkFieldTypeSelectorFactory::EVOIPCallSelector ));
       
   461 
       
   462     T1L( 1, handler->AddressAmount( 
       
   463             VPbkFieldTypeSelectorFactory::EVoiceCallSelector ));
       
   464     T1L( 1, handler->AddressAmount( 
       
   465             VPbkFieldTypeSelectorFactory::EEmailEditorSelector ));
       
   466     T1L( 1, handler->AddressAmount( 
       
   467             VPbkFieldTypeSelectorFactory::EVOIPCallSelector ));
       
   468 
       
   469     CleanupStack::PopAndDestroy( 3 );
       
   470 
       
   471     _LIT( KDescription, "TestUpdatesL passed" );
       
   472     aResult.SetResult( KErrNone, KDescription );
       
   473 
       
   474     // Case was executed
       
   475     return KErrNone;
       
   476     } 
       
   477 
       
   478 // -----------------------------------------------------------------------------
       
   479 // T_CCCAppCommLauncherContactHandler::TestDefaultAttributesL
       
   480 //
       
   481 // -----------------------------------------------------------------------------
       
   482 //
       
   483 TInt T_CCCAppCommLauncherContactHandler::TestDefaultAttributesL( 
       
   484         TTestResult& aResult )
       
   485     {
       
   486     CCCAppCommLauncherPlugin* plugin =
       
   487                 new (ELeave) CCCAppCommLauncherPlugin;
       
   488     CleanupStack::PushL( plugin );
       
   489     CCCAppCommLauncherView* view = CCCAppCommLauncherView::NewL();
       
   490     CleanupStack::PushL( view );
       
   491     CCCAppCommLauncherContactHandler* handler = 
       
   492             CCCAppCommLauncherContactHandler::NewL( *view, *plugin );
       
   493     CleanupStack::PushL( handler );
       
   494     
       
   495     TL( EFalse == handler->HasDefaultAttribute( 
       
   496             VPbkFieldTypeSelectorFactory::EVoiceCallSelector ) );
       
   497     TL( EFalse == handler->HasDefaultAttribute( 
       
   498             VPbkFieldTypeSelectorFactory::EUniEditorSelector ) );
       
   499     TL( EFalse == handler->HasDefaultAttribute( 
       
   500             VPbkFieldTypeSelectorFactory::EEmailEditorSelector ) );
       
   501     TL( EFalse == handler->HasDefaultAttribute( 
       
   502             VPbkFieldTypeSelectorFactory::EVOIPCallSelector ) );
       
   503                 
       
   504     CCmsContactField* emailField = new (ELeave) CCmsContactField ( EMAIL );
       
   505     CleanupStack::PushL( emailField );
       
   506     handler->UpdateDefaultAttributes( *emailField );
       
   507     
       
   508     TL( EFalse == handler->HasDefaultAttribute( 
       
   509             VPbkFieldTypeSelectorFactory::EVoiceCallSelector ) );
       
   510     TL( EFalse == handler->HasDefaultAttribute( 
       
   511             VPbkFieldTypeSelectorFactory::EUniEditorSelector ) );
       
   512     TL( handler->HasDefaultAttribute( 
       
   513             VPbkFieldTypeSelectorFactory::EEmailEditorSelector ) );
       
   514     TL( EFalse == handler->HasDefaultAttribute( 
       
   515             VPbkFieldTypeSelectorFactory::EVOIPCallSelector ) );
       
   516     
       
   517     CleanupStack::PopAndDestroy( emailField );
       
   518     
       
   519     CCmsContactField* voipField = new (ELeave) CCmsContactField ( VOIP );
       
   520     CleanupStack::PushL( voipField );
       
   521     handler->UpdateDefaultAttributes( *voipField );
       
   522     
       
   523     TL( EFalse == handler->HasDefaultAttribute( 
       
   524             VPbkFieldTypeSelectorFactory::EVoiceCallSelector ) );
       
   525     TL( EFalse == handler->HasDefaultAttribute( 
       
   526             VPbkFieldTypeSelectorFactory::EUniEditorSelector ) );
       
   527     TL( handler->HasDefaultAttribute( 
       
   528             VPbkFieldTypeSelectorFactory::EEmailEditorSelector ) );
       
   529     TL( handler->HasDefaultAttribute( 
       
   530             VPbkFieldTypeSelectorFactory::EVOIPCallSelector ) );
       
   531     
       
   532     CleanupStack::PopAndDestroy( voipField );
       
   533     
       
   534     CCmsContactField* phoneField = new (ELeave) CCmsContactField ( PHONE );
       
   535     CleanupStack::PushL( phoneField );
       
   536     handler->UpdateDefaultAttributes( *phoneField );
       
   537     
       
   538     TL( handler->HasDefaultAttribute( 
       
   539             VPbkFieldTypeSelectorFactory::EVoiceCallSelector ) );
       
   540     TL( EFalse == handler->HasDefaultAttribute( 
       
   541             VPbkFieldTypeSelectorFactory::EUniEditorSelector ) );
       
   542     TL( handler->HasDefaultAttribute( 
       
   543             VPbkFieldTypeSelectorFactory::EEmailEditorSelector ) );
       
   544     TL( handler->HasDefaultAttribute( 
       
   545             VPbkFieldTypeSelectorFactory::EVOIPCallSelector ) );
       
   546     
       
   547     CleanupStack::PopAndDestroy( phoneField );
       
   548     
       
   549     CCmsContactField* mmsField = new (ELeave) CCmsContactField ( MMS );
       
   550     CleanupStack::PushL( mmsField );
       
   551     handler->UpdateDefaultAttributes( *mmsField );
       
   552     
       
   553     TL( handler->HasDefaultAttribute( 
       
   554             VPbkFieldTypeSelectorFactory::EVoiceCallSelector ) );
       
   555     TL( handler->HasDefaultAttribute( 
       
   556             VPbkFieldTypeSelectorFactory::EUniEditorSelector ) );
       
   557     TL( handler->HasDefaultAttribute( 
       
   558             VPbkFieldTypeSelectorFactory::EEmailEditorSelector ) );
       
   559     TL( handler->HasDefaultAttribute( 
       
   560             VPbkFieldTypeSelectorFactory::EVOIPCallSelector ) );
       
   561     
       
   562     CleanupStack::PopAndDestroy( mmsField );
       
   563     
       
   564     CleanupStack::PopAndDestroy( 3 );
       
   565 
       
   566     _LIT( KDescription, "TestDefaultAttributesL passed" );
       
   567     aResult.SetResult( KErrNone, KDescription );
       
   568 
       
   569     // Case was executed
       
   570     return KErrNone;
       
   571     }   
       
   572 
       
   573 // -----------------------------------------------------------------------------
       
   574 // T_CCCAppCommLauncherContactHandler::TestContactStoreApiL
       
   575 //
       
   576 // -----------------------------------------------------------------------------
       
   577 //
       
   578 TInt T_CCCAppCommLauncherContactHandler::TestContactStoreApiL( 
       
   579         TTestResult& aResult )
       
   580     {
       
   581     // setup
       
   582     CCCAppCommLauncherPlugin* plugin =
       
   583                 new (ELeave) CCCAppCommLauncherPlugin;
       
   584     CleanupStack::PushL( plugin );
       
   585     CCCAppCommLauncherView* view = CCCAppCommLauncherView::NewL();
       
   586     CleanupStack::PushL( view );
       
   587     CCCAppCommLauncherContactHandler* handler = 
       
   588             CCCAppCommLauncherContactHandler::NewL( *view, *plugin );
       
   589     CleanupStack::PushL( handler );
       
   590     
       
   591     // test itself
       
   592     handler->iCmsWrapper->iContactStore_called = EFalse;
       
   593     TCmsContactStore cntStore = handler->ContactStore();
       
   594     TAL( handler->iCmsWrapper->iContactStore_called );
       
   595     // no need to test cntStore, since the functionality is just a
       
   596     // getter from a separate class
       
   597 
       
   598     // cleanup
       
   599     CleanupStack::PopAndDestroy( 3 );
       
   600 
       
   601     _LIT( KDescription, "TestContactStoreApiL passed" );
       
   602     aResult.SetResult( KErrNone, KDescription );
       
   603 
       
   604     // Case was executed
       
   605     return KErrNone;
       
   606     }
       
   607 
       
   608 //  [End of File] - do not remove
       
   609 
       
   610