1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/system/t_mstim2.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,84 @@
1.4 +// Copyright (c) 1997-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 the License "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 +// e32test\system\t_mstim2.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include <e32test.h>
1.22 +#include <e32uid.h>
1.23 +#include "d_mstim.h"
1.24 +
1.25 +RTest test(_L("T_MSTIM2"));
1.26 +RMsTim mstim;
1.27 +
1.28 +TBool PauseOnError = 0;
1.29 +#define GETCH() (PauseOnError&&test.Getch())
1.30 +
1.31 +#define TEST(c) ((void)((c)||(test.Printf(_L("Failed at line %d\n"),__LINE__),GETCH(),test(0),0)))
1.32 +#define CHECK(c) ((void)(((c)==0)||(test.Printf(_L("Error %d at line %d\n"),(c),__LINE__),GETCH(),test(0),0)))
1.33 +
1.34 +const TPtrC KLddFileName=_L("D_MSTIM.LDD");
1.35 +
1.36 +GLDEF_C TInt E32Main()
1.37 +//
1.38 +// Test millisecond timers
1.39 +//
1.40 + {
1.41 +// test.SetLogged(EFalse);
1.42 + test.Title();
1.43 +
1.44 + test.Start(_L("Load test LDD"));
1.45 + TInt r=User::LoadLogicalDevice(KLddFileName);
1.46 + TEST(r==KErrNone || r==KErrAlreadyExists);
1.47 +
1.48 + r=mstim.Open();
1.49 + CHECK(r);
1.50 +
1.51 + test.Next(_L("Repeated long period timer"));
1.52 + TBool exit=EFalse;
1.53 + while(!exit)
1.54 + {
1.55 + TRequestStatus ts;
1.56 + TRequestStatus cs;
1.57 + CConsoleBase* console=test.Console();
1.58 + console->Read(cs);
1.59 + mstim.StartOneShotInt(ts,0,30000);
1.60 + FOREVER
1.61 + {
1.62 + User::WaitForRequest(cs,ts);
1.63 + if (ts!=KRequestPending)
1.64 + {
1.65 + console->ReadCancel();
1.66 + break;
1.67 + }
1.68 + if (cs!=KRequestPending)
1.69 + {
1.70 + TKeyCode k=console->KeyCode();
1.71 + if (k==EKeyEscape)
1.72 + exit=ETrue;
1.73 + else
1.74 + console->Read(cs);
1.75 + }
1.76 + }
1.77 + SMsTimerInfo info;
1.78 + r=mstim.GetInfo(0,info);
1.79 + CHECK(r);
1.80 + TEST(info.iCount==1);
1.81 + test.Printf(_L("30s timer took %dus\n"),info.iMin);
1.82 + }
1.83 + mstim.Close();
1.84 + test.End();
1.85 + return(KErrNone);
1.86 + }
1.87 +