traceservices/tracefw/ulogger/unit_test/te-client/testsetprimaryfltstep.cpp
changeset 0 08ec8eefde2f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 2005-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 // Example CTestStep derived implementation
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file TestStartStep.cpp
       
    20  @internalTechnology
       
    21 */
       
    22 #include "testsetprimaryfltstep.h"
       
    23 #include "te_uloggerclientsuitedefs.h"
       
    24 
       
    25 CTestSetPrimaryFltStep::~CTestSetPrimaryFltStep()
       
    26 /**
       
    27  * Destructor
       
    28  */
       
    29 	{
       
    30 	}
       
    31 
       
    32 CTestSetPrimaryFltStep::CTestSetPrimaryFltStep()
       
    33 /**
       
    34  * Constructor
       
    35  */
       
    36 	{
       
    37 	// **MUST** call SetTestStepName in the constructor as the controlling
       
    38 	// framework uses the test step name immediately following construction to set
       
    39 	// up the step's unique logging ID.
       
    40 	SetTestStepName(KTestSetPrimaryFltStep);
       
    41 	}
       
    42 
       
    43 TVerdict CTestSetPrimaryFltStep::doTestStepPreambleL()
       
    44 /**
       
    45  * @return - TVerdict code
       
    46  * Override of base class virtual
       
    47  */
       
    48 {
       
    49 	CTestUloggerClientApiStepBase::doTestStepPreambleL();
       
    50 	return TestStepResult(); 
       
    51 }
       
    52 
       
    53 TVerdict CTestSetPrimaryFltStep::doTestStepL()
       
    54 /**
       
    55  * @return - TVerdict code
       
    56  * Override of base class pure virtual
       
    57  * Our implementation only gets called if the base class doTestStepPreambleL() did
       
    58  * not leave. That being the case, the current test result value will be EPass.
       
    59  */
       
    60 {
       
    61 	CArrayFixFlat<TUint8> *setfilters = new (ELeave)CArrayFixFlat<TUint8>(10);
       
    62 	CArrayFixFlat<TUint8> *getfilters = new (ELeave)CArrayFixFlat<TUint8>(10);
       
    63 
       
    64 	if (TestStepResult()==EPass)
       
    65 	{
       
    66 		setfilters->AppendL(KPrimaryFlt);
       
    67 	
       
    68 		/**************First set primary filter*************/
       
    69 
       
    70 		iSession->Connect();
       
    71 		TInt iErrCode = iSession->SetPrimaryFiltersEnabled(*setfilters, ETrue);
       
    72 
       
    73 		if( iErrCode == KErrNone )
       
    74 		{
       
    75 			INFO_PRINTF2(_L("Primary filter has been set with single filter, %d, check log"), setfilters->At(0));
       
    76 
       
    77 			setfilters->Reset();
       
    78 
       
    79 			iSession->GetPrimaryFiltersEnabled(*setfilters);
       
    80 
       
    81 			if( setfilters->Count() > 0 )
       
    82 			{
       
    83 				if( setfilters->At(0) == KPrimaryFlt )
       
    84 				{
       
    85 					INFO_PRINTF1(_L("Get primary filter successful"));	
       
    86 					SetTestStepResult(EPass);
       
    87 				}
       
    88 				else
       
    89 				{
       
    90 					INFO_PRINTF1(_L("Get primary filter failed"));
       
    91 					SetTestStepResult(EFail);;
       
    92 				}
       
    93 			}
       
    94 			else
       
    95 			{
       
    96 				INFO_PRINTF1(_L("GetFilter() Failed, can not varify the test output"));
       
    97 				SetTestStepResult(EFail);
       
    98 			}
       
    99 		}
       
   100 	}
       
   101 
       
   102 	if(TestStepResult() == EPass)
       
   103 	{
       
   104 		setfilters->Reset();
       
   105 		getfilters->Reset();
       
   106 
       
   107 		for(TInt i = 0; i < 256 ; i++ )
       
   108 		{
       
   109 			setfilters->AppendL((TUint8)(i));
       
   110 		}
       
   111 
       
   112 		TRAPD(err, iSession->SetPrimaryFiltersEnabled(*setfilters, ETrue));
       
   113 		if( KErrNone ==  err )
       
   114 		{
       
   115 			INFO_PRINTF1(_L("Primary filter has been set with multiple filters,from 0 to 255"));
       
   116 			SetTestStepResult(EPass);
       
   117 		}
       
   118 		else
       
   119 		{
       
   120 			INFO_PRINTF2(_L("Multiple primary filters have not been set succesfully, error code %d"), err);
       
   121 			SetTestStepResult(EFail);
       
   122 		}
       
   123 
       
   124 		//Now get the primary filter set above
       
   125 		iSession->GetPrimaryFiltersEnabled(*getfilters);
       
   126 
       
   127 		if( getfilters->Count() == setfilters->Count() )
       
   128 		{	
       
   129 			INFO_PRINTF1(_L("setfilter and getfilter have the same count"));
       
   130 			for(TInt i = 0; i < getfilters->Count(); i++)
       
   131 			{
       
   132 				for(TInt j = 0; j < setfilters->Count(); j++)
       
   133 				{
       
   134 					if(getfilters->At(i) == setfilters->At(j))
       
   135 						SetTestStepResult(EPass);
       
   136 					else
       
   137 						SetTestStepResult(EFail);
       
   138 				}
       
   139 			}
       
   140 		}	
       
   141 		else
       
   142 		{
       
   143 			INFO_PRINTF1(_L("setfilter and getfilter have different counts"));
       
   144 			INFO_PRINTF2(_L("setfilter has %d"), setfilters->Count());
       
   145 			INFO_PRINTF2(_L("getfilter has %d"), getfilters->Count());
       
   146 			SetTestStepResult(EFail);
       
   147 		}
       
   148 	}
       
   149 
       
   150 	setfilters->Reset();
       
   151 	getfilters->Reset();
       
   152 
       
   153 	if(setfilters)
       
   154 	{
       
   155 		delete setfilters;
       
   156 		setfilters=NULL;
       
   157 	}
       
   158 
       
   159 	if(getfilters)
       
   160 	{
       
   161 		delete getfilters;
       
   162 		getfilters=NULL;
       
   163 	}
       
   164 
       
   165 	return TestStepResult();
       
   166 }
       
   167 
       
   168 TVerdict CTestSetPrimaryFltStep::doTestStepPostambleL()
       
   169 /**
       
   170  * @return - TVerdict code
       
   171  * Override of base class virtual
       
   172  */
       
   173 {
       
   174 	INFO_PRINTF1(_L("TestSetPrimaryFltStep completed"));
       
   175 	CTestUloggerClientApiStepBase::doTestStepPostambleL();
       
   176 	return TestStepResult();
       
   177 }