messagingfw/msgtestfw/Framework/src/CMtfSetConfigurationTestStep.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 2003-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 //
       
    15 
       
    16 /**
       
    17  @file
       
    18 */
       
    19 
       
    20 #include "CMtfSetConfigurationTestStep.h"
       
    21 #include "CMtfConfigurationType.h"
       
    22 #include "CMtfTestCase.h"
       
    23 #include "CMtfTestServer.h"
       
    24 #include "CMtfScriptedTestCase.h"
       
    25 
       
    26 _LIT(KMtfConfigurationParameters,"configurationParams");
       
    27 
       
    28 CMtfSetConfigurationTestStep* CMtfSetConfigurationTestStep::NewL(CMtfTestServer& aTestServer)
       
    29 {
       
    30 	CMtfSetConfigurationTestStep* self=new(ELeave) CMtfSetConfigurationTestStep(aTestServer);
       
    31 	return self;
       
    32 }
       
    33  
       
    34 CMtfSetConfigurationTestStep::CMtfSetConfigurationTestStep(CMtfTestServer& aTestServer)
       
    35 :iTestServer(aTestServer)
       
    36 {
       
    37 }
       
    38 		
       
    39 CMtfSetConfigurationTestStep::~CMtfSetConfigurationTestStep() 
       
    40 {
       
    41 }
       
    42 
       
    43 TVerdict CMtfSetConfigurationTestStep::doTestStepPreambleL()  
       
    44 {
       
    45 	return TestStepResult();
       
    46 }
       
    47 	
       
    48 /** Obtain the test step parameters. The first parameter is the configuration type name,
       
    49 the second parameter is the name of the file. There must be at least two parameters. */
       
    50 TVerdict CMtfSetConfigurationTestStep::doTestStepL()
       
    51 {
       
    52 	TPtrC parameter;
       
    53 	
       
    54 	if (!GetStringFromConfig(ConfigSection(),KMtfConfigurationParameters,parameter))
       
    55 	{
       
    56 		User::Leave(KErrGeneral);
       
    57 	}
       
    58 	
       
    59 	TLex parser(parameter);
       
    60 	parser.SkipSpace();
       
    61 		
       
    62 	if (parser.Eos())
       
    63 	{
       
    64 		// type parameter is missing
       
    65 		User::Leave(KErrGeneral);
       
    66 	}
       
    67 		
       
    68 	_LIT(KCMtfConfigurationType,"CMtfConfigurationType::TMtfConfigurationType::");
       
    69 	TPtrC nextToken = parser.NextToken();
       
    70 	TInt length = KCMtfConfigurationType().Length() + nextToken.Length();
       
    71 	HBufC* enumerator = HBufC::NewLC(length);
       
    72 	enumerator->Des().Append(KCMtfConfigurationType);
       
    73 	enumerator->Des().Append(nextToken);
       
    74 		
       
    75 	// dummy test case used in calling ObtainValueParameter
       
    76 	// this only works because we are obtaining a constant value
       
    77 	CMtfScriptedTestCase* dummyCase = CMtfScriptedTestCase::NewL(iTestServer,EFalse);
       
    78 	CleanupStack::PushL(dummyCase);
       
    79 	CMtfConfigurationType::TMtfConfigurationType type = ObtainValueParameterL<CMtfConfigurationType::TMtfConfigurationType>(*dummyCase,*enumerator);
       
    80 	CleanupStack::PopAndDestroy(dummyCase);
       
    81 	CleanupStack::PopAndDestroy(enumerator);
       
    82 	
       
    83 	// now obtain the second (or more) parameter	
       
    84 	CMtfConfigurationType* configurationType = CMtfConfigurationType::NewL(type);
       
    85 	CleanupStack::PushL(configurationType);
       
    86 	parser.SkipSpace();
       
    87 		
       
    88 	while(!parser.Eos())
       
    89 	{
       
    90 		configurationType->AddConfigurationFilenameL(parser.NextToken());
       
    91 		parser.SkipSpace();
       
    92 	}		
       
    93 		
       
    94 	if (configurationType->Count() > 0)
       
    95 	{
       
    96 		CleanupStack::Pop(configurationType);
       
    97 		
       
    98 		// this function takes ownership immediately
       
    99 		iTestServer.SetMainScriptConfigurationTypeL(configurationType);
       
   100 	}
       
   101 	else
       
   102 	{
       
   103 		User::Leave(KErrGeneral);
       
   104 	}
       
   105 		
       
   106 	return TestStepResult();
       
   107 }
       
   108 		
       
   109 TVerdict CMtfSetConfigurationTestStep::doTestStepPostambleL()
       
   110 {
       
   111 	return TestStepResult();
       
   112 }