os/persistentdata/traceservices/commsdebugutility/TE_commsdebugutility/src/step_017_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_017_xx.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1048 @@
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 017.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_017_xx.h"
1.31 +
1.32 +
1.33 +/**
1.34 +* Function Name : CFloggerTest017_01
1.35 +* Input parameters : None
1.36 +* Output parameters : None
1.37 +* Description : This is the constructor
1.38 +*/
1.39 +
1.40 +
1.41 +CFloggerTest017_01::CFloggerTest017_01()
1.42 + {
1.43 + // store the name of this test case
1.44 + SetTestStepName(_L("step_017_01"));
1.45 + }
1.46 +
1.47 +
1.48 +/**
1.49 +* Function Name :~ CFloggerTest017_01
1.50 +* Input parameters : None
1.51 +* Output parameters : None
1.52 +* Description : This is the Destructor
1.53 +*/
1.54 +
1.55 +
1.56 +CFloggerTest017_01::~CFloggerTest017_01()
1.57 + {
1.58 + }
1.59 +
1.60 +
1.61 +/**
1.62 +* Function Name : doTestStepL
1.63 +* Input parameters : None
1.64 +* Output parameters : TVerdict
1.65 +* Description : This function returns weather the test case 017_01 has
1.66 +* passed or failed
1.67 +
1.68 +*/
1.69 +
1.70 +
1.71 +TVerdict CFloggerTest017_01::doTestStepL( )
1.72 + {
1.73 + INFO_PRINTF1(_L("Step 017.01 called "));
1.74 +
1.75 + if ( executeStepL(EFalse) == KErrNone )
1.76 + SetTestStepResult(EPass);
1.77 +
1.78 + else
1.79 + SetTestStepResult(EFail);
1.80 +
1.81 +
1.82 + User::After(KTimeForDisplay1);
1.83 + return TestStepResult();
1.84 + }
1.85 +/**
1.86 +* Function Name : executeStepL
1.87 +* Input parameters : None
1.88 +* Output parameters : TInt
1.89 +* Description : This function writes the test data in to the log file
1.90 +* This function check the test message is present in the
1.91 +* log file
1.92 +
1.93 +*/
1.94 +
1.95 +
1.96 +TInt CFloggerTest017_01::executeStepL()
1.97 + {
1.98 + return KErrGeneral;
1.99 + }
1.100 +
1.101 +/**
1.102 +* Function Name : executeStepL
1.103 +* Input parameters : None
1.104 +* Output parameters : TInt
1.105 +* Description : This function writes the test data in to the log file
1.106 +* This function check the test message is present in the
1.107 +* log file
1.108 +
1.109 +*/
1.110 +
1.111 +
1.112 +TInt CFloggerTest017_01::executeStepL(TBool heapTest)
1.113 + {
1.114 + TInt ret = KErrGeneral;
1.115 +
1.116 + ret = DoTestWrite();
1.117 + if (ret == KErrNone)
1.118 + {
1.119 + User::After(KTimeToLog);
1.120 + TRAPD(r, ret = DoTestCheckWriteL() );
1.121 + if ((heapTest) && ((ret == KErrNotFound) || (r != KErrNone)))
1.122 + {
1.123 + ret = KErrNoMemory;
1.124 + }
1.125 + else if (r != KErrNone)
1.126 + {
1.127 + ret = r;
1.128 + }
1.129 + }
1.130 + return ret;
1.131 + }
1.132 +
1.133 +
1.134 +/**
1.135 +* Function Name : DoTestWrite
1.136 +* Input parameters : None
1.137 +* Output parameters : TInt
1.138 +* Description : This function writes the data to the file logger in hexa format
1.139 +
1.140 +*/
1.141 +
1.142 +
1.143 +TInt CFloggerTest017_01::DoTestWrite()
1.144 + {
1.145 + _LIT8(KDescText, "TC 17_1:Test Msg----"); //Test body descriptor
1.146 +
1.147 + //Write the test datas in the hexa format
1.148 + RFileLogger::HexDump(KStdSubsysTag8,KStdCompTag8, KDescText, KHexTestHeader);
1.149 +
1.150 + // connect so we can flush file buffer for heap check since timer is killed in heap checks
1.151 + RFileLogger theFlogger;
1.152 + theFlogger.Connect();
1.153 + theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
1.154 + ForceLogFlush(theFlogger);
1.155 + theFlogger.Close();
1.156 + return KErrNone;
1.157 + }
1.158 +
1.159 +
1.160 +/**
1.161 +* Function Name : DoTestCheckWriteL
1.162 +* Input parameters : None
1.163 +* Output parameters : TInt
1.164 +* Description : This function checks the weather test data was written
1.165 +* in to the log file by DoTestWrite() or not.
1.166 +
1.167 +*/
1.168 +
1.169 +
1.170 +TInt CFloggerTest017_01::DoTestCheckWriteL()
1.171 + {
1.172 + User::After(KTimeToLog);
1.173 +
1.174 + RFile theFile;
1.175 + HBufC8 * hBuffer;
1.176 + TInt listfilesize;
1.177 + TInt returnCode;
1.178 + RFs fileSystem; //For file operation create a file system
1.179 + _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
1.180 +
1.181 + _LIT8(KBodyTxt,"TC 17_1:Test Msg");// First 16 chars of Test body descriptor
1.182 +
1.183 + User::LeaveIfError(fileSystem.Connect());
1.184 +
1.185 + //Open the file in the read mode
1.186 + User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)) ;
1.187 +
1.188 +
1.189 + User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
1.190 + hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
1.191 + CleanupStack::PushL(hBuffer);
1.192 +
1.193 + TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
1.194 +
1.195 + // Read from position 0, i.e starting of file
1.196 + returnCode = theFile.Read(ptrString);
1.197 +
1.198 + returnCode = ptrString.Find(KHexTestHeader); //find the test header descriptor in
1.199 + //the buffer read from the file
1.200 +
1.201 + if (returnCode > 0) //The header is present
1.202 + {
1.203 + returnCode = ptrString.Find(KHexTestMargin); //find the test margin descriptor in
1.204 + //the buffer read from the file
1.205 + }
1.206 +
1.207 + if (returnCode > 0) //The margin is present
1.208 + {
1.209 + returnCode = ptrString.Find(KBodyTxt); //find the test descriptor in the
1.210 + //buffer read from the file
1.211 + }
1.212 +
1.213 + theFile.Close();
1.214 + fileSystem.Close(); //Close the file server
1.215 + CleanupStack::PopAndDestroy(hBuffer);
1.216 +
1.217 + if (returnCode > 0) //The test body descriptor is present
1.218 + return KErrNone;
1.219 + else
1.220 + return KErrNotFound;
1.221 + }
1.222 +
1.223 +
1.224 +
1.225 +
1.226 +
1.227 +/**
1.228 +* Function Name : CFloggerTest017_02
1.229 +* Input parameters : None
1.230 +* Output parameters : None
1.231 +* Description : This is the constructor
1.232 +*/
1.233 +
1.234 +
1.235 +CFloggerTest017_02::CFloggerTest017_02()
1.236 + {
1.237 + // store the name of this test case
1.238 + SetTestStepName(_L("step_017_02"));
1.239 + }
1.240 +
1.241 +
1.242 +/**
1.243 +* Function Name :~ CFloggerTest017_02
1.244 +* Input parameters : None
1.245 +* Output parameters : None
1.246 +* Description : This is the Destructor
1.247 +*/
1.248 +
1.249 +
1.250 +CFloggerTest017_02::~CFloggerTest017_02()
1.251 + {
1.252 + }
1.253 +
1.254 +
1.255 +/**
1.256 +* Function Name : doTestStepL
1.257 +* Input parameters : None
1.258 +* Output parameters : TVerdict
1.259 +* Description : This function returns weather the test case 017_02 has
1.260 +* passed or failed
1.261 +
1.262 +*/
1.263 +
1.264 +
1.265 +TVerdict CFloggerTest017_02::doTestStepL( )
1.266 + {
1.267 + INFO_PRINTF1(_L("Step 017.02 called "));
1.268 +
1.269 + if ( executeStepL() == KErrNone )
1.270 + SetTestStepResult(EPass);
1.271 +
1.272 + else
1.273 + SetTestStepResult(EFail);
1.274 +
1.275 +
1.276 + User::After(KTimeForDisplay1);
1.277 + return TestStepResult();
1.278 + }
1.279 +
1.280 +/**
1.281 +* Function Name : executeStepL
1.282 +* Input parameters : None
1.283 +* Output parameters : TInt
1.284 +* Description : This function writes the test data in to the log file
1.285 +* This function check the test message is present in the
1.286 +* log file
1.287 +
1.288 +*/
1.289 +
1.290 +
1.291 +
1.292 +TInt CFloggerTest017_02::executeStepL(TBool)
1.293 + {
1.294 + return KErrGeneral;
1.295 + }
1.296 +/**
1.297 +* Function Name : executeStepL
1.298 +* Input parameters : None
1.299 +* Output parameters : TInt
1.300 +* Description : This function writes the test data in to the log file
1.301 +* This function check the test message is present in the
1.302 +* log file
1.303 +
1.304 +*/
1.305 +
1.306 +
1.307 +
1.308 +TInt CFloggerTest017_02::executeStepL( )
1.309 + {
1.310 + User::After(1000*1000); //Need this or connect will return KErrServerTerminated
1.311 + TInt ret = KErrGeneral;
1.312 +
1.313 + ret = DoTestWrite();
1.314 + if (ret == KErrNone )
1.315 + {
1.316 + TRAPD(r, ret = DoTestCheckWriteL());
1.317 + if (r != KErrNone)
1.318 + ret = r;
1.319 + }
1.320 +
1.321 + return ret;
1.322 + }
1.323 +
1.324 +
1.325 +/**
1.326 +* Function Name : DoTestWrite
1.327 +* Input parameters : None
1.328 +* Output parameters : TInt
1.329 +* Description : This function writes the data to the file logger
1.330 +
1.331 +*/
1.332 +
1.333 +
1.334 +TInt CFloggerTest017_02::DoTestWrite()
1.335 + {
1.336 +
1.337 + RFileLogger theFlogger;
1.338 + TInt ret = KErrNone;
1.339 +
1.340 + ret = theFlogger.Connect(); //Just to clear the old log message
1.341 + if (ret == KErrNone)
1.342 + ret = theFlogger.SetLogTags(KStdSubsysTag8,KStdCompTag8);
1.343 + if (ret == KErrNone)
1.344 + ret = theFlogger.ClearLog();
1.345 + if (ret == KErrNone)
1.346 + theFlogger.Close();
1.347 +
1.348 + if (ret == KErrNone)
1.349 + {
1.350 + _LIT8(KDescText,"TC 17_2:Test Msg");
1.351 +
1.352 + //Write the test datas in the hexa format
1.353 + RFileLogger::HexDump(KStdSubsysTag8,KStdCompTag8, KDescText, KEightSpaces8);
1.354 +
1.355 + return KErrNone;
1.356 + }
1.357 + return ret;
1.358 + }
1.359 +
1.360 +
1.361 +/**
1.362 +* Function Name : DoTestCheckWriteL
1.363 +* Input parameters : None
1.364 +* Output parameters : TInt
1.365 +* Description : This function checks the weather test data was written
1.366 +* in to the log file by DoTestWrite() or not.
1.367 +
1.368 +*/
1.369 +
1.370 +
1.371 +TInt CFloggerTest017_02::DoTestCheckWriteL()
1.372 + {
1.373 + User::After(KTimeToLog);
1.374 + RFile theFile;
1.375 + HBufC8 * hBuffer;
1.376 + TInt listfilesize;
1.377 + TInt returnCode;
1.378 + RFs fileSystem; //For file operation create a file system
1.379 + TBuf8<256> testData; //To hold the test descriptor
1.380 + _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
1.381 +
1.382 + _LIT8(KOOMError, "#Logs may be lost out of memory!!"); // Error message
1.383 +
1.384 + User::LeaveIfError(fileSystem.Connect());
1.385 +
1.386 + //Open the file in the read mode
1.387 + User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
1.388 +
1.389 + CleanupClosePushL(theFile);
1.390 +
1.391 + User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
1.392 + hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
1.393 + CleanupStack::PushL(hBuffer);
1.394 + TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
1.395 +
1.396 + // Read from position 0: start of file
1.397 + returnCode = theFile.Read(ptrString);
1.398 +
1.399 + testData.FillZ();
1.400 + testData.Copy(KEightSpaces8); //Copy the test descriptor
1.401 + returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
1.402 + //from the file
1.403 +
1.404 + if (returnCode == KErrNotFound) // Check for the error message in the log
1.405 + {
1.406 + returnCode = ptrString.Find(KOOMError);
1.407 + if (returnCode > 0)
1.408 + User::Leave(KErrNoMemory);
1.409 + }
1.410 +
1.411 + CleanupStack::PopAndDestroy(hBuffer);
1.412 + CleanupStack::PopAndDestroy(); //theFile
1.413 + if (returnCode > 0)
1.414 + return KErrNone;
1.415 + else
1.416 + return KErrGeneral;
1.417 + }
1.418 +
1.419 +
1.420 +
1.421 +/**
1.422 +* Function Name : CFloggerTest017_03
1.423 +* Input parameters : None
1.424 +* Output parameters : None
1.425 +* Description : This is the constructor
1.426 +* Description : This is the constructor
1.427 +*/
1.428 +
1.429 +
1.430 +CFloggerTest017_03::CFloggerTest017_03()
1.431 + {
1.432 + // store the name of this test case
1.433 + SetTestStepName(_L("step_017_03"));
1.434 + }
1.435 +
1.436 +
1.437 +/**
1.438 +* Function Name :~ CFloggerTest017_03
1.439 +* Input parameters : None
1.440 +* Output parameters : None
1.441 +* Description : This is the Destructor
1.442 +*/
1.443 +
1.444 +
1.445 +CFloggerTest017_03::~CFloggerTest017_03()
1.446 + {
1.447 + }
1.448 +
1.449 +
1.450 +/**
1.451 +* Function Name : doTestStepL
1.452 +* Input parameters : None
1.453 +* Output parameters : TVerdict
1.454 +* Description : This function returns weather the test case 017_03 has
1.455 +* passed or failed
1.456 +
1.457 +*/
1.458 +
1.459 +
1.460 +TVerdict CFloggerTest017_03::doTestStepL( )
1.461 + {
1.462 + INFO_PRINTF1(_L("Step 017.03 called "));
1.463 +
1.464 + if ( executeStepL() == KErrNone )
1.465 + SetTestStepResult(EPass);
1.466 +
1.467 + else
1.468 + SetTestStepResult(EFail);
1.469 +
1.470 +
1.471 + User::After(KTimeForDisplay1);
1.472 + return TestStepResult();
1.473 + }
1.474 +
1.475 +
1.476 +/**
1.477 +* Function Name : executeStepL
1.478 +* Input parameters : None
1.479 +* Output parameters : TInt
1.480 +* Description : This function writes the test data in to the log file
1.481 +* This function check the test message is present in the
1.482 +* log file
1.483 +
1.484 +*/
1.485 +
1.486 +
1.487 +TInt CFloggerTest017_03::executeStepL( )
1.488 + {
1.489 + User::After(1000*1000); //Need this or connect will return KErrServerTerminated
1.490 + TInt ret = KErrGeneral;
1.491 +
1.492 + ret = DoTestWrite();
1.493 + if (ret == KErrNone )
1.494 + {
1.495 + TRAPD(r, ret = DoTestCheckWriteL());
1.496 + if (ret != KErrNone)
1.497 + ret = r;
1.498 + }
1.499 +
1.500 + return ret;
1.501 + }
1.502 +
1.503 +/**
1.504 +* Function Name : executeStepL
1.505 +* Input parameters : None
1.506 +* Output parameters : TInt
1.507 +* Description : This function writes the test data in to the log file
1.508 +* This function check the test message is present in the
1.509 +* log file
1.510 +
1.511 +*/
1.512 +
1.513 +
1.514 +TInt CFloggerTest017_03::executeStepL(TBool)
1.515 + {
1.516 + return KErrGeneral;
1.517 + }
1.518 +
1.519 +//**
1.520 +/* Function Name : DoTestWrite
1.521 +* Input parameters : None
1.522 +* Output parameters : TInt
1.523 +* Description : This function writes the data to the file logger
1.524 +
1.525 +*/
1.526 +
1.527 +
1.528 +TInt CFloggerTest017_03::DoTestWrite()
1.529 + {
1.530 +
1.531 + RFileLogger theFlogger;
1.532 + TInt ret = KErrNone;
1.533 +
1.534 + ret = theFlogger.Connect(); //Just to clear the old log message
1.535 + if (ret == KErrNone)
1.536 + ret = theFlogger.SetLogTags(KStdSubsysTag8,KStdCompTag8);
1.537 + if (ret == KErrNone)
1.538 + ret = theFlogger.ClearLog();
1.539 + if (ret == KErrNone)
1.540 + theFlogger.Close();
1.541 +
1.542 + if (ret == KErrNone)
1.543 + {
1.544 + _LIT8(KDescText,"TC 17_3:Test Msg"); //8 bit test descriptor
1.545 +
1.546 + //Write the test datas in the hexa format
1.547 + RFileLogger::HexDump(KStdSubsysTag8,KStdCompTag8, KDescText);
1.548 +
1.549 +
1.550 + return KErrNone;
1.551 + }
1.552 + return ret;
1.553 + }
1.554 +
1.555 +
1.556 +/**
1.557 +* Function Name : DoTestCheckWriteL
1.558 +* Input parameters : None
1.559 +* Output parameters : TInt
1.560 +* Description : This function checks the weather test data was written
1.561 +* in to the log file by DoTestWrite() or not.
1.562 +
1.563 +*/
1.564 +
1.565 +
1.566 +TInt CFloggerTest017_03::DoTestCheckWriteL()
1.567 + {
1.568 +
1.569 + User::After(KTimeToLog);
1.570 + RFile theFile;
1.571 + HBufC8 * hBuffer;
1.572 + TInt listfilesize;
1.573 + TInt returnCode;
1.574 + RFs fileSystem; //For file operation create a file system
1.575 + TBuf8<256> testData; //To hold the test descriptor
1.576 + _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
1.577 +
1.578 + _LIT8(KBodyTxt,"TC 17_3:Test Msg");// Test body descriptor
1.579 +
1.580 + User::LeaveIfError(fileSystem.Connect());
1.581 +
1.582 + //Open the file in the read mode
1.583 + User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
1.584 + CleanupClosePushL(theFile);
1.585 +
1.586 + User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
1.587 + hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
1.588 + CleanupStack::PushL(hBuffer);
1.589 + TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
1.590 +
1.591 + // Read from position 0: start of file
1.592 + returnCode=theFile.Read(ptrString);
1.593 +
1.594 + testData.Copy(KBodyTxt); //Copy the test descriptor
1.595 + returnCode=ptrString.Find(testData); //find the test descriptor in the buffer read
1.596 + //from the file
1.597 +
1.598 + if (returnCode == KErrNotFound) //Find the error message
1.599 + {
1.600 + returnCode = ptrString.Find(KErrOOM);
1.601 + if (returnCode > 0)
1.602 + User::Leave(KErrNoMemory);
1.603 + }
1.604 +
1.605 + CleanupStack::PopAndDestroy(hBuffer);
1.606 + CleanupStack::PopAndDestroy(); //theFile object
1.607 + if (returnCode > 0)
1.608 + return KErrNone;
1.609 + else
1.610 + return KErrGeneral;
1.611 + }
1.612 +
1.613 +
1.614 +
1.615 +/**
1.616 +* Function Name : CFloggerTest017_04
1.617 +* Input parameters : None
1.618 +* Output parameters : None
1.619 +* Description : This is the constructor
1.620 +*/
1.621 +
1.622 +
1.623 +CFloggerTest017_04::CFloggerTest017_04()
1.624 + {
1.625 + // store the name of this test case
1.626 + SetTestStepName(_L("step_017_04"));
1.627 + }
1.628 +
1.629 +
1.630 +/**
1.631 +* Function Name :~ CFloggerTest017_04
1.632 +* Input parameters : None
1.633 +* Output parameters : None
1.634 +* Description : This is the Destructor
1.635 +*/
1.636 +
1.637 +
1.638 +CFloggerTest017_04::~CFloggerTest017_04()
1.639 + {
1.640 + }
1.641 +
1.642 +/**
1.643 +* Function Name : doTestStepL
1.644 +* Input parameters : None
1.645 +* Output parameters : TVerdict
1.646 +* Description : This function returns weather the test case 017_04 has
1.647 +* passed or failed
1.648 +
1.649 +*/
1.650 +
1.651 +
1.652 +TVerdict CFloggerTest017_04::doTestStepL( )
1.653 + {
1.654 + INFO_PRINTF1(_L("Step 017.04 called "));
1.655 +
1.656 + if ( executeStepL() == KErrNone )
1.657 + SetTestStepResult(EPass);
1.658 +
1.659 + else
1.660 + SetTestStepResult(EFail);
1.661 +
1.662 +
1.663 + User::After(KTimeForDisplay1);
1.664 + return TestStepResult();
1.665 + }
1.666 +
1.667 +
1.668 +/**
1.669 +* Function Name : executeStepL
1.670 +* Input parameters : None
1.671 +* Output parameters : TInt
1.672 +* Description : This function writes the test data in to the log file
1.673 +* This function check the test message is present in the
1.674 +* log file
1.675 +
1.676 +*/
1.677 +
1.678 +
1.679 +TInt CFloggerTest017_04::executeStepL( )
1.680 + {
1.681 + User::After(1000*1000); //Need this or connect will return KErrServerTerminated
1.682 + TInt ret = KErrGeneral;
1.683 +
1.684 + ret = DoTestWrite();
1.685 + if (ret == KErrNone )
1.686 + {
1.687 + TRAPD(r, ret = DoTestCheckWriteL());
1.688 + if (ret != KErrNone)
1.689 + ret = r;
1.690 + }
1.691 +
1.692 + return ret;
1.693 + }
1.694 +/**
1.695 +* Function Name : executeStepL
1.696 +* Input parameters : None
1.697 +* Output parameters : TInt
1.698 +* Description : This function writes the test data in to the log file
1.699 +* This function check the test message is present in the
1.700 +* log file
1.701 +
1.702 +*/
1.703 +
1.704 +
1.705 +TInt CFloggerTest017_04::executeStepL(TBool)
1.706 + {
1.707 + return KErrGeneral;
1.708 + }
1.709 +
1.710 +/**
1.711 +* Function Name : DoTestWrite
1.712 +* Input parameters : None
1.713 +* Output parameters : TInt
1.714 +* Description : This function writes the data to the file logger
1.715 +
1.716 +*/
1.717 +
1.718 +
1.719 +TInt CFloggerTest017_04::DoTestWrite()
1.720 + {
1.721 + _LIT8(KDescText,"TC 17_4:Test Msg");
1.722 +
1.723 + RFileLogger theFlogger;
1.724 + TInt ret = KErrNone;
1.725 + ret = theFlogger.Connect(); //Just to clear the old log message
1.726 + if (ret == KErrNone)
1.727 + ret = theFlogger.SetLogTags(KStdSubsysTag8,KStdCompTag8);
1.728 + if (ret == KErrNone)
1.729 + ret = theFlogger.ClearLog();
1.730 + if (ret == KErrNone)
1.731 + theFlogger.Close();
1.732 + if (ret == KErrNone)
1.733 + {
1.734 + //Write the test datas in the hexa format
1.735 + RFileLogger::HexDump(KStdSubsysTag8,KStdCompTag8, KDescText, KNullDesC8);
1.736 +
1.737 + return KErrNone;
1.738 + }
1.739 + return ret;
1.740 + }
1.741 +
1.742 +
1.743 +/**
1.744 +* Function Name : DoTestCheckWriteL
1.745 +* Input parameters : None
1.746 +* Output parameters : TInt
1.747 +* Description : This function checks the weather test data was written
1.748 +* in to the log file by DoTestWrite() or not.
1.749 +
1.750 +*/
1.751 +
1.752 +
1.753 +TInt CFloggerTest017_04::DoTestCheckWriteL()
1.754 + {
1.755 + User::After(KTimeToLog);
1.756 + RFile theFile;
1.757 + HBufC8 * hBuffer;
1.758 + TInt listfilesize;
1.759 + TInt returnCode;
1.760 + RFs fileSystem; //For file operation create a file system
1.761 + TBuf8<256> testData; //To hold the test descriptor
1.762 + _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
1.763 +
1.764 + _LIT(KBodyTxt,"TC 17_4:Test Msg");// Test body descriptor
1.765 + TUint numSuccessful = 0;
1.766 +
1.767 + User::LeaveIfError(fileSystem.Connect());
1.768 +
1.769 + //Open the file in the read mode
1.770 + User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
1.771 + CleanupClosePushL(theFile);
1.772 +
1.773 + User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
1.774 + hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
1.775 + CleanupStack::PushL(hBuffer);
1.776 + TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
1.777 +
1.778 + // Read from position 0: start of file
1.779 + returnCode = theFile.Read(ptrString);
1.780 +
1.781 +
1.782 + testData.Copy(KBodyTxt); //Copy the test descriptor
1.783 + returnCode=ptrString.Find(testData); //find the test descriptor in the buffer read
1.784 + //from the file
1.785 +
1.786 + if (returnCode > 0)
1.787 + numSuccessful++;
1.788 +
1.789 + returnCode=ptrString.Find(KHexTestHeader); //find the test descriptor in the buffer read
1.790 +
1.791 + if (returnCode == KErrNotFound)
1.792 + numSuccessful++;
1.793 +
1.794 +
1.795 + if (returnCode == KErrNotFound) //Find the error message
1.796 + {
1.797 + returnCode = ptrString.Find(KErrOOM);
1.798 + if (returnCode > 0)
1.799 + User::Leave(KErrNoMemory);
1.800 + }
1.801 +
1.802 + CleanupStack::PopAndDestroy(hBuffer);
1.803 + CleanupStack::PopAndDestroy(); //theFile object
1.804 +
1.805 + if (numSuccessful == 2)
1.806 + return KErrNone;
1.807 + else
1.808 + return KErrGeneral;
1.809 + }
1.810 +
1.811 +
1.812 +
1.813 +
1.814 +/**
1.815 +* Function Name : CFloggerTest017_05
1.816 +* Input parameters : None
1.817 +* Output parameters : None
1.818 +* Description : This is the constructor
1.819 +*/
1.820 +
1.821 +
1.822 +CFloggerTest017_05::CFloggerTest017_05()
1.823 + {
1.824 + // store the name of this test case
1.825 + SetTestStepName(_L("step_017_05"));
1.826 + }
1.827 +
1.828 +
1.829 +/**
1.830 +* Function Name :~ CFloggerTest017_05
1.831 +* Input parameters : None
1.832 +* Output parameters : None
1.833 +* Description : This is the Destructor
1.834 +*/
1.835 +
1.836 +
1.837 +CFloggerTest017_05::~CFloggerTest017_05()
1.838 + {
1.839 + }
1.840 +
1.841 +/**
1.842 +* Function Name : doTestStepL
1.843 +* Input parameters : None
1.844 +* Output parameters : TVerdict
1.845 +* Description : This function returns weather the test case 017_05 has
1.846 +* passed or failed
1.847 +
1.848 +*/
1.849 +
1.850 +
1.851 +TVerdict CFloggerTest017_05::doTestStepL( )
1.852 + {
1.853 + INFO_PRINTF1(_L("Step 017.05 called "));
1.854 +
1.855 + if ( executeStepL() == KErrNone )
1.856 + SetTestStepResult(EPass);
1.857 +
1.858 + else
1.859 + SetTestStepResult(EFail);
1.860 +
1.861 +
1.862 + User::After(KTimeForDisplay1);
1.863 + return TestStepResult();
1.864 + }
1.865 +
1.866 +/**
1.867 +* Function Name : executeStepL
1.868 +* Input parameters : None
1.869 +* Output parameters : TInt
1.870 +* Description : This function writes the test data in to the log file
1.871 +* This function check the test message is present in the
1.872 +* log file
1.873 +
1.874 +*/
1.875 +
1.876 +
1.877 +TInt CFloggerTest017_05::executeStepL(TBool)
1.878 + {
1.879 + return KErrGeneral;
1.880 + }
1.881 +/**
1.882 +* Function Name : executeStepL
1.883 +* Input parameters : None
1.884 +* Output parameters : TInt
1.885 +* Description : This function writes the test data in to the log file
1.886 +* This function check the test message is present in the
1.887 +* log file
1.888 +
1.889 +*/
1.890 +
1.891 +
1.892 +TInt CFloggerTest017_05::executeStepL( )
1.893 + {
1.894 + User::After(KTimeToLog); //Need this or connect will return KErrServerTerminated
1.895 + TInt ret = KErrGeneral;
1.896 +
1.897 + ret = DoTestWrite();
1.898 + if (ret == KErrNone )
1.899 + {
1.900 + TRAPD(r, ret = DoTestCheckWriteL());
1.901 + if (ret != KErrNone)
1.902 + ret = r;
1.903 + }
1.904 + return ret;
1.905 + }
1.906 +
1.907 +
1.908 +/**
1.909 +* Function Name : DoTestWrite
1.910 +* Input parameters : None
1.911 +* Output parameters : TInt
1.912 +* Description : This function writes the data to the file logger
1.913 +
1.914 +*/
1.915 +
1.916 +
1.917 +TInt CFloggerTest017_05::DoTestWrite()
1.918 + {
1.919 + RFileLogger theFlogger;
1.920 + TInt ret = KErrNone;
1.921 +
1.922 + ret = theFlogger.Connect(); //Just to clear the old log message
1.923 + if (ret == KErrNone)
1.924 + ret = theFlogger.SetLogTags(KStdSubsysTag8,KStdCompTag8);
1.925 + if (ret == KErrNone)
1.926 + ret = theFlogger.ClearLog();
1.927 + if (ret == KErrNone)
1.928 + theFlogger.Close();
1.929 +
1.930 + if (ret == KErrNone)
1.931 + {
1.932 + //Write the test datas in the hexa format
1.933 + RFileLogger::HexDump(KStdSubsysTag8,KStdCompTag8, KNullDesC8);
1.934 + return KErrNone;
1.935 + }
1.936 + return ret;
1.937 + }
1.938 +
1.939 +
1.940 +/**
1.941 +* Function Name : DoTestCheckWriteL
1.942 +* Input parameters : None
1.943 +* Output parameters : TInt
1.944 +* Description : This function checks the weather test data was written
1.945 +* in to the log file by DoTestWrite() or not.
1.946 +
1.947 +*/
1.948 +
1.949 +
1.950 +TInt CFloggerTest017_05::DoTestCheckWriteL()
1.951 + {
1.952 + User::After(KTimeToLog);
1.953 + RFile theFile;
1.954 + HBufC8 * hBuffer;
1.955 + TInt listfilesize;
1.956 + TInt returnCode;
1.957 + RFs fileSystem; //For file operation create a file system
1.958 + _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
1.959 + _LIT8(KExpectedString,"0000 :");
1.960 +
1.961 + _LIT8(KOOMError, "#Logs may be lost out of memory!!"); //Error message
1.962 +
1.963 + User::LeaveIfError(fileSystem.Connect());
1.964 +
1.965 + //Open the file in the read mode
1.966 + User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
1.967 + CleanupClosePushL(theFile);
1.968 +
1.969 +
1.970 + User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
1.971 + hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
1.972 + CleanupStack::PushL(hBuffer);
1.973 + TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
1.974 +
1.975 + // Read from position 0: start of file
1.976 + returnCode = theFile.Read(ptrString);
1.977 +
1.978 + //check for no OOM msg
1.979 + returnCode = ptrString.Find(KOOMError);
1.980 + if (returnCode > 0)
1.981 + {
1.982 + User::Leave(KErrNoMemory);
1.983 + }
1.984 +
1.985 +
1.986 + // we expect the output to be pretty blank, so not much to search for
1.987 + // except make sure the standard "0000: " ins't even there
1.988 + returnCode = ptrString.Find(KExpectedString); //find the test descriptor in the buffer read
1.989 + //from the file
1.990 +
1.991 + CleanupStack::PopAndDestroy(hBuffer);
1.992 + CleanupStack::PopAndDestroy(); //theFile object
1.993 + if (returnCode == KErrNotFound)
1.994 + return KErrNone;
1.995 + else
1.996 + return KErrGeneral;
1.997 + }
1.998 +
1.999 +
1.1000 +
1.1001 +/*
1.1002 +* Function Name : CFloggerTest017_06
1.1003 +* Input parameters : None
1.1004 +* Output parameters : None
1.1005 +* Description : This is the constructor
1.1006 +*/
1.1007 +
1.1008 +
1.1009 +CFloggerTest017_06::CFloggerTest017_06()
1.1010 + {
1.1011 + // store the name of this test case
1.1012 + SetTestStepName(_L("step_017_06"));
1.1013 + }
1.1014 +
1.1015 +
1.1016 +/**
1.1017 +* Function Name :~ CFloggerTest017_06
1.1018 +* Input parameters : None
1.1019 +* Output parameters : None
1.1020 +* Description : This is the Destructor
1.1021 +*/
1.1022 +
1.1023 +
1.1024 +CFloggerTest017_06::~CFloggerTest017_06()
1.1025 + {
1.1026 + }
1.1027 +
1.1028 +
1.1029 +/**
1.1030 +* Function Name : doTestStepL
1.1031 +* Input parameters : None
1.1032 +* Output parameters : TVerdict
1.1033 +* Description : This function is responsible for doing the heap test analysis
1.1034 +
1.1035 +*/
1.1036 +
1.1037 +
1.1038 +
1.1039 +TVerdict CFloggerTest017_06::doTestStepL( )
1.1040 + {
1.1041 + INFO_PRINTF1(_L("Step 017.06 called "));
1.1042 +
1.1043 + CFloggerTest017_01* step017_01 = new CFloggerTest017_01;
1.1044 + CleanupStack::PushL(step017_01);
1.1045 + doTestStepWithHeapFailureL( *step017_01, 1, 20, KErrNone, ETrue);
1.1046 +
1.1047 + CleanupStack::PopAndDestroy(step017_01);
1.1048 + User::After(KTimeForDisplay);
1.1049 + return TestStepResult();
1.1050 + }
1.1051 +