|
1 // Copyright (c) 2004-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 // Telephony Watchers Integration Test base test code. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 */ |
|
21 |
|
22 |
|
23 #include <e32uid.h> |
|
24 #include <simtsy.h> |
|
25 |
|
26 |
|
27 #include "TE_TelWatchersIntBase.h" |
|
28 |
|
29 |
|
30 const TInt KTsyShutdownGuardTimer = 500000; |
|
31 |
|
32 CTelWatchersIntTestStep::CTelWatchersIntTestStep() |
|
33 { |
|
34 // NOP |
|
35 } // CTelWatchersIntTestStep::CTelWatchersIntTestStep |
|
36 |
|
37 |
|
38 CTelWatchersIntTestStep::~CTelWatchersIntTestStep() |
|
39 { |
|
40 // NOP |
|
41 } // CTelWatchersIntTestStep::~CTelWatchersIntTestStep |
|
42 |
|
43 |
|
44 TVerdict CTelWatchersIntTestStep::doTestStepPreambleL() |
|
45 { |
|
46 // |
|
47 // Mark for memory leaks!!! |
|
48 // |
|
49 __UHEAP_MARK; |
|
50 |
|
51 // |
|
52 // Create an Active Scheduler... |
|
53 // |
|
54 iScheduler = new(ELeave) CActiveScheduler(); |
|
55 CActiveScheduler::Install(iScheduler); |
|
56 |
|
57 // |
|
58 // Initialise to a known state... |
|
59 // |
|
60 StartWatcher(); |
|
61 |
|
62 return TestStepResult(); |
|
63 } // CTelWatchersIntTestStep::doTestStepPreambleL |
|
64 |
|
65 |
|
66 TVerdict CTelWatchersIntTestStep::doTestStepPostambleL() |
|
67 { |
|
68 // |
|
69 // Ensure the Watcher is stopped so future tests can continue past |
|
70 // failures... |
|
71 // |
|
72 StopWatcher(); |
|
73 |
|
74 delete iScheduler; |
|
75 iScheduler = NULL; |
|
76 |
|
77 // |
|
78 // Check the heap for memory leaks... |
|
79 // |
|
80 __UHEAP_MARKEND; |
|
81 |
|
82 return TestStepResult(); |
|
83 } // CTelWatchersIntTestStep::doTestStepPostambleL |
|
84 |
|
85 |
|
86 /** |
|
87 * Start the Watcher. |
|
88 */ |
|
89 void CTelWatchersIntTestStep::StartWatcher() |
|
90 { |
|
91 INFO_PRINTF1(_L("Start the Watchers...")); |
|
92 |
|
93 if (iWatcherExeRunning == EFalse) |
|
94 { |
|
95 // |
|
96 // We can no longer move the watcher.exe after sysbin platform security enforcement |
|
97 // so the alternative method is to prevent the watchers from starting, in this case |
|
98 // we can start watchers from system/bin without worry, older builds still require z: |
|
99 TInt ret = iWatcherExe.Create(_L("z:\\watcher.exe"), _L("")); |
|
100 if (ret == KErrNotFound) |
|
101 { |
|
102 ret = iWatcherExe.Create(_L("watcher.exe"), _L("")); |
|
103 if (ret == KErrNotFound) |
|
104 { |
|
105 ret = iWatcherExe.Create(_L("z:\\System\\libs\\watcher.exe"), _L("")); |
|
106 } |
|
107 } |
|
108 |
|
109 INFO_PRINTF2(_L("Create watcher exe returned %d"), ret); |
|
110 iWatcherExe.Logon(iWatcherExeStatus); |
|
111 iWatcherExe.Resume(); |
|
112 iWatcherExeRunning = ETrue; |
|
113 } |
|
114 } // CTelWatchersIntTestStep::StartWatcher |
|
115 |
|
116 |
|
117 /** |
|
118 * Stop the Watchers. |
|
119 */ |
|
120 void CTelWatchersIntTestStep::StopWatcher() |
|
121 { |
|
122 INFO_PRINTF1(_L("Stop the Watchers...")); |
|
123 |
|
124 // |
|
125 // This is needed to ensure if ETel panics a dead client thread - that |
|
126 // the test code contines. |
|
127 // |
|
128 TBool oldJustInTimeStatus = User::JustInTime(); |
|
129 |
|
130 User::SetJustInTime(EFalse); |
|
131 |
|
132 // |
|
133 // Stop the watchers... |
|
134 // |
|
135 if (iWatcherExeRunning) |
|
136 { |
|
137 iWatcherExe.Kill(KErrAbort); |
|
138 User::WaitForRequest(iWatcherExeStatus); |
|
139 iWatcherExeRunning = EFalse; |
|
140 } |
|
141 User::After(KTsyShutdownGuardTimer); |
|
142 |
|
143 // |
|
144 // Reset the Just-In-Time debugging value. |
|
145 // |
|
146 User::SetJustInTime(oldJustInTimeStatus); |
|
147 } // CTelWatchersIntTestStep::StopWatcher |
|
148 |
|
149 |
|
150 /** |
|
151 * Set the test number given by the parameter aTestNumber. The test number |
|
152 * indicates which section in the config.txt file should be used. |
|
153 * |
|
154 * @param aTestNumber The test number section within the config.txt file |
|
155 * that should be used. |
|
156 */ |
|
157 void CTelWatchersIntTestStep::SetSimTsyTestNumberL(TInt aTestNumber) |
|
158 { |
|
159 INFO_PRINTF2(_L("Setting SIMTSY config to number %d..."), aTestNumber); |
|
160 |
|
161 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory,KPSSimTsyTestNumber,aTestNumber)); |
|
162 } // CTelWatchersIntTestStep::SetSimTsyTestNumberL |
|
163 |
|
164 void CTelWatchersIntTestStep::CheckSimTsyTestNumberL(TInt aTestNumber) |
|
165 { |
|
166 INFO_PRINTF2(_L("Checking SIMTSY config number to be %d..."), aTestNumber); |
|
167 |
|
168 // Ensure that the test number has been set properly |
|
169 RProperty testNumberInUseProperty; |
|
170 User::LeaveIfError(testNumberInUseProperty.Attach(KUidPSSimTsyCategory, KPSSimTsyTestNumberInUse)); |
|
171 CleanupClosePushL(testNumberInUseProperty); |
|
172 |
|
173 TInt testNumberInUseCheck; |
|
174 User::LeaveIfError(testNumberInUseProperty.Get(KUidPSSimTsyCategory, KPSSimTsyTestNumberInUse,testNumberInUseCheck)); |
|
175 if (aTestNumber != testNumberInUseCheck) |
|
176 { |
|
177 INFO_PRINTF2(_L("Incorrect SIMTSY config number (%d)..."), testNumberInUseCheck); |
|
178 User::Leave(KErrNotFound); |
|
179 } |
|
180 |
|
181 CleanupStack::PopAndDestroy(&testNumberInUseProperty); |
|
182 } // CTelWatchersIntTestStep::CheckSimTsyTestNumberL |