|
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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 */ |
|
19 |
|
20 #include "Te_SimPacketNotify2ThreadTest.h" |
|
21 |
|
22 CSimPacketNotify2ThreadTest::CSimPacketNotify2ThreadTest() |
|
23 { |
|
24 SetTestStepName(_L("Notify2ThreadTest")); |
|
25 } |
|
26 |
|
27 TVerdict CSimPacketNotify2ThreadTest::doTestStepL() |
|
28 { |
|
29 INFO_PRINTF1(_L("BeginPacketNotify2ThreadTest")); |
|
30 CreateConfigFileL(_L("c:\\config3.txt")); |
|
31 |
|
32 SetTestNumberL(6); |
|
33 |
|
34 const TInt KStackSize=0x8000; |
|
35 const TInt KHeapSize=0x8000; |
|
36 const TInt KMaxHeapSize=0x80000; |
|
37 |
|
38 _LIT(KGprsThreadName,"GprsThread"); |
|
39 _LIT(KRel99ThreadName,"Rel99Thread"); |
|
40 |
|
41 RThread gprs; |
|
42 RThread rel99; |
|
43 |
|
44 iGprsMutex.CreateLocal(); |
|
45 |
|
46 gprs.Create(KGprsThreadName,GprsThreadEntry, |
|
47 KStackSize,KHeapSize,KMaxHeapSize,this); |
|
48 |
|
49 rel99.Create(KRel99ThreadName,Rel99ThreadEntry, |
|
50 KStackSize,KHeapSize,KMaxHeapSize,this); |
|
51 |
|
52 //start the threads |
|
53 gprs.Resume(); |
|
54 rel99.Resume(); |
|
55 |
|
56 while (iMainFlag==EFalse) //loop until threads have finished. |
|
57 User::After(5000); |
|
58 |
|
59 iGprsMutex.Close(); |
|
60 |
|
61 gprs.Close(); |
|
62 rel99.Close(); |
|
63 return TestStepResult(); |
|
64 } |
|
65 |
|
66 TInt CSimPacketNotify2ThreadTest::GprsThreadEntry(TAny* aThreadData) |
|
67 { |
|
68 CSimPacketNotify2ThreadTest* thisptr = static_cast<CSimPacketNotify2ThreadTest*>(aThreadData); |
|
69 thisptr->GprsNotifyFunction(); |
|
70 ASSERT(RThread().RequestCount()==0); |
|
71 return(KErrNone); |
|
72 } |
|
73 |
|
74 TInt CSimPacketNotify2ThreadTest::Rel99ThreadEntry(TAny* aThreadData) |
|
75 { |
|
76 CSimPacketNotify2ThreadTest* thisptr = static_cast<CSimPacketNotify2ThreadTest*>(aThreadData); |
|
77 thisptr->Rel99NotifyFunction(); |
|
78 ASSERT(RThread().RequestCount()==0); |
|
79 return(KErrNone); |
|
80 } |
|
81 |
|
82 void CSimPacketNotify2ThreadTest::GprsNotifyFunction() |
|
83 { |
|
84 TRequestStatus gprsReqStatus; |
|
85 TRequestStatus gprsNotifyStatus; |
|
86 RTelServer gprsServer; |
|
87 RMobilePhone gprsPhone; |
|
88 |
|
89 CTrapCleanup* cleanup; |
|
90 if ((cleanup=CTrapCleanup::New())==NULL) |
|
91 return; |
|
92 |
|
93 // Open Etel |
|
94 TESTL(gprsServer.Connect()==KErrNone); |
|
95 TESTL(gprsServer.LoadPhoneModule(KSimtsyName)==KErrNone); |
|
96 |
|
97 // Open phone |
|
98 TESTL(gprsPhone.Open(gprsServer,KPhoneName)==KErrNone); |
|
99 |
|
100 // Open GPRS packet service |
|
101 TESTL(iGPRSPacketService.Open(gprsPhone)==KErrNone); |
|
102 |
|
103 // Open GPRS context |
|
104 TName gprsContextName; |
|
105 TName gprsContextNameCompare; |
|
106 TESTL(iGPRSPacketContext.OpenNewContext(iGPRSPacketService, gprsContextName)==KErrNone); |
|
107 |
|
108 iNewContextOpened = ETrue; |
|
109 |
|
110 gprsContextNameCompare.Append(KSimPrimaryPacketContextName); |
|
111 gprsContextNameCompare.AppendNum(1); |
|
112 TESTL(gprsContextName.Compare(gprsContextNameCompare)==KErrNone); |
|
113 |
|
114 // Configure GPRS context. |
|
115 RPacketContext::TContextConfigGPRS gprsContextConfig; |
|
116 TESTL(gprsContextConfig.ExtensionId()==TPacketDataConfigBase::KConfigGPRS); |
|
117 TPckg<RPacketContext::TContextConfigGPRS> contextConfigPckgGPRS(gprsContextConfig); |
|
118 gprsContextConfig.iAccessPointName = DPCKTTSY_ACCESS_POINT1; |
|
119 gprsContextConfig.iAnonymousAccessReqd = DPCKTTSY_ANONYMOUS_ACCESS1; |
|
120 gprsContextConfig.iPdpAddress = DPCKTTSY_PDP_ADDRESS1; |
|
121 gprsContextConfig.iPdpCompression = DPCKTTSY_COMPRESSION1; |
|
122 gprsContextConfig.iPdpType = DPCKTTSY_PDP_TYPE1; |
|
123 gprsContextConfig.iUseEdge = ETrue; |
|
124 gprsContextConfig.iProtocolConfigOption.iAuthInfo.iProtocol = SIM_PACKET_CONTEXT_PROTOCOL1; |
|
125 gprsContextConfig.iProtocolConfigOption.iAuthInfo.iUsername = SIM_PACKET_CONTEXT_USERNAME1; |
|
126 gprsContextConfig.iProtocolConfigOption.iAuthInfo.iPassword = SIM_PACKET_CONTEXT_PASSWORD1; |
|
127 gprsContextConfig.iProtocolConfigOption.iChallenge = SIM_PACKET_CONTEXT_CHALLENGE1; |
|
128 gprsContextConfig.iProtocolConfigOption.iResponse = SIM_PACKET_CONTEXT_RESPONSE1; |
|
129 gprsContextConfig.iProtocolConfigOption.iDnsAddresses.iPrimaryDns = SIM_PACKET_CONTEXT_PRIMARYSERVER1; |
|
130 gprsContextConfig.iProtocolConfigOption.iDnsAddresses.iSecondaryDns = SIM_PACKET_CONTEXT_SECONDARYSERVER1; |
|
131 gprsContextConfig.iProtocolConfigOption.iId = SIM_PACKET_CONTEXT_ID1; |
|
132 |
|
133 iGPRSPacketContext.NotifyConfigChanged(gprsNotifyStatus, contextConfigPckgGPRS); |
|
134 User::After(500000); |
|
135 iGprsMutex.Wait(); |
|
136 |
|
137 iGPRSPacketContext.SetConfig(gprsReqStatus, contextConfigPckgGPRS); |
|
138 User::WaitForRequest(gprsNotifyStatus); |
|
139 User::WaitForRequest(gprsReqStatus); |
|
140 iGprsMutex.Signal(); |
|
141 |
|
142 // Close |
|
143 iGPRSPacketContext.Close(); |
|
144 iGPRSPacketService.Close(); |
|
145 gprsPhone.Close(); |
|
146 gprsServer.UnloadPhoneModule(KSimtsyName); |
|
147 gprsServer.Close(); // disconnect from etel |
|
148 delete cleanup; |
|
149 iThreadFlag=ETrue;//marks that this thread has finished |
|
150 ASSERT(RThread().RequestCount()==0); |
|
151 } |
|
152 |
|
153 void CSimPacketNotify2ThreadTest::Rel99NotifyFunction() |
|
154 { |
|
155 TRequestStatus rel99ReqStatus; |
|
156 TRequestStatus rel99NotifyStatus; |
|
157 RTelServer rel99Server; |
|
158 RMobilePhone rel99Phone; |
|
159 |
|
160 CTrapCleanup* cleanup; |
|
161 if ((cleanup=CTrapCleanup::New())==NULL) |
|
162 return; |
|
163 |
|
164 // Open Etel |
|
165 TESTL(rel99Server.Connect()==KErrNone); |
|
166 TESTL(rel99Server.LoadPhoneModule(KSimtsyName)==KErrNone); |
|
167 |
|
168 // Open phone |
|
169 TESTL(rel99Phone.Open(rel99Server,KPhoneName)==KErrNone); |
|
170 // Open GPRS packet service |
|
171 TESTL(iRel99PacketService.Open(rel99Phone)==KErrNone); |
|
172 //Open Rel99 Context |
|
173 TName rel99ContextNameCompare; |
|
174 |
|
175 rel99ContextNameCompare.Append(KSimPrimaryPacketContextName); |
|
176 |
|
177 rel99ContextNameCompare.AppendNum(1); |
|
178 |
|
179 while(iNewContextOpened==EFalse) |
|
180 User::After(50000); |
|
181 |
|
182 TESTL(iRel99PacketContext.OpenExistingContext(iRel99PacketService, rel99ContextNameCompare)==KErrNone); |
|
183 |
|
184 RDebug::Print(_L("ThreadEntry9")); |
|
185 |
|
186 //Configure Rel99 Context |
|
187 RPacketContext::TContextConfigR99_R4 rel99ContextConfig; |
|
188 |
|
189 TESTL(rel99ContextConfig.ExtensionId()==TPacketDataConfigBase::KConfigRel99Rel4); |
|
190 TPckg<RPacketContext::TContextConfigR99_R4> contextConfigPckgRel99(rel99ContextConfig); |
|
191 rel99ContextConfig.iAccessPointName = DPCKTTSY_ACCESS_POINT1; |
|
192 rel99ContextConfig.iPdpAddress = DPCKTTSY_PDP_ADDRESS1; |
|
193 rel99ContextConfig.iPdpType = DPCKTTSY_PDP_TYPE1; |
|
194 rel99ContextConfig.iUseEdge = DPCKTTSY_EGPRS_REQUIRED; |
|
195 rel99ContextConfig.iProtocolConfigOption.iAuthInfo.iProtocol = SIM_PACKET_CONTEXT_PROTOCOL2; |
|
196 rel99ContextConfig.iProtocolConfigOption.iAuthInfo.iUsername = SIM_PACKET_CONTEXT_USERNAME2; |
|
197 rel99ContextConfig.iProtocolConfigOption.iAuthInfo.iPassword = SIM_PACKET_CONTEXT_PASSWORD2; |
|
198 rel99ContextConfig.iProtocolConfigOption.iChallenge = SIM_PACKET_CONTEXT_CHALLENGE2; |
|
199 rel99ContextConfig.iProtocolConfigOption.iResponse = SIM_PACKET_CONTEXT_RESPONSE2; |
|
200 rel99ContextConfig.iProtocolConfigOption.iDnsAddresses.iPrimaryDns = SIM_PACKET_CONTEXT_PRIMARYSERVER2; |
|
201 rel99ContextConfig.iProtocolConfigOption.iDnsAddresses.iSecondaryDns = SIM_PACKET_CONTEXT_SECONDARYSERVER2; |
|
202 rel99ContextConfig.iProtocolConfigOption.iId = SIM_PACKET_CONTEXT_ID2; |
|
203 |
|
204 iRel99PacketContext.NotifyConfigChanged(rel99ReqStatus, contextConfigPckgRel99); |
|
205 RDebug::Print(_L("ThreadEntry8")); |
|
206 iGprsMutex.Wait(); |
|
207 iRel99PacketContext.SetConfig(rel99ReqStatus, contextConfigPckgRel99); |
|
208 User::WaitForRequest(rel99NotifyStatus); |
|
209 User::WaitForRequest(rel99ReqStatus); |
|
210 iGprsMutex.Signal(); |
|
211 // Close |
|
212 iRel99PacketContext.Close(); |
|
213 iRel99PacketService.Close(); |
|
214 while(iThreadFlag==EFalse) //wait until the other thread has finished. |
|
215 User::After(50000); |
|
216 rel99Phone.Close(); |
|
217 rel99Server.UnloadPhoneModule(KSimtsyName); |
|
218 rel99Server.Close(); // disconnect from etel |
|
219 delete cleanup; |
|
220 iMainFlag=ETrue; //mark to say this thread (and hence the test) has finished. |
|
221 ASSERT(RThread().RequestCount()==0); |
|
222 } |
|
223 |
|
224 |