classicui_plat/grids_api/tsrc/src/testsdkgrids.cpp
branchRCL_3
changeset 19 aecbbf00d063
equal deleted inserted replaced
18:fcdfafb36fe7 19:aecbbf00d063
       
     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 grids_api
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /*
       
    20  *  INCLUDE FILES
       
    21  */
       
    22 #include <stiftestinterface.h>
       
    23 #include <settingserverclient.h>
       
    24 #include <e32property.h>
       
    25 #include <coeaui.h>
       
    26 
       
    27 #include "testsdkgridsview.h"
       
    28 #include "testsdkgridscontainer.h"
       
    29 #include "testsdkgrids.h"
       
    30 
       
    31 // ============================ MEMBER FUNCTIONS ===============================
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // Ctestsdkgrids::Ctestsdkgrids
       
    35 // C++ default constructor can NOT contain any code, that
       
    36 // might leave.
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CTestSDKGrids::CTestSDKGrids( CTestModuleIf& aTestModuleIf ):
       
    40     CScriptBase( aTestModuleIf )
       
    41     {
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // Ctestsdkgrids::ConstructL
       
    46 // Symbian 2nd phase constructor can leave.
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 void CTestSDKGrids::ConstructL()
       
    50     {
       
    51     iView = CTestSDKGridsView::NewL();
       
    52     iContainer = new( ELeave ) CTestSDKGridsContainer();
       
    53 
       
    54     iContainer->SetMopParent( iView );
       
    55     iContainer->ConstructL( iView->ClientRect() );
       
    56     CCoeEnv::Static()->AppUi()->AddToStackL( iContainer );
       
    57     iContainer->MakeVisible( ETrue );
       
    58     
       
    59     RSettingServer settingServer;
       
    60     TInt ret = settingServer.Connect();
       
    61     if(ret != KErrNone)
       
    62         {
       
    63         User::Leave(ret);
       
    64         }
       
    65     TLoggerSettings loggerSettings; 
       
    66     ret = settingServer.GetLoggerSettings(loggerSettings);
       
    67     if(ret != KErrNone)
       
    68         {
       
    69         User::Leave(ret);
       
    70         } 
       
    71     settingServer.Close();
       
    72 
       
    73     TFileName logFileName;
       
    74     
       
    75     if(loggerSettings.iAddTestCaseTitle)
       
    76         {
       
    77         TName title;
       
    78         TestModuleIf().GetTestCaseTitleL(title);
       
    79         logFileName.Format(KtestsdkgridsLogFileWithTitle, &title);
       
    80         }
       
    81     else
       
    82         {
       
    83         logFileName.Copy(KtestsdkgridsLogFile);
       
    84         }
       
    85 
       
    86     iLog = CStifLogger::NewL( KtestsdkgridsLogPath, 
       
    87                           logFileName,
       
    88                           CStifLogger::ETxt,
       
    89                           CStifLogger::EFile,
       
    90                           EFalse );
       
    91 
       
    92     iOffset = CCoeEnv::Static()->AddResourceFileL( _L( "C:\\resource\\testsdkgrids.rsc" ) );
       
    93 
       
    94     SendTestClassVersion();
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // Ctestsdkgrids::NewL
       
    99 // Two-phased constructor.
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 CTestSDKGrids* CTestSDKGrids::NewL( CTestModuleIf& aTestModuleIf )
       
   103     {
       
   104     CTestSDKGrids* self = new( ELeave ) CTestSDKGrids( aTestModuleIf );
       
   105 
       
   106     CleanupStack::PushL( self );
       
   107     self->ConstructL();
       
   108     CleanupStack::Pop();
       
   109 
       
   110     return self;
       
   111 
       
   112     }
       
   113 
       
   114 /*
       
   115  * Destructor
       
   116  */
       
   117 CTestSDKGrids::~CTestSDKGrids()
       
   118     { 
       
   119 
       
   120     Delete();
       
   121     CCoeEnv::Static()->AppUi()->RemoveFromStack( iContainer );
       
   122     delete iContainer;
       
   123     delete iView;
       
   124 
       
   125     delete iLog; 
       
   126 
       
   127     CCoeEnv::Static()->DeleteResourceFile( iOffset );
       
   128     }
       
   129 
       
   130 //-----------------------------------------------------------------------------
       
   131 // Ctestsdkgrids::SendTestClassVersion
       
   132 // Method used to send version of test class
       
   133 //-----------------------------------------------------------------------------
       
   134 //
       
   135 void CTestSDKGrids::SendTestClassVersion()
       
   136     {
       
   137     TVersion moduleVersion;
       
   138     moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
       
   139     moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
       
   140     moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
       
   141 
       
   142     TFileName moduleName;
       
   143     moduleName = _L( "testsdkgrids.dll" );
       
   144 
       
   145     TBool newVersionOfMethod = ETrue;
       
   146     TestModuleIf().SendTestModuleVersion( moduleVersion, moduleName, 
       
   147         newVersionOfMethod );
       
   148     }
       
   149 
       
   150 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   151 
       
   152 // -----------------------------------------------------------------------------
       
   153 // LibEntryL is a polymorphic Dll entry point.
       
   154 // Returns: CScriptBase: New CScriptBase derived object
       
   155 // -----------------------------------------------------------------------------
       
   156 //
       
   157 EXPORT_C CScriptBase* LibEntryL( 
       
   158     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
   159     {
       
   160     return ( CScriptBase* ) CTestSDKGrids::NewL( aTestModuleIf );
       
   161     }
       
   162 /*
       
   163  *   End of File
       
   164  */