os/persistentdata/traceservices/tracefw/ulogger/unit_test/te-server/uloggerservertest3step.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
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
//
sl@0
    15
sl@0
    16
/**
sl@0
    17
 @file UloggerServerTest3Step.cpp
sl@0
    18
 @internalTechnology
sl@0
    19
*/
sl@0
    20
sl@0
    21
sl@0
    22
#include "uloggerservertest3step.h"
sl@0
    23
#include "te_uloggerservertestsuitedefs.h"
sl@0
    24
#include "uloggerwatcher.h"
sl@0
    25
#include "pluginallocator.h"
sl@0
    26
sl@0
    27
sl@0
    28
CUloggerServerTest3Step::~CUloggerServerTest3Step()
sl@0
    29
/**
sl@0
    30
 * Destructor
sl@0
    31
 */
sl@0
    32
	{
sl@0
    33
	}
sl@0
    34
sl@0
    35
CUloggerServerTest3Step::CUloggerServerTest3Step()
sl@0
    36
/**
sl@0
    37
 * Constructor
sl@0
    38
 */
sl@0
    39
	{
sl@0
    40
	SetTestStepName(KUloggerServerTest3Step);
sl@0
    41
	}
sl@0
    42
sl@0
    43
TVerdict CUloggerServerTest3Step::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("****This is unit test for CPluginAllocator class****"));	
sl@0
    50
	
sl@0
    51
	
sl@0
    52
	iScheduler = new (ELeave) CActiveScheduler();
sl@0
    53
	CActiveScheduler::Install(iScheduler);
sl@0
    54
	
sl@0
    55
	SetTestStepResult(EPass);
sl@0
    56
	return TestStepResult();
sl@0
    57
	}
sl@0
    58
sl@0
    59
sl@0
    60
TVerdict CUloggerServerTest3Step::doTestStepL()
sl@0
    61
/**
sl@0
    62
 * @return - TVerdict code
sl@0
    63
 * Override of base class pure virtual
sl@0
    64
 * Our implementation only gets called if the base class doTestStepPreambleL() did
sl@0
    65
 * not leave. That being the case, the current test result value will be EPass.
sl@0
    66
 */
sl@0
    67
	{
sl@0
    68
	  iErrors = 0;
sl@0
    69
	  if (TestStepResult()==EPass)
sl@0
    70
	  {
sl@0
    71
	  
sl@0
    72
		iErrors += this->Test1L();//CPluginAllocator::NewL, GetOutputPlugin, GetControlPlugin
sl@0
    73
		iErrors += this->Test1_2L();//CPluginAllocator::NewL.... - condition 2
sl@0
    74
		iErrors += this->Test2L();//CPluginAllocator::NewLC
sl@0
    75
		iErrors += this->Test1_3L(); //CPluginAllocator::NewL - condition 3
sl@0
    76
		iErrors += this->Test1_4L(); //CPluginAllocator::NewL - condition 4
sl@0
    77
sl@0
    78
		//display results
sl@0
    79
		TBuf<128> res;
sl@0
    80
		res.AppendFormat(_L("%d errors"), iErrors);
sl@0
    81
		INFO_PRINTF1(_L("****Results****"));
sl@0
    82
		INFO_PRINTF1(res);
sl@0
    83
		if(iErrors == 0)  
sl@0
    84
			SetTestStepResult(EPass);
sl@0
    85
			else
sl@0
    86
				SetTestStepResult(EFail);
sl@0
    87
	  }
sl@0
    88
	  
sl@0
    89
	  return TestStepResult();
sl@0
    90
	}
sl@0
    91
sl@0
    92
sl@0
    93
sl@0
    94
TVerdict CUloggerServerTest3Step::doTestStepPostambleL()
sl@0
    95
/**
sl@0
    96
 * @return - TVerdict code
sl@0
    97
 * Override of base class virtual
sl@0
    98
 */
sl@0
    99
	{
sl@0
   100
	delete iScheduler;
sl@0
   101
	iScheduler = NULL;
sl@0
   102
	return TestStepResult();
sl@0
   103
	}
sl@0
   104
sl@0
   105
sl@0
   106
TInt CUloggerServerTest3Step::Test1L()
sl@0
   107
	{
sl@0
   108
	TInt errors = 0;
sl@0
   109
	
sl@0
   110
	INFO_PRINTF1(_L("Testing - CPluginAllocator::NewL method - condition 1"));
sl@0
   111
	CPluginAllocator *obj = CPluginAllocator::NewL(KFileTestPlugin(), KNullTestPlugin());
sl@0
   112
	if(obj == NULL)
sl@0
   113
	  {
sl@0
   114
	  INFO_PRINTF1(_L("error"));
sl@0
   115
	  errors++;
sl@0
   116
	  }
sl@0
   117
	  else
sl@0
   118
		{
sl@0
   119
		MOutputPlugin* output = obj->GetOutputPlugin(); //should exists
sl@0
   120
		MInputPlugin* input = obj->GetInputPlugin(); //should not exists
sl@0
   121
		if(!output || input)
sl@0
   122
			errors++;
sl@0
   123
		
sl@0
   124
		//cleanup
sl@0
   125
		delete obj;
sl@0
   126
		obj = NULL;
sl@0
   127
		}
sl@0
   128
		
sl@0
   129
	return errors;
sl@0
   130
	}
