os/persistentdata/traceservices/tracefw/ulogger/unit_test/te-client/testruloggerapi_ext.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) 2007-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 testruloggerapi_ext.cpp
sl@0
    20
 @internalTechnology
sl@0
    21
*/
sl@0
    22
#include "testruloggerapi_ext.h"
sl@0
    23
#include "te_uloggerclientsuitedefs.h"
sl@0
    24
#include <uloggerdatatypes.h>
sl@0
    25
sl@0
    26
CTestRULoggerAPIStep::~CTestRULoggerAPIStep()
sl@0
    27
/**
sl@0
    28
 * Destructor
sl@0
    29
 */
sl@0
    30
	{
sl@0
    31
	}
sl@0
    32
sl@0
    33
CTestRULoggerAPIStep::CTestRULoggerAPIStep()
sl@0
    34
/**
sl@0
    35
 * Constructor
sl@0
    36
 */
sl@0
    37
	{
sl@0
    38
	// **MUST** call SetTestStepName in the constructor as the controlling
sl@0
    39
	// framework uses the test step name immediately following construction to set
sl@0
    40
	// up the step's unique logging ID.
sl@0
    41
		
sl@0
    42
	SetTestStepName(KTestRULoggerAPIStep);
sl@0
    43
	}
sl@0
    44
sl@0
    45
TVerdict CTestRULoggerAPIStep::doTestStepPreambleL()
sl@0
    46
/**
sl@0
    47
 * @return - TVerdict code
sl@0
    48
 * Override of base class virtual
sl@0
    49
 */
sl@0
    50
	{
sl@0
    51
	INFO_PRINTF1(_L("CTestRULoggerAPIStep -Extended API tests- started"));
sl@0
    52
	
sl@0
    53
	TInt errCode = iUlogger.Connect();
sl@0
    54
	if(errCode != KErrNone)
sl@0
    55
		{
sl@0
    56
		TBuf<64> b;
sl@0
    57
		b.AppendFormat(_L("connect error: %d"), errCode);
sl@0
    58
		SetTestStepResult(EFail);
sl@0
    59
		}
sl@0
    60
	else
sl@0
    61
		SetTestStepResult(EPass);
sl@0
    62
	
sl@0
    63
	CTestUloggerClientApiStepBase::doTestStepPreambleL();
sl@0
    64
	return TestStepResult();
sl@0
    65
	}
sl@0
    66
sl@0
    67
sl@0
    68
TVerdict CTestRULoggerAPIStep::doTestStepL()
sl@0
    69
/**
sl@0
    70
 * @return - TVerdict code
sl@0
    71
 * Override of base class pure virtual
sl@0
    72
 * Our implementation only gets called if the base class doTestStepPreambleL() did
sl@0
    73
 * not leave. That being the case, the current test result value will be EPass.
sl@0
    74
 */
sl@0
    75
{
sl@0
    76
	if (TestStepResult()==EPass)
sl@0
    77
		{
sl@0
    78
		TInt errors = 0;
sl@0
    79
		errors += SetGetPrimaryFiletr_TestL();
sl@0
    80
		errors += SetGetSecondaryFiletr_TestL();
sl@0
    81
		errors += SetGetSecondaryFiltering_TestL();
sl@0
    82
		errors += SetGetOutputPlugin_TestL();
sl@0
    83
		errors += GetInstalledOutputPlugins_TestL();
sl@0
    84
		errors += SetGetInputPlugin_TestL();
sl@0
    85
		errors += GetInstalledInputPlugins_TestL();
sl@0
    86
		errors += SetGetRemovePluginConf_TestL();
sl@0
    87
		errors += SetGetTraceBuffer_TestL();
sl@0
    88
		
sl@0
    89
		//check errors
sl@0
    90
		if(errors)
sl@0
    91
			{
sl@0
    92
			SetTestStepResult(EFail);
sl@0
    93
			TBuf<64> b;
sl@0
    94
			b.AppendFormat(_L("%d errors were found !!!!"), errors);
sl@0
    95
			INFO_PRINTF1(b);
sl@0
    96
			}
sl@0
    97
		else
sl@0
    98
			{
sl@0
    99
			SetTestStepResult(EPass);
sl@0
   100
			INFO_PRINTF1(_L("CTestRULoggerAPIStep completed without problems."));
sl@0
   101
			}
sl@0
   102
		}
sl@0
   103
	
sl@0
   104
	return TestStepResult();	
sl@0
   105
}
sl@0
   106
sl@0
   107
TVerdict CTestRULoggerAPIStep::doTestStepPostambleL()
sl@0
   108
/**
sl@0
   109
 * @return - TVerdict code
sl@0
   110
 * Override of base class virtual
sl@0
   111
 */
sl@0
   112
	{
sl@0
   113
		INFO_PRINTF1(_L("CTestRULoggerAPIStep completed"));
sl@0
   114
		CTestUloggerClientApiStepBase::doTestStepPostambleL();	
sl@0
   115
		iUlogger.Close();
sl@0
   116
		return TestStepResult();
sl@0
   117
	}
sl@0
   118
sl@0
   119
sl@0
   120
