traceservices/tracefw/ulogger/unit_test/te-client/testsetsecondaryfltstep.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 TestSetSecondaryFltStep.cpp
       
    20  @internalTechnology
       
    21 */
       
    22 #include "testsetsecondaryfltstep.h"
       
    23 #include "te_uloggerclientsuitedefs.h"
       
    24 
       
    25 CTestSetSecondaryFltStep::~CTestSetSecondaryFltStep()
       
    26 /**
       
    27  * Destructor
       
    28  */
       
    29 	{
       
    30 	}
       
    31 
       
    32 CTestSetSecondaryFltStep::CTestSetSecondaryFltStep()
       
    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(KTestSetSecondaryFltStep);
       
    41 	}
       
    42 
       
    43 TVerdict CTestSetSecondaryFltStep::doTestStepPreambleL()
       
    44 /**
       
    45  * @return - TVerdict code
       
    46  * Override of base class virtual
       
    47  */
       
    48 	{
       
    49 	INFO_PRINTF1(_L("TestSetSecondaryFltStep started"));
       
    50 	CTestUloggerClientApiStepBase::doTestStepPreambleL();
       
    51 	return TestStepResult();
       
    52 	}
       
    53 
       
    54 TVerdict CTestSetSecondaryFltStep::doTestStepL()
       
    55 /**
       
    56  * @return - TVerdict code
       
    57  * Override of base class pure virtual
       
    58  * Our implementation only gets called if the base class doTestStepPreambleL() did
       
    59  * not leave. That being the case, the current test result value will be EPass.
       
    60  */
       
    61 {
       
    62 	RArray<TUint32> *setfilters = new (ELeave)RArray<TUint32>(10);
       
    63 	RArray<TUint32> *getfilters = new (ELeave)RArray<TUint32>(10);
       
    64 
       
    65 	if (TestStepResult()==EPass)
       
    66 	{
       
    67 		setfilters->AppendL(KSecondaryFlt);
       
    68 
       
    69 		/**************First set primary filter*************/
       
    70 
       
    71 		iSession->Connect();
       
    72 		TInt iErrCode = iSession->SetSecondaryFiltersEnabled(*setfilters, ETrue);
       
    73 
       
    74 		if( iErrCode == KErrNone )
       
    75 		{
       
    76 			INFO_PRINTF2(_L("Secondary filter has been set with single filter, %d, check log"), (*setfilters)[0]);
       
    77 
       
    78 			setfilters->Reset();
       
    79 
       
    80 			iSession->GetSecondaryFiltersEnabled(*setfilters);
       
    81 
       
    82 			if( setfilters->Count() > 0 )
       
    83 			{
       
    84 				if( (*setfilters)[0] == KSecondaryFlt )
       
    85 				{
       
    86 					INFO_PRINTF1(_L("Get secondary filter successful"));	
       
    87 					SetTestStepResult(EPass);
       
    88 				}
       
    89 				else
       
    90 				{
       
    91 					INFO_PRINTF1(_L("Get secondary filter value does not match with set value"));
       
    92 					SetTestStepResult(EFail);;
       
    93 				}
       
    94 			}
       
    95 			else
       
    96 			{
       
    97 				INFO_PRINTF1(_L("GetFilter() Failed, can not varify the test output"));
       
    98 				SetTestStepResult(EFail);
       
    99 			}
       
   100 		}
       
   101 	}
       
   102 
       
   103 	if(TestStepResult() == EPass)
       
   104 	{
       
   105 		//prepare test
       
   106 		getfilters->Reset();
       
   107 		iSession->GetSecondaryFiltersEnabled(*getfilters);
       
   108 		iSession->SetSecondaryFiltersEnabled(*getfilters, EFalse);
       
   109 		setfilters->Reset();
       
   110 		getfilters->Reset();
       
   111 
       
   112 		for(TInt i = 0; i < 4096 ; i++ )
       
   113 		{
       
   114 			setfilters->AppendL((TUint32)(i));
       
   115 		}
       
   116 
       
   117 		TRAPD(err, iSession->SetSecondaryFiltersEnabled(*setfilters, ETrue));
       
   118 		if( KErrNone == err )
       
   119 		{
       
   120 			INFO_PRINTF1(_L("Secondary filter has been set with multiple filters,from 0 to 4095"));
       
   121 			SetTestStepResult(EPass);
       
   122 		}
       
   123 		else
       
   124 		{
       
   125 			INFO_PRINTF2(_L("Multiple secondary filters have not been set succesfully, error code %d"), err);
       
   126 			SetTestStepResult(EFail);
       
   127 		}
       
   128 
       
   129 		//Now get the primary filter set above
       
   130 		iSession->GetSecondaryFiltersEnabled(*getfilters);
       
   131 
       
   132 		if( getfilters->Count() == setfilters->Count() )
       
   133 		{	
       
   134 			INFO_PRINTF1(_L("setfilter and getfilter have the same count"));
       
   135 			for(TInt i = 0; i < getfilters->Count(); i++)
       
   136 			{
       
   137 				for(TInt j = 0; j < setfilters->Count(); j++)
       
   138 				{
       
   139 					if( (*getfilters)[i] == (*setfilters)[j] )
       
   140 						SetTestStepResult(EPass);
       
   141 					else
       
   142 						SetTestStepResult(EFail);
       
   143 				}
       
   144 			}
       
   145 		}	
       
   146 		else
       
   147 		{
       
   148 			INFO_PRINTF1(_L("setfilter and getfilter have different counts"));
       
   149 			INFO_PRINTF2(_L("setfilter has %d"), setfilters->Count());
       
   150 			INFO_PRINTF2(_L("getfilter has %d"), getfilters->Count());
       
   151 			SetTestStepResult(EFail);
       
   152 		}
       
   153 	}
       
   154 
       
   155 	setfilters->Close();
       
   156 	getfilters->Close();
       
   157 
       
   158 	if(setfilters)
       
   159 	{
       
   160 		delete setfilters;
       
   161 		setfilters=NULL;
       
   162 	}
       
   163 
       
   164 	if(getfilters)
       
   165 	{
       
   166 		delete getfilters;
       
   167 		getfilters=NULL;
       
   168 	}
       
   169 
       
   170 	return TestStepResult();
       
   171 }
       
   172 
       
   173 TVerdict CTestSetSecondaryFltStep::doTestStepPostambleL()
       
   174 /**
       
   175  * @return - TVerdict code
       
   176  * Override of base class virtual
       
   177  */
       
   178 {
       
   179 	INFO_PRINTF1(_L("TestSetSecondaryFltStep completed"));
       
   180 	CTestUloggerClientApiStepBase::doTestStepPostambleL();
       
   181 	return TestStepResult();
       
   182 }