os/mm/mmtestenv/mmtestfwunittest/src/tsu_mmtsth12/TSU_MmTsth12.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // This file contains the test steps for Unit Test Suite 12 : TestSuite.cpp
    15 // 
    16 //
    17 
    18 // EPOC includes
    19 #include <e32base.h>
    20 
    21 // Test system includes
    22 #include <testframework.h>
    23 
    24 // Specific includes for this test suite
    25 #include "TSU_MmTsthStep12.h"
    26 #include "TSU_MmTsthSuite12.h"
    27 
    28 // Specific includes for these test steps
    29 #include "TSU_MmTsth12.h"
    30 
    31 // --------------------------------------------
    32 
    33 // Unit Test Suite 12 : TestSuite.cpp
    34 // Depends on : TestStep
    35 
    36 // Tests :-
    37 // 1 ConstructL / InitialiseL
    38 // 2 AddTestStepL
    39 // 3 DoTestStep
    40 // 11 Log - not tested explicitly (if things are logging, it's working!)
    41 // 12 LogExtra - not tested explicitly
    42 // 21 GetVersion
    43 // 22 accessors
    44 
    45 // ---------------------
    46 // RTestMmTsthU1201
    47 RTestMmTsthU1201* RTestMmTsthU1201::NewL()
    48 	{
    49 	RTestMmTsthU1201* self = new(ELeave) RTestMmTsthU1201;
    50 	return self;
    51 	}
    52 
    53 // Each test step initialises its own name.
    54 RTestMmTsthU1201::RTestMmTsthU1201()
    55 	{
    56 	iTestStepName = _L("MM-TSTH-U-1201");
    57 	}
    58 
    59 // preamble
    60 TVerdict RTestMmTsthU1201::OpenL()
    61 	{
    62 	// stub - purpose is that for this test we do not run the parent preamble
    63 	// which initialises iStepStub
    64 	return iTestStepResult = EPass;
    65 	}
    66 
    67 // postamble
    68 void RTestMmTsthU1201::Close()
    69 	{
    70 	}
    71 
    72 // do the test step
    73 TVerdict RTestMmTsthU1201::DoTestStepL()
    74 	{
    75 	INFO_PRINTF1(_L("Unit test for TestSuite - ConstructL / InitialiseL"));
    76 
    77 	TVerdict currentVerdict = EPass;
    78 
    79 	CTestSuiteVirtualStub* theSuiteStub = new (ELeave) CTestSuiteVirtualStub;
    80 	CleanupStack::PushL(theSuiteStub);
    81 	TRAPD(err, theSuiteStub->ConstructL());
    82 	if(err != KErrNone)
    83 		{
    84 		ERR_PRINTF1(_L("CTestSuiteVirtualStub::ConstructL() left"));
    85 		CleanupStack::PopAndDestroy(theSuiteStub);
    86 		return iTestStepResult = EFail;
    87 		}
    88 	iSuiteStub = theSuiteStub;
    89 
    90 	// NB ensure the suite can log - set its logger to ours
    91 	iSuiteStub->SetLogSystem(iSuite->LogSystem());
    92 
    93 	// ConstructL calls InitialiseL.
    94 	// the suite should be called TestSuiteVirtualStub and contain one step, TestStepVirtualStub
    95 	// we can't access this direct but we can run DoTestStep() on it,
    96 	// and any error code other than ETestSuiteError is a pass
    97 	
    98 	TVerdict stepVerdict = iSuiteStub->DoTestStep(_L("TestStepVirtualStub"), KNullDesC, KNullDesC);
    99 	if(stepVerdict == ETestSuiteError)
   100 	{
   101 		ERR_PRINTF1(_L("RTestSuiteVirtualStub::InitialiseL() did not setup test step"));
   102 		CleanupStack::PopAndDestroy(theSuiteStub);
   103 		return iTestStepResult = EFail;
   104 	}
   105 
   106 	CleanupStack::PopAndDestroy(theSuiteStub);
   107 	iSuiteStub = NULL;
   108 
   109 	return iTestStepResult = currentVerdict; // should be EPass if we've got here
   110 	}
   111 
   112 // ------------------------
   113 // RTestMmTsthU1202
   114 
   115 RTestMmTsthU1202* RTestMmTsthU1202::NewL()
   116 	{
   117 	RTestMmTsthU1202* self = new(ELeave) RTestMmTsthU1202;
   118 	return self;
   119 	}
   120 
   121 // Each test step initialises its own name.
   122 RTestMmTsthU1202::RTestMmTsthU1202()
   123 	{
   124 	iTestStepName = _L("MM-TSTH-U-1202");
   125 	}
   126 
   127 // do the test step
   128 TVerdict RTestMmTsthU1202::DoTestStepL()
   129 	{
   130 	INFO_PRINTF1(_L("Unit test for TestSuite - AddTestStepL"));
   131 
   132 	TVerdict currentVerdict = EPass;
   133 
   134 	TRAPD(err, iSuiteStub->AddTestStepL(RTestStepVirtualStub2::NewL()));
   135 	if(err != KErrNone)
   136 		{
   137 		ERR_PRINTF1(_L("RTestSuiteVirtualStub::AddTestStepL() left"));
   138 		return iTestStepResult = EFail;
   139 		}
   140 
   141 	// find the step we just added
   142 	TVerdict stepVerdict = iSuiteStub->DoTestStep(_L("TestStepVirtualStub2"), KNullDesC, KNullDesC);
   143 	if(stepVerdict == ETestSuiteError)
   144 		{
   145 		ERR_PRINTF1(_L("RTestSuiteVirtualStub::AddTestStepL() failed"));
   146 		return iTestStepResult = EFail;
   147 		}
   148 
   149 	// no pop / delete - the SUITE owns the step, we don't.
   150 	return iTestStepResult = currentVerdict; // should be EPass if we've got here
   151 	}
   152 
   153 // ------------------------
   154 // RTestMmTsthU1203
   155 
   156 RTestMmTsthU1203* RTestMmTsthU1203::NewL()
   157 	{
   158 	RTestMmTsthU1203* self = new(ELeave) RTestMmTsthU1203;
   159 	return self;
   160 	}
   161 
   162 // Each test step initialises its own name.
   163 RTestMmTsthU1203::RTestMmTsthU1203()
   164 	{
   165 	iTestStepName = _L("MM-TSTH-U-1203");
   166 	}
   167 
   168 // do the test step
   169 TVerdict RTestMmTsthU1203::DoTestStepL()
   170 	{
   171 	INFO_PRINTF1(_L("Unit test for TestSuite - DoTestStepL"));
   172 
   173 	TVerdict currentVerdict = EPass;
   174 
   175 	// do the step. this time we're testing for PASS only
   176 	TVerdict stepVerdict = iSuiteStub->DoTestStep(_L("TestStepVirtualStub"), KNullDesC, KNullDesC);
   177 	if(stepVerdict != EPass)
   178 		{
   179 		ERR_PRINTF1(_L("RTestSuiteVirtualStub::DoTestStepL() failed"));
   180 		return iTestStepResult = EFail;
   181 		}
   182 
   183 	return iTestStepResult = currentVerdict; // should be EPass if we've got here
   184 	}
   185 
   186 // ------------------------
   187 // RTestMmTsthU1221
   188 
   189 RTestMmTsthU1221* RTestMmTsthU1221::NewL()
   190 	{
   191 	RTestMmTsthU1221* self = new(ELeave) RTestMmTsthU1221;
   192 	return self;
   193 	}
   194 
   195 // Each test step initialises its own name.
   196 RTestMmTsthU1221::RTestMmTsthU1221()
   197 	{
   198 	iTestStepName = _L("MM-TSTH-U-1221");
   199 	}
   200 
   201 // do the test step
   202 TVerdict RTestMmTsthU1221::DoTestStepL()
   203 	{
   204 	INFO_PRINTF1(_L("Unit test for TestSuite - GetVersion"));
   205 
   206 	TVerdict currentVerdict = EPass;
   207 
   208 	// get the version, compare it against our known value
   209 	_LIT(KTestVersion,"CTestSuiteVirtualStub Version");
   210 	TPtrC version = iSuiteStub->GetVersion();
   211 	if(version != KTestVersion)
   212 		{
   213 		ERR_PRINTF1(_L("RTestSuiteVirtualStub::GetVersion() failed"));
   214 		return iTestStepResult = EFail;
   215 		}
   216 
   217 	return iTestStepResult = currentVerdict; // should be EPass if we've got here
   218 	}
   219 
   220 // ------------------------
   221 // RTestMmTsthU1222
   222 
   223 RTestMmTsthU1222* RTestMmTsthU1222::NewL()
   224 	{
   225 	RTestMmTsthU1222* self = new(ELeave) RTestMmTsthU1222;
   226 	return self;
   227 	}
   228 
   229 // Each test step initialises its own name.
   230 RTestMmTsthU1222::RTestMmTsthU1222()
   231 	{
   232 	iTestStepName = _L("MM-TSTH-U-1222");
   233 	}
   234 
   235 // do the test step.
   236 TVerdict RTestMmTsthU1222::DoTestStepL()
   237 	{
   238 	INFO_PRINTF1(_L("Unit test for TestSuite - accessors"));
   239 
   240 	TVerdict currentVerdict = EPass;
   241 
   242 	iSuiteStub->SetSeverity(ESevrInfo);
   243 	TInt theSev = iSuiteStub->Severity();
   244 	if(theSev != ESevrInfo)
   245 		{
   246 		ERR_PRINTF1(_L("CTestSuite::SetSeverity() failed"));
   247 		return iTestStepResult = EFail;
   248 		}
   249 
   250 	iSuiteStub->SetStepStatus(EStepStatusFinished);
   251 	TTestStepStatus theStepStatus = iSuiteStub->StepStatus();
   252 	if(theStepStatus != EStepStatusFinished)
   253 		{
   254 		ERR_PRINTF1(_L("CTestSuite::SetStepStatus() failed"));
   255 		return iTestStepResult = EFail;
   256 		}
   257 
   258 	CLog* theLog = CLog::NewL();
   259 	iSuiteStub->SetLogSystem(theLog);
   260 	CLog* theLogSystem = iSuiteStub->LogSystem();
   261 	if(theLog != theLogSystem)
   262 		{
   263 		ERR_PRINTF1(_L("CTestSuite::SetLogSystem() failed"));
   264 		delete theLog;
   265 		return iTestStepResult = EFail;
   266 		}
   267 
   268 	delete theLog;
   269 	return iTestStepResult = currentVerdict; // should be EPass if we've got here
   270 	}