TInt CTestRULoggerAPIStep::SetGetPrimaryFiletr_TestL()
sl@0
   121
{
sl@0
   122
	TInt err = 0;
sl@0
   123
	TInt i;
sl@0
   124
	CArrayFixFlat<TUint8> *filters = new (ELeave) CArrayFixFlat<TUint8>(1);
sl@0
   125
	CArrayFixFlat<TUint8> *gFilters = new (ELeave) CArrayFixFlat<TUint8>(1);
sl@0
   126
	TInt test;
sl@0
   127
	
sl@0
   128
	//set 256 filters
sl@0
   129
	for(i=0; i<256; i++)
sl@0
   130
		filters->AppendL((TUint8)i);	
sl@0
   131
	test = iUlogger.SetPrimaryFiltersEnabled(*filters, ETrue);
sl@0
   132
	if(test != KErrNone)
sl@0
   133
		{
sl@0
   134
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   135
		INFO_PRINTF1(_L("set 256 filters - failed"));
sl@0
   136
		err++;
sl@0
   137
		}
sl@0
   138
sl@0
   139
	//get 256 filetrs
sl@0
   140
	test = iUlogger.GetPrimaryFiltersEnabled(*gFilters);
sl@0
   141
	if(test!=KErrNone && gFilters->Count()!=256)
sl@0
   142
		{
sl@0
   143
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   144
		INFO_PRINTF1(_L("get 256 filters - failed!"));
sl@0
   145
		err++;
sl@0
   146
		}
sl@0
   147
	
sl@0
   148
	//set 257 filetrs
sl@0
   149
	filters->AppendL((TUint8)257); //value doesn't matter
sl@0
   150
	test = iUlogger.SetPrimaryFiltersEnabled(*filters, ETrue);
sl@0
   151
	if(test != KErrArgument)
sl@0
   152
		{
sl@0
   153
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   154
		INFO_PRINTF1(_L("set 257 filters - failed!"));
sl@0
   155
		err++;
sl@0
   156
		}
sl@0
   157
sl@0
   158
	//get 257 filetrs (should be 256 vin array)
sl@0
   159
	gFilters->Reset();
sl@0
   160
	test = iUlogger.GetPrimaryFiltersEnabled(*gFilters);
sl@0
   161
	if(test!=KErrNone && gFilters->Count()!=256)
sl@0
   162
		{
sl@0
   163
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   164
		INFO_PRINTF1(_L("get 257 filters - failed!"));
sl@0
   165
		err++;
sl@0
   166
		}
sl@0
   167
	
sl@0
   168
	//remove 256 filetrs
sl@0
   169
	test = iUlogger.SetPrimaryFiltersEnabled(*gFilters, EFalse);
sl@0
   170
	if(test != KErrNone)
sl@0
   171
		{
sl@0
   172
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   173
		INFO_PRINTF1(_L("remove 256 filetrs - failed!"));
sl@0
   174
		err++;
sl@0
   175
		}
sl@0
   176
	
sl@0
   177
	//remove 257 filetrs
sl@0
   178
	test = iUlogger.SetPrimaryFiltersEnabled(*filters, EFalse);
sl@0
   179
	if(test != KErrArgument)
sl@0
   180
		{
sl@0
   181
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   182
		INFO_PRINTF1(_L("remove 257 filetrs - failed!"));
sl@0
   183
		err++;
sl@0
   184
		}
sl@0
   185
sl@0
   186
	
sl@0
   187
	filters->Reset();
sl@0
   188
	gFilters->Reset();
sl@0
   189
	//set empty array ETrue test
sl@0
   190
	test = iUlogger.SetPrimaryFiltersEnabled(*filters, ETrue);
sl@0
   191
	if(test != KErrArgument)
sl@0
   192
		{
sl@0
   193
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   194
		INFO_PRINTF1(_L("set empty array ETrue test - failed!"));
sl@0
   195
		err++;
sl@0
   196
		}
sl@0
   197
sl@0
   198
	//set empty array EFalse test
sl@0
   199
	test = iUlogger.SetPrimaryFiltersEnabled(*filters, EFalse);
sl@0
   200
	if(test != KErrArgument)
sl@0
   201
		{
sl@0
   202
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   203
		INFO_PRINTF1(_L("set empty array EFalse test - failed!"));
sl@0
   204
		err++;
sl@0
   205
		}
sl@0
   206
sl@0
   207
	//getting empty array
sl@0
   208
	gFilters->Reset();
sl@0
   209
	test = iUlogger.GetPrimaryFiltersEnabled(*gFilters);
sl@0
   210
	if(test!=KErrNone && gFilters->Count()!=0)
sl@0
   211
		{
sl@0
   212
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   213
		INFO_PRINTF1(_L("getting empty array - failed!"));
sl@0
   214
		err++;
sl@0
   215
		}
sl@0
   216
	
sl@0
   217
	//summary
sl@0
   218
	TBuf<64> b;
sl@0
   219
	if(err)
sl@0
   220
		b.AppendFormat(_L("SetGetPrimaryFiletr_TestL failed with %d errors!!!"), err);
sl@0
   221
	else
sl@0
   222
		b.Append(_L("SetGetPrimaryFiletr_TestL passed"));
sl@0
   223
			
sl@0
   224
	
sl@0
   225
	delete gFilters;
sl@0
   226
	gFilters = NULL;
sl@0
   227
	delete filters;
sl@0
   228
	filters = NULL;
sl@0
   229
	return err;
sl@0
   230
}
sl@0
   231
sl@0
   232
sl@0
   233
