photos_plat/controllers_collection_api/tsrc/ut_collectionmanager/src/ut_collectionmanager.cpp
changeset 0 4e91876724a2
child 18 bcb43dc84c44
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     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 "ut_collectionmanager.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 // Cut_collectionmanager::Cut_collectionmanager
       
    76 // C++ default constructor can NOT contain any code, that
       
    77 // might leave.
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 Cut_collectionmanager::Cut_collectionmanager( 
       
    81     CTestModuleIf& aTestModuleIf ):
       
    82         CScriptBase( aTestModuleIf )
       
    83     {
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // Cut_collectionmanager::ConstructL
       
    88 // Symbian 2nd phase constructor can leave.
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 void Cut_collectionmanager::ConstructL()
       
    92     {
       
    93     //Read logger settings to check whether test case name is to be
       
    94     //appended to log file name.
       
    95     iAo = CGlxCollectionManagerAO :: NewL(*this);
       
    96     iWait = new (ELeave) CActiveSchedulerWait;
       
    97     RSettingServer settingServer;
       
    98     TInt ret = settingServer.Connect();
       
    99     if(ret != KErrNone)
       
   100         {
       
   101         User::Leave(ret);
       
   102         }
       
   103     // Struct to StifLogger settigs.
       
   104     TLoggerSettings loggerSettings; 
       
   105     // Parse StifLogger defaults from STIF initialization file.
       
   106     ret = settingServer.GetLoggerSettings(loggerSettings);
       
   107     if(ret != KErrNone)
       
   108         {
       
   109         User::Leave(ret);
       
   110         } 
       
   111     // Close Setting server session
       
   112     settingServer.Close();
       
   113 
       
   114     TFileName logFileName;
       
   115     
       
   116     if(loggerSettings.iAddTestCaseTitle)
       
   117         {
       
   118         TName title;
       
   119         TestModuleIf().GetTestCaseTitleL(title);
       
   120         logFileName.Format(Kut_collectionmanagerLogFileWithTitle, &title);
       
   121         }
       
   122     else
       
   123         {
       
   124         logFileName.Copy(Kut_collectionmanagerLogFile);
       
   125         }
       
   126 
       
   127     iLog = CStifLogger::NewL( Kut_collectionmanagerLogPath, 
       
   128                           logFileName,
       
   129                           CStifLogger::ETxt,
       
   130                           CStifLogger::EFile,
       
   131                           EFalse );
       
   132     
       
   133     SendTestClassVersion();
       
   134     
       
   135     }
       
   136 
       
   137 // -----------------------------------------------------------------------------
       
   138 // Cut_collectionmanager::NewL
       
   139 // Two-phased constructor.
       
   140 // -----------------------------------------------------------------------------
       
   141 //
       
   142 Cut_collectionmanager* Cut_collectionmanager::NewL( 
       
   143     CTestModuleIf& aTestModuleIf )
       
   144     {
       
   145     Cut_collectionmanager* self = new (ELeave) Cut_collectionmanager( aTestModuleIf );
       
   146 
       
   147     CleanupStack::PushL( self );
       
   148     self->ConstructL();
       
   149     CleanupStack::Pop();
       
   150 
       
   151     return self;
       
   152 
       
   153     }
       
   154 
       
   155         // Destructor
       
   156         Cut_collectionmanager::~Cut_collectionmanager()
       
   157             { 
       
   158             if( iWait )
       
   159                 {
       
   160                 delete iWait;
       
   161                 }
       
   162             if(iAo)
       
   163                 {
       
   164                 delete iAo;
       
   165                 iAo = NULL;
       
   166                 }
       
   167 
       
   168             // Delete resources allocated from test methods
       
   169             Delete();
       
   170 
       
   171     // Delete logger
       
   172     delete iLog; 
       
   173 
       
   174     }
       
   175 
       
   176 //-----------------------------------------------------------------------------
       
   177 // Cut_collectionmanager::SendTestClassVersion
       
   178 // Method used to send version of test class
       
   179 //-----------------------------------------------------------------------------
       
   180 //
       
   181 void Cut_collectionmanager::SendTestClassVersion()
       
   182 	{
       
   183 	TVersion moduleVersion;
       
   184 	moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
       
   185 	moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
       
   186 	moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
       
   187 	
       
   188 	TFileName moduleName;
       
   189 	moduleName = _L("ut_collectionmanager.dll");
       
   190 
       
   191 	TBool newVersionOfMethod = ETrue;
       
   192 	TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
       
   193 	}
       
   194 
       
   195 
       
   196 
       
   197 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   198 
       
   199 // -----------------------------------------------------------------------------
       
   200 // LibEntryL is a polymorphic Dll entry point.
       
   201 // Returns: CScriptBase: New CScriptBase derived object
       
   202 // -----------------------------------------------------------------------------
       
   203 //
       
   204 EXPORT_C CScriptBase* LibEntryL( 
       
   205     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
   206     {
       
   207 
       
   208     return ( CScriptBase* ) Cut_collectionmanager::NewL( aTestModuleIf );
       
   209 
       
   210     }
       
   211 
       
   212 
       
   213 //  End of File