toolsandutils/autotest/Test/th1.cpp
changeset 0 83f4b4db085c
child 1 d4b442d23379
equal deleted inserted replaced
-1:000000000000 0:83f4b4db085c
       
     1 // Copyright (c) 2000-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 // AUTOTEST.CPP
       
    15 // Demonstration code for the use of Autotest.Dll.
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file Th1.cpp
       
    21 */
       
    22 
       
    23 #include <e32std.h>
       
    24 // Autotest library header file
       
    25 #include <autotest.h>
       
    26 
       
    27 // Initialise an RTest instance
       
    28 // Autotest construction expects one
       
    29 _LIT(KTestTitle,"Test Harness");
       
    30 LOCAL_C RTest Test(KTestTitle);
       
    31 
       
    32 LOCAL_C TInt ApiCall1()
       
    33 // Function to represent an API call
       
    34 	{
       
    35 	// Do nothing but return ok
       
    36 	return KErrNone;
       
    37 	}
       
    38 
       
    39 LOCAL_C TInt ApiCall2()
       
    40 // Function to represent an API call
       
    41 	{
       
    42 	// Do nothing but return an error to demonstrate error handling
       
    43 	return KErrGeneral;
       
    44 	}
       
    45 
       
    46 LOCAL_C void Tests1L()
       
    47 // Function that calls one or more API calls
       
    48 	{
       
    49 	_LIT(KStartMessage,"Begin Test 1");
       
    50 	Test.Start(KStartMessage);
       
    51 	User::LeaveIfError(ApiCall1());
       
    52 	_LIT(KNext1,"API Call 1 Ok");
       
    53 	Test.Next(KNext1);
       
    54 	Test.End();
       
    55 	}
       
    56 
       
    57 LOCAL_C void Tests2L()
       
    58 // Function that calls one or more API calls
       
    59 	{
       
    60 	_LIT(KStartMessage,"Begin Test 2");
       
    61 	Test.Start(KStartMessage);
       
    62 	User::LeaveIfError(ApiCall2());
       
    63 	_LIT(KNext2,"API Call 2 Ok");
       
    64 	Test.Next(KNext2);
       
    65 	Test.End();
       
    66 	}
       
    67 // Set up the array of test functions, which make the API calls
       
    68 LOCAL_C const TAutoTestCase Cases[2] =
       
    69 	{
       
    70 	{Tests1L,_S("Test One")},
       
    71 	{Tests2L,_S("Test Two")}
       
    72 	};
       
    73 
       
    74 LOCAL_C void MainL()
       
    75 	{
       
    76 	Test.Title();
       
    77 	Test.SetLogged(EFalse);
       
    78 
       
    79 	_LIT(KDummyTests,"Dummy Tests.Txt");
       
    80 	_LIT8(KComponentInfo,"Dummy Test - xxx");
       
    81 	// Library defined macro
       
    82 	AUTOTEST_EXECUTE(Cases,KDummyTests,KComponentInfo,Test);
       
    83 
       
    84 	Test.Close();
       
    85 	}
       
    86 
       
    87 GLDEF_C TInt E32Main()
       
    88     {
       
    89 	__UHEAP_MARK;
       
    90 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    91 	if(cleanup == NULL)
       
    92 		{
       
    93 		return KErrNoMemory;
       
    94 		}
       
    95 	TRAPD(err,MainL());
       
    96 	_LIT(KPanic,"Th1");
       
    97 	__ASSERT_ALWAYS(!err, User::Panic(KPanic,err));
       
    98 	delete cleanup;
       
    99 	__UHEAP_MARKEND;
       
   100 	return KErrNone;
       
   101     }
       
   102 //