os/mm/mmtestenv/mmtestfwunittest/src/tsu_mmtsth02/TSU_MmTsth02.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 02 : Script.cpp
    15 // 
    16 //
    17 
    18 // EPOC includes
    19 #include <e32base.h>
    20 
    21 // Test system includes
    22 // Test system includes
    23 #include <testframework.h>
    24 #include "script.h"
    25 #include "parseline.h"
    26 #include "Filename.h"
    27 
    28 // Specific includes for this test suite
    29 #include "TSU_MmTsthSuite02.h"
    30 
    31 // Specific includes for these test steps
    32 #include "TSU_MmTsth02.h"
    33 
    34 // --------------------------------------------
    35 
    36 // Unit Test Suite 02: Script.cpp
    37 // Depends on : Parseline, FileName
    38 
    39 // Tests :-
    40 // 1 construct a CScript
    41 // 2 open a script file
    42 // 3 execute a script file
    43 // 12 add / display results	(removed - the functionality is covered by Parseline tests 0102 and 0103)
    44  
    45 // ---------------------
    46 // RTestMmTsthU0201
    47 
    48 RTestMmTsthU0201* RTestMmTsthU0201::NewL()
    49 	{
    50 	RTestMmTsthU0201* self = new(ELeave) RTestMmTsthU0201;
    51 	return self;
    52 	}
    53 
    54 // Each test step initialises its own name.
    55 RTestMmTsthU0201::RTestMmTsthU0201()
    56 	{
    57 	iTestStepName = _L("MM-TSTH-U-0201");
    58 	}
    59 
    60 // Do the test step.
    61 TVerdict RTestMmTsthU0201::DoTestStepL()
    62 	{
    63 	INFO_PRINTF1(_L("Unit test for Script : construction"));
    64 
    65 	TVerdict currentVerdict = EPass;
    66 
    67 	// initialise a CParseLine
    68 	CLog* theLogClient  = iSuite->LogSystem();
    69 	CTestUtils* theTestUtils  = CTestUtils::NewL(theLogClient);
    70 	CleanupStack::PushL(theTestUtils);
    71 	TInt64 defTime(-1);
    72 	CScript* theTestScript = CScript::NewLC(theTestUtils, theLogClient, defTime, KNullDesC);
    73 
    74 	// if we got here, we're constructed successfully
    75 	INFO_PRINTF1(_L("CScript constructed successfully"));
    76 
    77 	CleanupStack::PopAndDestroy(2); // theTestScript, theTestUtils
    78 	theTestScript = NULL; // just to remove warning
    79 
    80 	return iTestStepResult = currentVerdict; // should be EPass if we've got here
    81 	}
    82 
    83 // ---------------------
    84 // RTestMmTsthU0202
    85 
    86 RTestMmTsthU0202* RTestMmTsthU0202::NewL()
    87 	{
    88 	RTestMmTsthU0202* self = new(ELeave) RTestMmTsthU0202;
    89 	return self;
    90 	}
    91 
    92 // Each test step initialises its own name.
    93 RTestMmTsthU0202::RTestMmTsthU0202()
    94 	{
    95 	iTestStepName = _L("MM-TSTH-U-0202");
    96 	}
    97 
    98 // Do the test step.
    99 TVerdict RTestMmTsthU0202::DoTestStepL()
   100 	{
   101 	INFO_PRINTF1(_L("Unit test for Script - OpenScriptFile"));
   102 
   103 	TVerdict currentVerdict = EPass;
   104 
   105 	_LIT(KDummyScriptName, "TSU_MMTSTH02_DUMMY");
   106 	CFileName* scriptFileName = CFileName::NewLC();
   107 	*scriptFileName = KDummyScriptName;
   108 	if (iTestScript->OpenScriptFile(scriptFileName) == EFalse)
   109 	{
   110 		ERR_PRINTF2(_L("OpenScriptFile failed to open %S"), &KDummyScriptName());
   111 		currentVerdict = EFail;
   112 	}
   113 	CleanupStack::PopAndDestroy(scriptFileName);
   114 	return iTestStepResult = currentVerdict; // should be EPass if we've got here
   115 	}
   116 
   117 // ---------------------
   118 // RTestMmTsthU0203
   119 
   120 RTestMmTsthU0203* RTestMmTsthU0203::NewL()
   121 	{
   122 	RTestMmTsthU0203* self = new(ELeave) RTestMmTsthU0203;
   123 	return self;
   124 	}
   125 
   126 // Each test step initialises its own name.
   127 RTestMmTsthU0203::RTestMmTsthU0203()
   128 	{
   129 	iTestStepName = _L("MM-TSTH-U-0203");
   130 	}
   131 
   132 // Do the test step.
   133 TVerdict RTestMmTsthU0203::DoTestStepL()
   134 	{
   135 	INFO_PRINTF1(_L("Unit test for Script - ExecuteScriptL"));
   136 
   137 	TVerdict currentVerdict = EPass;
   138 
   139 	_LIT(KDummyScriptName, "TSU_MMTSTH02_DUMMY");
   140 	CFileName* scriptFileName = CFileName::NewLC();
   141 	*scriptFileName = KDummyScriptName;
   142 	if (iTestScript->OpenScriptFile(scriptFileName) == EFalse)
   143 		{
   144 		ERR_PRINTF2(_L("OpenScriptFile failed to open %S"), &KDummyScriptName());
   145 		CleanupStack::PopAndDestroy(scriptFileName);
   146 		return iTestStepResult = EInconclusive;
   147 		}
   148 
   149 	// execute the script
   150 	TVerdict theTestVerdict=EFail;
   151 	TRAPD(err, theTestVerdict = iTestScript->ExecuteScriptL());
   152 
   153 	if(err != KErrNone)
   154 		{
   155 		ERR_PRINTF2(_L("ExecuteScriptL left with error code %d"), err);
   156 		currentVerdict = EFail;
   157 		}
   158 	else if (theTestVerdict!=EPass)
   159 		{
   160 		ERR_PRINTF2(_L("ExecuteScriptL returned with error  %d"), theTestVerdict);
   161 		currentVerdict =theTestVerdict;
   162 		}
   163 
   164 	CleanupStack::PopAndDestroy(scriptFileName);
   165 	return iTestStepResult = currentVerdict; // should be EPass if we've got here
   166 	}
   167