os/mm/mmtestenv/mmtestfwunittest/src/tsu_mmtsth11/TSU_MmTsth11.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 11 : TestStep.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_MmTsthStep11.h"
    26 #include "TSU_MmTsthSuite11.h"
    27 
    28 // Specific includes for these test steps
    29 #include "TSU_MmTsth11.h"
    30 #include "TestStepVirtualStub.h"
    31 #include "TestSuiteVirtualStub.h"
    32 
    33 // --------------------------------------------
    34 
    35 // Unit Test Suite 11 : TestStep.cpp
    36 // Depends on : none
    37 // Requires : subclass implementing pure virtual DoTestStepL()
    38 
    39 // Tests :-
    40 //	RTestStep() constructor (thru stub)
    41 //  test accessors
    42 //	DoTestStepL
    43 //	DoTestStepPreamble
    44 //  DoTestStepPostamble
    45 //	Load / unload config
    46 
    47 // ---------------------
    48 // RTestMmTsthU1101
    49 
    50 RTestMmTsthU1101* RTestMmTsthU1101::NewL()
    51 	{
    52 	RTestMmTsthU1101* self = new(ELeave) RTestMmTsthU1101;
    53 	return self;
    54 	}
    55 
    56 // Each test step initialises its own name.
    57 RTestMmTsthU1101::RTestMmTsthU1101()
    58 	{
    59 	iTestStepName = _L("MM-TSTH-U-1101");
    60 	}
    61 
    62 
    63 // preamble
    64 TVerdict RTestMmTsthU1101::OpenL()
    65 	{
    66 	// stub - purpose is that for this test we do not run the parent preamble
    67 	// which initialises iStepStub
    68 	return iTestStepResult = EPass;
    69 	}
    70 
    71 // postamble
    72 void RTestMmTsthU1101::Close()
    73 	{
    74 	}
    75 
    76 // do the test step
    77 TVerdict RTestMmTsthU1101::DoTestStepL()
    78 	{
    79 	INFO_PRINTF1(_L("Unit test for TestStep - construct"));
    80 	TVerdict currentVerdict = EPass;
    81 
    82 	RTestStepVirtualStub* theStepStub = NULL;
    83 	TRAPD(err, theStepStub = RTestStepVirtualStub::NewL());
    84 	if(err != KErrNone)
    85 		{
    86 		ERR_PRINTF1(_L("RTestStepVirtualStub::NewL() left"));
    87 		return iTestStepResult = EFail;
    88 		}
    89 
    90 	const TPtrC& theName = theStepStub->StepName();
    91 	if(theName != KTestStepVirtualStubName)
    92 		{
    93 		ERR_PRINTF1(_L("RTestStepVirtualStub did not initialise correctly"));
    94 		delete theStepStub;
    95 		return iTestStepResult = EFail;
    96 		}
    97 
    98 	delete theStepStub;
    99 	return iTestStepResult = currentVerdict; // should be EPass if we've got here
   100 	}
   101 
   102 // ------------------------
   103 // RTestMmTsthU1102
   104 RTestMmTsthU1102* RTestMmTsthU1102::NewL()
   105 	{
   106 	RTestMmTsthU1102* self = new(ELeave) RTestMmTsthU1102;
   107 	return self;
   108 	}
   109 
   110 // Each test step initialises its own name.
   111 RTestMmTsthU1102::RTestMmTsthU1102()
   112 	{
   113 	iTestStepName = _L("MM-TSTH-U-1102");
   114 	}
   115 
   116 // do the test step
   117 TVerdict RTestMmTsthU1102::DoTestStepL()
   118 	{
   119 	// RTestStepVirtualStub contains extra methods by which we can verify our accessors
   120 	INFO_PRINTF1(_L("Unit test for TestStep - accessors"));
   121 
   122 	TVerdict currentVerdict = EPass;
   123 
   124 	// test accessor to set name - not part of RTestStep
   125 	TBufC<KMaxLenTestStepName> KTestStepName = _L("TestStepName");
   126 	iStepStub->TestSetStepName(KTestStepName);
   127 	const TPtrC& theName = iStepStub->StepName();
   128 	if(theName != KTestStepName)
   129 		{
   130 		ERR_PRINTF1(_L("RTestStep::StepName() failed"));
   131 		return iTestStepResult = EFail;
   132 		}
   133 
   134 	TVerdict theResult = EInconclusive;
   135 	iStepStub->SetResult(theResult);
   136 	// test accessor to get result - not part of RTestStep
   137 	if(theResult != iStepStub->TestGetResult())
   138 		{
   139 		ERR_PRINTF1(_L("RTestStep::SetResult() failed"));
   140 		return iTestStepResult = EFail;
   141 		}
   142 
   143 	CTestSuiteVirtualStub* theSuite = new (ELeave) CTestSuiteVirtualStub;
   144 	CleanupStack::PushL(theSuite);
   145 	theSuite->ConstructL();
   146 
   147 	iStepStub->SetSuite(theSuite);
   148 	// test accessor to get suite - not part of RTestStep
   149 	if(theSuite != iStepStub->TestGetSuite())
   150 		{
   151 		ERR_PRINTF1(_L("RTestStep::SetSuite() failed"));
   152 		CleanupStack::PopAndDestroy(); // theSuite
   153 		return iTestStepResult = EFail;
   154 		}
   155 	// cleanup
   156 	CleanupStack::PopAndDestroy(); // theSuite
   157 
   158 	return iTestStepResult = currentVerdict; // should be EPass if we've got here
   159 	}
   160 
   161 // ---------------------
   162 // RTestMmTsthU1103
   163 
   164 RTestMmTsthU1103* RTestMmTsthU1103::NewL()
   165 	{
   166 	RTestMmTsthU1103* self = new(ELeave) RTestMmTsthU1103;
   167 	return self;
   168 	}
   169 
   170 // Each test step initialises its own name.
   171 RTestMmTsthU1103::RTestMmTsthU1103()
   172 	{
   173 	iTestStepName = _L("MM-TSTH-U-1103");
   174 	}
   175 
   176 // do the test step.
   177 TVerdict RTestMmTsthU1103::DoTestStepL()
   178 	{
   179 	// RTestStepVirtualStub contains extra methods by which we can verify our accessors
   180 	INFO_PRINTF1(_L("Unit test for TestStep - preamble"));
   181 
   182 	TVerdict currentVerdict = EPass;
   183 
   184 	iStepStub->OpenL();
   185 	if(!iStepStub->PreambleRun())
   186 		{
   187 		ERR_PRINTF1(_L("RTestStep::OpenL() failed"));
   188 		return iTestStepResult = EFail;
   189 		}
   190 
   191 	return iTestStepResult = currentVerdict; // should be EPass if we've got here
   192 	}
   193 
   194 // ---------------------
   195 // RTestMmTsthU1104
   196 
   197 RTestMmTsthU1104* RTestMmTsthU1104::NewL()
   198 	{
   199 	RTestMmTsthU1104* self = new(ELeave) RTestMmTsthU1104;
   200 	return self;
   201 	}
   202 
   203 // Each test step initialises its own name.
   204 RTestMmTsthU1104::RTestMmTsthU1104()
   205 	{
   206 	iTestStepName = _L("MM-TSTH-U-1104");
   207 	}
   208 
   209 // do the test step
   210 TVerdict RTestMmTsthU1104::DoTestStepL()
   211 	{
   212 	// RTestStepVirtualStub contains extra methods by which we can verify our accessors
   213 	INFO_PRINTF1(_L("Unit test for TestStep - postamble"));
   214 
   215 	TVerdict currentVerdict = EPass;
   216 
   217 	iStepStub->Close();
   218 	if(!iStepStub->PostambleRun())
   219 		{
   220 		ERR_PRINTF1(_L("RTestStep::Close() failed"));
   221 		return iTestStepResult = EFail;
   222 		}
   223 
   224 	return iTestStepResult = currentVerdict; // should be EPass if we've got here
   225 	}
   226 
   227 // ---------------------
   228 // RTestMmTsthU1105
   229 RTestMmTsthU1105* RTestMmTsthU1105::NewL()
   230 	{
   231 	RTestMmTsthU1105* self = new(ELeave) RTestMmTsthU1105;
   232 	return self;
   233 	}
   234 
   235 // Each test step initialises its own name.
   236 RTestMmTsthU1105::RTestMmTsthU1105()
   237 	{
   238 	iTestStepName = _L("MM-TSTH-U-1105");
   239 	}
   240 
   241 // do the test step
   242 TVerdict RTestMmTsthU1105::DoTestStepL()
   243 	{
   244 	// RTestStepVirtualStub contains extra methods by which we can verify our accessors
   245 	INFO_PRINTF1(_L("Unit test for TestStep - step"));
   246 
   247 	TVerdict currentVerdict = EPass;
   248 
   249 	iStepStub->DoTestStepL();
   250 	if(!iStepStub->StepRun())
   251 		{
   252 		ERR_PRINTF1(_L("RTestStep::DoTestStepL() failed"));
   253 		return iTestStepResult = EFail;
   254 		}
   255 
   256 	return iTestStepResult = currentVerdict; // should be EPass if we've got here
   257 	}
   258 
   259 // ------------------------
   260 // RTestMmTsthU1111
   261 RTestMmTsthU1111* RTestMmTsthU1111::NewL()
   262 	{
   263 	RTestMmTsthU1111* self = new(ELeave) RTestMmTsthU1111;
   264 	return self;
   265 	}
   266 
   267 // Each test step initialises its own name.
   268 RTestMmTsthU1111::RTestMmTsthU1111()
   269 	{
   270 	iTestStepName = _L("MM-TSTH-U-1111");
   271 	}
   272 
   273 // do the test step
   274 TVerdict RTestMmTsthU1111::DoTestStepL()
   275 	{
   276 	const TInt KTestBufSize = 64;
   277 
   278 	// RTestStepVirtualStub contains extra methods by which we can verify our accessors
   279 	INFO_PRINTF1(_L("Unit test for TestStep - load config"));
   280 
   281 	TVerdict currentVerdict = EPass;
   282 
   283 	TBufC<KTestBufSize> KConfigName = _L("TSU_MMTSTH11_config.ini");
   284 	iStepStub->LoadConfig(KConfigName);
   285 
   286 	// we get no return saying that the file hasn't loaded - 
   287 	// therefore check something in the file we know is there : [SectionOne] keybool = true
   288 	// because these functions are protected, we have to wrap them in iStepStub
   289 
   290 	TBool aBoolResult;
   291 	TBool returnValue = iStepStub->TestGetBoolFromConfig(_L("SectionOne"),_L("Keybool"), aBoolResult);
   292 	if(!returnValue)
   293 		{
   294 		ERR_PRINTF1(_L("RTestStep::LoadConfig() failed"));
   295 		iStepStub->UnloadConfig();
   296 		return iTestStepResult = EFail;
   297 		}
   298 
   299 	iStepStub->UnloadConfig();
   300 	return iTestStepResult = currentVerdict; // should be EPass if we've got here
   301 	}
   302 
   303 // ------------------------
   304 
   305