usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/src/USBRemotePersonalityTest.cpp
changeset 0 1e05558e2206
child 87 18fe5224f0dc
equal deleted inserted replaced
-1:000000000000 0:1e05558e2206
       
     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 
       
    21 // INCLUDE FILES
       
    22 #include <Stiftestinterface.h>
       
    23 #include "USBRemotePersonalityTest.h"
       
    24 #include <SettingServerClient.h>
       
    25 
       
    26 // EXTERNAL DATA STRUCTURES
       
    27 //extern  ?external_data;
       
    28 
       
    29 // EXTERNAL FUNCTION PROTOTYPES  
       
    30 //extern ?external_function( ?arg_type,?arg_type );
       
    31 
       
    32 // CONSTANTS
       
    33 //const ?type ?constant_var = ?constant;
       
    34 
       
    35 // MACROS
       
    36 //#define ?macro ?macro_def
       
    37 
       
    38 // LOCAL CONSTANTS AND MACROS
       
    39 //const ?type ?constant_var = ?constant;
       
    40 //#define ?macro_name ?macro_def
       
    41 
       
    42 // MODULE DATA STRUCTURES
       
    43 //enum ?declaration
       
    44 //typedef ?declaration
       
    45 
       
    46 // LOCAL FUNCTION PROTOTYPES
       
    47 //?type ?function_name( ?arg_type, ?arg_type );
       
    48 
       
    49 // FORWARD DECLARATIONS
       
    50 //class ?FORWARD_CLASSNAME;
       
    51 
       
    52 // ============================= LOCAL FUNCTIONS ===============================
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // ?function_name ?description.
       
    56 // ?description
       
    57 // Returns: ?value_1: ?description
       
    58 //          ?value_n: ?description_line1
       
    59 //                    ?description_line2
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 /*
       
    63 ?type ?function_name(
       
    64     ?arg_type arg,  // ?description
       
    65     ?arg_type arg)  // ?description
       
    66     {
       
    67 
       
    68     ?code  // ?comment
       
    69 
       
    70     // ?comment
       
    71     ?code
       
    72     }
       
    73 */
       
    74 
       
    75 // ============================ MEMBER FUNCTIONS ===============================
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CUSBRemotePersonalityTest::CUSBRemotePersonalityTest
       
    79 // C++ default constructor can NOT contain any code, that
       
    80 // might leave.
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 CUSBRemotePersonalityTest::CUSBRemotePersonalityTest( 
       
    84     CTestModuleIf& aTestModuleIf ):
       
    85         CScriptBase( aTestModuleIf )
       
    86     {
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CUSBRemotePersonalityTest::ConstructL
       
    91 // Symbian 2nd phase constructor can leave.
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 void CUSBRemotePersonalityTest::ConstructL()
       
    95     {
       
    96     //Read logger settings to check whether test case name is to be
       
    97     //appended to log file name.
       
    98     RSettingServer settingServer;
       
    99     TInt ret = settingServer.Connect();
       
   100     if(ret != KErrNone)
       
   101         {
       
   102         User::Leave(ret);
       
   103         }
       
   104     // Struct to StifLogger settigs.
       
   105     TLoggerSettings loggerSettings; 
       
   106     // Parse StifLogger defaults from STIF initialization file.
       
   107     ret = settingServer.GetLoggerSettings(loggerSettings);
       
   108     if(ret != KErrNone)
       
   109         {
       
   110         User::Leave(ret);
       
   111         } 
       
   112     // Close Setting server session
       
   113     settingServer.Close();
       
   114 
       
   115     TFileName logFileName;
       
   116     
       
   117     if(loggerSettings.iAddTestCaseTitle)
       
   118         {
       
   119         TName title;
       
   120         TestModuleIf().GetTestCaseTitleL(title);
       
   121         logFileName.Format(KUSBRemotePersonalityTestLogFileWithTitle, &title);
       
   122         }
       
   123     else
       
   124         {
       
   125         logFileName.Copy(KUSBRemotePersonalityTestLogFile);
       
   126         }
       
   127 
       
   128     iLog = CStifLogger::NewL( KUSBRemotePersonalityTestLogPath, 
       
   129                           logFileName,
       
   130                           CStifLogger::ETxt,
       
   131                           CStifLogger::EFile,
       
   132                           EFalse );
       
   133     
       
   134     SendTestClassVersion();
       
   135     
       
   136     iUsbMan = new ( ELeave ) RUsb();
       
   137     User::LeaveIfError( iUsbMan -> Connect() );
       
   138     
       
   139     iUsbWatcher = new ( ELeave ) RUsbWatcher();
       
   140     User::LeaveIfError( iUsbWatcher -> Connect() );
       
   141     
       
   142     iDevUsbClient = new ( ELeave ) RDevUsbcClient();
       
   143     User::LeaveIfError( iDevUsbClient -> Open( 0 ) );
       
   144     
       
   145     iPlugin = ( reinterpret_cast< CRemotePersonalityHandler* >( 
       
   146             REComSession::CreateImplementationL( TUid::Uid( KRemotePersonalityPluginImpUid ), iPluginDtorIDKey ) ) );
       
   147     
       
   148     User::LeaveIfError( iSetupBuff.Create( KSetupPacketLength ) );
       
   149     User::LeaveIfError( iDataBuff.Create( 0 ) );
       
   150     
       
   151     }
       
   152 
       
   153 // -----------------------------------------------------------------------------
       
   154 // CUSBRemotePersonalityTest::NewL
       
   155 // Two-phased constructor.
       
   156 // -----------------------------------------------------------------------------
       
   157 //
       
   158 CUSBRemotePersonalityTest* CUSBRemotePersonalityTest::NewL( 
       
   159     CTestModuleIf& aTestModuleIf )
       
   160     {
       
   161     CUSBRemotePersonalityTest* self = new (ELeave) CUSBRemotePersonalityTest( aTestModuleIf );
       
   162 
       
   163     CleanupStack::PushL( self );
       
   164     self->ConstructL();
       
   165     CleanupStack::Pop();
       
   166 
       
   167     return self;
       
   168 
       
   169     }
       
   170 
       
   171 // Destructor
       
   172 CUSBRemotePersonalityTest::~CUSBRemotePersonalityTest()
       
   173     { 
       
   174 
       
   175     // Delete resources allocated from test methods
       
   176     Delete();
       
   177 
       
   178     // Delete logger
       
   179     delete iLog; 
       
   180 
       
   181     }
       
   182 
       
   183 //-----------------------------------------------------------------------------
       
   184 // CUSBRemotePersonalityTest::SendTestClassVersion
       
   185 // Method used to send version of test class
       
   186 //-----------------------------------------------------------------------------
       
   187 //
       
   188 void CUSBRemotePersonalityTest::SendTestClassVersion()
       
   189 	{
       
   190 	TVersion moduleVersion;
       
   191 	moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
       
   192 	moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
       
   193 	moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
       
   194 	
       
   195 	TFileName moduleName;
       
   196 	moduleName = _L("USBRemotePersonalityTest.dll");
       
   197 
       
   198 	TBool newVersionOfMethod = ETrue;
       
   199 	TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
       
   200 	}
       
   201 
       
   202 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   203 
       
   204 // -----------------------------------------------------------------------------
       
   205 // LibEntryL is a polymorphic Dll entry point.
       
   206 // Returns: CScriptBase: New CScriptBase derived object
       
   207 // -----------------------------------------------------------------------------
       
   208 //
       
   209 EXPORT_C CScriptBase* LibEntryL( 
       
   210     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
   211     {
       
   212 
       
   213     return ( CScriptBase* ) CUSBRemotePersonalityTest::NewL( aTestModuleIf );
       
   214 
       
   215     }
       
   216 
       
   217 
       
   218 //  End of File