|
1 // Copyright (c) 2001-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 #include "ObexHarness.h" |
|
18 #include "obextestutils.h" |
|
19 |
|
20 CObexClientTest* CObexClientTest::NewL(CObexTestUtils& aTestUtils, RTest& aTest) |
|
21 { |
|
22 CObexClientTest* self = new (ELeave) CObexClientTest(aTestUtils, aTest); |
|
23 CleanupStack::PushL(self); |
|
24 self->ConstructL(); |
|
25 CleanupStack::Pop(); // self |
|
26 return self; |
|
27 } |
|
28 |
|
29 |
|
30 CObexClientTest* CObexClientTest::NewL(CObexTestUtils* aTestUtils, RTest& aTest) |
|
31 { |
|
32 CObexClientTest* self = new (ELeave) CObexClientTest(aTestUtils, aTest); |
|
33 CleanupStack::PushL(self); |
|
34 self->ConstructL(); |
|
35 CleanupStack::Pop(); // self |
|
36 return self; |
|
37 } |
|
38 |
|
39 |
|
40 CObexClientTest::CObexClientTest(CObexTestUtils& aTestUtils, RTest& aTest) |
|
41 : CMsvClientTest(aTestUtils, aTest), |
|
42 iObexTestUtils(aTestUtils), |
|
43 iSessionReset(EFalse), |
|
44 iIgnoreSendErrors(EFalse) |
|
45 { |
|
46 iAllTestPassed = ETrue; |
|
47 } |
|
48 |
|
49 |
|
50 CObexClientTest::CObexClientTest(CObexTestUtils* aTestUtils, RTest& aTest) |
|
51 : CMsvClientTest(*aTestUtils, aTest), |
|
52 iObexTestUtils(*aTestUtils), |
|
53 iOwnedObexTestUtils(aTestUtils), |
|
54 iSessionReset(EFalse), |
|
55 iIgnoreSendErrors(EFalse) |
|
56 { |
|
57 iAllTestPassed = ETrue; |
|
58 } |
|
59 |
|
60 void CObexClientTest::ConstructL() |
|
61 { |
|
62 CMsvClientTest::ConstructL(); |
|
63 |
|
64 // Create the headers lists. |
|
65 iCurrentHeaders = CObexHeaderList::NewL(); |
|
66 iVerifyHeaders = CObexTestHeaderList::NewL(); |
|
67 } |
|
68 |
|
69 CObexClientTest::~CObexClientTest() |
|
70 { |
|
71 // All test states passed, log tests completed OK. |
|
72 if (iAllTestPassed) |
|
73 { |
|
74 ObexTestUtils().TestHarnessCompleted(); |
|
75 } |
|
76 |
|
77 delete iOwnedObexTestUtils; |
|
78 delete iSendAs; |
|
79 delete iCurrentHeaders; |
|
80 delete iVerifyHeaders; |
|
81 |
|
82 iAttachmentsList.ResetAndDestroy(); |
|
83 } |
|
84 |
|
85 void CObexClientTest::LogCommentL(const TDesC& aError) |
|
86 { |
|
87 iObexTestUtils.WriteComment(aError); |
|
88 } |
|
89 |
|
90 void CObexClientTest::Reset() |
|
91 { |
|
92 iObexTestUtils.Reset(); |
|
93 iSessionReset = ETrue; |
|
94 } |
|
95 |
|
96 /** |
|
97 * Creates the CSendAs object and its associated message. |
|
98 */ |
|
99 void CObexClientTest::CreateSendAsL() |
|
100 { |
|
101 // If a SendAs object's still around, delete it. |
|
102 if (iSendAs) |
|
103 { |
|
104 delete iSendAs; |
|
105 iSendAs = 0; |
|
106 } |
|
107 |
|
108 // create the member variable |
|
109 iSendAs = CSendAs::NewL(*this); |
|
110 |
|
111 // set it to always use the correct MTM |
|
112 iSendAs->SetMtmL(ObexTestUtils().CurrentObexMtm()); |
|
113 |
|
114 // set it to use the correct service (the only one in its array |
|
115 // of available services) |
|
116 iSendAs->SetService(0); |
|
117 |
|
118 // create the SendAs object's associated message |
|
119 iSendAs->CreateMessageL(); |
|
120 iObexTestUtils.SetEntryL(iSendAs->MessageId()); |
|
121 } |
|
122 |
|
123 |
|
124 void CObexClientTest::RunL() |
|
125 { |
|
126 CBaseTestHarness::RunL(); |
|
127 |
|
128 // Clear flag for a failed test state. |
|
129 if (iStatus.Int() != KErrNone && iStatus.Int() != KRequestPending) |
|
130 { |
|
131 iAllTestPassed = EFalse; |
|
132 } |
|
133 } |
|
134 |
|
135 void CObexClientTest::ClearCurrentHeadersL() |
|
136 { |
|
137 // To clear the headers, just delete and re-create the list, |
|
138 // the list will delete each of the headers. |
|
139 if (iCurrentHeaders) |
|
140 { |
|
141 delete iCurrentHeaders; |
|
142 iCurrentHeaders = NULL; |
|
143 |
|
144 iCurrentHeaders = CObexHeaderList::NewL(); |
|
145 } |
|
146 } |
|
147 |
|
148 void CObexClientTest::ClearVerifyHeadersL() |
|
149 { |
|
150 // To clear the headers, just delete and re-create the list, |
|
151 // the list will delete each of the headers. |
|
152 if (iVerifyHeaders) |
|
153 { |
|
154 delete iVerifyHeaders; |
|
155 iVerifyHeaders = NULL; |
|
156 |
|
157 iVerifyHeaders = CObexTestHeaderList::NewL(); |
|
158 } |
|
159 } |
|
160 |
|
161 void CObexClientTest::ReleaseCurrentHeaders() |
|
162 { |
|
163 // This must only be called after iCurrentHeaders has been handed over |
|
164 // via CurrentHeaders(). |
|
165 iCurrentHeaders = NULL; |
|
166 |
|
167 // Create a new set of headers. |
|
168 iCurrentHeaders = CObexHeaderList::NewL(); |
|
169 } |
|
170 |
|
171 |
|
172 void CObexClientTest::ClearAttachmentsL() |
|
173 { |
|
174 iAttachmentsList.ResetAndDestroy(); |
|
175 } |