messagingfw/deprecate/send_ui_api/tsrc/bc/src/SendUIAPITest.cpp
branchRCL_3
changeset 23 d51193d814ea
parent 22 d2c4c66342f3
child 24 002ade1da91c
equal deleted inserted replaced
22:d2c4c66342f3 23:d51193d814ea
     1 /*
       
     2 * Copyright (c) 2002-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:         SendUIAPITest implementation
       
    15 
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 // INCLUDE FILES
       
    29 #include <Stiftestinterface.h>
       
    30 #include "SendUIAPITest.h"
       
    31 #include <SettingServerClient.h>
       
    32 
       
    33 // EXTERNAL DATA STRUCTURES
       
    34 //extern  ?external_data;
       
    35 
       
    36 // EXTERNAL FUNCTION PROTOTYPES  
       
    37 //extern ?external_function( ?arg_type,?arg_type );
       
    38 
       
    39 // CONSTANTS
       
    40 //const ?type ?constant_var = ?constant;
       
    41 
       
    42 // MACROS
       
    43 //#define ?macro ?macro_def
       
    44 
       
    45 // LOCAL CONSTANTS AND MACROS
       
    46 //const ?type ?constant_var = ?constant;
       
    47 //#define ?macro_name ?macro_def
       
    48 
       
    49 // MODULE DATA STRUCTURES
       
    50 //enum ?declaration
       
    51 //typedef ?declaration
       
    52 
       
    53 // LOCAL FUNCTION PROTOTYPES
       
    54 //?type ?function_name( ?arg_type, ?arg_type );
       
    55 
       
    56 // FORWARD DECLARATIONS
       
    57 //class ?FORWARD_CLASSNAME;
       
    58 
       
    59 // ============================= LOCAL FUNCTIONS ===============================
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // ?function_name ?description.
       
    63 // ?description
       
    64 // Returns: ?value_1: ?description
       
    65 //          ?value_n: ?description_line1
       
    66 //                    ?description_line2
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 /*
       
    70 ?type ?function_name(
       
    71     ?arg_type arg,  // ?description
       
    72     ?arg_type arg)  // ?description
       
    73     {
       
    74 
       
    75     ?code  // ?comment
       
    76 
       
    77     // ?comment
       
    78     ?code
       
    79     }
       
    80 */
       
    81 
       
    82 // ============================ MEMBER FUNCTIONS ===============================
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CSendUIAPITest::CSendUIAPITest
       
    86 // C++ default constructor can NOT contain any code, that
       
    87 // might leave.
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 CSendUIAPITest::CSendUIAPITest( 
       
    91     CTestModuleIf& aTestModuleIf ):
       
    92         CScriptBase( aTestModuleIf ),
       
    93         iMessageData( NULL ),
       
    94         iMessageAddress( NULL )
       
    95     {
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CSendUIAPITest::ConstructL
       
   100 // Symbian 2nd phase constructor can leave.
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 void CSendUIAPITest::ConstructL()
       
   104     {
       
   105     //Read logger settings to check whether test case name is to be
       
   106     //appended to log file name.
       
   107     RSettingServer settingServer;
       
   108     TInt ret = settingServer.Connect();
       
   109     if(ret != KErrNone)
       
   110         {
       
   111         User::Leave(ret);
       
   112         }
       
   113     // Struct to StifLogger settigs.
       
   114     TLoggerSettings loggerSettings; 
       
   115     // Parse StifLogger defaults from STIF initialization file.
       
   116     ret = settingServer.GetLoggerSettings(loggerSettings);
       
   117     if(ret != KErrNone)
       
   118         {
       
   119         User::Leave(ret);
       
   120         } 
       
   121     // Close Setting server session
       
   122     settingServer.Close();
       
   123 
       
   124     TFileName logFileName;
       
   125     
       
   126     if(loggerSettings.iAddTestCaseTitle)
       
   127         {
       
   128         TName title;
       
   129         TestModuleIf().GetTestCaseTitleL(title);
       
   130         logFileName.Format(KSendUIAPITestLogFileWithTitle, &title);
       
   131         }
       
   132     else
       
   133         {
       
   134         logFileName.Copy(KSendUIAPITestLogFile);
       
   135         }
       
   136 
       
   137     iLog = CStifLogger::NewL( KSendUIAPITestLogPath, 
       
   138                           logFileName,
       
   139                           CStifLogger::ETxt,	
       
   140                           CStifLogger::EFile,
       
   141                           EFalse );
       
   142                           
       
   143 
       
   144     SendTestClassVersion();
       
   145     }
       
   146 
       
   147 // -----------------------------------------------------------------------------
       
   148 // CSendUIAPITest::NewL
       
   149 // Two-phased constructor.
       
   150 // -----------------------------------------------------------------------------
       
   151 //
       
   152 CSendUIAPITest* CSendUIAPITest::NewL( 
       
   153     CTestModuleIf& aTestModuleIf )
       
   154     {
       
   155     CSendUIAPITest* self = new (ELeave) CSendUIAPITest( aTestModuleIf );
       
   156 
       
   157     CleanupStack::PushL( self );
       
   158     self->ConstructL();
       
   159     CleanupStack::Pop( self );
       
   160 
       
   161     return self;
       
   162 
       
   163     }
       
   164 
       
   165 // Destructor
       
   166 CSendUIAPITest::~CSendUIAPITest()
       
   167     { 
       
   168 
       
   169     // Delete resources allocated from test methods
       
   170     Delete();
       
   171 	
       
   172     // Delete logger
       
   173     delete iLog; 
       
   174 
       
   175     }
       
   176 
       
   177 // -----------------------------------------------------------------------------
       
   178 // CSendUIAPITest::?MsgDataSetSubjectL
       
   179 // ?Test Case for Calling CMessageData's SetSubjectL fun
       
   180 // (other items were commented in a header).
       
   181 // -----------------------------------------------------------------------------
       
   182 //
       
   183 
       
   184 TInt CSendUIAPITest::MsgDataSetSubjectL( TPtrC& aSubject )
       
   185    {
       
   186    // Print to UI
       
   187    _LIT( KSendUIAPITest, "SendUIAPITest" );
       
   188    _LIT( KMsgDataSetSubjectL, "In MsgDataSetSubjectL" );
       
   189    TestModuleIf().Printf( 0, KSendUIAPITest, KMsgDataSetSubjectL );
       
   190    // Print to log file
       
   191    iLog->Log( KMsgDataSetSubjectL);
       
   192    
       
   193    //Create the instance of CMessageData
       
   194    CMessageData* messagedata = InitL();
       
   195    
       
   196    //Set the subject 
       
   197    TRAPD(err,messagedata->SetSubjectL(&aSubject));
       
   198    if(err == KErrNone)
       
   199 		{
       
   200 		return KErrNone;
       
   201 		}
       
   202 			
       
   203 	else
       
   204 		{
       
   205 		return err;
       
   206 		}
       
   207  
       
   208    }
       
   209    
       
   210  // -----------------------------------------------------------------------------
       
   211 // CSendUIAPITest::?MsgDataCompSubjectL
       
   212 // ?Test Case for Calling CMessageData's Subject fun and comparing it with passed param
       
   213 // (other items were commented in a header).
       
   214 // -----------------------------------------------------------------------------
       
   215 // 
       
   216 
       
   217 TInt CSendUIAPITest::MsgDataCompSubjectL( TPtrC& aSubject )
       
   218 	{
       
   219 	// Print to UI
       
   220 	_LIT( KSendUIAPITest, "SendUIAPITest" );
       
   221 	_LIT( KMsgDataCompSubjectL, "In MsgDataCompSubjectL" );
       
   222 	TestModuleIf().Printf( 0, KSendUIAPITest, KMsgDataCompSubjectL );
       
   223 	// Print to log file
       
   224 	iLog->Log( KMsgDataCompSubjectL);
       
   225 
       
   226 	//Create the instance of CMessageData
       
   227 	CMessageData* messagedata = InitL();
       
   228 	//Get the subject from message data
       
   229 	TPtrC msgdatasubject = messagedata->Subject();
       
   230 
       
   231 	//Compare the two subjects
       
   232 	if(msgdatasubject == aSubject)
       
   233 		{
       
   234 		return KErrNone;
       
   235 		}	
       
   236 	else
       
   237 		{
       
   238 		return KErrGeneral;
       
   239 		}
       
   240 	}
       
   241 	
       
   242 //-----------------------------------------------------------------------------
       
   243 // CSendUIAPITest::SendTestClassVersion
       
   244 // Method used to send version of test class
       
   245 //-----------------------------------------------------------------------------
       
   246 //
       
   247 void CSendUIAPITest::SendTestClassVersion()
       
   248 	{
       
   249 	TVersion moduleVersion;
       
   250 	moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
       
   251 	moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
       
   252 	moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
       
   253 	
       
   254 	TFileName moduleName;
       
   255 	moduleName = _L("SendUIAPITest.dll");
       
   256 
       
   257 	TBool newVersionOfMethod = ETrue;
       
   258 	TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
       
   259 	}
       
   260 
       
   261 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   262 
       
   263 // -----------------------------------------------------------------------------
       
   264 // LibEntryL is a polymorphic Dll entry point.
       
   265 // Returns: CScriptBase: New CScriptBase derived object
       
   266 // -----------------------------------------------------------------------------
       
   267 //
       
   268 EXPORT_C CScriptBase* LibEntryL( 
       
   269     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
   270     {
       
   271 
       
   272     return ( CScriptBase* ) CSendUIAPITest::NewL( aTestModuleIf );
       
   273 
       
   274     }
       
   275 
       
   276 
       
   277 //  End of File