os/mm/mmtestenv/mmtestfwunittest/src/tsu_mmtsth01/TSU_MmTsth01.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 01 : Parseline.cpp
    15 // 
    16 //
    17 
    18 // EPOC includes
    19 #include <e32base.h>
    20 
    21 // Test system includes
    22 #include <testframework.h>
    23 #include "script.h"
    24 #include "parseline.h"
    25 #include "Filename.h" 
    26 
    27 // Specific includes for this test suite
    28 #include "TSU_MmTsthSuite01.h"
    29 
    30 // Specific includes for these test steps
    31 #include "TSU_MmTsth01.h"
    32 
    33 // --------------------------------------------
    34 
    35 // Unit Test Suite 01 : Parseline.cpp
    36 // Depends on : none
    37 
    38 // Tests :-
    39 // 1 Initialise a CParseLine
    40 // 2 Process line : load & run a sample step
    41 // 3 Run a sample panic step
    42 // 4 Run a utility
    43 // 11 CSuiteDLL initialise and verify
    44 
    45 // (NB these tests are to test the parser ONLY; the underlying functionality of the
    46 // commands parsed is tested in CTestStep, CTestSuite, CTestUtils etc. suites)
    47 
    48 // ---------------------
    49 // RTestMmTsthU0101
    50 
    51 RTestMmTsthU0101* RTestMmTsthU0101::NewL()
    52 	{
    53 	RTestMmTsthU0101* self = new(ELeave) RTestMmTsthU0101;
    54 	return self;
    55 	}
    56 
    57 // Each test step initialises its own name.
    58 RTestMmTsthU0101::RTestMmTsthU0101()
    59 	{
    60 	iTestStepName = _L("MM-TSTH-U-0101");
    61 	}
    62 
    63 // preamble
    64 TVerdict RTestMmTsthU0101::OpenL()
    65 	{
    66 	// don't call the default preamble
    67 	return iTestStepResult = EPass;
    68 	}
    69 
    70 // postamble
    71 void RTestMmTsthU0101::Close()
    72 	{
    73 	// don't call the default postamble
    74 	}
    75 
    76 // Do the test step.
    77 TVerdict RTestMmTsthU0101::DoTestStepL()
    78 	{
    79 	INFO_PRINTF1(_L("Unit test for Parseline"));
    80 
    81 	TVerdict currentVerdict = EPass;
    82 
    83 	// initialise a CParseLine
    84 	CLog* theLogClient  = iSuite->LogSystem();
    85 	CTestUtils* theTestUtils  = CTestUtils::NewL(theLogClient);
    86 	TInt64 theGuardTimer (-1);
    87 
    88 	CleanupStack::PushL(theTestUtils);
    89 	CScript* theParseScript = CScript::NewLC(theTestUtils, theLogClient, theGuardTimer, KNullDesC);
    90 	CParseLine* theParser = CParseLine::NewL(theParseScript, theTestUtils, theLogClient, theGuardTimer, KNullDesC);
    91 	CleanupStack::PushL(theParser);
    92 
    93 	// if we got here, we're constructed successfully
    94 	INFO_PRINTF1(_L("CParseLine constructed successfully"));
    95 
    96 	CleanupStack::PopAndDestroy(3); // theParser, theParseScript, theTestUtils
    97 
    98 	return iTestStepResult = currentVerdict;
    99 	}
   100 
   101 
   102 // ---------------------
   103 // RTestMmTsthU0102
   104 
   105 RTestMmTsthU0102* RTestMmTsthU0102::NewL()
   106 	{
   107 	RTestMmTsthU0102* self = new(ELeave) RTestMmTsthU0102;
   108 	return self;
   109 	}
   110 
   111 // Each test step initialises its own name.
   112 RTestMmTsthU0102::RTestMmTsthU0102()
   113 	{
   114 	iTestStepName = _L("MM-TSTH-U-0102");
   115 	}
   116 
   117 // Do the test step.
   118 TVerdict RTestMmTsthU0102::DoTestStepL()
   119 	{
   120 	INFO_PRINTF1(_L("Unit test for ProcessLineL 1"));
   121 
   122 	TVerdict currentVerdict = EPass;
   123 	_LIT8(KTestStepScriptLine1, "LOAD_SUITE TSU_MMTSTH01");
   124 	_LIT8(KTestStepScriptLine2, "RUN_TEST_STEP 1000 TSU_MMTSTH01 RTestStepDummy");
   125 
   126 	TRAPD(err1, iParseLine->ProcessLineL(KTestStepScriptLine1, 1));
   127 	if(err1 != KErrNone)
   128 	{
   129 		ERR_PRINTF2(_L("ProcessLineL for LOAD_SUITE left, error code %d"), err1);
   130 		return iTestStepResult = EFail;
   131 	}
   132 	TRAPD(err2, iParseLine->ProcessLineL(KTestStepScriptLine2, 2));
   133 	if(err2 != KErrNone)
   134 	{
   135 		ERR_PRINTF2(_L("ProcessLineL for RUN_TEST_STEP left, error code %d"), err2);
   136 		return iTestStepResult = EFail;
   137 	}
   138 
   139 	return iTestStepResult = currentVerdict;
   140 	}
   141 
   142 // ---------------------
   143 // RTestMmTsthU0103
   144 
   145 RTestMmTsthU0103* RTestMmTsthU0103::NewL()
   146 	{
   147 	RTestMmTsthU0103* self = new(ELeave) RTestMmTsthU0103;
   148 	return self;
   149 	}
   150 
   151 // Each test step initialises its own name.
   152 RTestMmTsthU0103::RTestMmTsthU0103()
   153 	{
   154 	iTestStepName = _L("MM-TSTH-U-0103");
   155 	}
   156 
   157 // Do the test step.
   158 TVerdict RTestMmTsthU0103::DoTestStepL()
   159 	{
   160 	INFO_PRINTF1(_L("Unit test for ProcessLineL 2"));
   161 
   162 	TVerdict currentVerdict = EPass;
   163 	_LIT8(KTestStepScriptLine1, "LOAD_SUITE TSU_MMTSTH01");
   164 	_LIT8(KTestStepScriptLine2, "RUN_PANIC_STEP 1000 TSU_MMTSTH01 RPanicTestStepDummy, PanicDummy, 0");
   165 
   166 	TRAPD(err1, iParseLine->ProcessLineL(KTestStepScriptLine1, 1));
   167 	if(err1 != KErrNone)
   168 	{
   169 		ERR_PRINTF2(_L("ProcessLineL for LOAD_SUITE left, error code %d"), err1);
   170 		return iTestStepResult = EInconclusive;
   171 	}
   172 	TRAPD(err2, iParseLine->ProcessLineL(KTestStepScriptLine2, 2));
   173 	if(err2 != KErrNone)
   174 	{
   175 		ERR_PRINTF2(_L("ProcessLineL for RUN_PANIC_STEP left, error code %d"), err2);
   176 		return iTestStepResult = EFail;
   177 	}
   178 
   179 	return iTestStepResult = currentVerdict;
   180 	}
   181 
   182 
   183 // ---------------------
   184 // RTestMmTsthU0104
   185 
   186 RTestMmTsthU0104* RTestMmTsthU0104::NewL()
   187 	{
   188 	RTestMmTsthU0104* self = new(ELeave) RTestMmTsthU0104;
   189 	return self;
   190 	}
   191 
   192 // Each test step initialises its own name.
   193 RTestMmTsthU0104::RTestMmTsthU0104()
   194 	{
   195 	iTestStepName = _L("MM-TSTH-U-0104");
   196 	}
   197 
   198 // Do the test step.
   199 TVerdict RTestMmTsthU0104::DoTestStepL()
   200 	{
   201 
   202 	INFO_PRINTF1(_L("This test step is not available on EKA2 - Passing test!"));
   203 	return EPass;
   204 
   205 	}
   206 
   207 // ---------------------
   208 // RTestMmTsthU0111
   209 
   210 RTestMmTsthU0111* RTestMmTsthU0111::NewL()
   211 	{
   212 	RTestMmTsthU0111* self = new(ELeave) RTestMmTsthU0111;
   213 	return self;
   214 	}
   215 
   216 // Each test step initialises its own name.
   217 RTestMmTsthU0111::RTestMmTsthU0111()
   218 	{
   219 	iTestStepName = _L("MM-TSTH-U-0111");
   220 	}
   221 
   222 // Do the test step.
   223 TVerdict RTestMmTsthU0111::DoTestStepL()
   224 	{
   225 	INFO_PRINTF1(_L("Unit test for CSuiteDLL"));
   226 
   227 	TVerdict currentVerdict = EPass;
   228 
   229 	// create a new CSuiteDll object to store info on loaded DLL
   230 	_LIT(KTestSuiteName, "TSU_MMTSTH01");
   231 	CSuiteDll* newRef = NULL;
   232 	TRAPD(err, newRef = CSuiteDll::NewL(KTestSuiteName, iLogClient));
   233 	if(err != KErrNone)
   234 	{
   235 		ERR_PRINTF2(_L("CSuiteDll::NewL left, error code %d"), err);
   236 		return iTestStepResult = EFail;
   237 	}
   238 
   239 	// make sure it's not NULL, get its name out and see if it matches
   240 	CTestSuite* theTestSuite = newRef->Suite();
   241 	if(theTestSuite == NULL)
   242 	{
   243 		ERR_PRINTF1(_L("CSuiteDll::Suite() is NULL"));
   244 		return iTestStepResult = EFail;
   245 	}
   246 
   247 	TPtrC theName = newRef->Name();
   248 	if (theName != KTestSuiteName)
   249 	{
   250 		ERR_PRINTF2(_L("CSuiteDll::Name() is %S"), &theName);
   251 		return iTestStepResult = EFail;
   252 	}
   253 
   254 	return iTestStepResult = currentVerdict;
   255 	}
   256 
   257 // ---------------------
   258 // Dummy test step for Parseline testing
   259 
   260 RTestStepDummy* RTestStepDummy::NewL()
   261 	{
   262 	RTestStepDummy* self = new(ELeave) RTestStepDummy;
   263 	return self;
   264 	}
   265 
   266 // Each test step initialises its own name.
   267 RTestStepDummy::RTestStepDummy()
   268 	{
   269 	iTestStepName = _L("RTestStepDummy");
   270 	}
   271 
   272 // Do the test step.
   273 TVerdict RTestStepDummy::DoTestStepL()
   274 	{
   275 	INFO_PRINTF1(_L("Dummy step completed"));
   276 
   277 	TVerdict currentVerdict = EPass;
   278 
   279 	return iTestStepResult = currentVerdict;
   280 	}
   281 
   282 
   283 // ---------------------
   284 // Dummy panic test steps for Parseline testing
   285 
   286 RPanicTestStepDummy* RPanicTestStepDummy::NewL()
   287 	{
   288 	RPanicTestStepDummy* self = new(ELeave) RPanicTestStepDummy;
   289 	return self;
   290 	}
   291 
   292 // Each test step initialises its own name.
   293 RPanicTestStepDummy::RPanicTestStepDummy()
   294 	{
   295 	iTestStepName = _L("RPanicTestStepDummy");
   296 	}
   297 
   298 // Do the test step.
   299 TVerdict RPanicTestStepDummy::DoTestStepL()
   300 	{
   301 	INFO_PRINTF1(_L("Dummy panic step running"));
   302 	User::Panic(_L("PanicDummy"), 0);
   303 
   304 	// NB this code cannot be reached
   305 	TVerdict currentVerdict = EPass;
   306 	return iTestStepResult = currentVerdict;
   307 	}
   308 
   309