|
1 // Copyright (c) 2002-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 #include "OomTests.h" |
|
17 #include "CStubbedAgent.h" |
|
18 #include "DbAccess.h" |
|
19 #include "NetConLog.h" |
|
20 |
|
21 // |
|
22 // Test Case NC-5-1 |
|
23 // |
|
24 |
|
25 CNetConTest0501* CNetConTest0501::NewLC() |
|
26 { |
|
27 |
|
28 CNetConTest0501* self = new(ELeave) CNetConTest0501(); |
|
29 CleanupStack::PushL(self); |
|
30 self->ConstructL(); |
|
31 return self; |
|
32 } |
|
33 |
|
34 CNetConTest0501::CNetConTest0501() |
|
35 {} |
|
36 |
|
37 CNetConTest0501::~CNetConTest0501() |
|
38 {} |
|
39 |
|
40 const TDesC& CNetConTest0501::Name() const |
|
41 { |
|
42 |
|
43 _LIT(KTestName, "Test Case NC-5-1"); |
|
44 return KTestName(); |
|
45 } |
|
46 |
|
47 void CNetConTest0501::StartTestL() |
|
48 { |
|
49 |
|
50 iNetCon->SelectAgent(this, NULL, EConnStartExplicit, 1, KErrNone); |
|
51 } |
|
52 |
|
53 void CNetConTest0501::SelectComplete(const TDesC&) |
|
54 { |
|
55 |
|
56 CleanupAgent(); |
|
57 |
|
58 CompleteTest(MNetConTest::EPassed); |
|
59 } |
|
60 |
|
61 void CNetConTest0501::SelectComplete(TInt) |
|
62 { |
|
63 |
|
64 CleanupAgent(); |
|
65 |
|
66 CompleteTest(MNetConTest::EFailed); |
|
67 } |
|
68 |
|
69 void CNetConTest0501::CleanupAgent() |
|
70 // |
|
71 // Free agent allocated in dummy Nif class |
|
72 // (normally this would be done by Nifman) |
|
73 // |
|
74 { |
|
75 |
|
76 CNetwork* network; |
|
77 TInt ret = iNetCon->FindNetworkById(1, network); |
|
78 if(ret==KErrNone) |
|
79 { |
|
80 CNifAgentBase* agent; |
|
81 ret = network->FindAgentByIap(1, agent); |
|
82 if(ret==KErrNone) |
|
83 { |
|
84 LOG( NetConLog::Printf(_L("CleanupAgent() deleting agent at [0x%08x]"), agent); ) |
|
85 |
|
86 CleanupStack::PopAndDestroy(); // CStubbedAgent allocated by Nif::CreateAgent() |
|
87 } |
|
88 } |
|
89 } |
|
90 |
|
91 |
|
92 // |
|
93 // Test Case NC-5-2 |
|
94 // |
|
95 |
|
96 CNetConTest0502* CNetConTest0502::NewLC() |
|
97 { |
|
98 |
|
99 CNetConTest0502* self = new(ELeave) CNetConTest0502(); |
|
100 CleanupStack::PushL(self); |
|
101 self->ConstructL(); |
|
102 return self; |
|
103 } |
|
104 |
|
105 CNetConTest0502::CNetConTest0502() |
|
106 {} |
|
107 |
|
108 void CNetConTest0502::ConstructL() |
|
109 { |
|
110 |
|
111 COomTestBase::ConstructL(); |
|
112 |
|
113 iDatabase = CCommsDbAccess::NewL(); |
|
114 iAgent = new(ELeave) CStubbedAgent(); |
|
115 } |
|
116 |
|
117 CNetConTest0502::~CNetConTest0502() |
|
118 { |
|
119 |
|
120 if(iAgent) |
|
121 delete iAgent; |
|
122 |
|
123 if(iDatabase) |
|
124 delete iDatabase; |
|
125 } |
|
126 |
|
127 const TDesC& CNetConTest0502::Name() const |
|
128 { |
|
129 |
|
130 _LIT(KTestName, "Test Case NC-5-2"); |
|
131 return KTestName(); |
|
132 } |
|
133 |
|
134 void CNetConTest0502::StartTestL() |
|
135 { |
|
136 |
|
137 // setup agent's connection settings |
|
138 TConnectionSettings settings; |
|
139 iDatabase->GetCurrentSettingsL(settings, ECommDbConnectionDirectionOutgoing, 1); |
|
140 iAgent->SetConnectionSettingsL(settings); |
|
141 |
|
142 iNetCon->Reconnect(this, iAgent); |
|
143 } |
|
144 |
|
145 void CNetConTest0502::ReconnectComplete(TInt aError) |
|
146 { |
|
147 |
|
148 if(aError == KErrNone) |
|
149 CompleteTest(MNetConTest::EPassed); |
|
150 else |
|
151 CompleteTest(MNetConTest::EFailed); |
|
152 } |
|
153 |