|
1 // Copyright (c) 2005-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 // Contains implementation of CTestWaitStep class |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalTechnology |
|
21 */ |
|
22 |
|
23 // User Include |
|
24 #include "TestWaitStep.h" |
|
25 |
|
26 /** |
|
27 Constructor. Sets the test step name. Testserver reference passed to make use |
|
28 of TEF's method of sharing data between test steps |
|
29 @internalTechnology |
|
30 @test |
|
31 */ |
|
32 CTestWaitStep::CTestWaitStep(CTestMultipleAlarmsServer& aTestServer) |
|
33 : CTestBaseStep(aTestServer) |
|
34 { |
|
35 //Call base class method to set human readable name for test step |
|
36 SetTestStepName(KTestWaitStep); |
|
37 } |
|
38 |
|
39 /** |
|
40 Base class pure virtual. |
|
41 @return EPass or EFail indicating the result of the test step. |
|
42 @internalTechnology |
|
43 @test |
|
44 */ |
|
45 TVerdict CTestWaitStep::doTestStepL() |
|
46 { |
|
47 TInt error = KErrNone; |
|
48 TInt after = 0; |
|
49 TPtrC at(KNullDesC); |
|
50 if(ReadIntsFromConfig(ConfigSection(), &KIniAfter(), &after, NULL)) |
|
51 { |
|
52 TRAP(error, SleepAndWakeUpL(after)); |
|
53 PrintIfError(error); |
|
54 } |
|
55 else if(ReadStringsFromConfig(ConfigSection(), &KIniAt(), &at, NULL)) |
|
56 { |
|
57 TRAP(error, SleepAndWakeUpL(at)); |
|
58 PrintIfError(error); |
|
59 } |
|
60 else |
|
61 { |
|
62 IniProblem(); |
|
63 } |
|
64 return TestStepResult(); |
|
65 } |
|
66 |
|
67 /** |
|
68 Starts a timer and delays execution till it expires |
|
69 @param aAfter Minutes after which the timer must wake-up. |
|
70 YYYYMMDD:HHMMSS.MMMMMM. |
|
71 @internalTechnology |
|
72 @test |
|
73 */ |
|
74 void CTestWaitStep::SleepAndWakeUpL(const TInt& aAfter) |
|
75 { |
|
76 RTimer timer; |
|
77 TRequestStatus status; |
|
78 |
|
79 // Leave if not able to create Kernel object |
|
80 User::LeaveIfError(timer.CreateLocal()); |
|
81 // Convert minutes into microseconds and start timer |
|
82 timer.After(status, TTimeIntervalMicroSeconds32(aAfter * 60 * 1000000)); |
|
83 // Wait for timer to expire |
|
84 User::WaitForRequest(status); |
|
85 // Eat signal. Leave if something is wrong |
|
86 User::LeaveIfError(status.Int()); |
|
87 } |
|
88 |
|
89 /** |
|
90 Starts a timer and delays execution till it expires |
|
91 @param aAt Time at which the timer must wake-up. Format is |
|
92 YYYYMMDD:HHMMSS.MMMMMM. |
|
93 @internalTechnology |
|
94 @test |
|
95 */ |
|
96 void CTestWaitStep::SleepAndWakeUpL(const TDesC& aAt) |
|
97 { |
|
98 TTime time; |
|
99 RTimer timer; |
|
100 TRequestStatus status; |
|
101 |
|
102 // Leave if not able to create Kernel object |
|
103 User::LeaveIfError(timer.CreateLocal()); |
|
104 // Create TTime from string |
|
105 User::LeaveIfError(time.Set(aAt)); |
|
106 // start timer |
|
107 timer.At(status, time); |
|
108 // Wait for timer to expire |
|
109 User::WaitForRequest(status); |
|
110 // Eat signal. Leave if something is wrong |
|
111 User::LeaveIfError(status.Int()); |
|
112 } |