TInt CTestRULoggerAPIStep::SetGetSecondaryFiletr_TestL()
sl@0
   234
{
sl@0
   235
	TInt err = 0;
sl@0
   236
	TInt i;
sl@0
   237
	RArray<TUint32> filters;
sl@0
   238
	RArray<TUint32> gFilters;
sl@0
   239
	TInt test;
sl@0
   240
sl@0
   241
	//clean
sl@0
   242
	iUlogger.GetSecondaryFiltersEnabled(gFilters);
sl@0
   243
	iUlogger.SetSecondaryFiltersEnabled(gFilters, EFalse);
sl@0
   244
	gFilters.Reset();
sl@0
   245
	
sl@0
   246
	//set 4096 filters
sl@0
   247
	for(i=0; i<4096; i++)
sl@0
   248
		filters.AppendL((TUint32)i);	
sl@0
   249
	test = iUlogger.SetSecondaryFiltersEnabled(filters, ETrue);
sl@0
   250
	if(test != KErrNone)
sl@0
   251
		{
sl@0
   252
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   253
		INFO_PRINTF1(_L("set 4096 filters - failed"));
sl@0
   254
		err++;
sl@0
   255
		}
sl@0
   256
sl@0
   257
	//get 4096 filetrs
sl@0
   258
	test = iUlogger.GetSecondaryFiltersEnabled(gFilters);
sl@0
   259
	if(test!=KErrNone && gFilters.Count()!=4096)
sl@0
   260
		{
sl@0
   261
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   262
		INFO_PRINTF1(_L("get 4096 filters - failed!"));
sl@0
   263
		err++;
sl@0
   264
		}
sl@0
   265
	
sl@0
   266
	//set 4096+1 filetrs
sl@0
   267
	filters.AppendL(4097); //value doesn't matter
sl@0
   268
	test = iUlogger.SetSecondaryFiltersEnabled(filters, ETrue);
sl@0
   269
	if(test != KErrArgument)
sl@0
   270
		{
sl@0
   271
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   272
		INFO_PRINTF1(_L("set 4096+1 filters - failed!"));
sl@0
   273
		err++;
sl@0
   274
		}
sl@0
   275
sl@0
   276
	//get 4096+1 filetrs (should be 4096 in array)
sl@0
   277
	gFilters.Reset();
sl@0
   278
	test = iUlogger.GetSecondaryFiltersEnabled(gFilters);
sl@0
   279
	if(test!=KErrNone && gFilters.Count()!=4096)
sl@0
   280
		{
sl@0
   281
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   282
		INFO_PRINTF1(_L("get 4096+1 filters - failed!"));
sl@0
   283
		err++;
sl@0
   284
		}
sl@0
   285
	
sl@0
   286
	//remove 4096 filetrs
sl@0
   287
	test = iUlogger.SetSecondaryFiltersEnabled(gFilters, EFalse);
sl@0
   288
	if(test != KErrNone)
sl@0
   289
		{
sl@0
   290
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   291
		INFO_PRINTF1(_L("remove 4096 filetrs - failed!"));
sl@0
   292
		err++;
sl@0
   293
		}
sl@0
   294
	
sl@0
   295
	//remove 4096+1 filetrs
sl@0
   296
	test = iUlogger.SetSecondaryFiltersEnabled(filters, EFalse);
sl@0
   297
	if(test != KErrArgument)
sl@0
   298
		{
sl@0
   299
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   300
		INFO_PRINTF1(_L("remove 4096+1 filetrs - failed!"));
sl@0
   301
		err++;
sl@0
   302
		}
sl@0
   303
sl@0
   304
	
sl@0
   305
	filters.Reset();
sl@0
   306
	gFilters.Reset();
sl@0
   307
	//set empty array ETrue test
sl@0
   308
	test = iUlogger.SetSecondaryFiltersEnabled(filters, ETrue);
sl@0
   309
	if(test != KErrArgument)
sl@0
   310
		{
sl@0
   311
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   312
		INFO_PRINTF1(_L("set empty array ETrue test - failed!"));
sl@0
   313
		err++;
sl@0
   314
		}
sl@0
   315
sl@0
   316
	//set empty array EFalse test
sl@0
   317
	test = iUlogger.SetSecondaryFiltersEnabled(filters, EFalse);
sl@0
   318
	if(test != KErrArgument)
sl@0
   319
		{
sl@0
   320
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   321
		INFO_PRINTF1(_L("set empty array EFalse test - failed!"));
sl@0
   322
		err++;
sl@0
   323
		}
sl@0
   324
sl@0
   325
	//getting empty array
sl@0
   326
	gFilters.Reset();
sl@0
   327
	test = iUlogger.GetSecondaryFiltersEnabled(gFilters);
sl@0
   328
	if(test!=KErrNone && gFilters.Count()!=0)
sl@0
   329
		{
sl@0
   330
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   331
		INFO_PRINTF1(_L("getting empty array - failed!"));
sl@0
   332
		err++;
sl@0
   333
		}
sl@0
   334
	
sl@0
   335
	//summary
sl@0
   336
	TBuf<64> b;
sl@0
   337
	if(err)
sl@0
   338
		b.AppendFormat(_L("SetGetSecondaryFiletr_TestL failed with %d errors!!!"), err);
sl@0
   339
	else
sl@0
   340
		b.Append(_L("SetGetSecondaryFiletr_TestL passed"));
sl@0
   341
	INFO_PRINTF1(b);
sl@0
   342
	
sl@0
   343
	gFilters.Close();
sl@0
   344
	filters.Close();
sl@0
   345
	return err;
sl@0
   346
}
sl@0
   347
sl@0
   348
sl@0
   349
