os/kernelhwsrv/kerneltest/e32test/system/t_mstim2.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 1997-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 the License "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 // e32test\system\t_mstim2.cpp
    15 // 
    16 //
    17 
    18 #include <e32test.h>
    19 #include <e32uid.h>
    20 #include "d_mstim.h"
    21 
    22 RTest test(_L("T_MSTIM2"));
    23 RMsTim mstim;
    24 
    25 TBool PauseOnError = 0;
    26 #define GETCH()		(PauseOnError&&test.Getch())
    27 
    28 #define TEST(c)		((void)((c)||(test.Printf(_L("Failed at line %d\n"),__LINE__),GETCH(),test(0),0)))
    29 #define CHECK(c)	((void)(((c)==0)||(test.Printf(_L("Error %d at line %d\n"),(c),__LINE__),GETCH(),test(0),0)))
    30 
    31 const TPtrC KLddFileName=_L("D_MSTIM.LDD");
    32 
    33 GLDEF_C TInt E32Main()
    34 //
    35 // Test millisecond timers
    36 //
    37     {
    38 //	test.SetLogged(EFalse);
    39 	test.Title();
    40 
    41 	test.Start(_L("Load test LDD"));
    42 	TInt r=User::LoadLogicalDevice(KLddFileName);
    43 	TEST(r==KErrNone || r==KErrAlreadyExists);
    44 	
    45 	r=mstim.Open();
    46 	CHECK(r);
    47 
    48 	test.Next(_L("Repeated long period timer"));
    49 	TBool exit=EFalse;
    50 	while(!exit)
    51 		{
    52 		TRequestStatus ts;
    53 		TRequestStatus cs;
    54 		CConsoleBase* console=test.Console();
    55 		console->Read(cs);
    56 		mstim.StartOneShotInt(ts,0,30000);
    57 		FOREVER
    58 			{
    59 			User::WaitForRequest(cs,ts);
    60 			if (ts!=KRequestPending)
    61 				{
    62 				console->ReadCancel();
    63 				break;
    64 				}
    65 			if (cs!=KRequestPending)
    66 				{
    67 				TKeyCode k=console->KeyCode();
    68 				if (k==EKeyEscape)
    69 					exit=ETrue;
    70 				else
    71 					console->Read(cs);
    72 				}
    73 			}
    74 		SMsTimerInfo info;
    75 		r=mstim.GetInfo(0,info);
    76 		CHECK(r);
    77 		TEST(info.iCount==1);
    78 		test.Printf(_L("30s timer took %dus\n"),info.iMin);
    79 		}
    80 	mstim.Close();
    81 	test.End();
    82 	return(KErrNone);
    83     }
    84