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