TInt CTestRULoggerAPIStep::SetGetSecondaryFiltering_TestL()
sl@0
   350
{
sl@0
   351
	TInt err = 0;
sl@0
   352
	TInt test = 0;
sl@0
   353
	TBool val = ETrue;
sl@0
   354
	
sl@0
   355
	//set secondary filtering as ETrue
sl@0
   356
	iUlogger.SetSecondaryFilteringEnabled(EFalse);
sl@0
   357
	test = iUlogger.SetSecondaryFilteringEnabled(ETrue);
sl@0
   358
	if(test!=KErrNone)
sl@0
   359
		{
sl@0
   360
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   361
		INFO_PRINTF1(_L("set secondary filtering as ETrue - failed!"));
sl@0
   362
		err++;
sl@0
   363
		}
sl@0
   364
sl@0
   365
	//set secondary filtering as ETrue again
sl@0
   366
	test = iUlogger.SetSecondaryFilteringEnabled(ETrue);
sl@0
   367
	if(test != KErrNone)
sl@0
   368
		{
sl@0
   369
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   370
		INFO_PRINTF1(_L("set secondary filtering as ETrue again - failed!"));
sl@0
   371
		err++;
sl@0
   372
		}
sl@0
   373
sl@0
   374
	//get secondary filtering ETrue
sl@0
   375
	test = iUlogger.GetSecondaryFilteringEnabled(val);
sl@0
   376
	if(test != KErrNone || !val)
sl@0
   377
		{
sl@0
   378
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   379
		INFO_PRINTF1(_L("get secondary filtering ETrue - failed!"));
sl@0
   380
		err++;
sl@0
   381
		}
sl@0
   382
sl@0
   383
	//set secondary filtering as EFalse
sl@0
   384
	test = iUlogger.SetSecondaryFilteringEnabled(EFalse);
sl@0
   385
	if(test != KErrNone)
sl@0
   386
		{
sl@0
   387
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   388
		INFO_PRINTF1(_L("set secondary filtering as EFalse - failed!"));
sl@0
   389
		err++;
sl@0
   390
		}
sl@0
   391
	
sl@0
   392
	//set secondary filtering as EFalse again
sl@0
   393
	test = iUlogger.SetSecondaryFilteringEnabled(EFalse);
sl@0
   394
	if(test != KErrNone)
sl@0
   395
		{
sl@0
   396
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   397
		INFO_PRINTF1(_L("set secondary filtering as EFalse again - failed!"));
sl@0
   398
		err++;
sl@0
   399
		}
sl@0
   400
	
sl@0
   401
	//get secondary filtering EFalse
sl@0
   402
	test = iUlogger.GetSecondaryFilteringEnabled(val);
sl@0
   403
	if(test != KErrNone || val)
sl@0
   404
		{
sl@0
   405
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   406
		INFO_PRINTF1(_L("get secondary filtering EFalse - failed!"));
sl@0
   407
		err++;
sl@0
   408
		}
sl@0
   409
	
sl@0
   410
	//summary
sl@0
   411
	TBuf<64> b;
sl@0
   412
	if(err)
sl@0
   413
		b.AppendFormat(_L("SetGetSecondaryFiltering_TestL failed with %d errors!!!"), err);
sl@0
   414
	else
sl@0
   415
		b.Append(_L("SetGetSecondaryFiltering_TestL passed"));
sl@0
   416
	INFO_PRINTF1(b);
sl@0
   417
	return err;
sl@0
   418
}
sl@0
   419
sl@0
   420
TInt CTestRULoggerAPIStep::SetGetOutputPlugin_TestL()
sl@0
   421
{
sl@0
   422
	TInt err = 0;
sl@0
   423
	TInt test = KErrNone;
sl@0
   424
	TBuf8<256> plugin;
sl@0
   425
	_LIT8(KFilePlugin, "uloggerfileplugin");
sl@0
   426
	_LIT8(KSerialPlugin, "uloggerserialplugin");
sl@0
   427
	iUlogger.ActivateOutputPlugin(KSerialPlugin); //initial settings
sl@0
   428
	
sl@0
   429
	//set uloggerfileplugin as output
sl@0
   430
	test = iUlogger.ActivateOutputPlugin(KFilePlugin);
sl@0
   431
	if(test!=KErrNone)
sl@0
   432
		{
sl@0
   433
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   434
		INFO_PRINTF1(_L("set uloggerfileplugin as output - failed!"));
sl@0
   435
		err++;
sl@0
   436
		}
sl@0
   437
	
sl@0
   438
	//get uloggerfileplugin
sl@0
   439
	test = iUlogger.GetActiveOutputPlugin(plugin);
sl@0
   440
	if(plugin.Compare(KFilePlugin) != 0 || test!=KErrNone)
sl@0
   441
		{
sl@0
   442
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   443
		INFO_PRINTF1(_L("get uloggerfileplugin - failed!"));
sl@0
   444
		err++;
sl@0
   445
		}
sl@0
   446
	
sl@0
   447
	//set uloggerfileplugin as output again
sl@0
   448
	test = iUlogger.ActivateOutputPlugin(KFilePlugin);
sl@0
   449
	if(test != KErrNone) //dont return an error although already exists isnt a "failure"
sl@0
   450
		{
sl@0
   451
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   452
		INFO_PRINTF1(_L("set uloggerfileplugin as output again - failed!"));
sl@0
   453
		err++;
sl@0
   454
		}
sl@0
   455
	
sl@0
   456
	TBuf8<2> smallBuf;
sl@0
   457
	//get uloggerfileplugin to small buf
sl@0
   458
	test = iUlogger.GetActiveOutputPlugin(smallBuf);
sl@0
   459
	if(test!=KErrOverflow)
sl@0
   460
		{
sl@0
   461
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   462
		INFO_PRINTF1(_L("get uloggerfileplugin to small buf - failed!"));
sl@0
   463
		err++;
sl@0
   464
		}
sl@0
   465
	
sl@0
   466
	
sl@0
   467
	//summary
sl@0
   468
	TBuf<64> b;
sl@0
   469
	if(err)
sl@0
   470
		b.AppendFormat(_L("SetGetOutputPlugin_TestL failed with %d errors!!!"), err);
sl@0
   471
	else
sl@0
   472
		b.Append(_L("SetGetOutputPlugin_TestL passed"));
sl@0
   473
	INFO_PRINTF1(b);
sl@0
   474
	return err;
sl@0
   475
}
sl@0
   476
