traceservices/tracefw/integ_test/ost/TEF/te_ostv2integsuite_functional/src/te_filepluginerr.cpp
changeset 0 08ec8eefde2f
child 23 26645d81f48d
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 2007-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 /**
       
    20  @file te_tracecollectorserial.cpp
       
    21  @internalTechnology
       
    22 */
       
    23 
       
    24 #include "te_filepluginerr.h"
       
    25 #include "te_tracecollectorfile.h"
       
    26 #include "te_ostv2integsuite_defs.h"
       
    27 #include "te_dataparameters.h"
       
    28 using namespace Ulogger; //CA:added so can use old ulogger api
       
    29 
       
    30 ///negative testing
       
    31 CTCMFilePluginErrWrapper::~CTCMFilePluginErrWrapper()
       
    32 {
       
    33 }
       
    34 
       
    35 CTCMFilePluginErrWrapper::CTCMFilePluginErrWrapper()
       
    36 {
       
    37 }
       
    38 
       
    39 
       
    40 CTCMFilePluginErrWrapper* CTCMFilePluginErrWrapper::NewLC()
       
    41 	{
       
    42 	CTCMFilePluginErrWrapper* self = new (ELeave)CTCMFilePluginErrWrapper();
       
    43 	CleanupStack::PushL(self);
       
    44 	self->ConstructL();
       
    45 	return self;
       
    46 	}
       
    47 
       
    48 CTCMFilePluginErrWrapper* CTCMFilePluginErrWrapper::NewL()
       
    49 	{
       
    50 	CTCMFilePluginErrWrapper* self=CTCMFilePluginErrWrapper::NewLC();
       
    51 	CleanupStack::Pop(); // self;
       
    52 	return self;
       
    53 	}
       
    54 
       
    55 void CTCMFilePluginErrWrapper::ConstructL()
       
    56 	{
       
    57 	}
       
    58 
       
    59 TAny* CTCMFilePluginErrWrapper::GetObject()
       
    60 	{
       
    61 	return NULL;
       
    62 	}
       
    63 
       
    64 TBool CTCMFilePluginErrWrapper::DoCommandL(	const TTEFFunction& /*aCommand*/,
       
    65 					const TTEFSectionName& /*aSection*/, 
       
    66 					const TInt /*aAsyncErrorIndex*/)
       
    67 	{
       
    68 	  if (BlockResult()==EPass)
       
    69 		  {
       
    70 		  TInt result = 0;
       
    71 		  INFO_PRINTF1(_L("Testing..."));
       
    72 		  RULogger logger;
       
    73 		  result =logger.Connect();
       
    74 		  INFO_PRINTF2(_L("Connection to Ulogger: %d, attempt: 1"), result);
       
    75 		  if (result!=KErrNone)
       
    76 		      {
       
    77 		      INFO_PRINTF1(_L("Connection to Ulogger failed. Will try to connect max. 10 times"));
       
    78 		      for (TInt i=2; i<12;i++)
       
    79 		          {
       
    80                       User::After(1000);
       
    81                       result = logger.Connect();
       
    82                       INFO_PRINTF3(_L("Connection to Ulogger: %d, attempt: %d"), result, i);
       
    83                       if (result==KErrNone)
       
    84                           {
       
    85                           break;
       
    86                           }
       
    87 		          }
       
    88 		      }
       
    89 		  CClearConfig configIni;
       
    90 		  configIni.Clear(logger);
       
    91 		  _LIT8(KTextmedia,"te_fileplugin");
       
    92 		  const TPtrC8 mediaptr(KTextmedia);
       
    93 		  INFO_PRINTF1(_L("Setting test plugin as active..."));
       
    94 		  result = logger.ActivateOutputPlugin(mediaptr);//C.A. previously:result = logger.SetActiveOutputPlugin(mediaptr);
       
    95 		  if(result != KErrNone && result != KErrAlreadyExists)
       
    96 			  {
       
    97 			  INFO_PRINTF1(_L("ERROR: Setting test plugin as active error."));
       
    98 			  SetBlockResult(EFail);
       
    99 			  }
       
   100 		  
       
   101 		  if(result==0||result==-11)	
       
   102 		  	{	
       
   103 		  	INFO_PRINTF1(_L("Tesr File Plugin active"));
       
   104 		  	_LIT(KTextsetting, "ErrorCode");
       
   105 		  	_LIT(KTextvalue, "10");
       
   106 		  	// test setting the plugin settings
       
   107 		  	TPluginConfiguration pluginConfig;
       
   108 		  	pluginConfig.SetKey(KTextsetting);
       
   109 		  	pluginConfig.SetValue(KTextvalue);			
       
   110 		  	result=logger.SetPluginConfigurations(mediaptr,pluginConfig);
       
   111 		  	if(result!=KErrNone)	
       
   112 		  		{
       
   113 		  		INFO_PRINTF1(_L("ERROR: Setting test plugin configuration error."));
       
   114 		  		SetBlockResult(EFail);
       
   115 		  		}
       
   116 		  	_LIT(KTextsetting2, "output_path");
       
   117 		  	_LIT(KTextvalue2, "C:\\logs\\ULoggerFileLoggingTest.utf");
       
   118 		  	// test setting the plugin settings
       
   119 		  	TPluginConfiguration pluginConfig2;
       
   120 		  	pluginConfig2.SetKey(KTextsetting2);
       
   121 		  	pluginConfig2.SetValue(KTextvalue2);			
       
   122 		  	result=logger.SetPluginConfigurations(mediaptr,pluginConfig2);
       
   123 		  	if(result!=KErrNone)	
       
   124 		  		{
       
   125 		  		INFO_PRINTF1(_L("ERROR: Setting test plugin configuration (path) error."));
       
   126 		  		SetBlockResult(EFail);
       
   127 		  		}	  	
       
   128 		  	
       
   129 		  	INFO_PRINTF1(_L("setting filters..."));
       
   130 		  	CArrayFixFlat<TUint8> *a = new (ELeave) CArrayFixFlat<TUint8>(1);
       
   131 		  	a->AppendL(KGroupId);
       
   132 		  	result=logger.SetPrimaryFiltersEnabled(*a,ETrue);//C.A. previously:result=logger.EnableClassifications(*a);
       
   133 		  	//C.A. already done by default, but previously:result=logger.EnableClassificationFiltering();
       
   134 		  	//result=logger.DisableModuleUidFiltering(); ;//as only setting primary filters- we do not care about secondary
       
   135 		  	result=logger.SetNotificationSize(0);
       
   136 		  	result=logger.SetBufferSize(1020);
       
   137 		  	delete a;
       
   138 		  	
       
   139 		  	INFO_PRINTF1(_L("starting ulogger with primary filters only configured..."));
       
   140 		  	result = logger.Stop();//C.A. previously:result = logger.StopOutputting();
       
   141 		  	result = logger.Start();//C.A. previously:result = logger.StartOutputting();
       
   142 		  	if(result != KErrNone)
       
   143 		  		{
       
   144 		  		INFO_PRINTF2(_L("ERROR: Starting Ulogger error: %d"), result);
       
   145 		  		SetBlockResult(EFail);
       
   146 		  		}
       
   147 		  	User::After(1*1000*1000);
       
   148 		  	
       
   149 		  	INFO_PRINTF1(_L("stopping ulogger..."));
       
   150 		  	result = logger.Stop();//C.A. previously:result = logger.StopOutputting();
       
   151 
       
   152 		  	if(result != KErrNone)
       
   153 		  		{
       
   154 		  		INFO_PRINTF2(_L("ERROR: Stopping error %d (server probably panicked)"), result);
       
   155 		  		SetBlockResult(EFail);
       
   156 		  		}
       
   157 		  }
       
   158 		  else
       
   159 			  {
       
   160 			  INFO_PRINTF1(_L("ERROR: Test plugin not found."));
       
   161 		  	  SetBlockResult(EFail);
       
   162 			  }
       
   163 		  }
       
   164 	return ETrue;
       
   165 	}
       
   166 
       
   167