os/persistentdata/traceservices/tracefw/ulogger/unit_test/te-client/testremoveprimaryfltstep.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Example CTestStep derived implementation
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
/**
sl@0
    19
 @file TestRemovePrimaryFltStep.cpp
sl@0
    20
 @internalTechnology
sl@0
    21
*/
sl@0
    22
#include "testremoveprimaryfltstep.h"
sl@0
    23
#include "te_uloggerclientsuitedefs.h"
sl@0
    24
sl@0
    25
CTestRemovePrimaryFltStep::~CTestRemovePrimaryFltStep()
sl@0
    26
/**
sl@0
    27
 * Destructor
sl@0
    28
 */
sl@0
    29
	{
sl@0
    30
	}
sl@0
    31
sl@0
    32
CTestRemovePrimaryFltStep::CTestRemovePrimaryFltStep()
sl@0
    33
/**
sl@0
    34
 * Constructor
sl@0
    35
 */
sl@0
    36
	{
sl@0
    37
	// **MUST** call SetTestStepName in the constructor as the controlling
sl@0
    38
	// framework uses the test step name immediately following construction to set
sl@0
    39
	// up the step's unique logging ID.
sl@0
    40
	SetTestStepName(KTestRemovePrimaryFltStep);
sl@0
    41
	}
sl@0
    42
sl@0
    43
TVerdict CTestRemovePrimaryFltStep::doTestStepPreambleL()
sl@0
    44
/**
sl@0
    45
 * @return - TVerdict code
sl@0
    46
 * Override of base class virtual
sl@0
    47
 */
sl@0
    48
{
sl@0
    49
	CTestUloggerClientApiStepBase::doTestStepPreambleL();		
sl@0
    50
	return TestStepResult();
sl@0
    51
}
sl@0
    52
sl@0
    53
sl@0
    54
TVerdict CTestRemovePrimaryFltStep::doTestStepL()
sl@0
    55
/**
sl@0
    56
 * @return - TVerdict code
sl@0
    57
 * Override of base class pure virtual
sl@0
    58
 * Our implementation only gets called if the base class doTestStepPreambleL() did
sl@0
    59
 * not leave. That being the case, the current test result value will be EPass.
sl@0
    60
 */
sl@0
    61
{
sl@0
    62
	CArrayFixFlat<TUint8> *setfilters = new (ELeave)CArrayFixFlat<TUint8>(10);
sl@0
    63
	CArrayFixFlat<TUint8> *getfilters = new (ELeave)CArrayFixFlat<TUint8>(10);
sl@0
    64
sl@0
    65
	if (TestStepResult()==EPass)
sl@0
    66
	{
sl@0
    67
		const unsigned char KPrimaryFilter = 23;
sl@0
    68
		setfilters->AppendL(KPrimaryFilter);
sl@0
    69
sl@0
    70
		/**************First set primary filter*************/
sl@0
    71
sl@0
    72
		iSession->Connect();
sl@0
    73
		TInt iErrCode = iSession->SetPrimaryFiltersEnabled(*setfilters, ETrue);
sl@0
    74
sl@0
    75
		if( iErrCode == KErrNone )
sl@0
    76
		{
sl@0
    77
			iErrCode = iSession->SetPrimaryFiltersEnabled(*setfilters, EFalse);
sl@0
    78
			if( iErrCode == KErrNone )
sl@0
    79
			{
sl@0
    80
				SetTestStepResult(EPass);
sl@0
    81
				setfilters->Reset();
sl@0
    82
				iSession->GetPrimaryFiltersEnabled(*setfilters);
sl@0
    83
sl@0
    84
				if( setfilters->Count() <= 0 )
sl@0
    85
				{
sl@0
    86
					INFO_PRINTF2(_L("Primary filter has been removed , %d"), setfilters->At(0));
sl@0
    87
					SetTestStepResult(EPass);
sl@0
    88
				}
sl@0
    89
				else
sl@0
    90
				{
sl@0
    91
					for(TInt i = 0; i < setfilters->Count(); i++)
sl@0
    92
					{
sl@0
    93
						if(setfilters->At(i) == KPrimaryFilter)
sl@0
    94
						{
sl@0
    95
							INFO_PRINTF1(_L("GetFilter() Failed, can not varify the test output"));
sl@0
    96
							SetTestStepResult(EFail);
sl@0
    97
						}
sl@0
    98
						else
sl@0
    99
						{
sl@0
   100
							INFO_PRINTF2(_L("Primary filter has been removed , %d"), setfilters->At(0));
sl@0
   101
							SetTestStepResult(EPass);
sl@0
   102
						}
sl@0
   103
					}
sl@0
   104
				}
sl@0
   105
			}
sl@0
   106
			else
sl@0
   107
			{
sl@0
   108
				INFO_PRINTF2(_L("Primary filter remove failed , %d"), setfilters->At(0));
sl@0
   109
				SetTestStepResult(EFail);
sl@0
   110
			}	
sl@0
   111
		}
sl@0
   112
	}
sl@0
   113
sl@0
   114
	if(TestStepResult() == EPass)
sl@0
   115
	{
sl@0
   116
		setfilters->Reset();
sl@0
   117
		getfilters->Reset();
sl@0
   118
sl@0
   119
		for(TInt i = 0; i < 256 ; i++ )
sl@0
   120
		{
sl@0
   121
			setfilters->AppendL((TUint8)(i));
sl@0
   122
		}
sl@0
   123
sl@0
   124
		TRAPD(err, iSession->SetPrimaryFiltersEnabled(*setfilters, ETrue));
sl@0
   125
		if( KErrNone ==  err )
sl@0
   126
		{
sl@0
   127
			TInt iFailCount = 0;
sl@0
   128
		//	for(TInt i = 0; i < 256; i++)
sl@0
   129
		//	{
sl@0
   130
				 if(iSession->SetPrimaryFiltersEnabled(*setfilters, EFalse) != KErrNone)
sl@0
   131
				 {
sl@0
   132
				 	iFailCount ++;
sl@0
   133
				 	INFO_PRINTF1(_L("Remove primary filters failed"));
sl@0
   134
					SetTestStepResult(EFail);
sl@0
   135
		//		 }
sl@0
   136
			}
sl@0
   137
			if(iFailCount == 0)
sl@0
   138
			{
sl@0
   139
			 	INFO_PRINTF1(_L("All primary filters Removed"));
sl@0
   140
				SetTestStepResult(EPass);
sl@0
   141
			}
sl@0
   142
		}
sl@0
   143
	}
sl@0
   144
sl@0
   145
	setfilters->Reset();
sl@0
   146
	getfilters->Reset();
sl@0
   147
sl@0
   148
	if(setfilters)
sl@0
   149
	{
sl@0
   150
		delete setfilters;
sl@0
   151
		setfilters=NULL;
sl@0
   152
	}
sl@0
   153
sl@0
   154
	if(getfilters)
sl@0
   155
	{
sl@0
   156
		delete getfilters;
sl@0
   157
		getfilters=NULL;
sl@0
   158
	}
sl@0
   159
sl@0
   160
	return TestStepResult();
sl@0
   161
}
sl@0
   162
sl@0
   163
TVerdict CTestRemovePrimaryFltStep::doTestStepPostambleL()
sl@0
   164
/**
sl@0
   165
 * @return - TVerdict code
sl@0
   166
 * Override of base class virtual
sl@0
   167
 */
sl@0
   168
{
sl@0
   169
	CTestUloggerClientApiStepBase::doTestStepPostambleL();
sl@0
   170
	return TestStepResult();
sl@0
   171
}