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