mmappcomponents/mmmtpdataprovider/tsrc/mtpdataprovidertestmodule/src/cmmmtpdataprovidertestmodule.cpp
changeset 0 a2952bb97e68
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     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:  Test module for mmmtpdataprovider plugin
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include <stiftestinterface.h>
       
    22 #include <settingserverclient.h>
       
    23 #include <mtp/mmtpdataprovider.h>
       
    24 #include <mtp/cmtpdataproviderplugin.h>
       
    25 #include "cmmmtpdataprovidertestmodule.h"
       
    26 #include "logging.h"
       
    27 
       
    28 // MACROS
       
    29 
       
    30 #ifdef LOGGER
       
    31 #undef LOGGER
       
    32 #endif
       
    33 #define LOGGER iLog
       
    34 
       
    35 // MEMBER FUNCTIONS
       
    36 
       
    37 CMmMtpDataProviderTestModule::CMmMtpDataProviderTestModule( 
       
    38         CTestModuleIf& aTestModuleIf )
       
    39         : CScriptBase( aTestModuleIf )
       
    40     {
       
    41     // no implementation required
       
    42     }
       
    43 
       
    44 void CMmMtpDataProviderTestModule::ConstructL()
       
    45     {
       
    46     TFileName logFileName;  
       
    47     logFileName.Copy(KMtpDataProviderTestModuleLogFile);
       
    48     
       
    49     iLog = CStifLogger::NewL( KMtpDataProviderTestModuleLogPath, 
       
    50             logFileName,
       
    51             CStifLogger::ETxt,
       
    52             TRACE_TARGET,
       
    53             ETrue, ETrue, ETrue, EFalse, ETrue );
       
    54     PRINTF0( ">CMmMtpDataProviderTestModule::ConstructL" );
       
    55     
       
    56     SendTestClassVersion();
       
    57     
       
    58     if ( CActiveScheduler::Current() == NULL ) 
       
    59         {
       
    60         iActiveScheduler = new ( ELeave ) CActiveScheduler;
       
    61         CActiveScheduler::Install( iActiveScheduler );        
       
    62         }
       
    63     iTestObserver = CTestObserver::NewL( this );
       
    64     iTestConnChannel = new ( ELeave ) CTestConnectionChannel();
       
    65     iRequest = new ( ELeave ) TMTPTypeRequest();
       
    66     
       
    67     PRINTF0( "<CMmMtpDataProviderTestModule::ConstructL" );
       
    68     }
       
    69 
       
    70 CMmMtpDataProviderTestModule* CMmMtpDataProviderTestModule::NewL( 
       
    71         CTestModuleIf& aTestModuleIf )
       
    72     {
       
    73     CMmMtpDataProviderTestModule* self = 
       
    74             new ( ELeave ) CMmMtpDataProviderTestModule( aTestModuleIf );
       
    75     
       
    76     CleanupStack::PushL( self );
       
    77     self->ConstructL();
       
    78     CleanupStack::Pop();
       
    79     
       
    80     return self;
       
    81     }
       
    82 
       
    83 CMmMtpDataProviderTestModule::~CMmMtpDataProviderTestModule()
       
    84     { 
       
    85     PRINTF0( ">CMmMtpDataProviderTestModule::~CMmMtpDataProviderTestModule" );
       
    86     
       
    87     // delete resources allocated from test methods
       
    88     Delete();
       
    89     
       
    90     if ( iTestObserver ) 
       
    91         {
       
    92         delete iTestObserver;
       
    93         }
       
    94      if ( iTestConnChannel )
       
    95         {
       
    96         delete iTestConnChannel;
       
    97         }
       
    98      if ( iActiveScheduler )
       
    99         {
       
   100         delete iActiveScheduler;
       
   101         }
       
   102      
       
   103      PRINTF0( "<CMmMtpDataProviderTestModule::~CMmMtpDataProviderTestModule" );
       
   104      if ( iLog )
       
   105          {
       
   106          delete iLog;
       
   107          }
       
   108     }
       
   109 
       
   110 void CMmMtpDataProviderTestModule::SendTestClassVersion()
       
   111     {
       
   112     PRINTF0( ">CMmMtpDataProviderTestModule::SendTestClassVersion" );
       
   113     TVersion moduleVersion;
       
   114     moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
       
   115     moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
       
   116     moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
       
   117     
       
   118     _LIT( KModuleName, "mmmtpdataprovidertester.dll" );
       
   119     TFileName moduleName( KModuleName );
       
   120     
       
   121     TBool newVersionOfMethod = ETrue;
       
   122     TestModuleIf().SendTestModuleVersion( moduleVersion, moduleName,
       
   123             newVersionOfMethod );
       
   124     PRINTF0( "<CMmMtpDataProviderTestModule::SendTestClassVersion" );
       
   125     }
       
   126 
       
   127 // EXPORTED FUNCTIONS
       
   128 
       
   129 // polymorphic library entry point
       
   130 EXPORT_C CScriptBase* LibEntryL( CTestModuleIf& aTestModuleIf )
       
   131     {
       
   132     return ( CScriptBase* ) CMmMtpDataProviderTestModule::NewL( aTestModuleIf );
       
   133     }