sl@0
   477
TInt CTestRULoggerAPIStep::GetInstalledOutputPlugins_TestL()
sl@0
   478
{
sl@0
   479
	TInt err = 0;
sl@0
   480
	TInt test = KErrNone;
sl@0
   481
	
sl@0
   482
	CArrayPtrFlat<HBufC8>* plugins = new (ELeave) CArrayPtrFlat<HBufC8>(1);
sl@0
   483
	test = iUlogger.GetInstalledOutputPlugins(*plugins);
sl@0
   484
	if(test != KErrNone)
sl@0
   485
		{
sl@0
   486
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   487
		INFO_PRINTF1(_L("GetInstalledOutputPlugins_TestL - failed!"));
sl@0
   488
		err++;
sl@0
   489
		}
sl@0
   490
	
sl@0
   491
	plugins->ResetAndDestroy();
sl@0
   492
	delete plugins;
sl@0
   493
	plugins = NULL;
sl@0
   494
	
sl@0
   495
	//summary
sl@0
   496
	TBuf<64> b;
sl@0
   497
	if(err)
sl@0
   498
		b.AppendFormat(_L("GetInstalledOutputPlugins_TestL failed with %d errors!!!"), err);
sl@0
   499
	else
sl@0
   500
		b.Append(_L("GetInstalledOutputPlugins_TestL passed"));
sl@0
   501
	INFO_PRINTF1(b);
sl@0
   502
	return err;
sl@0
   503
}
sl@0
   504
sl@0
   505
TInt CTestRULoggerAPIStep::SetGetInputPlugin_TestL()
sl@0
   506
	{
sl@0
   507
	TInt err = 0;
sl@0
   508
	TInt test = KErrNone;
sl@0
   509
	
sl@0
   510
	TBuf8<256> plugin;
sl@0
   511
	_LIT8(KFilePlugin, "uloggerfileplugin");
sl@0
   512
	_LIT8(KUsbPlugin, "uloggerusbplugin");
sl@0
   513
	iUlogger.DeActivateInputPlugin(); //set initial state
sl@0
   514
	
sl@0
   515
	//set uloggerusbplugin as input
sl@0
   516
	test = iUlogger.ActivateInputPlugin(KUsbPlugin);
sl@0
   517
	if(test!=KErrNone && test!=KErrNotFound)
sl@0
   518
		{
sl@0
   519
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   520
		INFO_PRINTF1(_L("set uloggerusbplugin as input - failed!"));
sl@0
   521
		err++;
sl@0
   522
		}
sl@0
   523
	
sl@0
   524
	//set uloggerusbplugin as input again
sl@0
   525
	test = iUlogger.ActivateInputPlugin(KUsbPlugin);
sl@0
   526
	if(test!=KErrAlreadyExists && test!=KErrNotFound)
sl@0
   527
		{
sl@0
   528
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   529
		INFO_PRINTF1(_L("set uloggerusbplugin as input again - failed!"));
sl@0
   530
		err++;
sl@0
   531
		}
sl@0
   532
	
sl@0
   533
	//set uloggerfileplugin as input
sl@0
   534
	test = iUlogger.ActivateInputPlugin(KFilePlugin);
sl@0
   535
	if(test!=KErrNotFound)
sl@0
   536
		{
sl@0
   537
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   538
		INFO_PRINTF1(_L("set uloggerfileplugin as input - failed!"));
sl@0
   539
		err++;
sl@0
   540
		}
sl@0
   541
	
sl@0
   542
	//set empty as input
sl@0
   543
	test = iUlogger.ActivateInputPlugin(_L8(""));
sl@0
   544
	if(test!=KErrArgument)
sl@0
   545
		{
sl@0
   546
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   547
		INFO_PRINTF1(_L("set empty as inputt - failed!"));
sl@0
   548
		err++;
sl@0
   549
		}
sl@0
   550
	
sl@0
   551
	//get active input plugin
sl@0
   552
	test = iUlogger.GetActiveInputPlugin(plugin);
sl@0
   553
	if(test!=KErrNone && test != KErrNotFound)
sl@0
   554
		{
sl@0
   555
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   556
		INFO_PRINTF1(_L("get active input plugin - failed!"));
sl@0
   557
		err++;
sl@0
   558
		}
sl@0
   559
	
sl@0
   560
	//deactivate input
sl@0
   561
	test = iUlogger.DeActivateInputPlugin();
sl@0
   562
	if(test!=KErrNone && test != KErrNotFound)
sl@0
   563
		{
sl@0
   564
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   565
		INFO_PRINTF1(_L("deactivate input - failed!"));
sl@0
   566
		err++;
sl@0
   567
		}
sl@0
   568
	
sl@0
   569
	//deactivate input again
sl@0
   570
	test = iUlogger.DeActivateInputPlugin();
sl@0
   571
	if(test != KErrNotFound)
sl@0
   572
		{
sl@0
   573
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   574
		INFO_PRINTF1(_L("deactivate input again - failed!"));
sl@0
   575
		err++;
sl@0
   576
		}
sl@0
   577
	
sl@0
   578
	//get active input plugin again
sl@0
   579
	test = iUlogger.GetActiveInputPlugin(plugin);
sl@0
   580
	if(test != KErrNotFound)
sl@0
   581
		{
sl@0
   582
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   583
		INFO_PRINTF1(_L("get active input plugin again - failed!"));
sl@0
   584
		err++;
sl@0
   585
		}
sl@0
   586
	
sl@0
   587
	
sl@0
   588
	//summary
sl@0
   589
	TBuf<64> b;
sl@0
   590
	if(err)
sl@0
   591
		b.AppendFormat(_L("SetGetInputPlugin_TestL failed with %d errors!!!"), err);
sl@0
   592
	else
sl@0
   593
		b.Append(_L("SetGetInputPlugin_TestL passed"));
sl@0
   594
	INFO_PRINTF1(b);
sl@0
   595
	return err;
sl@0
   596
	}
