|
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 the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "cimmobilitytestframework.h" |
|
17 #include "cimmobilitytesttls.h" |
|
18 #include "cimmobilitymanager.h" |
|
19 #include "cmsgtestpropertywatcher.h" |
|
20 #include "mobilitytestpropertyvalue.h" |
|
21 |
|
22 /** |
|
23 Creates a test framework. |
|
24 Static method. |
|
25 |
|
26 @param aServiceId Service ID of associated MTM |
|
27 @param aMobilityManager Associated mobility manager |
|
28 */ |
|
29 EXPORT_C void CImMobilityTestFramework::Create(TMsvId aServiceId, CImMobilityManager& aMobilityManager) |
|
30 { |
|
31 TRAP_IGNORE(NewL(aServiceId, aMobilityManager)); |
|
32 } |
|
33 |
|
34 /** |
|
35 Deletes a test framework. |
|
36 Static method. |
|
37 |
|
38 @param aMobilityManager Associated mobility manager |
|
39 */ |
|
40 EXPORT_C void CImMobilityTestFramework::Delete(CImMobilityManager& aMobilityManager) |
|
41 { |
|
42 CImMobilityTestTls* testTls = static_cast<CImMobilityTestTls*>(Dll::Tls()); |
|
43 |
|
44 if (testTls) |
|
45 { |
|
46 TBool lastOne = EFalse; |
|
47 CImMobilityTestFramework* framework = testTls->RemoveFramework(aMobilityManager, lastOne); |
|
48 |
|
49 if (framework) |
|
50 { |
|
51 delete framework; |
|
52 } |
|
53 |
|
54 if (lastOne) |
|
55 { |
|
56 delete testTls; |
|
57 } |
|
58 } |
|
59 } |
|
60 |
|
61 /** |
|
62 Called by an MTM when it reaches a specific operation state. |
|
63 Static method. |
|
64 |
|
65 @param aServiceId Service ID of MTM |
|
66 @param aMtmState MTM state |
|
67 */ |
|
68 EXPORT_C void CImMobilityTestFramework::MtmState(TMsvId aServiceId, TImMobilityTestMtmState aMtmState) |
|
69 { |
|
70 CImMobilityTestTls* testTls = static_cast<CImMobilityTestTls*>(Dll::Tls()); |
|
71 |
|
72 if (testTls) |
|
73 { |
|
74 CImMobilityTestFramework* framework = testTls->GetFramework(aServiceId); |
|
75 if (framework) |
|
76 { |
|
77 // Flag the call |
|
78 RProperty& property = framework->iPropertyWatcher->Property(); |
|
79 property.Set(aMtmState); |
|
80 } |
|
81 } |
|
82 } |
|
83 |
|
84 /** |
|
85 Called by the net test stub to determine the service id. |
|
86 Static method. |
|
87 |
|
88 @param aProtocol reference to MMobilityProtocolResp |
|
89 */ |
|
90 EXPORT_C TMsvId CImMobilityTestFramework::GetServiceId(MMobilityProtocolResp& aProtocol) |
|
91 { |
|
92 CImMobilityTestTls* testTls = static_cast<CImMobilityTestTls*>(Dll::Tls()); |
|
93 |
|
94 if (testTls) |
|
95 { |
|
96 CImMobilityTestFramework* framework = testTls->GetFramework(aProtocol); |
|
97 if (framework) |
|
98 { |
|
99 return framework->ServiceId(); |
|
100 } |
|
101 } |
|
102 |
|
103 return KErrNotFound; |
|
104 } |
|
105 |
|
106 /** |
|
107 Factory constructor. |
|
108 Static method. |
|
109 |
|
110 @param aServiceId Service ID of associated MTM |
|
111 @param aMobilityManager Associated mobility manager |
|
112 */ |
|
113 void CImMobilityTestFramework::NewL(TMsvId aServiceId, CImMobilityManager& aMobilityManager) |
|
114 { |
|
115 CImMobilityTestTls* testTls = CImMobilityTestTls::NewL(); |
|
116 |
|
117 CImMobilityTestFramework* self = new (ELeave) CImMobilityTestFramework(aServiceId, aMobilityManager); |
|
118 CleanupStack::PushL(self); |
|
119 self->ConstructL(); |
|
120 CleanupStack::Pop(self); |
|
121 // Store framework. Ownership is passed. |
|
122 testTls->AddFrameworkL(*self); |
|
123 } |
|
124 |
|
125 /** |
|
126 Class constructor. |
|
127 |
|
128 @param aServiceId Service ID of associated MTM |
|
129 @param aMobilityManager Associated mobility manager |
|
130 */ |
|
131 CImMobilityTestFramework::CImMobilityTestFramework(TMsvId aServiceId, CImMobilityManager& aMobilityManager) : |
|
132 iMobilityManager(aMobilityManager), |
|
133 iServiceId(aServiceId) |
|
134 { |
|
135 } |
|
136 |
|
137 /** |
|
138 Second phase constructor |
|
139 */ |
|
140 void CImMobilityTestFramework::ConstructL() |
|
141 { |
|
142 iPropertyWatcher = CMsgTestPropertyWatcher::NewL(KPropertyCatMsgTestUtilityServer2, EMyPropertyCounter, *this); |
|
143 } |
|
144 |
|
145 /** |
|
146 Class destructor |
|
147 */ |
|
148 CImMobilityTestFramework::~CImMobilityTestFramework() |
|
149 { |
|
150 delete iPropertyWatcher; |
|
151 } |
|
152 |
|
153 /** |
|
154 Returns service ID of associated MTM |
|
155 |
|
156 @return Service ID of MTM |
|
157 */ |
|
158 TMsvId CImMobilityTestFramework::ServiceId() |
|
159 { |
|
160 return iServiceId; |
|
161 } |
|
162 |
|
163 /** |
|
164 Returns associated mobility maanger |
|
165 |
|
166 @return Mobility manager |
|
167 */ |
|
168 CImMobilityManager& CImMobilityTestFramework::MobilityManager() |
|
169 { |
|
170 return iMobilityManager; |
|
171 } |
|
172 |
|
173 void CImMobilityTestFramework::HandleEventL(RProperty& /*aProperty*/, TUint /*aKey*/) |
|
174 { |
|
175 //Don't need to respond to events here. |
|
176 } |