mmsharing/mmshui/tsrc/ut_ui/src/ut_musuistartcontroller.cpp
branchRCL_3
changeset 33 bc78a40cd63c
parent 0 f0cf47e981f9
equal deleted inserted replaced
32:73a1feb507fb 33:bc78a40cd63c
       
     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_musuistartcontroller.h"
       
    21 #include "musuistartcontroller.h"
       
    22 
       
    23 #include "musuidefinitions.h"
       
    24 #include "musmanagercommon.h"
       
    25 
       
    26 #include "musuieventobserveradapter.h"
       
    27 
       
    28 #include <e32Property.h>
       
    29 
       
    30 
       
    31 //  SYSTEM INCLUDES
       
    32 #include <digia/eunit/eunitmacros.h>
       
    33 //#include <centralrepository.h>
       
    34 //#include <mcedisplaysink.h>
       
    35 
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 UT_CMusUiStartController* UT_CMusUiStartController::NewL()
       
    42     {
       
    43     UT_CMusUiStartController* self = UT_CMusUiStartController::NewLC();
       
    44     CleanupStack::Pop( self );
       
    45     return self;
       
    46     }
       
    47 
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 UT_CMusUiStartController* UT_CMusUiStartController::NewLC()
       
    54     {
       
    55     UT_CMusUiStartController* self = new( ELeave ) UT_CMusUiStartController();
       
    56     CleanupStack::PushL( self );
       
    57     self->ConstructL();
       
    58     return self;
       
    59     }
       
    60 
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 UT_CMusUiStartController::~UT_CMusUiStartController()
       
    67     {
       
    68     // NOP
       
    69     }
       
    70 
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // Default constructor
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 UT_CMusUiStartController::UT_CMusUiStartController()
       
    77     {
       
    78     // NOP
       
    79     }
       
    80 
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // Second phase construct
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 void UT_CMusUiStartController::ConstructL()
       
    87     {
       
    88     // The ConstructL from the base class CEUnitTestSuiteClass must be called.
       
    89     // It generates the test case table.
       
    90     CEUnitTestSuiteClass::ConstructL();
       
    91     }
       
    92 
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 void UT_CMusUiStartController::SetupL()
       
    99     {
       
   100     iEventObserver = new (ELeave) CMusUiEventObserverAdapter();
       
   101     }
       
   102 
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 void UT_CMusUiStartController::Teardown()
       
   109     {
       
   110 
       
   111     delete iEventObserver;
       
   112 
       
   113     // Tests are made in construction phase
       
   114     // Because class implementation is constructor based
       
   115 
       
   116     }
       
   117 
       
   118 
       
   119 
       
   120 // TEST CASES
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 void UT_CMusUiStartController::UT_CMusUiStartController_UseCasePropertyLL()
       
   127     {
       
   128     EUNIT_ASSERT( iEventObserver );
       
   129 
       
   130     // Testing leave
       
   131     RProperty::iErrorCode = KErrNotFound;
       
   132     TRAPD( err, CMusUiStartController::NewL( *iEventObserver ) );
       
   133     EUNIT_ASSERT( err == KErrNotFound );
       
   134 
       
   135     }
       
   136 
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 // -----------------------------------------------------------------------------
       
   141 //
       
   142 void UT_CMusUiStartController::UT_CMusUiStartController_SetStartViewLL()
       
   143     {
       
   144     EUNIT_ASSERT( iEventObserver );
       
   145 
       
   146     // Testing leave
       
   147     RProperty::iErrorCode = KErrNotFound;
       
   148     RProperty::iIntProperty = -9999;
       
   149     iEventObserver->iErrorCode = KErrNone;
       
   150     TRAPD( err, CMusUiStartController::NewL( *iEventObserver ) );
       
   151     EUNIT_ASSERT( err == KErrNotFound );
       
   152 
       
   153     // Testing leave
       
   154     RProperty::iErrorCode = KErrNone;
       
   155     RProperty::iIntProperty = -9999;
       
   156     iEventObserver->iErrorCode = KErrCancel;
       
   157     TRAP( err, CMusUiStartController::NewL( *iEventObserver ) );
       
   158     EUNIT_ASSERT( err == KErrCancel );
       
   159 
       
   160     // case default
       
   161 
       
   162     RProperty::iErrorCode = KErrNone;
       
   163     RProperty::iIntProperty = -9999;
       
   164     iEventObserver->iErrorCode = KErrNone;
       
   165     CMusUiStartController* scdefault = CMusUiStartController::NewL( *iEventObserver );
       
   166     EUNIT_ASSERT( iEventObserver->iCalledObserver == CMusUiEventObserverAdapter::EHandleExitL );
       
   167 
       
   168     delete scdefault;
       
   169 
       
   170     // case EMusLiveVideo
       
   171 
       
   172     RProperty::iErrorCode = KErrNone;
       
   173     RProperty::iIntProperty = EMusLiveVideo;
       
   174     iEventObserver->iErrorCode = KErrNone;
       
   175     CMusUiStartController* sclive = CMusUiStartController::NewL( *iEventObserver );
       
   176     EUNIT_ASSERT( iEventObserver->iCalledObserver == CMusUiEventObserverAdapter::EActivateLocalMusViewL );
       
   177     EUNIT_ASSERT( iEventObserver->iViewId == KMusUidLiveSharingView );
       
   178 
       
   179     delete sclive;
       
   180 
       
   181     // case EMusClipVideo
       
   182 
       
   183     RProperty::iErrorCode = KErrNone;
       
   184     RProperty::iIntProperty = EMusClipVideo;
       
   185     iEventObserver->iErrorCode = KErrNone;
       
   186     CMusUiStartController* scclip = CMusUiStartController::NewL( *iEventObserver );
       
   187     EUNIT_ASSERT( iEventObserver->iCalledObserver == CMusUiEventObserverAdapter::EActivateLocalMusViewL );
       
   188     EUNIT_ASSERT( iEventObserver->iViewId == KMusUidClipSharingView );
       
   189 
       
   190     delete scclip;
       
   191 
       
   192     // case EMusReceive
       
   193 
       
   194     RProperty::iErrorCode = KErrNone;
       
   195     RProperty::iIntProperty = EMusReceive;
       
   196     iEventObserver->iErrorCode = KErrNone;
       
   197     CMusUiStartController* screceive = CMusUiStartController::NewL( *iEventObserver );
       
   198     EUNIT_ASSERT( iEventObserver->iCalledObserver == CMusUiEventObserverAdapter::EActivateLocalMusViewL );
       
   199     EUNIT_ASSERT( iEventObserver->iViewId == KMusUidReceivingView );
       
   200 
       
   201     delete screceive;
       
   202 
       
   203     }
       
   204 
       
   205 
       
   206 
       
   207 
       
   208 //  TEST TABLE
       
   209 
       
   210 EUNIT_BEGIN_TEST_TABLE(
       
   211     UT_CMusUiStartController,
       
   212     "UT_CMusUiStartController",
       
   213     "UNIT" )
       
   214 
       
   215 EUNIT_TEST(
       
   216     "UseCasePropertyLL - test ",
       
   217     "CMusUiStartController",
       
   218     "UseCasePropertyLL",
       
   219     "FUNCTIONALITY",
       
   220     SetupL, UT_CMusUiStartController_UseCasePropertyLL, Teardown)
       
   221 
       
   222 EUNIT_TEST(
       
   223     "SetStartViewLL - test ",
       
   224     "CMusUiStartController",
       
   225     "SetStartViewLL",
       
   226     "FUNCTIONALITY",
       
   227     SetupL, UT_CMusUiStartController_SetStartViewLL, Teardown)
       
   228 
       
   229 EUNIT_END_TEST_TABLE
       
   230 
       
   231 //  END OF FILE