sl@0
   131
sl@0
   132
TInt CUloggerServerTest3Step::Test1_2L()
sl@0
   133
	{
sl@0
   134
	TInt errors = 0;
sl@0
   135
	
sl@0
   136
	INFO_PRINTF1(_L("Testing - CPluginAllocator::NewL method - condition 2"));
sl@0
   137
	CPluginAllocator *obj = NULL;
sl@0
   138
	obj = CPluginAllocator::NewL(KNullTestPlugin(), KNullTestPlugin());
sl@0
   139
	if(obj)
sl@0
   140
		{
sl@0
   141
		delete obj;
sl@0
   142
		obj = NULL;
sl@0
   143
		}
sl@0
   144
	else
sl@0
   145
		{
sl@0
   146
		errors++;
sl@0
   147
		INFO_PRINTF1(_L("error - obj not exists!"));
sl@0
   148
		}
sl@0
   149
		
sl@0
   150
	return errors;
sl@0
   151
	}
sl@0
   152
sl@0
   153
sl@0
   154
TInt CUloggerServerTest3Step::Test1_3L()
sl@0
   155
	{
sl@0
   156
	TInt errors = 0;
sl@0
   157
	
sl@0
   158
	INFO_PRINTF1(_L("Testing - CPluginAllocator::NewL method - condition 3"));
sl@0
   159
	CPluginAllocator *obj = NULL;
sl@0
   160
	TRAPD(err, obj = CPluginAllocator::NewL(KFileTestPlugin(), KUsbTestPlugin()));
sl@0
   161
	if(obj && err==KErrNone)
sl@0
   162
		{
sl@0
   163
		MOutputPlugin* output = obj->GetOutputPlugin(); //should exists
sl@0
   164
		MInputPlugin* input = obj->GetInputPlugin(); //does not matter
sl@0
   165
		if(!output)
sl@0
   166
			errors++;
sl@0
   167
		
sl@0
   168
		delete obj;
sl@0
   169
		obj = NULL;
sl@0
   170
		}
sl@0
   171
	else
sl@0
   172
		{
sl@0
   173
		INFO_PRINTF1(_L("plugin allocator not create. probably there is no usb plugin."));
sl@0
   174
		}
sl@0
   175
		
sl@0
   176
	return errors;
sl@0
   177
	}
sl@0
   178
sl@0
   179
sl@0
   180
TInt CUloggerServerTest3Step::Test1_4L()
sl@0
   181
	{
sl@0
   182
	TInt errors = 0;
sl@0
   183
	
sl@0
   184
	INFO_PRINTF1(_L("Testing - CPluginAllocator::NewL method - condition 4"));
sl@0
   185
	CPluginAllocator *obj = NULL;
sl@0
   186
	//should leave
sl@0
   187
	TRAPD(errCode, obj=CPluginAllocator::NewL(KFileTestPlugin(), KBadNameTestPlugin()));
sl@0
   188
	if(errCode == KErrNone)
sl@0
   189
		{
sl@0
   190
		errors++;
sl@0
   191
		INFO_PRINTF1(_L("error - method should leave!"));		
sl@0
   192
		}
sl@0
   193
	if(obj)
sl@0
   194
		{
sl@0
   195
		errors++;
sl@0
   196
		INFO_PRINTF1(_L("error - obj should not exist!"));		
sl@0
   197
		delete obj;
sl@0
   198
		obj = NULL;
sl@0
   199
		}
sl@0
   200
		
sl@0
   201
	return errors;
sl@0
   202
	}
sl@0
   203
sl@0
   204
sl@0
   205
TInt CUloggerServerTest3Step::Test2L()
sl@0
   206
	{
sl@0
   207
	TInt errors = 0;
sl@0
   208
	
sl@0
   209
	INFO_PRINTF1(_L("Testing - CPluginAllocator::NewLC method"));
sl@0
   210
	CPluginAllocator *obj = CPluginAllocator::NewLC(KFileTestPlugin(), KNullTestPlugin());
sl@0
   211
	if(obj == NULL)
sl@0
   212
	  {
sl@0
   213
	  INFO_PRINTF1(_L("error"));
sl@0
   214
	  errors++;
sl@0
   215
	  }
sl@0
   216
	  else
sl@0
   217
		{
sl@0
   218
		MOutputPlugin* output = obj->GetOutputPlugin(); //should exists
sl@0
   219
		MInputPlugin* input = obj->GetInputPlugin(); //should not exists
sl@0
   220
		if(!output || input)
sl@0
   221
			{
sl@0
   222
			INFO_PRINTF1(_L("error"));
sl@0
   223
			errors++;
sl@0
   224
			}
sl@0
   225
		
sl@0
   226
		//cleanup
sl@0
   227
		CleanupStack::PopAndDestroy(); //obj
sl@0
   228
		}
sl@0
   229
		
sl@0
   230
	return errors;
sl@0
   231
	}