mmsharing/mmshengine/tsrc/ut_engine/src/ut_musengsessionmanager.cpp
branchRCL_3
changeset 33 bc78a40cd63c
parent 32 73a1feb507fb
child 35 6c57ef9392d2
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 "musengstubs.h"
       
    21 #include "ut_musengsessionmanager.h"
       
    22 #include "musengsessionmanager.h"
       
    23 #include "musengmcesession.h"
       
    24 #include "musengmceoutsession.h"
       
    25 #include "mussessionproperties.h"
       
    26 #include "centralrepository.h"
       
    27 #include "e32property.h"
       
    28 #include "musengtestdefs.h"
       
    29 
       
    30 //  SYSTEM INCLUDES
       
    31 #include <eunitmacros.h>
       
    32 
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 UT_CMusEngSessionManager* UT_CMusEngSessionManager::NewL()
       
    39     {
       
    40     UT_CMusEngSessionManager* self = UT_CMusEngSessionManager::NewLC();
       
    41     CleanupStack::Pop( self );
       
    42     return self;
       
    43     }
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 UT_CMusEngSessionManager* UT_CMusEngSessionManager::NewLC()
       
    50     {
       
    51     UT_CMusEngSessionManager* self = new( ELeave )UT_CMusEngSessionManager();
       
    52     CleanupStack::PushL( self );
       
    53     self->ConstructL();
       
    54     return self;
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 UT_CMusEngSessionManager::~UT_CMusEngSessionManager()
       
    62     {
       
    63     // NOP
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // Default constructor
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 UT_CMusEngSessionManager::UT_CMusEngSessionManager()
       
    71     {
       
    72     }
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // Second phase construct
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 void UT_CMusEngSessionManager::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 void UT_CMusEngSessionManager::SetupL()
       
    90     {
       
    91     User::LeaveIfError(
       
    92         RProperty::Set( 
       
    93             NMusSessionApi::KCategoryUid, 
       
    94             NMusSessionApi::KUseCase, 
       
    95             MultimediaSharing::EMusLiveVideo ) );
       
    96     iSessionManager = CMusEngSessionManager::NewL();
       
    97     
       
    98     iLcUiProvider = new( ELeave )CLcUiProviderStub;
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 void UT_CMusEngSessionManager::Teardown()
       
   106     {
       
   107     delete iSessionManager;
       
   108     delete iLcUiProvider;
       
   109     // The Central Repository stub is using RProperty stub to store global data. 
       
   110     // The global data must be freed here.
       
   111     PropertyHelper::Close(); 
       
   112     }
       
   113 
       
   114 // TEST CASES
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 void UT_CMusEngSessionManager::UT_NewL()
       
   121     {
       
   122     EUNIT_ASSERT( iSessionManager->iSession != NULL )
       
   123     }
       
   124 
       
   125 // -----------------------------------------------------------------------------
       
   126 //
       
   127 // -----------------------------------------------------------------------------
       
   128 //
       
   129 void UT_CMusEngSessionManager::UT_SessionL()
       
   130     {
       
   131     EUNIT_ASSERT( iSessionManager->iSession == &( iSessionManager->Session() ) )
       
   132     }
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 void UT_CMusEngSessionManager::UT_IsFeatureSupportedL()
       
   139     {
       
   140     EUNIT_ASSERT( 
       
   141         iSessionManager->IsFeatureSupported( CLcEngine::ELcShowAcceptQuery ) )
       
   142         
       
   143     EUNIT_ASSERT( 
       
   144         iSessionManager->IsFeatureSupported( CLcEngine::ELcShowInvitingNote ) )
       
   145         
       
   146     EUNIT_ASSERT( 
       
   147         iSessionManager->IsFeatureSupported( CLcEngine::ELcShowWaitingNote ) )        
       
   148     }
       
   149 
       
   150 // -----------------------------------------------------------------------------
       
   151 //
       
   152 // -----------------------------------------------------------------------------
       
   153 //
       
   154 void UT_CMusEngSessionManager::UT_CreateMusSessionL()
       
   155     {
       
   156     CMusEngMceSession* session = NULL;
       
   157 
       
   158     // Live session
       
   159     session = 
       
   160         iSessionManager->CreateMusSessionL( 
       
   161             MultimediaSharing::EMusLiveVideo );
       
   162     EUNIT_ASSERT( session != NULL )
       
   163     delete session;
       
   164 
       
   165     // Clip session
       
   166     session =
       
   167         iSessionManager->CreateMusSessionL( 
       
   168             MultimediaSharing::EMusClipVideo );
       
   169     EUNIT_ASSERT( session != NULL )
       
   170     delete session;    
       
   171     
       
   172     // Receive session
       
   173     session = 
       
   174         iSessionManager->CreateMusSessionL( 
       
   175             MultimediaSharing::EMusReceive );   
       
   176     EUNIT_ASSERT( session != NULL )
       
   177     delete session;
       
   178 
       
   179     // Two way session
       
   180     session = 
       
   181         iSessionManager->CreateMusSessionL( 
       
   182             MultimediaSharing::EMusTwoWayVideo );
       
   183     EUNIT_ASSERT( session != NULL )
       
   184     delete session;
       
   185     
       
   186     // Two way receive session
       
   187     session = 
       
   188         iSessionManager->CreateMusSessionL( 
       
   189             MultimediaSharing::EMusReceiveTwoWayVideo );   
       
   190     EUNIT_ASSERT( session != NULL )
       
   191     delete session;    
       
   192     
       
   193     // Other session types
       
   194     EUNIT_ASSERT_SPECIFIC_LEAVE(
       
   195         iSessionManager->CreateMusSessionL( MultimediaSharing::EMusStillImage ),
       
   196         KErrNotSupported )
       
   197 
       
   198     EUNIT_ASSERT_SPECIFIC_LEAVE(
       
   199         iSessionManager->CreateMusSessionL( MultimediaSharing::EMusContinue ),
       
   200         KErrNotSupported )
       
   201     }
       
   202 
       
   203 // -----------------------------------------------------------------------------
       
   204 //
       
   205 // -----------------------------------------------------------------------------
       
   206 //
       
   207 void UT_CMusEngSessionManager::UT_PropertyChangedL()
       
   208     {
       
   209     iSessionManager->Session().SetLcUiProvider( iLcUiProvider );
       
   210 
       
   211     // Background startup not active, property change ignored
       
   212     MLcSession* origSession = &iSessionManager->Session();
       
   213     iSessionManager->PropertyChanged( 
       
   214             NMusSessionApi::KUseCase, MultimediaSharing::EMusReceiveTwoWayVideo );
       
   215     
       
   216     EUNIT_ASSERT( origSession == &iSessionManager->Session() );
       
   217     EUNIT_ASSERT( iLcUiProvider->iCalledFunction != CLcUiProviderStub::EHandleForegroundStatus );
       
   218     
       
   219     // Background startup active, usecase not changed, no effect
       
   220     User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid, 
       
   221                     NMusSessionApi::KFastMode, 
       
   222                     MusSettingsKeys::EFastModeOn ) );
       
   223     iSessionManager->iSession->iBackground = ETrue;
       
   224     origSession = &iSessionManager->Session();
       
   225     iSessionManager->PropertyChanged( 
       
   226             NMusSessionApi::KUseCase, iSessionManager->iCurrentUseCase );
       
   227     
       
   228     EUNIT_ASSERT( origSession == &iSessionManager->Session() );
       
   229     EUNIT_ASSERT( iLcUiProvider->iCalledFunction != CLcUiProviderStub::EHandleForegroundStatus );
       
   230 
       
   231     // Background startup active, usecase changed, uiprovider informed and
       
   232     // new session replaces old one
       
   233     origSession = &iSessionManager->Session();
       
   234     iSessionManager->PropertyChanged( 
       
   235             NMusSessionApi::KUseCase, MultimediaSharing::EMusClipVideo );
       
   236     if ( origSession == &iSessionManager->Session() )
       
   237         {
       
   238         // Couldn't create new session because running out of memory
       
   239         User::Leave( KErrNoMemory );
       
   240         }
       
   241     EUNIT_ASSERT( origSession != &iSessionManager->Session() );
       
   242     EUNIT_ASSERT( iLcUiProvider->iCalledFunction == CLcUiProviderStub::EHandleForegroundStatus );
       
   243     EUNIT_ASSERT( iLcUiProvider->iForeground );
       
   244     }
       
   245 
       
   246 //  TEST TABLE
       
   247 
       
   248 EUNIT_BEGIN_TEST_TABLE(
       
   249     UT_CMusEngSessionManager,
       
   250     "UT_CMusEngSessionManager",
       
   251     "UNIT" )
       
   252 
       
   253 EUNIT_TEST(
       
   254     "NewL - test ",
       
   255     "CMusEngSessionManager",
       
   256     "NewL",
       
   257     "FUNCTIONALITY",
       
   258     SetupL, UT_NewL, Teardown)
       
   259 
       
   260 EUNIT_TEST(
       
   261     "Session - test ",
       
   262     "CMusEngSessionManager",
       
   263     "Session",
       
   264     "FUNCTIONALITY",
       
   265     SetupL, UT_SessionL, Teardown)
       
   266 
       
   267 EUNIT_TEST(
       
   268     "IsFeatureSupported - test ",
       
   269     "CMusEngSessionManager",
       
   270     "IsFeatureSupported",
       
   271     "FUNCTIONALITY",
       
   272     SetupL, UT_IsFeatureSupportedL, Teardown)
       
   273 
       
   274 EUNIT_TEST(
       
   275     "CreateMusSessionL - test ",
       
   276     "CMusEngSessionManager",
       
   277     "CreateMusSessionL",
       
   278     "FUNCTIONALITY",
       
   279     SetupL, UT_CreateMusSessionL, Teardown)
       
   280 
       
   281 EUNIT_TEST(
       
   282     "PropertyChanged - test ",
       
   283     "CMusEngSessionManager",
       
   284     "PropertyChanged",
       
   285     "FUNCTIONALITY",
       
   286     SetupL, UT_PropertyChangedL, Teardown)
       
   287     
       
   288 EUNIT_END_TEST_TABLE
       
   289 
       
   290 
       
   291 //  END OF FILE
       
   292 
       
   293