|
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_SimPacketGPRSContextTest.h" |
|
21 |
|
22 CSimPacketGPRSContextTest::CSimPacketGPRSContextTest() |
|
23 { |
|
24 SetTestStepName(_L("GPRSContextTest")); |
|
25 } |
|
26 |
|
27 TVerdict CSimPacketGPRSContextTest::doTestStepL() |
|
28 { |
|
29 INFO_PRINTF1(_L("BeginPacketGPRSContextTest")); |
|
30 |
|
31 CreateConfigFileL(_L("c:\\config3.txt")); |
|
32 SetTestNumberL(6); |
|
33 |
|
34 TInt ret = iPhone.Open(iTelServer,KPhoneName); |
|
35 INFO_PRINTF2(_L("Result: %d"),ret); |
|
36 TESTL(ret == KErrNone); |
|
37 INFO_PRINTF1(_L("Opened phone object")); |
|
38 |
|
39 TESTL(iGPRSPacketService.Open(iPhone)==KErrNone); |
|
40 INFO_PRINTF1(_L("Opened Packet object")); |
|
41 |
|
42 TRequestStatus reqStatus; |
|
43 TRequestStatus notifyStatus; |
|
44 |
|
45 // test RPacketContext::OpenNewContext |
|
46 TName gprsContextName; |
|
47 TName gprsContextNameCompare; |
|
48 TESTL(iGPRSPacketContext.OpenNewContext(iGPRSPacketService, gprsContextName)==KErrNone); |
|
49 gprsContextNameCompare.Append(KSimPrimaryPacketContextName); |
|
50 gprsContextNameCompare.AppendNum(1); |
|
51 TESTL(gprsContextName.Compare(gprsContextNameCompare)==KErrNone); |
|
52 INFO_PRINTF1(_L("Opened GPRS Context object")); |
|
53 |
|
54 // GPRS |
|
55 RPacketContext::TContextConfigGPRS gprsContextConfig; |
|
56 TESTL(gprsContextConfig.ExtensionId()==TPacketDataConfigBase::KConfigGPRS); |
|
57 TPckg<RPacketContext::TContextConfigGPRS> contextConfigPckgGPRS(gprsContextConfig); |
|
58 |
|
59 RPacketContext::TContextConfigGPRS gprsContextNotify; |
|
60 TESTL(gprsContextNotify.ExtensionId()==TPacketDataConfigBase::KConfigGPRS); |
|
61 TPckg<RPacketContext::TContextConfigGPRS> contextNotifyPckgGPRS(gprsContextNotify); |
|
62 |
|
63 gprsContextConfig.iAccessPointName = DPCKTTSY_ACCESS_POINT1; |
|
64 gprsContextConfig.iAnonymousAccessReqd = DPCKTTSY_ANONYMOUS_ACCESS1; |
|
65 gprsContextConfig.iPdpAddress = DPCKTTSY_PDP_ADDRESS1; |
|
66 gprsContextConfig.iPdpCompression = DPCKTTSY_COMPRESSION1; |
|
67 gprsContextConfig.iPdpType = DPCKTTSY_PDP_TYPE1; |
|
68 gprsContextConfig.iUseEdge = DPCKTTSY_EGPRS_REQUIRED; |
|
69 gprsContextConfig.iProtocolConfigOption.iAuthInfo.iProtocol = SIM_PACKET_CONTEXT_PROTOCOL1; |
|
70 gprsContextConfig.iProtocolConfigOption.iAuthInfo.iUsername = SIM_PACKET_CONTEXT_USERNAME1; |
|
71 gprsContextConfig.iProtocolConfigOption.iAuthInfo.iPassword = SIM_PACKET_CONTEXT_PASSWORD1; |
|
72 gprsContextConfig.iProtocolConfigOption.iChallenge = SIM_PACKET_CONTEXT_CHALLENGE1; |
|
73 gprsContextConfig.iProtocolConfigOption.iResponse = SIM_PACKET_CONTEXT_RESPONSE1; |
|
74 gprsContextConfig.iProtocolConfigOption.iDnsAddresses.iPrimaryDns = SIM_PACKET_CONTEXT_PRIMARYSERVER1; |
|
75 gprsContextConfig.iProtocolConfigOption.iDnsAddresses.iSecondaryDns = SIM_PACKET_CONTEXT_SECONDARYSERVER1; |
|
76 gprsContextConfig.iProtocolConfigOption.iId = SIM_PACKET_CONTEXT_ID1; |
|
77 |
|
78 iGPRSPacketContext.NotifyConfigChanged(notifyStatus, contextNotifyPckgGPRS); |
|
79 iGPRSPacketContext.SetConfig(reqStatus, contextConfigPckgGPRS); |
|
80 |
|
81 User::WaitForRequest(notifyStatus); |
|
82 User::WaitForRequest(reqStatus); |
|
83 TESTL(reqStatus.Int()==KErrNone); |
|
84 TESTL(notifyStatus.Int()==KErrNone); |
|
85 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("E.12")); |
|
86 |
|
87 INFO_PRINTF1(_L("SetConfig GPRS test passed")); |
|
88 |
|
89 TESTL(gprsContextNotify.iAccessPointName==DPCKTTSY_ACCESS_POINT1); |
|
90 TESTL(gprsContextNotify.iAnonymousAccessReqd==DPCKTTSY_ANONYMOUS_ACCESS1); |
|
91 TESTL(gprsContextNotify.iPdpAddress==DPCKTTSY_PDP_ADDRESS1); |
|
92 TESTL(gprsContextNotify.iPdpCompression==DPCKTTSY_COMPRESSION1); |
|
93 TESTL(gprsContextNotify.iPdpType==DPCKTTSY_PDP_TYPE1); |
|
94 TESTL(gprsContextNotify.iProtocolConfigOption.iAuthInfo.iProtocol == SIM_PACKET_CONTEXT_PROTOCOL1); |
|
95 TESTL(gprsContextNotify.iProtocolConfigOption.iAuthInfo.iUsername == SIM_PACKET_CONTEXT_USERNAME1); |
|
96 TESTL(gprsContextNotify.iProtocolConfigOption.iAuthInfo.iPassword == SIM_PACKET_CONTEXT_PASSWORD1); |
|
97 TESTL(gprsContextNotify.iProtocolConfigOption.iChallenge == SIM_PACKET_CONTEXT_CHALLENGE1); |
|
98 TESTL(gprsContextNotify.iProtocolConfigOption.iResponse == SIM_PACKET_CONTEXT_RESPONSE1); |
|
99 TESTL(gprsContextNotify.iProtocolConfigOption.iDnsAddresses.iPrimaryDns == SIM_PACKET_CONTEXT_PRIMARYSERVER1); |
|
100 TESTL(gprsContextNotify.iProtocolConfigOption.iDnsAddresses.iSecondaryDns == SIM_PACKET_CONTEXT_SECONDARYSERVER1); |
|
101 TESTL(gprsContextNotify.iProtocolConfigOption.iId == SIM_PACKET_CONTEXT_ID1); |
|
102 |
|
103 INFO_PRINTF1(_L("NotifyConfigChanged GPRS Test Passed")); |
|
104 |
|
105 // now test the getting of DNS server names |
|
106 RPacketContext::TDnsInfoV2 dnsInfoV2; |
|
107 RPacketContext::TTDnsInfoV2Pckg dnsInfoV2pckg(dnsInfoV2); |
|
108 |
|
109 iGPRSPacketContext.GetDnsInfo(reqStatus, dnsInfoV2pckg); |
|
110 User::WaitForRequest(reqStatus); |
|
111 |
|
112 TESTL(dnsInfoV2.iPrimaryDns==SIM_PACKET_CONTEXT_PRIMARYSERVER1); |
|
113 TESTL(dnsInfoV2.iSecondaryDns==SIM_PACKET_CONTEXT_SECONDARYSERVER1); |
|
114 |
|
115 TESTL(reqStatus.Int()==KErrNone); |
|
116 INFO_PRINTF1(_L("GetDnsInfo Test Passed")); |
|
117 |
|
118 // test cancelling of retrieval of DNS server names |
|
119 iGPRSPacketContext.GetDnsInfo(reqStatus, dnsInfoV2pckg); |
|
120 iGPRSPacketContext.CancelAsyncRequest(EPacketContextGetDNSInfo); |
|
121 User::WaitForRequest(reqStatus); |
|
122 TESTL(reqStatus.Int()==KErrNone); |
|
123 INFO_PRINTF1(_L("GetDnsInfoCancel Test Passed")); |
|
124 |
|
125 reqStatus = KRequestPending; |
|
126 iGPRSPacketContext.SetConfig(reqStatus, contextConfigPckgGPRS); |
|
127 iGPRSPacketContext.CancelAsyncRequest(EPacketContextSetConfig); |
|
128 User::WaitForRequest(reqStatus); |
|
129 |
|
130 TESTL(reqStatus.Int()==KErrNone); //not supporting cancel of SetConfig |
|
131 |
|
132 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("E.15")); |
|
133 INFO_PRINTF1(_L("SetConfig Cancel GPRS test passed")); |
|
134 // GPRS tests finished |
|
135 |
|
136 // GetConfig - GPRS |
|
137 iGPRSPacketContext.GetConfig(reqStatus, contextConfigPckgGPRS); |
|
138 User::WaitForRequest(reqStatus); |
|
139 TESTL(reqStatus.Int()==KErrNone); |
|
140 TESTL(gprsContextConfig.iAccessPointName==DPCKTTSY_ACCESS_POINT1); |
|
141 TESTL(gprsContextConfig.iAnonymousAccessReqd==DPCKTTSY_ANONYMOUS_ACCESS1); |
|
142 TESTL(gprsContextConfig.iPdpAddress==DPCKTTSY_PDP_ADDRESS1); |
|
143 TESTL(gprsContextConfig.iPdpCompression==DPCKTTSY_COMPRESSION1); |
|
144 TESTL(gprsContextConfig.iPdpType==DPCKTTSY_PDP_TYPE1); |
|
145 TESTL(gprsContextConfig.iProtocolConfigOption.iAuthInfo.iProtocol == SIM_PACKET_CONTEXT_PROTOCOL1); |
|
146 TESTL(gprsContextConfig.iProtocolConfigOption.iAuthInfo.iUsername == SIM_PACKET_CONTEXT_USERNAME1); |
|
147 TESTL(gprsContextConfig.iProtocolConfigOption.iAuthInfo.iPassword == SIM_PACKET_CONTEXT_PASSWORD1); |
|
148 TESTL(gprsContextConfig.iProtocolConfigOption.iChallenge == SIM_PACKET_CONTEXT_CHALLENGE1); |
|
149 TESTL(gprsContextConfig.iProtocolConfigOption.iResponse == SIM_PACKET_CONTEXT_RESPONSE1); |
|
150 TESTL(gprsContextConfig.iProtocolConfigOption.iDnsAddresses.iPrimaryDns == SIM_PACKET_CONTEXT_PRIMARYSERVER1); |
|
151 TESTL(gprsContextConfig.iProtocolConfigOption.iDnsAddresses.iSecondaryDns == SIM_PACKET_CONTEXT_SECONDARYSERVER1); |
|
152 TESTL(gprsContextConfig.iProtocolConfigOption.iId == SIM_PACKET_CONTEXT_ID1); |
|
153 |
|
154 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("E.18")); |
|
155 INFO_PRINTF1(_L("GetConfig test passed")); |
|
156 |
|
157 iGPRSPacketContext.Close(); |
|
158 iGPRSPacketService.Close(); |
|
159 iPhone.Close(); |
|
160 ASSERT(RThread().RequestCount()==0); |
|
161 |
|
162 return TestStepResult(); |
|
163 } |
|
164 |