cryptomgmtlibs/securitytestfw/test/testhandler2/t_testactionspec.cpp
changeset 0 2c201484c85f
child 8 35751d3474b7
equal deleted inserted replaced
-1:000000000000 0:2c201484c85f
       
     1 /*
       
     2 * Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "t_testactionspec.h"
       
    20 #include "t_testsetup.h"
       
    21 #include "tScriptSetup.h"
       
    22 #include "t_input.h"
       
    23 #include "tScriptTests.h"
       
    24 
       
    25 _LIT8(KTrue, "true");
       
    26 _LIT8(KFalse, "false");
       
    27 
       
    28 _LIT8(KExOOMStart, "<exoom>");
       
    29 _LIT8(KExOOMEnd, "</exoom>");
       
    30 _LIT8(KInOOMStart, "<inoom>");
       
    31 _LIT8(KInOOMEnd, "</inoom>");
       
    32 _LIT8(KExCancelStart, "<excancel>");
       
    33 _LIT8(KExCancelEnd, "</excancel>");
       
    34 _LIT8(KInCancelStart, "<incancel>");
       
    35 _LIT8(KInCancelEnd, "</incancel>");
       
    36 _LIT8(KSkippedStart, "<skipped>");
       
    37 _LIT8(KSkippedEnd, "</skipped>");
       
    38 _LIT8(KSmokeStart, "<smoke>");
       
    39 _LIT8(KSmokeEnd, "</smoke>");
       
    40 _LIT8(KInteractiveStart, "<interactive>");
       
    41 _LIT8(KInteractiveEnd, "</interactive>");
       
    42 
       
    43 TTestActionSpec::TTestActionSpec()
       
    44 	{
       
    45 	}
       
    46 
       
    47 TInt TTestActionSpec::Init(const TDesC8& aInput, 
       
    48 						   TInt& aPos, 
       
    49 						   CConsoleBase& /*aConsole*/,
       
    50 						   Output& aOut,
       
    51 						   TInt& aBitFlag)
       
    52 	{
       
    53 	TInt err = KErrNone;
       
    54 	iActionName.Set(Input::ParseElement(aInput, KActionNameStart, KActionNameEnd, 
       
    55 		aPos, err));
       
    56 	if (err != KErrNone)
       
    57 		{
       
    58 		aOut.writeString(_L("Error couldn't find actionname in test case spec"));
       
    59 		aOut.writeNewLine();
       
    60 		return err;
       
    61 		}
       
    62 	
       
    63 	iActionType.Set(Input::ParseElement(aInput, KActionTypeStart, KActionTypeEnd, aPos, err));
       
    64 	if (err != KErrNone)
       
    65 		{
       
    66 		aOut.writeString(_L("Error couldn't find actiontype in test case spec"));
       
    67 		aOut.writeNewLine();
       
    68 		return err;
       
    69 		}
       
    70 	
       
    71 	iActionGroup.Set(Input::ParseElement(aInput, KActionGroupingStart, KActionGroupingEnd, aPos, err));
       
    72 	if (err == KErrNone)
       
    73 		{
       
    74 		//Do parsing of the returned groupings string
       
    75 		TInt relativePos=0;
       
    76 		TPtrC8 excludeOOM = Input::ParseElement(iActionGroup, KExOOMStart, KExOOMEnd, relativePos, err);
       
    77 		relativePos=0;
       
    78 		TPtrC8 includeOOM = Input::ParseElement(iActionGroup, KInOOMStart, KInOOMEnd, relativePos, err);
       
    79 		relativePos=0;
       
    80 		TPtrC8 excludeCancel = Input::ParseElement(iActionGroup, KExCancelStart, KExCancelEnd, relativePos, err);
       
    81 		relativePos=0;
       
    82 		TPtrC8 includeCancel = Input::ParseElement(iActionGroup, KInCancelStart, KInCancelEnd, relativePos, err);
       
    83 		relativePos=0;
       
    84 		TPtrC8 skipped = Input::ParseElement(iActionGroup, KSkippedStart, KSkippedEnd, relativePos, err);
       
    85 		relativePos=0;
       
    86 		TPtrC8 smoketest = Input::ParseElement(iActionGroup, KSmokeStart, KSmokeEnd, relativePos, err);
       
    87 		relativePos=0;
       
    88 		TPtrC8 interactive = Input::ParseElement(iActionGroup, KInteractiveStart, KInteractiveEnd, relativePos, err);
       
    89 
       
    90 		if (excludeOOM==KTrue)
       
    91 			{
       
    92 			aBitFlag|=EXOOM;
       
    93 			}
       
    94 		else if (excludeOOM==KFalse)
       
    95 			{
       
    96 			aBitFlag&= (~EXOOM);
       
    97 			}
       
    98 		
       
    99 		if (includeOOM==KTrue)
       
   100 			{
       
   101 			aBitFlag|=INOOM;
       
   102 			}
       
   103 		else if (includeOOM==KFalse)
       
   104 			{
       
   105 			aBitFlag&= (~INOOM);
       
   106 			}
       
   107 
       
   108 		if (excludeCancel==KTrue)
       
   109 			{
       
   110 			aBitFlag|=EXCANCEL;
       
   111 			}
       
   112 		else if (excludeCancel==KFalse)
       
   113 			{
       
   114 			aBitFlag&= (~EXCANCEL);
       
   115 			}
       
   116 
       
   117 		if (includeCancel==KTrue)
       
   118 			{
       
   119 			aBitFlag|=INCANCEL;
       
   120 			}
       
   121 		else if (includeCancel==KFalse)
       
   122 			{
       
   123 			aBitFlag&= (~INCANCEL);
       
   124 			}
       
   125 
       
   126 		if (skipped==KTrue)
       
   127 			{
       
   128 			aBitFlag|=SKIP;
       
   129 			}
       
   130 		else if (skipped==KFalse)
       
   131 			{
       
   132 			aBitFlag&= (~SKIP);
       
   133 			}
       
   134 	
       
   135 		if (smoketest==KTrue)
       
   136 			{
       
   137 			aBitFlag|=SMOKE;
       
   138 			}
       
   139 		else if (smoketest==KFalse)
       
   140 			{
       
   141 			aBitFlag&= (~SMOKE);
       
   142 			}
       
   143 
       
   144 		if (interactive==KTrue)
       
   145 			{
       
   146 			aBitFlag|=INTER;
       
   147 			}
       
   148 		else if (interactive==KFalse)
       
   149 			{
       
   150 			aBitFlag&= (~INTER);
       
   151 			}
       
   152 		}
       
   153 	
       
   154 	iActionBody.Set(Input::ParseElement(aInput, KActionBodyStart, KActionBodyEnd, aPos, err));
       
   155 	iActionResult.Set(Input::ParseElement(aInput, KActionResultStart, KActionResultEnd, aPos, err));
       
   156 	
       
   157 	return KErrNone; 
       
   158 	}
       
   159 
       
   160 void TTestActionSpec::HardcodedInit(const TDesC8& aInput)
       
   161 	{
       
   162 	iActionName.Set(aInput);
       
   163 	iActionType.Set(KNullDesC8);
       
   164 	iActionGroup.Set(KNullDesC8);
       
   165 	iActionBody.Set(KNullDesC8);
       
   166 	iActionResult.Set(KNullDesC8);
       
   167 	}