sl@0: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\system\t_mstim2.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include "d_mstim.h" sl@0: sl@0: RTest test(_L("T_MSTIM2")); sl@0: RMsTim mstim; sl@0: sl@0: TBool PauseOnError = 0; sl@0: #define GETCH() (PauseOnError&&test.Getch()) sl@0: sl@0: #define TEST(c) ((void)((c)||(test.Printf(_L("Failed at line %d\n"),__LINE__),GETCH(),test(0),0))) sl@0: #define CHECK(c) ((void)(((c)==0)||(test.Printf(_L("Error %d at line %d\n"),(c),__LINE__),GETCH(),test(0),0))) sl@0: sl@0: const TPtrC KLddFileName=_L("D_MSTIM.LDD"); sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: // sl@0: // Test millisecond timers sl@0: // sl@0: { sl@0: // test.SetLogged(EFalse); sl@0: test.Title(); sl@0: sl@0: test.Start(_L("Load test LDD")); sl@0: TInt r=User::LoadLogicalDevice(KLddFileName); sl@0: TEST(r==KErrNone || r==KErrAlreadyExists); sl@0: sl@0: r=mstim.Open(); sl@0: CHECK(r); sl@0: sl@0: test.Next(_L("Repeated long period timer")); sl@0: TBool exit=EFalse; sl@0: while(!exit) sl@0: { sl@0: TRequestStatus ts; sl@0: TRequestStatus cs; sl@0: CConsoleBase* console=test.Console(); sl@0: console->Read(cs); sl@0: mstim.StartOneShotInt(ts,0,30000); sl@0: FOREVER sl@0: { sl@0: User::WaitForRequest(cs,ts); sl@0: if (ts!=KRequestPending) sl@0: { sl@0: console->ReadCancel(); sl@0: break; sl@0: } sl@0: if (cs!=KRequestPending) sl@0: { sl@0: TKeyCode k=console->KeyCode(); sl@0: if (k==EKeyEscape) sl@0: exit=ETrue; sl@0: else sl@0: console->Read(cs); sl@0: } sl@0: } sl@0: SMsTimerInfo info; sl@0: r=mstim.GetInfo(0,info); sl@0: CHECK(r); sl@0: TEST(info.iCount==1); sl@0: test.Printf(_L("30s timer took %dus\n"),info.iMin); sl@0: } sl@0: mstim.Close(); sl@0: test.End(); sl@0: return(KErrNone); sl@0: } sl@0: