uiservicetab/vimpststorage/tsrc/vimpststorage_ut/src/vimpststorage_test.cpp
branchRCL_3
changeset 29 9a48e301e94b
parent 0 5e5d6b214f4f
equal deleted inserted replaced
28:3104fc151679 29:9a48e301e94b
       
     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:  
       
    15 :                
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include <Stiftestinterface.h>
       
    24 #include "vimpststorage_test.h"
       
    25 #include <SettingServerClient.h>
       
    26 #include <cntdb.h>
       
    27 #include <cntitem.h>
       
    28 #include <cntfldst.h>
       
    29 #include <cntfield.h>
       
    30 
       
    31 // CONSTANTS
       
    32 
       
    33 
       
    34 
       
    35 // ============================= LOCAL FUNCTIONS ===============================
       
    36 
       
    37 
       
    38 
       
    39 // ============================ MEMBER FUNCTIONS ===============================
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // Cvimpststorage_test::Cvimpststorage_test
       
    43 // C++ default constructor can NOT contain any code, that
       
    44 // might leave.
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 Cvimpststorage_test::Cvimpststorage_test( 
       
    48     CTestModuleIf& aTestModuleIf ):
       
    49         CScriptBase( aTestModuleIf )
       
    50     {
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // Cvimpststorage_test::ConstructL
       
    55 // Symbian 2nd phase constructor can leave.
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 void Cvimpststorage_test::ConstructL()
       
    59     {
       
    60     //Read logger settings to check whether test case name is to be
       
    61     //appended to log file name.
       
    62     RSettingServer settingServer;
       
    63     TInt ret = settingServer.Connect();
       
    64     if(ret != KErrNone)
       
    65         {
       
    66         User::Leave(ret);
       
    67         }
       
    68     // Struct to StifLogger settigs.
       
    69     TLoggerSettings loggerSettings; 
       
    70     // Parse StifLogger defaults from STIF initialization file.
       
    71     ret = settingServer.GetLoggerSettings(loggerSettings);
       
    72     if(ret != KErrNone)
       
    73         {
       
    74         User::Leave(ret);
       
    75         } 
       
    76     // Close Setting server session
       
    77     settingServer.Close();
       
    78 
       
    79     TFileName logFileName;
       
    80     
       
    81     if(loggerSettings.iAddTestCaseTitle)
       
    82         {
       
    83         TName title;
       
    84         TestModuleIf().GetTestCaseTitleL(title);
       
    85         logFileName.Format(Kvimpststorage_testLogFileWithTitle, &title);
       
    86         }
       
    87     else
       
    88         {
       
    89         logFileName.Copy(Kvimpststorage_testLogFile);
       
    90         }
       
    91 
       
    92     iLog = CStifLogger::NewL( Kvimpststorage_testLogPath, 
       
    93                           logFileName,
       
    94                           CStifLogger::ETxt,
       
    95                           CStifLogger::EFile,
       
    96                           EFalse );
       
    97 
       
    98     
       
    99     CActiveScheduler* activeexist =CActiveScheduler::Current();
       
   100     if( !activeexist )
       
   101 		{
       
   102 		iActive = new (ELeave) CActiveScheduler();
       
   103 		CActiveScheduler::Install(iActive);	
       
   104 		}
       
   105 		
       
   106     }
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // Cvimpststorage_test::NewL
       
   110 // Two-phased constructor.
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 Cvimpststorage_test* Cvimpststorage_test::NewL( 
       
   114     CTestModuleIf& aTestModuleIf )
       
   115     {
       
   116     Cvimpststorage_test* self = new (ELeave) Cvimpststorage_test( aTestModuleIf );
       
   117 
       
   118     CleanupStack::PushL( self );
       
   119     self->ConstructL();
       
   120     CleanupStack::Pop();
       
   121 
       
   122     return self;
       
   123 
       
   124     }
       
   125 
       
   126 // Destructor
       
   127 Cvimpststorage_test::~Cvimpststorage_test()
       
   128     { 
       
   129     
       
   130     
       
   131 	
       
   132     // Delete resources allocated from test methods
       
   133     Delete();
       
   134 
       
   135     // Delete logger
       
   136     delete iLog; 
       
   137     
       
   138     if(iActive)
       
   139 	    {
       
   140 	    delete iActive;	
       
   141 	    }
       
   142 
       
   143     }
       
   144 
       
   145 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   146 
       
   147 // -----------------------------------------------------------------------------
       
   148 // LibEntryL is a polymorphic Dll entry point.
       
   149 // Returns: CScriptBase: New CScriptBase derived object
       
   150 // -----------------------------------------------------------------------------
       
   151 //
       
   152 EXPORT_C CScriptBase* LibEntryL( 
       
   153     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
   154     {
       
   155 
       
   156     return ( CScriptBase* ) Cvimpststorage_test::NewL( aTestModuleIf );
       
   157 
       
   158     }
       
   159 
       
   160 
       
   161 //  End of File