|
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_SimPacketFinalContextTest.h" |
|
21 |
|
22 CSimPacketFinalContextTest::CSimPacketFinalContextTest() |
|
23 { |
|
24 SetTestStepName(_L("FinalContextTest")); |
|
25 } |
|
26 |
|
27 TVerdict CSimPacketFinalContextTest::doTestStepL() |
|
28 { |
|
29 INFO_PRINTF1(_L("BeginPacketFinalContextTest")); |
|
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 TESTL(iPacketService.Open(iPhone)==KErrNone); |
|
39 INFO_PRINTF1(_L("Opened Packet object")); |
|
40 |
|
41 TRequestStatus reqStatus; |
|
42 |
|
43 // test RPacketContext::OpenNewContext |
|
44 TName contextName; |
|
45 TName contextNameCompare; |
|
46 TESTL(iFirstPrimaryPacketContext.OpenNewContext(iPacketService, contextName)==KErrNone); |
|
47 contextNameCompare.Append(KSimPrimaryPacketContextName); |
|
48 contextNameCompare.AppendNum(1); |
|
49 TESTL(contextName.Compare(contextNameCompare)==KErrNone); |
|
50 INFO_PRINTF1(_L("Opened Context object")); |
|
51 |
|
52 // test RPacketContext::Activate |
|
53 StartNTRasSimulation(); |
|
54 iFirstPrimaryPacketContext.Activate(reqStatus); |
|
55 User::WaitForRequest(reqStatus); |
|
56 TESTL(reqStatus.Int()==KErrNone); |
|
57 INFO_PRINTF1(_L("Activate test passed")); |
|
58 |
|
59 // test RPacketContext::InitialiseContext |
|
60 RPacketContext::TDataChannelV2 channelV2; |
|
61 RPacketContext::TDataChannelV2Pckg channelV2pckg(channelV2); |
|
62 iFirstPrimaryPacketContext.InitialiseContext(reqStatus, channelV2pckg); |
|
63 User::WaitForRequest(reqStatus); |
|
64 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("E.41")); |
|
65 |
|
66 // test RPacketContext::LoanCommPort |
|
67 RCall::TCommPort commPort; |
|
68 iFirstPrimaryPacketContext.LoanCommPort(reqStatus, commPort); |
|
69 iFirstPrimaryPacketContext.CancelAsyncRequest(EPacketContextLoanCommPort);//does nothing |
|
70 User::WaitForRequest(reqStatus); |
|
71 TESTL(commPort.iCsy==DPCKTTSY_CSY); |
|
72 TESTL(commPort.iPort==DPCKTTSY_PORT); |
|
73 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("E.23")); |
|
74 INFO_PRINTF1(_L("Loan Comm Port test passed")); |
|
75 |
|
76 _LIT8(KWriteTestData,"SIMULATOR TSY PACKET TEST"); |
|
77 _LIT(KPortName,"LOOPBACK::1"); |
|
78 _LIT(KCsyName,"LOOPBACK.CSY"); |
|
79 |
|
80 RCommServ cs; |
|
81 |
|
82 cs.Connect(); |
|
83 cs.LoadCommModule(KCsyName); |
|
84 |
|
85 RComm port; |
|
86 TESTL(port.Open(cs,KPortName,ECommShared)==KErrNone); |
|
87 |
|
88 port.Write(reqStatus,KWriteTestData); |
|
89 User::WaitForRequest(reqStatus); |
|
90 TESTL(reqStatus.Int()==KErrNone); |
|
91 |
|
92 port.Close(); |
|
93 cs.Close(); |
|
94 |
|
95 // test RPacketContext::RecoverCommPort |
|
96 iFirstPrimaryPacketContext.RecoverCommPort(reqStatus); |
|
97 iFirstPrimaryPacketContext.CancelAsyncRequest(EPacketContextRecoverCommPort); |
|
98 User::WaitForRequest(reqStatus); |
|
99 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("E.24")); |
|
100 INFO_PRINTF1(_L("Recover Comm Port test passed")); |
|
101 |
|
102 // test RPacketContext::Deactivate |
|
103 iFirstPrimaryPacketContext.Deactivate(reqStatus); |
|
104 User::WaitForRequest(reqStatus); |
|
105 CHECKPOINTL(reqStatus.Int(),KErrNone,CHP_CNTXT_CASE("E.25")); |
|
106 INFO_PRINTF1(_L("Deactivate test passed")); |
|
107 |
|
108 // test RPacketContext::Delete |
|
109 iFirstPrimaryPacketContext.Delete(reqStatus); |
|
110 iFirstPrimaryPacketContext.CancelAsyncRequest(EPacketContextDelete); |
|
111 User::WaitForRequest(reqStatus); |
|
112 if (reqStatus.Int()==KErrNone) |
|
113 { |
|
114 INFO_PRINTF1(_L("Delete request completed before its cancelation")); |
|
115 } |
|
116 else if (reqStatus.Int()==KErrCancel) |
|
117 { |
|
118 INFO_PRINTF1(_L("Delete Cancel test passed")); |
|
119 // successfully canceled, reissue the async. request again |
|
120 iFirstPrimaryPacketContext.Delete(reqStatus); |
|
121 User::WaitForRequest(reqStatus); |
|
122 } |
|
123 TESTL(reqStatus.Int()==KErrNone); |
|
124 INFO_PRINTF1(_L("Delete test passed")); |
|
125 |
|
126 // test RPacketContext::Detach |
|
127 iPacketService.Detach(reqStatus); |
|
128 User::WaitForRequest(reqStatus); |
|
129 TESTL(reqStatus==KErrNone); |
|
130 INFO_PRINTF1(_L("Packet Detach Successful")); |
|
131 |
|
132 // End of RPacketContext and RPacketService tests |
|
133 iFirstPrimaryPacketContext.Close(); |
|
134 iPacketService.Close(); |
|
135 iPhone.Close(); |
|
136 ASSERT(RThread().RequestCount()==0); |
|
137 |
|
138 return TestStepResult(); |
|
139 } |
|
140 |