classicui_plat/dialogs_api/tsrc/src/testsdkdialogs.cpp
changeset 49 31c16e0c5e3e
equal deleted inserted replaced
40:7165f928e888 49:31c16e0c5e3e
       
     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:  Test EIKDIALG.H
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <stiftestinterface.h>
       
    22 #include <settingserverclient.h>
       
    23 #include <coeaui.h>
       
    24 
       
    25 #include "testsdkdialogs.h"
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ===============================
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CTestSDKDialogs::CTestSDKDialogs
       
    31 // C++ default constructor can NOT contain any code, that
       
    32 // might leave.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 CTestSDKDialogs::CTestSDKDialogs( CTestModuleIf& aTestModuleIf ):
       
    36     CScriptBase( aTestModuleIf )
       
    37     {
       
    38     }
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // CTestSDKDialogs::ConstructL
       
    42 // Symbian 2nd phase constructor can leave.
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 void CTestSDKDialogs::ConstructL()
       
    46     {
       
    47     //Read logger settings to check whether test case name is to be
       
    48     //appended to log file name.
       
    49     RSettingServer settingServer;
       
    50     CleanupClosePushL( settingServer );
       
    51     TInt ret = settingServer.Connect();
       
    52     if(ret != KErrNone)
       
    53         {
       
    54         User::Leave(ret);
       
    55         }
       
    56     // Struct to StifLogger settigs.
       
    57     TLoggerSettings loggerSettings; 
       
    58     // Parse StifLogger defaults from STIF initialization file.
       
    59     ret = settingServer.GetLoggerSettings(loggerSettings);
       
    60     if(ret != KErrNone)
       
    61         {
       
    62         User::Leave(ret);
       
    63         } 
       
    64     // Close Setting server session
       
    65     CleanupStack::PopAndDestroy( &settingServer );
       
    66 
       
    67     TFileName logFileName;
       
    68     
       
    69     if(loggerSettings.iAddTestCaseTitle)
       
    70         {
       
    71         TName title;
       
    72         TestModuleIf().GetTestCaseTitleL(title);
       
    73         logFileName.Format(KtestsdkdialogsLogFileWithTitle, &title);
       
    74         }
       
    75     else
       
    76         {
       
    77         logFileName.Copy(KtestsdkdialogsLogFile);
       
    78         }
       
    79 
       
    80     iLog = CStifLogger::NewL( KtestsdkdialogsLogPath, 
       
    81                           logFileName,
       
    82                           CStifLogger::ETxt,
       
    83                           CStifLogger::EFile,
       
    84                           EFalse );
       
    85     _LIT( KFile, "C:\\resource\\testsdkdialogs.rsc" );
       
    86     iOffset = CCoeEnv::Static()->AddResourceFileL( KFile );
       
    87     SendTestClassVersion();
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CTestSDKDialogs::NewL
       
    92 // Two-phased constructor.
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 CTestSDKDialogs* CTestSDKDialogs::NewL( CTestModuleIf& aTestModuleIf )
       
    96     {
       
    97     CTestSDKDialogs* self = new( ELeave ) CTestSDKDialogs( aTestModuleIf );
       
    98 
       
    99     CleanupStack::PushL( self );
       
   100     self->ConstructL();
       
   101     CleanupStack::Pop( self );
       
   102 
       
   103     return self;
       
   104 
       
   105     }
       
   106 
       
   107 // Destructor
       
   108 CTestSDKDialogs::~CTestSDKDialogs()
       
   109     { 
       
   110 
       
   111     // Delete resources allocated from test methods
       
   112     Delete();
       
   113 
       
   114     // Delete logger
       
   115     delete iLog; 
       
   116 
       
   117     CCoeEnv::Static()->DeleteResourceFile( iOffset );
       
   118     }
       
   119 
       
   120 //-----------------------------------------------------------------------------
       
   121 // CTestSDKDialogs::SendTestClassVersion
       
   122 // Method used to send version of test class
       
   123 //-----------------------------------------------------------------------------
       
   124 //
       
   125 void CTestSDKDialogs::SendTestClassVersion()
       
   126     {
       
   127     TVersion moduleVersion;
       
   128     moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
       
   129     moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
       
   130     moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
       
   131     
       
   132     _LIT( KFileName, "testsdkdialogs.dll" );
       
   133     TFileName moduleName( KFileName );
       
   134 
       
   135     TBool newVersionOfMethod = ETrue;
       
   136     TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
       
   137     }
       
   138 
       
   139 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   140 
       
   141 // -----------------------------------------------------------------------------
       
   142 // LibEntryL is a polymorphic Dll entry point.
       
   143 // Returns: CScriptBase: New CScriptBase derived object
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 EXPORT_C CScriptBase* LibEntryL( 
       
   147     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
   148     {
       
   149 
       
   150     return ( CScriptBase* ) CTestSDKDialogs::NewL( aTestModuleIf );
       
   151 
       
   152     }
       
   153 
       
   154 //  End of File