os/persistentdata/traceservices/commsdebugutility/TE_commsdebugutility/src/step_010_xx.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/traceservices/commsdebugutility/TE_commsdebugutility/src/step_010_xx.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,850 @@
1.4 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// This contains Flogger Unit Test Case 010.xx
1.18 +
1.19 +// EPOC includes
1.20 +#include <e32base.h>
1.21 +
1.22 +// Test system includes
1.23 +#include <comms-infras/commsdebugutility.h>
1.24 +#include "TestMessage.h"
1.25 +#include <f32file.h>
1.26 +
1.27 +
1.28 +//User includes
1.29 +#include "teststepcomsdbg.h"
1.30 +#include "step_010_xx.h"
1.31 +
1.32 +
1.33 +
1.34 +
1.35 +CFloggerTest010_01::CFloggerTest010_01()
1.36 + {
1.37 + // store the name of this test case
1.38 + SetTestStepName(_L("step_010_01"));
1.39 + }
1.40 +
1.41 +
1.42 +
1.43 +
1.44 +CFloggerTest010_01::~CFloggerTest010_01()
1.45 + {
1.46 + }
1.47 +
1.48 +
1.49 +
1.50 +
1.51 +TVerdict CFloggerTest010_01::doTestStepL( )
1.52 + {
1.53 + INFO_PRINTF1(_L("Step 010.01 called "));
1.54 +
1.55 + if ( executeStepL(EFalse) == KErrNone )
1.56 + SetTestStepResult(EPass);
1.57 +
1.58 + else
1.59 + SetTestStepResult(EFail);
1.60 +
1.61 +
1.62 + User::After(KTimeForDisplay);
1.63 + return TestStepResult();
1.64 + }
1.65 +
1.66 +
1.67 +
1.68 +TInt CFloggerTest010_01::executeStepL(TBool heapTest)
1.69 + {
1.70 + User::After(100*1000); //Need this or connect could return KErrServerTerminated
1.71 + TInt ret = KErrGeneral;
1.72 +
1.73 + ret = DoTestConnect();
1.74 + if (ret == KErrNone)
1.75 + {
1.76 + ret = DoTestWrite();
1.77 + if (ret == KErrNone)
1.78 + {
1.79 + TRAPD(r, ret = DoTestCheckWriteL());
1.80 + if ((heapTest) && ((ret == KErrNotFound) || (r != KErrNone)))
1.81 + {
1.82 + ret = KErrNoMemory;
1.83 + }
1.84 + else if (r != KErrNone)
1.85 + {
1.86 + ret = r;
1.87 + }
1.88 + }
1.89 + }
1.90 + iFlogger.Close();
1.91 + return ret;
1.92 + }
1.93 +
1.94 +TInt CFloggerTest010_01::executeStepL()
1.95 + {
1.96 + return KErrGeneral;
1.97 + }
1.98 +
1.99 +
1.100 +TInt CFloggerTest010_01::DoTestWrite()
1.101 + {
1.102 + _LIT8(KDescTxt,"TC 10_1:Test Msg----"); //8 bit test descriptor
1.103 +
1.104 + iFlogger.HexDump(KDescTxt,KHexTestHeader);
1.105 +
1.106 + ForceLogFlush(iFlogger);
1.107 +
1.108 + iFlogger.__DbgShutDownServer();
1.109 + iFlogger.Close();
1.110 + return KErrNone;
1.111 + }
1.112 +
1.113 +
1.114 +
1.115 +
1.116 +TInt CFloggerTest010_01::DoTestCheckWriteL()
1.117 + {
1.118 + User::After(KTimeToLog);
1.119 +
1.120 + RFile theFile;
1.121 + HBufC8 * hBuffer;
1.122 + TInt listfilesize;
1.123 + TInt returnCode;
1.124 + RFs fileSystem; //For file operation create a file system
1.125 + TBuf8<256> testData; //To hold the test descriptor
1.126 + _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
1.127 +
1.128 + _LIT(KHeaderTxt,"Test Header");// Test header
1.129 + _LIT8(KBodyTxt1,"TC 10_1:Test Msg"); // first 16 chars
1.130 +
1.131 + _LIT8(KOOMError, "#Logs may be lost out of memory!!"); //Error message
1.132 +
1.133 + User::LeaveIfError(fileSystem.Connect());
1.134 +
1.135 + //Open the file in the read mode
1.136 + User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
1.137 + CleanupClosePushL(theFile);
1.138 +
1.139 + User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
1.140 + hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
1.141 + CleanupStack::PushL(hBuffer);
1.142 + TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
1.143 +
1.144 + // Read from position 0: start of file
1.145 + returnCode = theFile.Read(ptrString);
1.146 +
1.147 + testData.Copy(KHeaderTxt); //Copy the test header descriptor
1.148 + returnCode = ptrString.Find(testData); //find the test header descriptor in the buffer read
1.149 + //from the file
1.150 + if (returnCode > 0)
1.151 + {
1.152 + testData.Copy(KHexTestMargin); //Copy the test margin descriptor
1.153 + returnCode = ptrString.Find(testData); //find the test margin descriptor in the buffer read
1.154 + //from the file
1.155 + }
1.156 +
1.157 + if (returnCode > 0)
1.158 + {
1.159 + testData.Copy(KBodyTxt1); //Copy the test descriptor
1.160 + returnCode=ptrString.Find(testData); //find the test descriptor in the buffer read
1.161 + //from the file
1.162 + }
1.163 +
1.164 + if (returnCode == KErrNotFound) //Find the error message
1.165 + {
1.166 + returnCode = ptrString.Find(KOOMError);
1.167 + if (returnCode > 0)
1.168 + User::Leave(KErrNoMemory);
1.169 + }
1.170 +
1.171 + CleanupStack::PopAndDestroy(hBuffer);
1.172 + CleanupStack::PopAndDestroy(); //theFile object
1.173 + if (returnCode > 0)
1.174 + return KErrNone;
1.175 + else
1.176 + return KErrNotFound;
1.177 + }
1.178 +
1.179 +
1.180 +
1.181 +
1.182 +TInt CFloggerTest010_01::DoTestConnect()
1.183 + {
1.184 +
1.185 + TInt ret;
1.186 + TPtrC8 ptrSubSystem;
1.187 + TPtrC8 ptrComponent;
1.188 + ptrSubSystem.Set(_L8("SubSystem"));
1.189 + ptrComponent.Set(_L8("Component"));
1.190 +
1.191 + ret = iFlogger.Connect(); //Call connect() of Flogger
1.192 +
1.193 + if (ret == KErrNone)
1.194 + ret = iFlogger.SetLogTags(ptrSubSystem, ptrComponent); //SetLogTags() of Flogger called
1.195 +
1.196 + if (ret == KErrNone)
1.197 + ret = iFlogger.ClearLog(); //clear the contents from the log
1.198 +
1.199 + return ret;
1.200 + }
1.201 +
1.202 +
1.203 +
1.204 +
1.205 +
1.206 +
1.207 +
1.208 +
1.209 +
1.210 +CFloggerTest010_02::CFloggerTest010_02()
1.211 + {
1.212 + // store the name of this test case
1.213 + SetTestStepName(_L("step_010_02"));
1.214 + }
1.215 +
1.216 +
1.217 +
1.218 +
1.219 +CFloggerTest010_02::~CFloggerTest010_02()
1.220 + {
1.221 + }
1.222 +
1.223 +
1.224 +
1.225 +TVerdict CFloggerTest010_02::doTestStepL( )
1.226 + {
1.227 + INFO_PRINTF1(_L("Step 010.02 called "));
1.228 +
1.229 + if ( executeStepL() == KErrNone )
1.230 + SetTestStepResult(EPass);
1.231 +
1.232 + else
1.233 + SetTestStepResult(EFail);
1.234 +
1.235 +
1.236 + User::After(KTimeForDisplay);
1.237 + return TestStepResult();
1.238 + }
1.239 +
1.240 +
1.241 +
1.242 +TInt CFloggerTest010_02::executeStepL( )
1.243 + {
1.244 + TInt ret = KErrGeneral;
1.245 + ret = DoTestConnect();
1.246 +
1.247 + if (ret == KErrNone)
1.248 + {
1.249 + ret = DoTestWrite();
1.250 + if (ret == KErrNone)
1.251 + {
1.252 + TRAPD(r, ret = DoTestCheckWriteL());
1.253 +
1.254 + if (r != KErrNone)
1.255 + ret = r;
1.256 +
1.257 + }
1.258 +
1.259 + }
1.260 + iFlogger.Close();
1.261 + return ret;
1.262 + }
1.263 +
1.264 +TInt CFloggerTest010_02::executeStepL(TBool)
1.265 + {
1.266 + return KErrGeneral;
1.267 + }
1.268 +
1.269 +
1.270 +TInt CFloggerTest010_02::DoTestWrite()
1.271 + {
1.272 + _LIT8(KDescText,"TC 10_2:Test Msg");
1.273 +
1.274 + iFlogger.HexDump(KDescText, KEightSpaces8);
1.275 + ForceLogFlush(iFlogger);
1.276 +
1.277 + iFlogger.__DbgShutDownServer();
1.278 + iFlogger.Close();
1.279 + return KErrNone;
1.280 + }
1.281 +
1.282 +
1.283 +
1.284 +
1.285 +TInt CFloggerTest010_02::DoTestCheckWriteL()
1.286 + {
1.287 + User::After(KTimeToLog);
1.288 + RFile theFile;
1.289 + HBufC8 * hBuffer;
1.290 + TInt listfilesize;
1.291 + TInt returnCode;
1.292 + RFs fileSystem; //For file operation create a file system
1.293 + TBuf8<256> testData; //To hold the test descriptor
1.294 + _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
1.295 +
1.296 + _LIT8(KOOMError, "#Logs may be lost out of memory!!"); // Error message
1.297 +
1.298 + User::LeaveIfError(fileSystem.Connect());
1.299 +
1.300 + //Open the file in the read mode
1.301 + User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
1.302 +
1.303 + CleanupClosePushL(theFile);
1.304 +
1.305 + User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
1.306 + hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
1.307 + CleanupStack::PushL(hBuffer);
1.308 + TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
1.309 +
1.310 + // Read from position 0: start of file
1.311 + returnCode = theFile.Read(ptrString);
1.312 +
1.313 + testData.FillZ();
1.314 + testData.Copy(KEightSpaces8); //Copy the test descriptor
1.315 + returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
1.316 + //from the file
1.317 +
1.318 + if (returnCode == KErrNotFound) // Check for the error message in the log
1.319 + {
1.320 + returnCode = ptrString.Find(KOOMError);
1.321 + if (returnCode > 0)
1.322 + User::Leave(KErrNoMemory);
1.323 + }
1.324 +
1.325 + CleanupStack::PopAndDestroy(hBuffer);
1.326 + CleanupStack::PopAndDestroy(); //theFile
1.327 + if (returnCode > 0)
1.328 + return KErrNone;
1.329 + else
1.330 + return KErrGeneral;
1.331 + }
1.332 +
1.333 +
1.334 +
1.335 +TInt CFloggerTest010_02::DoTestConnect()
1.336 + {
1.337 + TInt ret = KErrGeneral;
1.338 + TPtrC8 ptrSubSystem, ptrComponent;
1.339 + ptrSubSystem.Set(_L8("SubSystem"));
1.340 + ptrComponent.Set(_L8("Component"));
1.341 +
1.342 + ret = iFlogger.Connect(); //Call connect() of Flogger
1.343 + if (ret == KErrNone)
1.344 + ret = iFlogger.SetLogTags(ptrSubSystem, ptrComponent); //SetLogTags() of Flogger called
1.345 +
1.346 + if (ret == KErrNone)
1.347 + ret = iFlogger.ClearLog(); //clear the contents from the log
1.348 +
1.349 + return ret;
1.350 + }
1.351 +
1.352 +
1.353 +
1.354 +
1.355 +
1.356 +
1.357 +
1.358 +
1.359 +CFloggerTest010_03::CFloggerTest010_03()
1.360 + {
1.361 + // store the name of this test case
1.362 + SetTestStepName(_L("step_010_03"));
1.363 + }
1.364 +
1.365 +
1.366 +
1.367 +
1.368 +CFloggerTest010_03::~CFloggerTest010_03()
1.369 + {
1.370 + //iFlogger.Close(); //Close the flogger
1.371 + }
1.372 +
1.373 +
1.374 +
1.375 +
1.376 +TVerdict CFloggerTest010_03::doTestStepL( )
1.377 + {
1.378 + INFO_PRINTF1(_L("Step 010.03 called "));
1.379 +
1.380 + if ( executeStepL() == KErrNone )
1.381 + SetTestStepResult(EPass);
1.382 +
1.383 + else
1.384 + SetTestStepResult(EFail);
1.385 +
1.386 +
1.387 + User::After(KTimeForDisplay);
1.388 + return TestStepResult();
1.389 + }
1.390 +
1.391 +
1.392 +TInt CFloggerTest010_03::executeStepL(TBool)
1.393 + {
1.394 + return KErrGeneral;
1.395 + }
1.396 +
1.397 +TInt CFloggerTest010_03::executeStepL( )
1.398 + {
1.399 + TInt ret = KErrGeneral;
1.400 + ret = DoTestConnect();
1.401 +
1.402 + if (ret == KErrNone)
1.403 + {
1.404 + ret = DoTestWrite();
1.405 + if (ret == KErrNone)
1.406 + {
1.407 + TRAPD(r, ret = DoTestCheckWriteL());
1.408 +
1.409 + if (r != KErrNone)
1.410 + ret = r;
1.411 + }
1.412 + }
1.413 + iFlogger.Close();
1.414 + return ret;
1.415 + }
1.416 +
1.417 +
1.418 +
1.419 +
1.420 +TInt CFloggerTest010_03::DoTestWrite()
1.421 + {
1.422 + _LIT8(KDescTxt,"TC 10_3:Test Msg"); //8 bit test descriptor
1.423 +
1.424 +
1.425 + iFlogger.HexDump(KDescTxt);
1.426 + ForceLogFlush(iFlogger);
1.427 +
1.428 + iFlogger.__DbgShutDownServer();
1.429 + iFlogger.Close();
1.430 + return KErrNone;
1.431 + }
1.432 +
1.433 +
1.434 +
1.435 +
1.436 +
1.437 +TInt CFloggerTest010_03::DoTestCheckWriteL()
1.438 + {
1.439 + User::After(KTimeToLog);
1.440 + RFile theFile;
1.441 + HBufC8 * hBuffer;
1.442 + TInt listfilesize;
1.443 + TInt returnCode;
1.444 + RFs fileSystem; //For file operation create a file system
1.445 + TBuf8<256> testData; //To hold the test descriptor
1.446 + _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
1.447 +
1.448 + _LIT8(KBodyTxt,"TC 10_3:Test Msg");// Test body descriptor
1.449 + _LIT8(KOOMError, "#Logs may be lost out of memory!!"); //Error message
1.450 +
1.451 + User::LeaveIfError(fileSystem.Connect());
1.452 +
1.453 + //Open the file in the read mode
1.454 + User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
1.455 + CleanupClosePushL(theFile);
1.456 +
1.457 + User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
1.458 + hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
1.459 + CleanupStack::PushL(hBuffer);
1.460 + TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
1.461 +
1.462 + // Read from position 0: start of file
1.463 + returnCode=theFile.Read(ptrString);
1.464 +
1.465 + testData.Copy(KBodyTxt); //Copy the test descriptor
1.466 + returnCode=ptrString.Find(testData); //find the test descriptor in the buffer read
1.467 + //from the file
1.468 +
1.469 + if (returnCode == KErrNotFound) //Find the error message
1.470 + {
1.471 + returnCode = ptrString.Find(KOOMError);
1.472 + if (returnCode > 0)
1.473 + User::Leave(KErrNoMemory);
1.474 + }
1.475 +
1.476 + CleanupStack::PopAndDestroy(hBuffer);
1.477 + CleanupStack::PopAndDestroy(); //theFile object
1.478 + if (returnCode > 0)
1.479 + return KErrNone;
1.480 + else
1.481 + return KErrGeneral;
1.482 + }
1.483 +
1.484 +
1.485 +
1.486 +
1.487 +TInt CFloggerTest010_03::DoTestConnect()
1.488 + {
1.489 + TInt result;
1.490 + TPtrC8 ptrSubSystem;
1.491 + TPtrC8 ptrComponent;
1.492 + ptrSubSystem.Set(_L8("SubSystem"));
1.493 + ptrComponent.Set(_L8("Component"));
1.494 +
1.495 + result = iFlogger.Connect(); //Call connect() of Flogger
1.496 + if (result == KErrNone)
1.497 + {
1.498 + result = iFlogger.SetLogTags(ptrSubSystem, ptrComponent); //SetLogTags() of Flogger called
1.499 + //to set the tags
1.500 + result = iFlogger.ClearLog(); //clear the contents in the log
1.501 +
1.502 + }
1.503 + return result;
1.504 +
1.505 + }
1.506 +
1.507 +
1.508 +
1.509 +
1.510 +
1.511 +
1.512 +
1.513 +
1.514 +CFloggerTest010_04::CFloggerTest010_04()
1.515 + {
1.516 + // store the name of this test case
1.517 + SetTestStepName(_L("step_010_04"));
1.518 + }
1.519 +
1.520 +
1.521 +
1.522 +
1.523 +CFloggerTest010_04::~CFloggerTest010_04()
1.524 + {
1.525 + }
1.526 +
1.527 +
1.528 +
1.529 +TVerdict CFloggerTest010_04::doTestStepL( )
1.530 + {
1.531 +
1.532 + INFO_PRINTF1(_L("Step 010.04 called "));
1.533 +
1.534 + if ( executeStepL() == KErrNone )
1.535 + SetTestStepResult(EPass);
1.536 +
1.537 + else
1.538 + SetTestStepResult(EFail);
1.539 +
1.540 +
1.541 + User::After(KTimeForDisplay);
1.542 + return TestStepResult();
1.543 + }
1.544 +
1.545 +TInt CFloggerTest010_04::executeStepL(TBool)
1.546 + {
1.547 + return KErrGeneral;
1.548 + }
1.549 +
1.550 +TInt CFloggerTest010_04::executeStepL( )
1.551 + {
1.552 + TInt ret = KErrGeneral;
1.553 + ret = DoTestConnect();
1.554 +
1.555 + if (ret == KErrNone)
1.556 + {
1.557 + ret = DoTestWrite();
1.558 + if (ret == KErrNone)
1.559 + {
1.560 + TRAPD(r, ret = DoTestCheckWriteL());
1.561 +
1.562 + if (r != KErrNone)
1.563 + ret = r;
1.564 + }
1.565 + }
1.566 + iFlogger.Close();
1.567 + return ret;
1.568 + }
1.569 +
1.570 +
1.571 +
1.572 +
1.573 +TInt CFloggerTest010_04::DoTestWrite()
1.574 + {
1.575 + _LIT8(KTestDesc,"TC 10_4:Test Msg");
1.576 +
1.577 + iFlogger.HexDump(KTestDesc, KNullDesC8);
1.578 + ForceLogFlush(iFlogger);
1.579 + iFlogger.__DbgShutDownServer();
1.580 + iFlogger.Close();
1.581 + return KErrNone;
1.582 + }
1.583 +
1.584 +
1.585 +
1.586 +
1.587 +TInt CFloggerTest010_04::DoTestCheckWriteL()
1.588 + {
1.589 + User::After(KTimeToLog);
1.590 + RFile theFile;
1.591 + HBufC8 * hBuffer;
1.592 + TInt listfilesize;
1.593 + TInt returnCode;
1.594 + RFs fileSystem; //For file operation create a file system
1.595 + TBuf8<256> testData; //To hold the test descriptor
1.596 + _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
1.597 +
1.598 + _LIT8(KBodyTxt,"TC 10_4:Test Msg");// Test body descriptor
1.599 + _LIT8(KOOMError, "#Logs may be lost out of memory!!"); //Error message
1.600 + TInt numSuccessful= 0;
1.601 +
1.602 + User::LeaveIfError(fileSystem.Connect());
1.603 +
1.604 + //Open the file in the read mode
1.605 + User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
1.606 + CleanupClosePushL(theFile);
1.607 +
1.608 + User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
1.609 + hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
1.610 + CleanupStack::PushL(hBuffer);
1.611 + TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
1.612 +
1.613 + // Read from position 0: start of file
1.614 + returnCode = theFile.Read(ptrString);
1.615 +
1.616 +
1.617 + testData.Copy(KBodyTxt); //Copy the test descriptor
1.618 + returnCode=ptrString.Find(testData); //find the test descriptor in the buffer read
1.619 + //from the file
1.620 +
1.621 + if (returnCode > 0)
1.622 + numSuccessful++;
1.623 +
1.624 + returnCode=ptrString.Find(KHexTestHeader); //find the test descriptor in the buffer read
1.625 +
1.626 + if (returnCode == KErrNotFound)
1.627 + numSuccessful++;
1.628 +
1.629 +
1.630 + if (returnCode == KErrNotFound) //Find the error message
1.631 + {
1.632 + returnCode = ptrString.Find(KOOMError);
1.633 + if (returnCode > 0)
1.634 + User::Leave(KErrNoMemory);
1.635 + }
1.636 +
1.637 + CleanupStack::PopAndDestroy(hBuffer);
1.638 + CleanupStack::PopAndDestroy(); //theFile object
1.639 +
1.640 + if (numSuccessful == 2)
1.641 + return KErrNone;
1.642 + else
1.643 + return KErrGeneral;
1.644 + }
1.645 +
1.646 +
1.647 +
1.648 +
1.649 +TInt CFloggerTest010_04::DoTestConnect()
1.650 + {
1.651 + TInt ret = KErrGeneral;
1.652 + TPtrC8 ptrSubSystem;
1.653 + TPtrC8 ptrComponent;
1.654 + ptrSubSystem.Set(_L8("SubSystem"));
1.655 + ptrComponent.Set(_L8("Component"));
1.656 +
1.657 + ret = iFlogger.Connect(); //Call connect() of Flogger
1.658 + if (ret == KErrNone)
1.659 + ret = iFlogger.SetLogTags(ptrSubSystem, ptrComponent); //SetLogTags() of Flogger called
1.660 +
1.661 + if (ret == KErrNone)
1.662 + ret = iFlogger.ClearLog(); //clear the contents from the log
1.663 +
1.664 + return ret;
1.665 + }
1.666 +
1.667 +
1.668 +
1.669 +
1.670 +
1.671 +
1.672 +
1.673 +
1.674 +
1.675 +CFloggerTest010_05::CFloggerTest010_05()
1.676 + {
1.677 + // store the name of this test case
1.678 + SetTestStepName(_L("step_010_05"));
1.679 + }
1.680 +
1.681 +
1.682 +
1.683 +CFloggerTest010_05::~CFloggerTest010_05()
1.684 + {
1.685 + }
1.686 +
1.687 +
1.688 +
1.689 +
1.690 +TVerdict CFloggerTest010_05::doTestStepL( )
1.691 + {
1.692 + INFO_PRINTF1(_L("Step 010.05 called "));
1.693 +
1.694 + if ( executeStepL() == KErrNone )
1.695 + SetTestStepResult(EPass);
1.696 +
1.697 + else
1.698 + SetTestStepResult(EFail);
1.699 +
1.700 +
1.701 + User::After(KTimeForDisplay);
1.702 + return TestStepResult();
1.703 + }
1.704 +
1.705 +
1.706 +
1.707 +TInt CFloggerTest010_05::executeStepL(TBool)
1.708 + {
1.709 + return KErrGeneral;
1.710 + }
1.711 +
1.712 +TInt CFloggerTest010_05::executeStepL( )
1.713 + {
1.714 + User::After(100*1000); //Need this or connect will return KErrServerTerminated
1.715 + TInt ret = KErrGeneral;
1.716 + ret = DoTestConnect();
1.717 +
1.718 + if (ret == KErrNone)
1.719 + {
1.720 + ret = DoTestWrite();
1.721 + if (ret == KErrNone)
1.722 + {
1.723 + TRAPD(r, ret = DoTestCheckWriteL());
1.724 +
1.725 + if (r != KErrNone)
1.726 + ret = r;
1.727 + }
1.728 + }
1.729 + if (ret == KErrNone)
1.730 + iFlogger.__DbgShutDownServer();
1.731 + iFlogger.Close();
1.732 + return ret;
1.733 + }
1.734 +
1.735 +
1.736 +
1.737 +TInt CFloggerTest010_05::DoTestWrite()
1.738 + {
1.739 + ForceLogFlush(iFlogger);
1.740 +
1.741 + iFlogger.HexDump(KNullDesC8);
1.742 + return KErrNone;
1.743 + }
1.744 +
1.745 +
1.746 +
1.747 +TInt CFloggerTest010_05::DoTestCheckWriteL()
1.748 + {
1.749 + User::After(KTimeToLog);
1.750 + RFile theFile;
1.751 + HBufC8 * hBuffer;
1.752 + TInt listfilesize;
1.753 + TInt returnCode;
1.754 + RFs fileSystem; //For file operation create a file system
1.755 + _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
1.756 + _LIT8(KExpectedString,"0000 :");
1.757 +
1.758 + _LIT8(KOOMError, "#Logs may be lost out of memory!!"); //Error message
1.759 +
1.760 + User::LeaveIfError(fileSystem.Connect());
1.761 +
1.762 + //Open the file in the read mode
1.763 + User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
1.764 + CleanupClosePushL(theFile);
1.765 +
1.766 +
1.767 + User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
1.768 + hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
1.769 + CleanupStack::PushL(hBuffer);
1.770 + TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
1.771 +
1.772 + // Read from position 0: start of file
1.773 + returnCode = theFile.Read(ptrString);
1.774 +
1.775 + //check for no OOM msg
1.776 + returnCode = ptrString.Find(KOOMError);
1.777 + if (returnCode > 0)
1.778 + {
1.779 + User::Leave(KErrNoMemory);
1.780 + }
1.781 +
1.782 +
1.783 + // we expect the output to be pretty blank, so not much to search for
1.784 + // except make sure the standard "0000: " ins't even there
1.785 + returnCode = ptrString.Find(KExpectedString); //find the test descriptor in the buffer read
1.786 + //from the file
1.787 +
1.788 + CleanupStack::PopAndDestroy(hBuffer);
1.789 + CleanupStack::PopAndDestroy(); //theFile object
1.790 + if (returnCode == KErrNotFound)
1.791 + return KErrNone;
1.792 + else
1.793 + return KErrGeneral;
1.794 + }
1.795 +
1.796 +
1.797 +
1.798 +
1.799 +
1.800 +TInt CFloggerTest010_05::DoTestConnect()
1.801 + {
1.802 + TInt ret = KErrGeneral;
1.803 + TPtrC8 ptrSubSystem, ptrComponent;
1.804 + ptrSubSystem.Set(_L8("SubSystem"));
1.805 + ptrComponent.Set(_L8("Component"));
1.806 +
1.807 + ret = iFlogger.Connect(); //Call connect() of Flogger
1.808 + if (ret == KErrNone)
1.809 + ret = iFlogger.SetLogTags(ptrSubSystem, ptrComponent); //SetLogTags() of Flogger called
1.810 +
1.811 + if (ret == KErrNone)
1.812 + ret = iFlogger.ClearLog(); //clear the contents from the log
1.813 +
1.814 + return ret;
1.815 +
1.816 + }
1.817 +
1.818 +
1.819 +
1.820 +
1.821 +
1.822 +
1.823 +CFloggerTest010_06::CFloggerTest010_06()
1.824 + {
1.825 + // store the name of this test case
1.826 + SetTestStepName(_L("step_010_06"));
1.827 + }
1.828 +
1.829 +
1.830 +
1.831 +
1.832 +CFloggerTest010_06::~CFloggerTest010_06()
1.833 + {
1.834 + }
1.835 +
1.836 +
1.837 +
1.838 +TVerdict CFloggerTest010_06::doTestStepL( )
1.839 + {
1.840 + User::After(100*1000); //Need this or connect will return KErrServerTerminated
1.841 +
1.842 + INFO_PRINTF1(_L("Step 010.06 called "));
1.843 +
1.844 + CFloggerTest010_01* step010_01 = new CFloggerTest010_01;
1.845 + CleanupStack::PushL(step010_01);
1.846 + doTestStepWithHeapFailureL( *step010_01, 1, 20, KErrNone, ETrue);
1.847 +
1.848 + CleanupStack::PopAndDestroy(step010_01);
1.849 +
1.850 + User::After(KTimeForDisplay);
1.851 + return TestStepResult();
1.852 + }
1.853 +