sl@0
   597
sl@0
   598
TInt CTestRULoggerAPIStep::GetInstalledInputPlugins_TestL()
sl@0
   599
{
sl@0
   600
	TInt err = 0;
sl@0
   601
	TInt test = KErrNone;
sl@0
   602
sl@0
   603
	CArrayPtrFlat<HBufC8> *plugins = new (ELeave) CArrayPtrFlat<HBufC8>(1);
sl@0
   604
	test = iUlogger.GetInstalledInputPlugins(*plugins);
sl@0
   605
	if(test!=KErrNone)
sl@0
   606
		{
sl@0
   607
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   608
		INFO_PRINTF1(_L("GetInstalledInputPlugins - failed!"));
sl@0
   609
		err++;
sl@0
   610
		}
sl@0
   611
	
sl@0
   612
	plugins->ResetAndDestroy();
sl@0
   613
	delete plugins;
sl@0
   614
	plugins = NULL;
sl@0
   615
	
sl@0
   616
	//summary
sl@0
   617
	TBuf<64> b;
sl@0
   618
	if(err)
sl@0
   619
		b.AppendFormat(_L("GetInstalledInputPlugins_TestL failed with %d errors!!!"), err);
sl@0
   620
	else
sl@0
   621
		b.Append(_L("GetInstalledInputPlugins_TestL passed"));
sl@0
   622
	INFO_PRINTF1(b);
sl@0
   623
	return err;
sl@0
   624
}
sl@0
   625
sl@0
   626
TInt CTestRULoggerAPIStep::SetGetRemovePluginConf_TestL()
sl@0
   627
	{
sl@0
   628
	TInt err = 0;
sl@0
   629
	TInt test = KErrNone;
sl@0
   630
	_LIT8(KFilePlugin, "uloggerfileplugin");
sl@0
   631
	_LIT8(KDummyPlugin, "uloggerdummyplugin");
sl@0
   632
	_LIT(KTestKey, "testKey");
sl@0
   633
	_LIT(KTestVal, "testVal");
sl@0
   634
	
sl@0
   635
	//set uloggerfileplugin settings
sl@0
   636
	TPluginConfiguration conf;
sl@0
   637
	conf.SetKey(KTestKey);
sl@0
   638
	conf.SetValue(KTestVal);
sl@0
   639
	test = iUlogger.SetPluginConfigurations(KFilePlugin, conf);
sl@0
   640
	if(test != KErrNone)
sl@0
   641
		{
sl@0
   642
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   643
		INFO_PRINTF1(_L("set uloggerfileplugin settings - failed!"));
sl@0
   644
		err++;
sl@0
   645
		}
sl@0
   646
	
sl@0
   647
	//check uloggerfileplugin settings
sl@0
   648
	RPointerArray<TPluginConfiguration> confCheck;
sl@0
   649
	test = iUlogger.GetPluginConfigurations(KFilePlugin, confCheck);
sl@0
   650
	if(test != KErrNone)
sl@0
   651
		{
sl@0
   652
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   653
		INFO_PRINTF1(_L("check uloggerfileplugin settings - failed!"));
sl@0
   654
		err++;
sl@0
   655
		}
sl@0
   656
	else
sl@0
   657
		{
sl@0
   658
		TBool e = ETrue;
sl@0
   659
		for(TInt i=0; i<confCheck.Count(); ++i)
sl@0
   660
			{
sl@0
   661
			TPluginConfiguration* check = confCheck[i];
sl@0
   662
			INFO_PRINTF1(check->Key());
sl@0
   663
			INFO_PRINTF1(check->Value());
sl@0
   664
			if(!check->Key().Compare(KTestKey) && !check->Value().Compare(KTestVal))
sl@0
   665
				{
sl@0
   666
				e = EFalse;
sl@0
   667
				break;
sl@0
   668
				}
sl@0
   669
			}
sl@0
   670
		if(e)
sl@0
   671
			{
sl@0
   672
			INFO_PRINTF2(_L("err: %d"), test);
sl@0
   673
			INFO_PRINTF1(_L("check uloggerfileplugin settings (wrong values) - failed!"));
sl@0
   674
			err++;
sl@0
   675
			}
sl@0
   676
		}
sl@0
   677
	confCheck.ResetAndDestroy();
sl@0
   678
	confCheck.Close();
sl@0
   679
	
sl@0
   680
	
sl@0
   681
	//set uloggerdummyplugin settings
sl@0
   682
	test = iUlogger.SetPluginConfigurations(KDummyPlugin, conf);
sl@0
   683
	if(test != KErrNotFound)
sl@0
   684
		{
sl@0
   685
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   686
		INFO_PRINTF1(_L("set uloggerdummyplugin settings - failed!"));
sl@0
   687
		err++;
sl@0
   688
		}
sl@0
   689
	
sl@0
   690
	//pass empty descriptor
sl@0
   691
	test = iUlogger.SetPluginConfigurations(_L8(""), conf);
sl@0
   692
	if(test != KErrArgument)
sl@0
   693
		{
sl@0
   694
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   695
		INFO_PRINTF1(_L("pass empty descriptor - failed!"));
sl@0
   696
		err++;
sl@0
   697
		}
sl@0
   698
	
sl@0
   699
	
sl@0
   700
	//Get uloggerdummyplugin settings
sl@0
   701
	RPointerArray<TPluginConfiguration> confCheck2;
sl@0
   702
	test = iUlogger.GetPluginConfigurations(KDummyPlugin, confCheck2);
sl@0
   703
	if(test != KErrNotFound)
sl@0
   704
		{
sl@0
   705
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   706
		INFO_PRINTF1(_L("Get uloggerdummyplugin settings - failed!"));
sl@0
   707
		err++;
sl@0
   708
		}
sl@0
   709
	confCheck2.ResetAndDestroy();
sl@0
   710
	confCheck2.Close();
sl@0
   711
	
sl@0
   712
	
sl@0
   713
	//Get emptyName settings
sl@0
   714
	RPointerArray<TPluginConfiguration> confCheck3;
sl@0
   715
	test = iUlogger.GetPluginConfigurations(_L8(""), confCheck3);
sl@0
   716
	if(test != KErrArgument)
sl@0
   717
		{
sl@0
   718
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   719
		INFO_PRINTF1(_L("Get emptyName settings - failed!"));
sl@0
   720
		err++;
sl@0
   721
		}
sl@0
   722
	confCheck3.ResetAndDestroy();
sl@0
   723
	confCheck3.Close();
sl@0
   724
	
sl@0
   725
	
sl@0
   726
	//remove uloggerfileplugin settings
sl@0
   727
	test = iUlogger.RemovePluginConfigurations(KFilePlugin);
sl@0
   728
	if(test != KErrNone) //expected error
sl@0
   729
		{
sl@0
   730
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   731
		INFO_PRINTF1(_L("remove uloggerfileplugin settings - failed!"));
sl@0
   732
		err++;
sl@0
   733
		}
sl@0
   734
sl@0
   735
	//remove uloggerfileplugin settings again
sl@0
   736
	test = iUlogger.RemovePluginConfigurations(KFilePlugin);
sl@0
   737
	if(test != KErrNotFound) //expected error
sl@0
   738
		{
sl@0
   739
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   740
		INFO_PRINTF1(_L("remove uloggerfileplugin settings again - failed!"));
sl@0
   741
		err++;
sl@0
   742
		}
sl@0
   743
sl@0
   744
	//remove uloggerdummyplugin settings
sl@0
   745
	test = iUlogger.RemovePluginConfigurations(KFilePlugin);
sl@0
   746
	if(test != KErrNotFound) //expected error
sl@0
   747
		{
sl@0
   748
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   749
		INFO_PRINTF1(_L("remove uloggerdummyplugin settings - failed!"));
sl@0
   750
		err++;
sl@0
   751
		}
sl@0
   752
sl@0
   753
	//remove empty desc plugin settings
sl@0
   754
	test = iUlogger.RemovePluginConfigurations(_L8(""));
sl@0
   755
	if(test != KErrArgument) //expected error
sl@0
   756
		{
sl@0
   757
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   758
		INFO_PRINTF1(_L("remove empty desc plugin settings - failed!"));
sl@0
   759
		err++;
sl@0
   760
		}
sl@0
   761
	
sl@0
   762
	
sl@0
   763
	//summary
sl@0
   764
	TBuf<64> b;
sl@0
   765
	if(err)
sl@0
   766
		b.AppendFormat(_L("SetGetRemovePluginConf_TestL failed with %d errors!!!"), err);
sl@0
   767
	else
sl@0
   768
		b.Append(_L("SetGetRemovePluginConf_TestL passed"));
sl@0
   769
	INFO_PRINTF1(b);
sl@0
   770
	return err;
sl@0
   771
	}
