os/persistentdata/traceservices/tracefw/ulogger/unit_test/te-server/uloggerservertest2step.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) 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 UloggerServerTest2Step.cpp
sl@0
    20
 @internalTechnology
sl@0
    21
*/
sl@0
    22
#include "uloggerservertest2step.h"
sl@0
    23
#include "te_uloggerservertestsuitedefs.h"
sl@0
    24
#include "uloggerserver.h"
sl@0
    25
#include "uloggersession.h"
sl@0
    26
sl@0
    27
using namespace Ulogger;
sl@0
    28
sl@0
    29
CUloggerServerTest2Step::~CUloggerServerTest2Step()
sl@0
    30
/**
sl@0
    31
 * Destructor
sl@0
    32
 */
sl@0
    33
	{
sl@0
    34
	}
sl@0
    35
sl@0
    36
CUloggerServerTest2Step::CUloggerServerTest2Step()
sl@0
    37
/**
sl@0
    38
 * Constructor
sl@0
    39
 */
sl@0
    40
	{
sl@0
    41
	// **MUST** call SetTestStepName in the constructor as the controlling
sl@0
    42
	// framework uses the test step name immediately following construction to set
sl@0
    43
	// up the step's unique logging ID.
sl@0
    44
	SetTestStepName(KUloggerServerTest2Step);
sl@0
    45
	}
sl@0
    46
sl@0
    47
TVerdict CUloggerServerTest2Step::doTestStepPreambleL()
sl@0
    48
/**
sl@0
    49
 * @return - TVerdict code
sl@0
    50
 * Override of base class virtual
sl@0
    51
 */
sl@0
    52
	{
sl@0
    53
	iScheduler = new (ELeave) CActiveScheduler();
sl@0
    54
	CActiveScheduler::Install(iScheduler);
sl@0
    55
	
sl@0
    56
	SetTestStepResult(EPass);
sl@0
    57
	return TestStepResult();
sl@0
    58
	}
sl@0
    59
sl@0
    60
sl@0
    61
TVerdict CUloggerServerTest2Step::doTestStepL()
sl@0
    62
	{
sl@0
    63
	  if (TestStepResult()==EPass)
sl@0
    64
		{
sl@0
    65
		TInt errors = 0;
sl@0
    66
		
sl@0
    67
		errors += Test1L();//CULoggerSession::NewL
sl@0
    68
		errors += Test2L();//CULoggerSession::NewLC
sl@0
    69
		
sl@0
    70
		
sl@0
    71
		
sl@0
    72
			/*
sl@0
    73
			 * Method CULoggerSession::ServiceL cannot be tested here because it require
sl@0
    74
			 * of passing RMessage2 reference with valid RMessagePtr (IPC)
sl@0
    75
			 * If we are going to pass empty RMessage2 system will panic our process with
sl@0
    76
			 * User Panic 70.
sl@0
    77
			 * */
sl@0
    78
			
sl@0
    79
		//display results
sl@0
    80
		TBuf<128> res;
sl@0
    81
		res.AppendFormat(_L("%d errors"), errors);
sl@0
    82
		INFO_PRINTF1(_L("****Results****"));
sl@0
    83
		INFO_PRINTF1(res);
sl@0
    84
		if(errors == 0)  
sl@0
    85
			SetTestStepResult(EPass);
sl@0
    86
			else
sl@0
    87
				SetTestStepResult(EFail);
sl@0
    88
		}
sl@0
    89
	  return TestStepResult();
sl@0
    90
	}
sl@0
    91
sl@0
    92
sl@0
    93
sl@0
    94
TVerdict CUloggerServerTest2Step::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
TInt CUloggerServerTest2Step::Test1L()
sl@0
   106
{//CULoggerSession::NewL
sl@0
   107
	TInt errors = 0;
sl@0
   108
  	INFO_PRINTF1(_L("Testing - CULoggerSession::NewL method"));
sl@0
   109
  	CULoggerServer *server = NULL;
sl@0
   110
  	server = CULoggerServer::NewLC(EPriorityBackground);
sl@0
   111
  	if(server != NULL)
sl@0
   112
  		{
sl@0
   113
  		RThread thread;
sl@0
   114
  		CULoggerSession *serverSession = CULoggerSession::NewL(thread, *server);
sl@0
   115
  		if(serverSession != NULL)
sl@0
   116
  			{
sl@0
   117
  			//delete serverSession; //don't need to delete session
sl@0
   118
  			}
sl@0
   119
  			else
sl@0
   120
  				{
sl@0
   121
  				INFO_PRINTF1(_L("error"));
sl@0
   122
  				++errors;
sl@0
   123
  				}
sl@0
   124
  			
sl@0
   125
  		CleanupStack::PopAndDestroy();
sl@0
   126
  		}
sl@0
   127
  		else
sl@0
   128
  		{
sl@0
   129
  		INFO_PRINTF1(_L("server creation error"));
sl@0
   130
  		++errors;
sl@0
   131
  		}
sl@0
   132
  	return errors;
sl@0
   133
}
sl@0
   134
sl@0
   135
TInt CUloggerServerTest2Step::Test2L()
sl@0
   136
{//CULoggerSession::NewLC
sl@0
   137
	TInt errors = 0;
sl@0
   138
  	INFO_PRINTF1(_L("Testing - CULoggerSession::NewLC method"));
sl@0
   139
  	CULoggerServer *server = NULL;
sl@0
   140
  	server = CULoggerServer::NewLC(EPriorityBackground);
sl@0
   141
  	if(server != NULL)
sl@0
   142
  		{
sl@0
   143
  		RThread thread;
sl@0
   144
  		CULoggerSession *serverSession = CULoggerSession::NewLC(thread, *server);
sl@0
   145
  		if(serverSession != NULL)
sl@0
   146
  			{
sl@0
   147
  			CleanupStack::Pop();//serverSession
sl@0
   148
  			}
sl@0
   149
  			else
sl@0
   150
  				{
sl@0
   151
  				INFO_PRINTF1(_L("error"));
sl@0
   152
  				++errors;
sl@0
   153
  				}
sl@0
   154
  			
sl@0
   155
  		CleanupStack::PopAndDestroy();
sl@0
   156
  		}
sl@0
   157
  		else
sl@0
   158
  		{
sl@0
   159
  		INFO_PRINTF1(_L("server creation error"));
sl@0
   160
  		++errors;
sl@0
   161
  		}
sl@0
   162
  	return errors;
sl@0
   163
}