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