sl@0
|
1 |
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32test\system\t_mstim2.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <e32test.h>
|
sl@0
|
19 |
#include <e32uid.h>
|
sl@0
|
20 |
#include "d_mstim.h"
|
sl@0
|
21 |
|
sl@0
|
22 |
RTest test(_L("T_MSTIM2"));
|
sl@0
|
23 |
RMsTim mstim;
|
sl@0
|
24 |
|
sl@0
|
25 |
TBool PauseOnError = 0;
|
sl@0
|
26 |
#define GETCH() (PauseOnError&&test.Getch())
|
sl@0
|
27 |
|
sl@0
|
28 |
#define TEST(c) ((void)((c)||(test.Printf(_L("Failed at line %d\n"),__LINE__),GETCH(),test(0),0)))
|
sl@0
|
29 |
#define CHECK(c) ((void)(((c)==0)||(test.Printf(_L("Error %d at line %d\n"),(c),__LINE__),GETCH(),test(0),0)))
|
sl@0
|
30 |
|
sl@0
|
31 |
const TPtrC KLddFileName=_L("D_MSTIM.LDD");
|
sl@0
|
32 |
|
sl@0
|
33 |
GLDEF_C TInt E32Main()
|
sl@0
|
34 |
//
|
sl@0
|
35 |
// Test millisecond timers
|
sl@0
|
36 |
//
|
sl@0
|
37 |
{
|
sl@0
|
38 |
// test.SetLogged(EFalse);
|
sl@0
|
39 |
test.Title();
|
sl@0
|
40 |
|
sl@0
|
41 |
test.Start(_L("Load test LDD"));
|
sl@0
|
42 |
TInt r=User::LoadLogicalDevice(KLddFileName);
|
sl@0
|
43 |
TEST(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
44 |
|
sl@0
|
45 |
r=mstim.Open();
|
sl@0
|
46 |
CHECK(r);
|
sl@0
|
47 |
|
sl@0
|
48 |
test.Next(_L("Repeated long period timer"));
|
sl@0
|
49 |
TBool exit=EFalse;
|
sl@0
|
50 |
while(!exit)
|
sl@0
|
51 |
{
|
sl@0
|
52 |
TRequestStatus ts;
|
sl@0
|
53 |
TRequestStatus cs;
|
sl@0
|
54 |
CConsoleBase* console=test.Console();
|
sl@0
|
55 |
console->Read(cs);
|
sl@0
|
56 |
mstim.StartOneShotInt(ts,0,30000);
|
sl@0
|
57 |
FOREVER
|
sl@0
|
58 |
{
|
sl@0
|
59 |
User::WaitForRequest(cs,ts);
|
sl@0
|
60 |
if (ts!=KRequestPending)
|
sl@0
|
61 |
{
|
sl@0
|
62 |
console->ReadCancel();
|
sl@0
|
63 |
break;
|
sl@0
|
64 |
}
|
sl@0
|
65 |
if (cs!=KRequestPending)
|
sl@0
|
66 |
{
|
sl@0
|
67 |
TKeyCode k=console->KeyCode();
|
sl@0
|
68 |
if (k==EKeyEscape)
|
sl@0
|
69 |
exit=ETrue;
|
sl@0
|
70 |
else
|
sl@0
|
71 |
console->Read(cs);
|
sl@0
|
72 |
}
|
sl@0
|
73 |
}
|
sl@0
|
74 |
SMsTimerInfo info;
|
sl@0
|
75 |
r=mstim.GetInfo(0,info);
|
sl@0
|
76 |
CHECK(r);
|
sl@0
|
77 |
TEST(info.iCount==1);
|
sl@0
|
78 |
test.Printf(_L("30s timer took %dus\n"),info.iMin);
|
sl@0
|
79 |
}
|
sl@0
|
80 |
mstim.Close();
|
sl@0
|
81 |
test.End();
|
sl@0
|
82 |
return(KErrNone);
|
sl@0
|
83 |
}
|
sl@0
|
84 |
|