messagingfw/biomsgfw/BITSTSRC/T_BIOLOG.CPP
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 1999-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 // Test harness for CMsvBIOTestLogger, a class which is used to log 
       
    15 // results of other test harnesses. 
       
    16 // 
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 #pragma warning( disable : 4100 )
       
    22 
       
    23 //  Includes...
       
    24 #include <e32test.h>
       
    25 #include <biologgr.h>
       
    26 
       
    27 
       
    28 //  Global functions..
       
    29 //  functions()
       
    30 GLDEF_C void doMainL();
       
    31 GLDEF_C TInt E32Main();
       
    32 GLDEF_C void doTestEventsL(CMsvBIOTestLogger& aLogger);
       
    33 GLDEF_C void doTestErrorsL(CMsvBIOTestLogger& aLogger);
       
    34 GLDEF_C void doTestCommentingL(CMsvBIOTestLogger& aLogger);
       
    35 GLDEF_C void doTestOutputL(CMsvBIOTestLogger& aLogger);
       
    36 
       
    37 
       
    38 //  Resources..
       
    39 GLDEF_C RTest test(_L("BIO Test Logger Tester"));
       
    40 LOCAL_D CTrapCleanup*       myCleanup;
       
    41 // LOCAL_D CTestScheduler*              theScheduler;
       
    42 LOCAL_D RFs                 rFs;
       
    43 
       
    44 
       
    45 //*****************************************************************************
       
    46 //
       
    47 //  Implementation; global stuff
       
    48 //
       
    49 //*****************************************************************************
       
    50 GLDEF_C void doTestEventsL(CMsvBIOTestLogger& aLogger)
       
    51     {
       
    52 	test.Printf(_L("Testing the events logging\n"));
       
    53 	aLogger.LogEventL(EBIOParserCreate,_L("Made a parser"));
       
    54 	aLogger.LogEventL(EBIOParserDelete,_L("Got rid of a parser"));
       
    55 	aLogger.LogEventL(EBIOParserParseMessage,_L("Parsing my Smart Message"));
       
    56 	aLogger.LogEventL(EBIOParserProcessMessage,_L("Processing message to create settings"));
       
    57 	aLogger.LogEventL(EOpenBIOMessage,_L("Opening a new message"));
       
    58 	aLogger.LogEventL(ECloseBIOMessage,_L("Closing this message"));
       
    59 	aLogger.LogEventL(ECreateBIOAttachment,_L("Creating a new attachment file"));
       
    60 	aLogger.LogEventL(ECloseBIOAttachment,_L("Closing the attachment file"));
       
    61 	aLogger.LogEventL(ECreateBIODataStream,_L("Creating a data stream to store the parsed data"));
       
    62 	aLogger.LogEventL(ECloseBIODataStream,_L("Closing the data stream"));
       
    63 	test.Printf(_L("Completed test of event logging\n"));
       
    64 
       
    65 	}
       
    66 
       
    67 
       
    68 GLDEF_C void doTestErrorsL(CMsvBIOTestLogger& aLogger)
       
    69     {
       
    70 	test.Printf(_L("Testing the error logging\n"));
       
    71 	aLogger.LogErrorL(0,_L("No problemo"));
       
    72 	aLogger.LogErrorL(1,_L("Positive value"));
       
    73 	aLogger.LogErrorL(-1,_L("Negative value - error"));
       
    74 	aLogger.LogErrorL(KErrNone,_L("KErrNone received"));
       
    75 	aLogger.LogErrorL(KErrNotFound,_L("Could find it "));
       
    76 	aLogger.LogErrorL(KErrPathNotFound,_L("Could find the path"));
       
    77 	aLogger.LogErrorL(KErrNoMemory,_L("Out of memory"));
       
    78 	
       
    79 	test.Printf(_L("Completed test of error  logging\n"));
       
    80 
       
    81 	}
       
    82 
       
    83 GLDEF_C void doTestCommentingL(CMsvBIOTestLogger& aLogger)
       
    84     {
       
    85 	test.Printf(_L("Testing the comment logging\n"));
       
    86 	aLogger.LogCommentL(_L("A"));
       
    87 	aLogger.LogCommentL(_L("Smallish comment"));
       
    88 	aLogger.LogCommentL(_L("An exceedingly large, even humongous comment, which stretches the limits of the descriptors to their maximums, to ensure that the class is capable of holding the maximum likely size of a description. This should be more than sufficient for the task but you never can tell when therell be a problem so you're best testing every thing"));
       
    89 	test.Printf(_L("Completed the testing of the comment logging\n"));
       
    90 	}
       
    91 
       
    92 GLDEF_C void doTestOutputL(CMsvBIOTestLogger& aLogger)
       
    93     {
       
    94 	test.Printf(_L("Testing the output logging\n"));
       
    95 	aLogger.LogOutputL(_L("Some output text"));
       
    96 	test.Printf(_L("Completed testing output logging\n"));
       
    97 	}
       
    98 
       
    99 GLDEF_C TInt E32Main()
       
   100     {
       
   101 	__UHEAP_MARK;
       
   102 	myCleanup = CTrapCleanup::New();
       
   103 	TRAPD(err,doMainL());           
       
   104 	test(err==KErrNone);
       
   105 	delete myCleanup;       
       
   106 	test.End();
       
   107 	test.Close();
       
   108 	__UHEAP_MARKEND;
       
   109 	return(KErrNone);
       
   110     }
       
   111 
       
   112 GLDEF_C void doMainL()
       
   113     {
       
   114 	// Create an active scheduler for the program session
       
   115     //theScheduler = new (ELeave) CTestScheduler();
       
   116     //CleanupStack::PushL(theScheduler);
       
   117     //CActiveScheduler::Install(theScheduler);
       
   118     test.Title();
       
   119     test.Printf(_L("\n"));
       
   120     test.Start(_L("Starting logger test harness"));
       
   121 	rFs.Connect();
       
   122 	TInt portAddr = 5000;
       
   123 	test.Printf(_L("Creating a logger via port address 5000"));
       
   124 	// Create a logger using a port address 
       
   125 	CMsvBIOTestLogger* myLogger = CMsvBIOTestLogger::NewL(rFs, portAddr);
       
   126 	CleanupStack::PushL(myLogger);
       
   127 	doTestEventsL(*myLogger);
       
   128 	doTestErrorsL(*myLogger);
       
   129 	doTestCommentingL(*myLogger);
       
   130 	doTestOutputL(*myLogger);
       
   131 	CleanupStack::PopAndDestroy(); //myLogger
       
   132 	test.Printf(_L("Destroying current logger"));
       
   133 	// Create a logger by passing a filename.  Replace the existing file.
       
   134 	test.Printf(_L("Creating a new logger using file name c:\\logs\\Bio\\iap.txt"));
       
   135 	myLogger = CMsvBIOTestLogger::NewL(rFs, _L("C:\\logs\\Bio\\iap.txt"),EReplace);
       
   136 	CleanupStack::PushL(myLogger);
       
   137 	doTestEventsL(*myLogger);
       
   138 	doTestErrorsL(*myLogger);
       
   139 	doTestCommentingL(*myLogger);
       
   140 	doTestOutputL(*myLogger);
       
   141 	test.Printf(_L("Destroying current logger"));
       
   142 	test.Printf(_L("Logging tests completed"));
       
   143 	CleanupStack::PopAndDestroy(); //myLogger
       
   144 
       
   145 	// Create a logger by passing a filename.  Append to the existing file.
       
   146 	myLogger = CMsvBIOTestLogger::NewL(rFs, _L("C:\\logs\\Bio\\wap.txt"),EAppend);
       
   147 	CleanupStack::PushL(myLogger);
       
   148 	doTestEventsL(*myLogger);
       
   149 	doTestErrorsL(*myLogger);
       
   150 	doTestCommentingL(*myLogger);
       
   151 	doTestOutputL(*myLogger);
       
   152 	test.Printf(_L("Destroying current logger"));
       
   153 	test.Printf(_L("Logging tests completed"));
       
   154 	CleanupStack::PopAndDestroy(); //myLogger
       
   155     rFs.Close();  
       
   156     }
       
   157