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