sl@0
   772
sl@0
   773
TInt CTestRULoggerAPIStep::SetGetTraceBuffer_TestL()
sl@0
   774
	{
sl@0
   775
	TInt err = 0;
sl@0
   776
	TInt test = KErrNone;
sl@0
   777
	TInt val = 0;
sl@0
   778
	
sl@0
   779
	//test SetBufferSize(-1)
sl@0
   780
	test = iUlogger.SetBufferSize(-1);
sl@0
   781
	if(test != KErrArgument)
sl@0
   782
		{
sl@0
   783
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   784
		INFO_PRINTF1(_L("test SetBufferSize(-1) - failed!"));
sl@0
   785
		err++;
sl@0
   786
		}
sl@0
   787
	
sl@0
   788
	//test SetBufferSize(1025)
sl@0
   789
	test = iUlogger.SetBufferSize(1025);
sl@0
   790
	if(test != KErrArgument)
sl@0
   791
		{
sl@0
   792
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   793
		INFO_PRINTF1(_L("test SetBufferSize(1025) - failed!"));
sl@0
   794
		err++;
sl@0
   795
		}
sl@0
   796
	
sl@0
   797
	//test SetBufferSize(1000)
sl@0
   798
	test = iUlogger.SetBufferSize(1000);
sl@0
   799
	if(test != KErrNone)
sl@0
   800
		{
sl@0
   801
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   802
		INFO_PRINTF1(_L("test SetBufferSize(1000) - failed!"));
sl@0
   803
		err++;
sl@0
   804
		}
sl@0
   805
	
sl@0
   806
	test = iUlogger.GetBufferSize(val);
sl@0
   807
	if(test!=KErrNone || val != 1000)
sl@0
   808
		{
sl@0
   809
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   810
		INFO_PRINTF1(_L("test GetBufferSize(val) - failed!"));
sl@0
   811
		err++;
sl@0
   812
		}
sl@0
   813
	
sl@0
   814
	iUlogger.GetNotificationSize(val);
sl@0
   815
	test = iUlogger.SetBufferSize(val-1);
sl@0
   816
	if(test != KErrGeneral)
sl@0
   817
		{
sl@0
   818
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   819
		INFO_PRINTF1(_L("test SetBufferSize(val-1) (less than dns)  - failed!"));
sl@0
   820
		err++;
sl@0
   821
		}
sl@0
   822
	
sl@0
   823
	//summary
sl@0
   824
	TBuf<64> b;
sl@0
   825
	if(err)
sl@0
   826
		b.AppendFormat(_L("SetGetTraceBuffer_TestL failed with %d errors!!!"), err);
sl@0
   827
	else
sl@0
   828
		b.Append(_L("SetGetTraceBuffer_TestL passed"));
sl@0
   829
	INFO_PRINTF1(b);
sl@0
   830
	return err;
sl@0
   831
	}
