traceservices/tracefw/integ_test/ulogger/TEF/te_ulogger/src/te_uloggerserialpluginstep.cpp
changeset 0 08ec8eefde2f
child 23 26645d81f48d
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Example CTestStep derived implementation
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file te_uloggerserialpluginstep.cpp
       
    20  @internalTechnology
       
    21 */
       
    22 #include "te_uloggerserialpluginstep.h"
       
    23 #include "te_uloggermclsuitedefs.h"
       
    24 
       
    25 using namespace Ulogger;
       
    26 
       
    27 CULoggerSerialPluginStep::~CULoggerSerialPluginStep()
       
    28 /**
       
    29  * Destructor
       
    30  */
       
    31 	{
       
    32 	}
       
    33 
       
    34 CULoggerSerialPluginStep::CULoggerSerialPluginStep()
       
    35 /**
       
    36  * Constructor
       
    37  */
       
    38 	{
       
    39 		SetTestStepName(KULoggerSerialPluginStep);
       
    40 	}
       
    41 
       
    42 TVerdict CULoggerSerialPluginStep::doTestStepPreambleL()
       
    43 /**
       
    44  * @return - TVerdict code
       
    45  * Override of base class virtual
       
    46  */
       
    47 	{
       
    48 		INFO_PRINTF1(_L("Please delete this line or modify it. I am in Test Step Preamble in Class CULoggerSerialPluginStep"));
       
    49 		SetTestStepResult(EPass);
       
    50 		return TestStepResult();
       
    51 	}
       
    52 
       
    53 
       
    54 TVerdict CULoggerSerialPluginStep::doTestStepL()
       
    55 /**
       
    56  * @return - TVerdict code
       
    57  * Override of base class pure virtual
       
    58  * Our implementation only gets called if the base class doTestStepPreambleL() did
       
    59  * not leave. That being the case, the current test result value will be EPass.
       
    60  */
       
    61 	{
       
    62 	    if (TestStepResult()==EPass)
       
    63 		{		
       
    64 		//  ************** Delete the Block, the block start ****************
       
    65 		
       
    66 			TInt Result=0;
       
    67 			SetTestStepResult(EPass);
       
    68 			INFO_PRINTF1(_L("About to test serial plugin"));  //Block start
       
    69 			RULogger logger;
       
    70 			logger.Connect();
       
    71 			CClearConfig configIni;
       
    72 			configIni.Clear(logger);
       
    73 			CArrayFixFlat<TUint8> *setprimfilter = new (ELeave)CArrayFixFlat<TUint8>(1);
       
    74 			setprimfilter->AppendL(UTracePrimary);
       
    75 			RArray<TUint32> setsecondfilter;
       
    76 			setsecondfilter.Append((TUint32) UTraceSecondary);
       
    77 			logger.SetPrimaryFiltersEnabled(*setprimfilter,ETrue);
       
    78 			logger.SetSecondaryFiltersEnabled(setsecondfilter,ETrue);
       
    79 			_LIT8(KTextmedia,"uloggerserialplugin");
       
    80 			const TPtrC8 mediaptr(KTextmedia);
       
    81 			// test the plugin can be activated
       
    82 			Result=logger.ActivateOutputPlugin(mediaptr);	
       
    83 			if(Result==0||Result==-11)	
       
    84 			{	
       
    85 				INFO_PRINTF1(_L("Serial Plugin active"));		
       
    86 				_LIT(KTextsetting, "output_port");	
       
    87 				_LIT(KTextvalue, "3");
       
    88 				// test setting the plugin settings
       
    89 				TPluginConfiguration pluginConfig;
       
    90 				pluginConfig.SetKey(KTextsetting);
       
    91 				pluginConfig.SetValue(KTextvalue);			
       
    92 				Result=logger.SetPluginConfigurations(mediaptr,pluginConfig);
       
    93 				if(Result==0)	
       
    94 				{
       
    95 					INFO_PRINTF1(_L("Serial Plugin Settings set correctly"));
       
    96 				// test that the plugging settings can be retrieved
       
    97 				RPointerArray<TPluginConfiguration> getPluginConfigs;
       
    98 				if(Result==0)	
       
    99 				{
       
   100 					INFO_PRINTF1(_L("Serial Plugin Settings got correctly"));
       
   101 					Result=logger.GetPluginConfigurations(mediaptr, getPluginConfigs);
       
   102 					_LIT(KTextChecksetting, "output_port");
       
   103 					_LIT(KTextCheckValue, "3");
       
   104 					// test that the plugging settings retrieved are correct
       
   105 					if (!getPluginConfigs[0]->Key().Compare(KTextChecksetting) && !getPluginConfigs[0]->Value().Compare(KTextCheckValue))
       
   106 					{
       
   107 						INFO_PRINTF1(_L("Retrieved serial plugin settings are correct"));
       
   108 					}
       
   109 					else
       
   110 					{		
       
   111 						INFO_PRINTF1(_L("Retrieved serial plugin settings are incorrect"));
       
   112 						SetTestStepResult(EFail);
       
   113 					}
       
   114 					Result=logger.Start();
       
   115 					INFO_PRINTF2(_L("ulogger start returns error %d"), Result);
       
   116 #ifndef __WINSCW__				
       
   117 					CUTraces Testtracer;
       
   118 					for(TInt i=0; i!=256; i++)
       
   119 					{
       
   120 						if(!Testtracer.DoTheTrace(8))
       
   121 						{
       
   122 							INFO_PRINTF1(_L("UTrace primary filter writing via serial plugin failed"));
       
   123 							SetTestStepResult(EFail);
       
   124 						}
       
   125 						if(!Testtracer.DoTheTrace(3))
       
   126 						{
       
   127 							INFO_PRINTF1(_L("UTrace general data filter writing via serial plugin failed"));
       
   128 							SetTestStepResult(EFail);
       
   129 						}
       
   130 					}
       
   131 #endif					
       
   132 					logger.Stop();	
       
   133 				}
       
   134 				else
       
   135 				{
       
   136 					INFO_PRINTF1(_L("Failed to get serial Plugin Settings"));
       
   137 					SetTestStepResult(EFail);
       
   138 				}
       
   139 				getPluginConfigs.ResetAndDestroy();
       
   140 			}
       
   141 			else
       
   142 			{
       
   143 				INFO_PRINTF1(_L("Serial Plugin Settings error"));
       
   144 				SetTestStepResult(EFail);
       
   145 			}					
       
   146 		}
       
   147 		else
       
   148 		{			
       
   149 			INFO_PRINTF1(_L("Serial Plugin error when activated"));
       
   150 			SetTestStepResult(EFail);
       
   151 		}		
       
   152 		TBuf8<32>activeplugins;	
       
   153 		_LIT8(KTextmedia1,"uloggerserialplugin");
       
   154 		TBuf8<32> checkplugins(KTextmedia1);
       
   155 		// test the active plugin name can be retrieved
       
   156 		logger.GetActiveOutputPlugin(activeplugins);
       
   157 		if (activeplugins.Compare(checkplugins)==0)
       
   158 			INFO_PRINTF1(_L("Got correct active serial plugin"));
       
   159 		else
       
   160 		{
       
   161 			INFO_PRINTF1(_L("Got incorrect active serial plugin"));
       
   162 			SetTestStepResult(EFail);
       
   163 		}
       
   164 		// test activating the second plugin
       
   165 		_LIT8(KTextmedia2,"te_fileplugin");
       
   166 		const TPtrC8 mediaptr2(KTextmedia2);
       
   167 		Result=logger.ActivateOutputPlugin(mediaptr2);	
       
   168 		if(Result==0)			
       
   169 			INFO_PRINTF1(_L("Second plugin activated correctly"));
       
   170 		else
       
   171 		{
       
   172 			INFO_PRINTF1(_L("Second plugin activation error"));
       
   173 			SetTestStepResult(EFail);
       
   174 		}
       
   175 		// test the first plugin can now be removed as it is no longer the active plugin
       
   176 		Result=logger.RemovePluginConfigurations(mediaptr);
       
   177 		if(Result==0)
       
   178 		{	
       
   179 			INFO_PRINTF1(_L("Removed serial Plugin correctly"));
       
   180 		}
       
   181 		else
       
   182 		{
       
   183 			INFO_PRINTF1(_L("Failed to remove serial Plugin"));
       
   184 			SetTestStepResult(EFail);
       
   185 		}
       
   186 		logger.Stop();
       
   187 		logger.Close();
       
   188 		INFO_PRINTF1(_L("serial plugin tests complete!"));
       
   189 		
       
   190 		//  **************   Block end ****************
       
   191 		}
       
   192 		
       
   193 	  	return TestStepResult();
       
   194 	}
       
   195 
       
   196 
       
   197 
       
   198 TVerdict CULoggerSerialPluginStep::doTestStepPostambleL()
       
   199 /**
       
   200  * @return - TVerdict code
       
   201  * Override of base class virtual
       
   202  */
       
   203 	{
       
   204 		INFO_PRINTF1(_L("Please delete this line or modify it. I am in Test Step Postamble in Class CULoggerSerialPluginStep"));
       
   205 		return TestStepResult();
       
   206 	}