adaptationlayer/tsy/nokiatsy_dll/internal/test/nokiatsy_test_tool/core_exports_to_roots/src/core.cpp
changeset 4 510c70acdbf6
parent 3 1972d8c2e329
child 5 8ccc39f9d787
equal deleted inserted replaced
3:1972d8c2e329 4:510c70acdbf6
     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 the License "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:   Base class of all other test classes
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <stiftestinterface.h>
       
    23 #include "core.h"
       
    24 #include "cmmessagemanagercallback.h"
       
    25 #include "tsylogger.h"
       
    26 
       
    27 
       
    28 static const TUint KIscTestCaseCompletionSignalCode = 1;
       
    29 
       
    30 // ============================ MEMBER FUNCTIONS ===============================
       
    31 
       
    32 TTestCaseObserverHelper::TTestCaseObserverHelper(CCore& aCore) :
       
    33     iCore(aCore)
       
    34     {}
       
    35 
       
    36 void TTestCaseObserverHelper::IscTestCaseCompleteL()
       
    37     {
       
    38     iCore.IscTestCaseCompleteL();
       
    39     }
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CCore::CCore
       
    43 // C++ default constructor can NOT contain any code, that
       
    44 // might leave.
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 EXPORT_C CCore::CCore(
       
    48     CTestModuleIf& aTestModuleIf ):
       
    49         CScriptBase( aTestModuleIf ),
       
    50         iHelper(*this)
       
    51     {
       
    52 
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CCore::BaseConstructL
       
    57 // Symbian 2nd phase constructor can leave.
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 EXPORT_C void CCore::BaseConstructL( CCore* aTestModule )
       
    61     {
       
    62     iCoreLog = CStifLogger::NewL( KCoreLogPath,
       
    63                           KCoreLogFile,
       
    64                           CStifLogger::ETxt,
       
    65                           CStifLogger::EFile,
       
    66                           EFalse );
       
    67 
       
    68     _LIT8(KBaseConstruct, "CCore:BaseConstructL");
       
    69     iCoreLog->Log((TDesC8)KBaseConstruct);
       
    70 
       
    71     iTestModule = aTestModule;
       
    72 
       
    73     iIscTestCase = new(ELeave) CIscTestCase();
       
    74 
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CCore::NewL
       
    79 // Two-phased constructor.
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 CCore* CCore::NewL(
       
    83     CTestModuleIf& aTestModuleIf )
       
    84     {
       
    85 
       
    86     CCore* self = new (ELeave) CCore( aTestModuleIf );
       
    87     CleanupStack::PushL( (CScriptBase*)self );
       
    88     self->BaseConstructL( self );
       
    89     CleanupStack::Pop(self);
       
    90 
       
    91     return self;
       
    92     }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // CCore::~CCore()
       
    96 // Destructor
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 EXPORT_C CCore::~CCore()
       
   100     {
       
   101     iCoreLog->Log(_L("CCore::~CCore") );
       
   102 
       
   103     // Delete resources allocated from test methods
       
   104     Delete();
       
   105 
       
   106     // delete isc controller
       
   107     delete iIscTestCase;
       
   108 
       
   109     CloseNTSY();
       
   110 
       
   111     // Delete logger
       
   112     delete iCoreLog;
       
   113     }
       
   114 
       
   115 // -----------------------------------------------------------------------------
       
   116 // CCore::CloseNTSY()
       
   117 // Close/delete NTSY
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 EXPORT_C TInt CCore::CloseNTSY()
       
   121     {
       
   122     iCoreLog->Log(_L("CCore::CloseNTSY") );
       
   123 
       
   124     if ( iMessageManagerCallBack )
       
   125         {
       
   126         //delete messageManager object
       
   127         delete iMessageManagerCallBack;
       
   128         iMessageManagerCallBack = NULL;
       
   129         }
       
   130 
       
   131     if ( iLtsyFactory )
       
   132         {
       
   133         iLtsyFactory->Release();
       
   134         iLtsyFactory = NULL;
       
   135         }
       
   136 
       
   137     return KErrNone;
       
   138     }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CCore::InitializeIscControlL
       
   142 // Two-phased constructor.
       
   143 // -----------------------------------------------------------------------------
       
   144 //
       
   145 EXPORT_C void CCore::InitializeIscControlL(const TDesC& aIscTestCaseFile)
       
   146     {
       
   147     iCoreLog->Log(_L("CCore::InitializeIscControl(%S)"), &aIscTestCaseFile );
       
   148     iIscTestCase->InitializeL(aIscTestCaseFile);
       
   149     }
       
   150 
       
   151 // -----------------------------------------------------------------------------
       
   152 // CCCore::SyncIscControl
       
   153 // Two-phased constructor.
       
   154 // -----------------------------------------------------------------------------
       
   155 //
       
   156 EXPORT_C void CCore::SyncIscControl()
       
   157     {
       
   158     iCoreLog->Log(_L("CCore::SyncIscControl"));
       
   159     iIscTestCase->Sync();
       
   160     }
       
   161 
       
   162 // -----------------------------------------------------------------------------
       
   163 // CCore::RunIscControlTestCase
       
   164 // Two-phased constructor.
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 EXPORT_C void CCore::RunIscControlTestCase(TInt aTestControlId, TInt aTestCaseId)
       
   168     {
       
   169     iCoreLog->Log(_L("CCore::RunIscControlTestCase (%d,%d)"), aTestControlId, aTestCaseId);
       
   170     iIscTestCase->RunTestCase(aTestControlId, aTestCaseId, iHelper);
       
   171     }
       
   172 
       
   173 // -----------------------------------------------------------------------------
       
   174 // CCore::CreateMMAndLTSYfactoryAndGetMessageRouter
       
   175 // Create Message Manager, LTSY factory and get message router
       
   176 // -----------------------------------------------------------------------------
       
   177 //
       
   178 EXPORT_C void CCore::CreateMMAndLTSYfactoryAndGetMessageRouter( void )
       
   179     {
       
   180     // Create Message Manager (the 'core' of the LTSY Plug-in API)
       
   181 
       
   182     if( !iMessageManagerCallBack )
       
   183         {
       
   184         iMessageManagerCallBack = CMmMessageManagerCallback::NewL( iTestModule );
       
   185 
       
   186         // create LTSY factory
       
   187         iLtsyFactory = ( MLtsyFactoryV1* ) LTsyFactoryL();
       
   188 
       
   189         // Get message router
       
   190         iMessageRouter = iLtsyFactory->GetMessageRouter( *iMessageManagerCallBack );
       
   191         }
       
   192     }
       
   193 
       
   194 
       
   195 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   196 
       
   197 // -----------------------------------------------------------------------------
       
   198 // LibEntryL is a polymorphic Dll entry point.
       
   199 // Returns: CScriptBase: New CScriptBase derived object
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 EXPORT_C CScriptBase* LibEntryL(
       
   203     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
   204     {
       
   205 
       
   206     return ( CScriptBase* ) CCore::NewL( aTestModuleIf );
       
   207 
       
   208     }
       
   209 
       
   210 // -----------------------------------------------------------------------------
       
   211 // CCore::IscTestCaseCompleteL
       
   212 // Handles notification when ISC testcase is done
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 void CCore::IscTestCaseCompleteL()
       
   216     {
       
   217     _LIT8(KLog, "CCore::IscTestCaseCompleteL");
       
   218     iCoreLog->Log((TDesC8)KLog);
       
   219     // to keep the functionality
       
   220     Signal(KIscTestCaseCompletionSignalCode);
       
   221     }
       
   222 //  End of File