|
1 // Copyright (c) 2007-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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #include "sysmontesthelper.h" |
|
23 #include "sysmon_patch.h" |
|
24 |
|
25 LOCAL_C TInt MainL() |
|
26 { |
|
27 TInt runCount = 0; |
|
28 CCommandLineArguments* args = CCommandLineArguments::NewLC(); |
|
29 runCount = CSysMonTestHelper::ReadRunCountL(args->Arg(0)); |
|
30 CSysMonTestHelper::IncrementRunCountL(args->Arg(0)); |
|
31 CleanupStack::PopAndDestroy(args); |
|
32 |
|
33 TBool keepRunning = EFalse; |
|
34 |
|
35 CSysMonTestHelper* helper = NULL; |
|
36 TDateTime datetime1; |
|
37 TTime time1; |
|
38 TInt millisecs = 0; |
|
39 |
|
40 switch (runCount) |
|
41 { |
|
42 case 1: |
|
43 { |
|
44 RProcess::Rendezvous(KErrNone); |
|
45 User::After(KWaitTime); |
|
46 time1.HomeTime(); |
|
47 datetime1 = time1.DateTime(); |
|
48 millisecs = (datetime1.MicroSecond() / 1000) + |
|
49 (datetime1.Second() * 1000) + |
|
50 (datetime1.Minute() * 60 * 1000) + |
|
51 (datetime1.Hour() * 60 * 60 * 1000); |
|
52 |
|
53 helper = CSysMonTestHelper::NewLC(); |
|
54 helper->WriteResultL(millisecs); |
|
55 CleanupStack::PopAndDestroy(helper); |
|
56 break; |
|
57 } |
|
58 case 2: |
|
59 { |
|
60 RProcess::Rendezvous(KErrNone); |
|
61 time1.HomeTime(); |
|
62 datetime1 = time1.DateTime(); |
|
63 millisecs = (datetime1.MicroSecond() / 1000) + |
|
64 (datetime1.Second() * 1000) + |
|
65 (datetime1.Minute() * 60 * 1000) + |
|
66 (datetime1.Hour() * 60 * 60 * 1000); |
|
67 |
|
68 TInt secondRunTime; |
|
69 CSysMonTestHelper::GetResultIntL(_L("APPFWK-SYSMON-0038"), secondRunTime); |
|
70 CSysMonTestHelper* helper = CSysMonTestHelper::NewLC(); |
|
71 |
|
72 if ( (secondRunTime - millisecs) < 2000 ) |
|
73 { |
|
74 helper->WriteResultL(1); |
|
75 } |
|
76 else |
|
77 { |
|
78 helper->WriteResultL(0); |
|
79 } |
|
80 CleanupStack::PopAndDestroy(helper); |
|
81 keepRunning = ETrue; |
|
82 break; |
|
83 } |
|
84 default: //Run normally |
|
85 { |
|
86 RProcess::Rendezvous(KErrNone); |
|
87 keepRunning = ETrue; |
|
88 break; |
|
89 } |
|
90 } |
|
91 |
|
92 while (keepRunning) |
|
93 { |
|
94 User::After(5000000); // 5 seconds |
|
95 } |
|
96 return 0; |
|
97 } |
|
98 |
|
99 |
|
100 |
|
101 // Global Functions |
|
102 |
|
103 GLDEF_C TInt E32Main() |
|
104 { |
|
105 // Create cleanup stack |
|
106 RDebug::Print(_L("appfwk-sysmon-0038_slave: E32Main")); |
|
107 __UHEAP_MARK; |
|
108 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
109 |
|
110 // Run application code inside TRAP harness |
|
111 TRAPD(testError, MainL()); |
|
112 if (testError) |
|
113 { |
|
114 User::Panic(_L("Test failure"), testError); |
|
115 } |
|
116 |
|
117 delete cleanup; |
|
118 __UHEAP_MARKEND; |
|
119 RDebug::Print(_L("appfwk-sysmon-0038_slave: E32Main end")); |
|
120 return KErrNone; |
|
121 } //lint -e765 -e714 Suppress 'not referenced' and 'could be static' |