sl@0
   832
sl@0
   833
TInt CTestRULoggerAPIStep::SetGetDnsBuffer_TestL()
sl@0
   834
	{
sl@0
   835
	TInt err = 0;
sl@0
   836
	TInt test = KErrNone;
sl@0
   837
	TInt val = 0;
sl@0
   838
	
sl@0
   839
	test = iUlogger.SetNotificationSize(-1);
sl@0
   840
	if(test != KErrArgument)
sl@0
   841
		{
sl@0
   842
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   843
		INFO_PRINTF1(_L("test SetNotificationSize(-1)  - failed!"));
sl@0
   844
		err++;
sl@0
   845
		}
sl@0
   846
	
sl@0
   847
	test = iUlogger.SetNotificationSize(1025);
sl@0
   848
	if(test != KErrArgument)
sl@0
   849
		{
sl@0
   850
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   851
		INFO_PRINTF1(_L("test SetNotificationSize(1025)  - failed!"));
sl@0
   852
		err++;
sl@0
   853
		}
sl@0
   854
	
sl@0
   855
	test = iUlogger.SetNotificationSize(32);
sl@0
   856
	if(test != KErrNone)
sl@0
   857
		{
sl@0
   858
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   859
		INFO_PRINTF1(_L("test SetNotificationSize(32)  - failed!"));
sl@0
   860
		err++;
sl@0
   861
		}
sl@0
   862
	
sl@0
   863
	iUlogger.GetBufferSize(val);
sl@0
   864
	test = iUlogger.SetNotificationSize(val+1);
sl@0
   865
	if(test != KErrNone)
sl@0
   866
		{
sl@0
   867
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   868
		INFO_PRINTF1(_L("test SetNotificationSize(val+1) (greater than buffer)  - failed!"));
sl@0
   869
		err++;
sl@0
   870
		}
sl@0
   871
	
sl@0
   872
	
sl@0
   873
	//summary
sl@0
   874
	TBuf<64> b;
sl@0
   875
	if(err)
sl@0
   876
		b.AppendFormat(_L("SetGetDnsBuffer_TestL failed with %d errors!!!"), err);
sl@0
   877
	else
sl@0
   878
		b.Append(_L("SetGetDnsBuffer_TestL passed"));
sl@0
   879
	INFO_PRINTF1(b);
sl@0
   880
	return err;
sl@0
   881
	}
sl@0
   882
sl@0
   883
TInt CTestRULoggerAPIStep::SetGetBufferMode_TestL()
sl@0
   884
	{
sl@0
   885
	TInt err = 0;
sl@0
   886
	TInt test = KErrNone;
sl@0
   887
	TInt val = 0;
sl@0
   888
	
sl@0
   889
	iUlogger.SetBufferMode(0);
sl@0
   890
	test = iUlogger.SetBufferMode(1);
sl@0
   891
	if(test != KErrNone)
sl@0
   892
		{
sl@0
   893
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   894
		INFO_PRINTF1(_L("test iUlogger.SetBufferMode(1) - failed!"));
sl@0
   895
		err++;
sl@0
   896
		}
sl@0
   897
sl@0
   898
	test = iUlogger.SetBufferMode(1);
sl@0
   899
	if(test != KErrNone)
sl@0
   900
		{
sl@0
   901
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   902
		INFO_PRINTF1(_L("test iUlogger.SetBufferMode(1) again - failed!"));
sl@0
   903
		err++;
sl@0
   904
		}
sl@0
   905
sl@0
   906
	test = iUlogger.SetBufferMode(3);
sl@0
   907
	if(test != KErrArgument)
sl@0
   908
		{
sl@0
   909
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   910
		INFO_PRINTF1(_L("test iUlogger.iUlogger.SetBufferMode(3) (wrong) - failed!"));
sl@0
   911
		err++;
sl@0
   912
		}
sl@0
   913
		
sl@0
   914
	test = iUlogger.GetBufferMode(val);
sl@0
   915
	if(test != KErrNone || val != 1)
sl@0
   916
		{
sl@0
   917
		INFO_PRINTF2(_L("err: %d"), test);
sl@0
   918
		INFO_PRINTF1(_L("test iUlogger.iUlogger.GetBufferMode(val) - failed!"));
sl@0
   919
		err++;
sl@0
   920
		}
sl@0
   921
	
sl@0
   922
	//summary
sl@0
   923
	TBuf<64> b;
sl@0
   924
	if(err)
sl@0
   925
		b.AppendFormat(_L("SetGetBufferMode_TestL failed with %d errors!!!"), err);
sl@0
   926
	else
sl@0
   927
		b.Append(_L("SetGetBufferMode_TestL passed"));
sl@0
   928
	INFO_PRINTF1(b);
sl@0
   929
	return err;
sl@0
   930
	}
sl@0
   931