testexecfw/stf/examples/demomodule/src/DemoModule.cpp
author Johnson Ma <johnson.ma@nokia.com>
Thu, 13 May 2010 17:42:48 +0800
changeset 3 a5f55a5789f3
parent 2 8bb370ba6d1d
permissions -rw-r--r--
Defect Fix: TeamTrack DEF145107
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     1
/*
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     8
*
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    11
*
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    12
* Contributors:
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    13
* 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    14
* Description: This file (DemoModule.cpp) contains all test 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    15
* framework related parts of this test module. Actual test cases 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    16
* are implemented in file DemoModuleCases.cpp.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    17
*
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    18
* CTestModuleDemo is an example of test module implementation. This example
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    19
* uses hard coded test cases (i.e it does not have any test case
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    20
* configuration file).
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    21
*
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    22
* Example uses function pointers to call test cases. This provides an easy
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    23
* method to add new test cases.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    24
*
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    25
* See function Cases in file DemoModuleCases.cpp for instructions how to
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    26
* add new test cases. It is not necessary to modify this file when adding
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    27
* new test cases.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    28
*
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    29
* To take this module into use, add following lines to test framework
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    30
* initialisation file:
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    31
*
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    32
* # Demo module
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    33
* [New_Module]
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    34
* ModuleName= DemoModule
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    35
* [End_Module]
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    36
*
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    37
*/
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    38
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    39
// INCLUDE FILES
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    40
#include <StifTestInterface.h>
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    41
#include "DemoModule.h"
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    42
#include <e32math.h>
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    43
#include "SettingServerClient.h"
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    44
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    45
// EXTERNAL DATA STRUCTURES
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    46
// None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    47
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    48
// EXTERNAL FUNCTION PROTOTYPES  
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    49
// None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    50
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    51
// CONSTANTS
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    52
// None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    53
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    54
// MACROS
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    55
// None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    56
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    57
// LOCAL CONSTANTS AND MACROS
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    58
// None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    59
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    60
// MODULE DATA STRUCTURES
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    61
// None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    62
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    63
// LOCAL FUNCTION PROTOTYPES
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    64
// None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    65
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    66
// FORWARD DECLARATIONS
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    67
// None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    68
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    69
// ==================== LOCAL FUNCTIONS =======================================
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    70
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    71
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    72
// ================= MEMBER FUNCTIONS =========================================
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    73
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    74
/*
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    75
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    76
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    77
    Class: CDemoModule
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    78
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    79
    Method: CDemoModule
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    80
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    81
    Description: C++ default constructor can NOT contain any code, that
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    82
    might leave.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    83
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    84
    Parameters: None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    85
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    86
    Return Values: None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    87
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    88
    Errors/Exceptions: None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    89
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    90
    Status: Approved
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    91
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    92
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    93
*/
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    94
CDemoModule::CDemoModule()
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    95
    {
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    96
    }
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    97
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    98
/*
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    99
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   100
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   101
    Class: CDemoModule
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   102
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   103
    Method: ConstructL
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   104
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   105
    Description: Symbian 2nd phase constructor that can leave.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   106
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   107
    Note: If OOM test case uses STIF Logger, then STIF Logger must be created
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   108
    with static buffer size parameter (aStaticBufferSize). Otherwise Logger 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   109
    allocates memory from heap and therefore causes error situations with OOM 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   110
    testing. For more information about STIF Logger construction, see STIF 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   111
    Users Guide.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   112
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   113
    Parameters: None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   114
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   115
    Return Values: None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   116
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   117
    Errors/Exceptions: None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   118
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   119
    Status: Approved
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   120
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   121
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   122
*/
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   123
void CDemoModule::ConstructL()
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   124
    {
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   125
    //Read logger settings to check whether test case name is to be
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   126
    //appended to log file name.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   127
    RSettingServer settingServer;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   128
    TInt ret = settingServer.Connect();
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   129
    if(ret != KErrNone)
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   130
        {
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   131
        User::Leave(ret);
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   132
        }
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   133
    // Struct to StifLogger settigs.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   134
    TLoggerSettings loggerSettings; 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   135
    // Parse StifLogger defaults from STIF initialization file.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   136
    ret = settingServer.GetLoggerSettings(loggerSettings);
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   137
    if(ret != KErrNone)
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   138
        {
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   139
        User::Leave(ret);
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   140
        } 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   141
    // Close Setting server session
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   142
    settingServer.Close();
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   143
    iAddTestCaseTitleToLogName = loggerSettings.iAddTestCaseTitle;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   144
    
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   145
    // Constructing static buffer size logger, needed with OOM testing because
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   146
    // normally logger allocates memory from heap!
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   147
    iStdLog = CStifLogger::NewL( KDemoModuleLogPath, 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   148
                              KDemoModuleLogFile,
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   149
                              CStifLogger::ETxt,
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   150
                              CStifLogger::EFile,
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   151
                              ETrue,
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   152
                              ETrue,
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   153
                              ETrue,
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   154
                              EFalse,
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   155
                              ETrue,
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   156
                              EFalse,
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   157
                              100 );
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   158
    iLog = iStdLog;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   159
    
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   160
    // Sample how to use logging
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   161
    _LIT( KLogInfo, "DemoModule logging starts!" );
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   162
    iLog->Log( KLogInfo );
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   163
    }
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   164
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   165
/*
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   166
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   167
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   168
    Class: CTestModuleDemo
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   169
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   170
    Method: NewL
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   171
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   172
    Description: Two-phased constructor. Constructs new CTestModuleDemo
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   173
    instance and returns pointer to it.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   174
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   175
    Parameters:    None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   176
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   177
    Return Values: CTestModuleDemo*: new object.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   178
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   179
    Errors/Exceptions: Leaves if memory allocation fails or ConstructL leaves.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   180
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   181
    Status: Approved
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   182
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   183
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   184
*/
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   185
CDemoModule* CDemoModule::NewL()
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   186
    {
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   187
    CDemoModule* self = new (ELeave) CDemoModule;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   188
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   189
    CleanupStack::PushL( self );
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   190
    self->ConstructL();
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   191
    CleanupStack::Pop();
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   192
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   193
    return self;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   194
    }
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   195
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   196
/*
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   197
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   198
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   199
    Class: CTestModuleDemo
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   200
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   201
    Method: ~CTestModuleDemo
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   202
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   203
    Description: Destructor.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   204
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   205
    Parameters:    None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   206
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   207
    Return Values: None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   208
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   209
    Errors/Exceptions: None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   210
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   211
    Status: Approved
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   212
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   213
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   214
*/
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   215
CDemoModule::~CDemoModule()
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   216
    { 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   217
    iLog = NULL;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   218
    delete iStdLog;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   219
    iStdLog = NULL;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   220
    delete iTCLog;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   221
    iTCLog = NULL;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   222
    }
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   223
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   224
/*
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   225
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   226
    Class: CTestModuleDemo
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   227
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   228
    Method: InitL
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   229
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   230
    Description: Method for test case initialization
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   231
    
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   232
    Parameters: None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   233
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   234
    Return Values: None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   235
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   236
    Errors/Exceptions: None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   237
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   238
    Status: Approved
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   239
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   240
*/
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   241
TInt CDemoModule::InitL( TFileName& /*aIniFile*/, 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   242
                         TBool /*aFirstTime*/ )
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   243
    {
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   244
    return KErrNone;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   245
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   246
    }
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   247
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   248
/*
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   249
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   250
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   251
    Class: CTestModuleDemo
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   252
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   253
    Method: GetTestCases
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   254
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   255
    Description: GetTestCases is used to inquire test cases 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   256
    from the test module. Because this test module has hard coded test cases
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   257
    (i.e cases are not read from file), paramter aConfigFile is not used.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   258
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   259
    This function loops through all cases defined in Cases() function and 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   260
    adds corresponding items to aTestCases array.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   261
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   262
    Parameters: const TFileName&  : in: Configuration file name. Not used                                                       
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   263
                RPointerArray<TTestCaseInfo>& aTestCases: out: 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   264
                      Array of TestCases.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   265
    
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   266
    Return Values: KErrNone: No error
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   267
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   268
    Errors/Exceptions: Function leaves if any memory allocation operation fails
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   269
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   270
    Status: Proposal
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   271
    
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   272
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   273
*/      
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   274
TInt CDemoModule::GetTestCasesL( const TFileName& /*aConfig*/, 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   275
                                 RPointerArray<TTestCaseInfo>& aTestCases )
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   276
    {
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   277
    // Loop through all test cases and create new
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   278
    // TTestCaseInfo items and append items to aTestCase array    
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   279
    for( TInt i = 0; Case(i).iMethod != NULL; i++ )
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   280
        {
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   281
        // Allocate new TTestCaseInfo from heap for a testcase definition.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   282
        TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo();
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   283
    
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   284
        // PushL TTestCaseInfo to CleanupStack.    
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   285
        CleanupStack::PushL( newCase );
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   286
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   287
        // Set number for the testcase.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   288
        // When the testcase is run, this comes as a parameter to RunTestCaseL.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   289
        newCase->iCaseNumber = i;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   290
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   291
        // Set title for the test case. This is shown in UI to user.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   292
        newCase->iTitle.Copy( Case(i).iCaseName );
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   293
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   294
        // Append TTestCaseInfo to the testcase array. After appended 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   295
        // successfully the TTestCaseInfo object is owned (and freed) 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   296
        // by the TestServer. 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   297
        User::LeaveIfError(aTestCases.Append ( newCase ) );
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   298
        
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   299
        // Pop TTestCaseInfo from the CleanupStack.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   300
        CleanupStack::Pop( newCase );
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   301
        }
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   302
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   303
    return KErrNone;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   304
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   305
    }
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   306
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   307
/*
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   308
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   309
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   310
    Class: CTestModuleDemo
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   311
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   312
    Method: RunTestCase
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   313
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   314
    Description: Run a specified testcase.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   315
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   316
    Function runs a test case specified by test case number. Test case file
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   317
    parameter is not used.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   318
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   319
    If case number is valid, this function runs a test case returned by
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   320
    function Cases(). 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   321
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   322
    Parameters: const TInt aCaseNumber: in: Testcase number 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   323
                const TFileName& : in: Configuration file name. Not used
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   324
                TTestResult& aResult: out: Testcase result
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   325
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   326
    Return Values: KErrNone: Testcase ran.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   327
                   KErrNotFound: Unknown testcase
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   328
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   329
    Errors/Exceptions: None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   330
    
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   331
    Status: Proposal
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   332
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   333
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   334
*/
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   335
TInt CDemoModule::RunTestCaseL( const TInt aCaseNumber,
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   336
                                const TFileName& /* aConfig */,
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   337
                                TTestResult& aResult )
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   338
    {
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   339
    // Return value
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   340
    TInt execStatus = KErrNone;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   341
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   342
    // Get the pointer to test case function
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   343
    TCaseInfo tmp = Case ( aCaseNumber );
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   344
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   345
    _LIT( KLogInfo, "Starting testcase [%S]" );
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   346
    iLog->Log( KLogInfo, &tmp.iCaseName);
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   347
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   348
    // Check that case number was valid
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   349
    if ( tmp.iMethod != NULL )
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   350
        {
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   351
        //Open new log file with test case title in file name
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   352
        if(iAddTestCaseTitleToLogName)
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   353
            {
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   354
            //delete iLog; //Close currently opened log
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   355
            //iLog = NULL;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   356
            //Delete test case logger if exists
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   357
            if(iTCLog)
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   358
                {
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   359
                delete iTCLog;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   360
                iTCLog = NULL;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   361
                }
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   362
                
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   363
            TFileName logFileName;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   364
            TName title;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   365
            TestModuleIf().GetTestCaseTitleL(title);
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   366
        
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   367
            logFileName.Format(KDemoModuleLogFileWithTitle, &title);
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   368
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   369
            iTCLog = CStifLogger::NewL(KDemoModuleLogPath, 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   370
                                     logFileName,
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   371
                                     CStifLogger::ETxt,
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   372
                                     CStifLogger::EFile,
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   373
                                     ETrue,
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   374
                                     ETrue,
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   375
                                     ETrue,
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   376
                                     EFalse,
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   377
                                     ETrue,
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   378
                                     EFalse,
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   379
                                     100);
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   380
            iLog = iTCLog;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   381
            }
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   382
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   383
        // Valid case was found, call it via function pointer
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   384
        iMethod = tmp.iMethod;        
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   385
        //execStatus  = ( this->*iMethod )( aResult );
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   386
        TRAPD(err, execStatus  = ( this->*iMethod )( aResult ));
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   387
        if(iAddTestCaseTitleToLogName)
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   388
            {
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   389
            //Restore standard log and destroy test case logger
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   390
            iLog = iStdLog;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   391
            delete iTCLog; //Close currently opened log
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   392
            iTCLog = NULL;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   393
            }
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   394
        User::LeaveIfError(err);
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   395
        
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   396
        }
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   397
    else
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   398
        {
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   399
        // Valid case was not found, return error.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   400
        execStatus = KErrNotFound;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   401
        }
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   402
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   403
    // Return case execution status (not the result of the case execution)
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   404
    return execStatus;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   405
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   406
    }
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   407
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   408
/*
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   409
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   410
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   411
    Class: CDemoModule
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   412
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   413
    Method: OOMTestQueryL
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   414
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   415
    Description: Checks test case information for OOM execution. 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   416
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   417
    Return Values: TBool
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   418
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   419
    Errors/Exceptions: None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   420
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   421
    Status: Proposal
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   422
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   423
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   424
*/
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   425
TBool CDemoModule::OOMTestQueryL( const TFileName& /* aTestCaseFile */, 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   426
                                  const TInt aCaseNumber, 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   427
                                  TOOMFailureType& /* aFailureType */, 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   428
                                  TInt& aFirstMemFailure, 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   429
                                  TInt& aLastMemFailure ) 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   430
    {
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   431
    _LIT( KLogInfo, "CDemoModule::OOMTestQueryL" );
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   432
    iLog->Log( KLogInfo ); 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   433
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   434
    aFirstMemFailure = Case( aCaseNumber ).iFirstMemoryAllocation;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   435
    aLastMemFailure = Case( aCaseNumber ).iLastMemoryAllocation;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   436
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   437
    return Case( aCaseNumber ).iIsOOMTest;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   438
    }
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   439
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   440
/*
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   441
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   442
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   443
    Class: CDemoModule
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   444
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   445
    Method: OOMTestInitializeL
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   446
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   447
    Description: Used to perform the test environment setup for a particular
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   448
    OOM test case. Test Modules may use the initialization file to read 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   449
    parameters for Test Module initialization but they can also have their own
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   450
    configure file or some other routine to initialize themselves. 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   451
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   452
    NOTE: User may add implementation for OOM test environment initialization.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   453
    Usually no implementation is required.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   454
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   455
    Return Values: None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   456
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   457
    Errors/Exceptions: None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   458
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   459
    Status: Proposal
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   460
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   461
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   462
*/
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   463
void CDemoModule::OOMTestInitializeL( const TFileName& /* aTestCaseFile */, 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   464
                                      const TInt /* aCaseNumber */ )
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   465
    {
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   466
    _LIT( KLogInfo, "CDemoModule::OOMTestInitializeL" );
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   467
    iLog->Log( KLogInfo ); 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   468
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   469
    }
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   470
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   471
/*
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   472
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   473
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   474
    Class: CDemoModule
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   475
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   476
    Method: OOMHandleWarningL
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   477
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   478
    Description: Used in OOM testing to provide a way to the derived TestModule 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   479
    to handle warnings related to non-leaving or TRAPped allocations.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   480
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   481
    In some cases the allocation should be skipped, either due to problems in 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   482
    the OS code or components used by the code being tested, or even inside the
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   483
    tested components which are implemented this way on purpose (by design), so
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   484
    it is important to give the tester a way to bypass allocation failures.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   485
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   486
    NOTE: User may add implementation for OOM test warning handling. Usually no
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   487
    implementation is required.    
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   488
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   489
    Return Values: None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   490
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   491
    Errors/Exceptions: None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   492
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   493
    Status: Proposal
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   494
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   495
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   496
*/
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   497
void CDemoModule::OOMHandleWarningL( const TFileName& /* aTestCaseFile */,
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   498
                                     const TInt /* aCaseNumber */, 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   499
                                     TInt& /* aFailNextValue */ )
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   500
    {
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   501
    _LIT( KLogInfo, "CDemoModule::OOMHandleWarningL" );
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   502
    iLog->Log( KLogInfo );
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   503
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   504
    }
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   505
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   506
/*
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   507
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   508
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   509
    Class: CDemoModule
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   510
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   511
    Method: OOMTestFinalizeL
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   512
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   513
    Description: Used to perform the test environment cleanup for a particular OOM 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   514
    test case.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   515
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   516
    NOTE: User may add implementation for OOM test environment finalization.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   517
    Usually no implementation is required.   
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   518
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   519
    Return Values: None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   520
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   521
    Errors/Exceptions: None
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   522
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   523
    Status: Proposal
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   524
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   525
-------------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   526
*/
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   527
void CDemoModule::OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   528
                                    const TInt /* aCaseNumber */ )
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   529
    {
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   530
    _LIT( KLogInfo, "CDemoModule::OOMTestFinalizeL" );
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   531
    iLog->Log( KLogInfo );
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   532
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   533
    }
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   534
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   535
// ========================== OTHER EXPORTED FUNCTIONS =========================
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   536
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   537
// -----------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   538
// LibEntryL is a polymorphic Dll entry point
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   539
// Returns: CTestModuleBase*: Pointer to Test Module object
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   540
// -----------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   541
//
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   542
EXPORT_C CTestModuleBase* LibEntryL()
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   543
    {
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   544
    return CDemoModule::NewL();
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   545
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   546
    }
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   547
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   548
// -----------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   549
// SetRequirements handles test module parameters(implements evolution
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   550
// version 1 for test module's heap and stack sizes configuring).
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   551
// Returns: TInt: Symbian error code.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   552
// -----------------------------------------------------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   553
//
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   554
EXPORT_C TInt SetRequirements( CTestModuleParam*& /*aTestModuleParam*/, 
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   555
                                TUint32& /*aParameterValid*/ )
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   556
    {
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   557
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   558
    /* --------------------------------- NOTE ---------------------------------
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   559
    USER PANICS occurs in test thread creation when:
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   560
    1) "The panic occurs when the value of the stack size is negative."
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   561
    2) "The panic occurs if the minimum heap size specified is less
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   562
       than KMinHeapSize".
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   563
       KMinHeapSize: "Functions that require a new heap to be allocated will
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   564
       either panic, or will reset the required heap size to this value if
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   565
       a smaller heap size is specified".
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   566
    3) "The panic occurs if the minimum heap size specified is greater than
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   567
       the maximum size to which the heap can grow".
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   568
    Other:
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   569
    1) Make sure that your hardware or Symbian OS is supporting given sizes.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   570
       e.g. Hardware might support only sizes that are divisible by four.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   571
    ------------------------------- NOTE end ------------------------------- */
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   572
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   573
    // Normally STIF uses default heap and stack sizes for test thread, see:
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   574
    // KTestThreadMinHeap, KTestThreadMinHeap and KStackSize.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   575
    // If needed heap and stack sizes can be configured here by user. Remove
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   576
    // comments and define sizes.
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   577
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   578
/*
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   579
    aParameterValid = KStifTestModuleParameterChanged;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   580
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   581
    CTestModuleParamVer01* param = CTestModuleParamVer01::NewL();
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   582
    // Stack size
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   583
    param->iTestThreadStackSize= 16384; // 16K stack
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   584
    // Heap sizes
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   585
    param->iTestThreadMinHeap = 4096;   // 4K heap min
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   586
    param->iTestThreadMaxHeap = 1048576;// 1M heap max
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   587
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   588
    aTestModuleParam = param;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   589
*/
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   590
    return KErrNone;
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   591
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   592
    }
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   593
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   594
8bb370ba6d1d contribute STF 1.0.0
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   595
//  End of File