traceservices/tracefw/ulogger/unit_test/te-client/testremoveprimaryfltstep.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 TestRemovePrimaryFltStep.cpp
       
    20  @internalTechnology
       
    21 */
       
    22 #include "testremoveprimaryfltstep.h"
       
    23 #include "te_uloggerclientsuitedefs.h"
       
    24 
       
    25 CTestRemovePrimaryFltStep::~CTestRemovePrimaryFltStep()
       
    26 /**
       
    27  * Destructor
       
    28  */
       
    29 	{
       
    30 	}
       
    31 
       
    32 CTestRemovePrimaryFltStep::CTestRemovePrimaryFltStep()
       
    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(KTestRemovePrimaryFltStep);
       
    41 	}
       
    42 
       
    43 TVerdict CTestRemovePrimaryFltStep::doTestStepPreambleL()
       
    44 /**
       
    45  * @return - TVerdict code
       
    46  * Override of base class virtual
       
    47  */
       
    48 {
       
    49 	CTestUloggerClientApiStepBase::doTestStepPreambleL();		
       
    50 	return TestStepResult();
       
    51 }
       
    52 
       
    53 
       
    54 TVerdict CTestRemovePrimaryFltStep::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 	CArrayFixFlat<TUint8> *setfilters = new (ELeave)CArrayFixFlat<TUint8>(10);
       
    63 	CArrayFixFlat<TUint8> *getfilters = new (ELeave)CArrayFixFlat<TUint8>(10);
       
    64 
       
    65 	if (TestStepResult()==EPass)
       
    66 	{
       
    67 		const unsigned char KPrimaryFilter = 23;
       
    68 		setfilters->AppendL(KPrimaryFilter);
       
    69 
       
    70 		/**************First set primary filter*************/
       
    71 
       
    72 		iSession->Connect();
       
    73 		TInt iErrCode = iSession->SetPrimaryFiltersEnabled(*setfilters, ETrue);
       
    74 
       
    75 		if( iErrCode == KErrNone )
       
    76 		{
       
    77 			iErrCode = iSession->SetPrimaryFiltersEnabled(*setfilters, EFalse);
       
    78 			if( iErrCode == KErrNone )
       
    79 			{
       
    80 				SetTestStepResult(EPass);
       
    81 				setfilters->Reset();
       
    82 				iSession->GetPrimaryFiltersEnabled(*setfilters);
       
    83 
       
    84 				if( setfilters->Count() <= 0 )
       
    85 				{
       
    86 					INFO_PRINTF2(_L("Primary filter has been removed , %d"), setfilters->At(0));
       
    87 					SetTestStepResult(EPass);
       
    88 				}
       
    89 				else
       
    90 				{
       
    91 					for(TInt i = 0; i < setfilters->Count(); i++)
       
    92 					{
       
    93 						if(setfilters->At(i) == KPrimaryFilter)
       
    94 						{
       
    95 							INFO_PRINTF1(_L("GetFilter() Failed, can not varify the test output"));
       
    96 							SetTestStepResult(EFail);
       
    97 						}
       
    98 						else
       
    99 						{
       
   100 							INFO_PRINTF2(_L("Primary filter has been removed , %d"), setfilters->At(0));
       
   101 							SetTestStepResult(EPass);
       
   102 						}
       
   103 					}
       
   104 				}
       
   105 			}
       
   106 			else
       
   107 			{
       
   108 				INFO_PRINTF2(_L("Primary filter remove failed , %d"), setfilters->At(0));
       
   109 				SetTestStepResult(EFail);
       
   110 			}	
       
   111 		}
       
   112 	}
       
   113 
       
   114 	if(TestStepResult() == EPass)
       
   115 	{
       
   116 		setfilters->Reset();
       
   117 		getfilters->Reset();
       
   118 
       
   119 		for(TInt i = 0; i < 256 ; i++ )
       
   120 		{
       
   121 			setfilters->AppendL((TUint8)(i));
       
   122 		}
       
   123 
       
   124 		TRAPD(err, iSession->SetPrimaryFiltersEnabled(*setfilters, ETrue));
       
   125 		if( KErrNone ==  err )
       
   126 		{
       
   127 			TInt iFailCount = 0;
       
   128 		//	for(TInt i = 0; i < 256; i++)
       
   129 		//	{
       
   130 				 if(iSession->SetPrimaryFiltersEnabled(*setfilters, EFalse) != KErrNone)
       
   131 				 {
       
   132 				 	iFailCount ++;
       
   133 				 	INFO_PRINTF1(_L("Remove primary filters failed"));
       
   134 					SetTestStepResult(EFail);
       
   135 		//		 }
       
   136 			}
       
   137 			if(iFailCount == 0)
       
   138 			{
       
   139 			 	INFO_PRINTF1(_L("All primary filters Removed"));
       
   140 				SetTestStepResult(EPass);
       
   141 			}
       
   142 		}
       
   143 	}
       
   144 
       
   145 	setfilters->Reset();
       
   146 	getfilters->Reset();
       
   147 
       
   148 	if(setfilters)
       
   149 	{
       
   150 		delete setfilters;
       
   151 		setfilters=NULL;
       
   152 	}
       
   153 
       
   154 	if(getfilters)
       
   155 	{
       
   156 		delete getfilters;
       
   157 		getfilters=NULL;
       
   158 	}
       
   159 
       
   160 	return TestStepResult();
       
   161 }
       
   162 
       
   163 TVerdict CTestRemovePrimaryFltStep::doTestStepPostambleL()
       
   164 /**
       
   165  * @return - TVerdict code
       
   166  * Override of base class virtual
       
   167  */
       
   168 {
       
   169 	CTestUloggerClientApiStepBase::doTestStepPostambleL();
       
   170 	return TestStepResult();
       
   171 }