|
1 // Copyright (c) 2004-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 <mtmuids.h> |
|
17 #include "sendas2test.h" |
|
18 |
|
19 RTest test(_L("SendAs2 - MTM capability testing")); |
|
20 |
|
21 // |
|
22 |
|
23 LOCAL_C void TestMtmAvailable(RSendAs& aSendAs, CSendAsMessageTypes* aMtmList, const TDesC& aName, TBool aAvailable) |
|
24 { |
|
25 TRAPD(error, aSendAs.FilteredMessageTypesL(*aMtmList)); |
|
26 test(error == KErrNone); |
|
27 TRAP(error, aMtmList->UidFromNameL(aName)); |
|
28 if (error == KErrNone) |
|
29 { |
|
30 test(aAvailable); |
|
31 return; |
|
32 } |
|
33 test(!aAvailable); |
|
34 } |
|
35 |
|
36 LOCAL_C void TestMtmSelectionL() |
|
37 { |
|
38 // connect to sendas2 |
|
39 RSendAs sendas; |
|
40 CleanupClosePushL(sendas); |
|
41 User::LeaveIfError(sendas.Connect()); |
|
42 |
|
43 // filtered list of mtms |
|
44 CSendAsMessageTypes* mtmList = CSendAsMessageTypes::NewL(); |
|
45 CleanupStack::PushL(mtmList); |
|
46 |
|
47 // sendmtm2 cannot send |
|
48 sendas.FilteredMessageTypesL(*mtmList); |
|
49 test(mtmList->Count() >= KNumberOfTestMtmsCanSend); |
|
50 TestMtmAvailable(sendas, mtmList, KMtmName1, ETrue); |
|
51 TestMtmAvailable(sendas, mtmList, KMtmName2, EFalse); |
|
52 TestMtmAvailable(sendas, mtmList, KMtmName3, ETrue); |
|
53 TestMtmAvailable(sendas, mtmList, KMtmName4, ETrue); |
|
54 TestMtmAvailable(sendas, mtmList, KMtmName5, ETrue); |
|
55 |
|
56 // support attachments |
|
57 User::LeaveIfError(sendas.FilterAgainstCapability(KUidMtmQuerySupportAttachments)); |
|
58 sendas.FilteredMessageTypesL(*mtmList); |
|
59 test(mtmList->Count() >= 2); |
|
60 TestMtmAvailable(sendas, mtmList, KMtmName1, ETrue); |
|
61 TestMtmAvailable(sendas, mtmList, KMtmName2, EFalse); |
|
62 TestMtmAvailable(sendas, mtmList, KMtmName3, EFalse); |
|
63 TestMtmAvailable(sendas, mtmList, KMtmName4, ETrue); |
|
64 TestMtmAvailable(sendas, mtmList, KMtmName5, EFalse); |
|
65 |
|
66 // reset |
|
67 User::LeaveIfError(sendas.ResetMessageFilter()); |
|
68 sendas.FilteredMessageTypesL(*mtmList); |
|
69 test(mtmList->Count() >= KNumberOfTestMtmsCanSend); |
|
70 TestMtmAvailable(sendas, mtmList, KMtmName1, ETrue); |
|
71 TestMtmAvailable(sendas, mtmList, KMtmName2, EFalse); |
|
72 TestMtmAvailable(sendas, mtmList, KMtmName3, ETrue); |
|
73 TestMtmAvailable(sendas, mtmList, KMtmName4, ETrue); |
|
74 TestMtmAvailable(sendas, mtmList, KMtmName5, ETrue); |
|
75 |
|
76 // off line mode |
|
77 User::LeaveIfError(sendas.FilterAgainstCapability(KUidMtmQueryOffLineAllowed)); |
|
78 sendas.FilteredMessageTypesL(*mtmList); |
|
79 test(mtmList->Count() >= 3); |
|
80 TestMtmAvailable(sendas, mtmList, KMtmName1, EFalse); |
|
81 TestMtmAvailable(sendas, mtmList, KMtmName2, EFalse); |
|
82 TestMtmAvailable(sendas, mtmList, KMtmName3, ETrue); |
|
83 TestMtmAvailable(sendas, mtmList, KMtmName4, ETrue); |
|
84 TestMtmAvailable(sendas, mtmList, KMtmName5, ETrue); |
|
85 |
|
86 // reset |
|
87 User::LeaveIfError(sendas.ResetMessageFilter()); |
|
88 sendas.FilteredMessageTypesL(*mtmList); |
|
89 test(mtmList->Count() >= KNumberOfTestMtmsCanSend); |
|
90 TestMtmAvailable(sendas, mtmList, KMtmName1, ETrue); |
|
91 TestMtmAvailable(sendas, mtmList, KMtmName2, EFalse); |
|
92 TestMtmAvailable(sendas, mtmList, KMtmName3, ETrue); |
|
93 TestMtmAvailable(sendas, mtmList, KMtmName4, ETrue); |
|
94 TestMtmAvailable(sendas, mtmList, KMtmName5, ETrue); |
|
95 |
|
96 // obviously both support sending |
|
97 User::LeaveIfError(sendas.FilterAgainstCapability(KUidMtmQueryCanSendMsg)); |
|
98 sendas.FilteredMessageTypesL(*mtmList); |
|
99 test(mtmList->Count() >= KNumberOfTestMtmsCanSend); |
|
100 TestMtmAvailable(sendas, mtmList, KMtmName1, ETrue); |
|
101 TestMtmAvailable(sendas, mtmList, KMtmName2, EFalse); |
|
102 TestMtmAvailable(sendas, mtmList, KMtmName3, ETrue); |
|
103 TestMtmAvailable(sendas, mtmList, KMtmName4, ETrue); |
|
104 TestMtmAvailable(sendas, mtmList, KMtmName5, ETrue); |
|
105 |
|
106 // 0x1000 body size |
|
107 User::LeaveIfError(sendas.FilterAgainstCapability(KUidMtmQueryMaxBodySize, 0x1000, RSendAs::ESendAsGreaterThan)); |
|
108 sendas.FilteredMessageTypesL(*mtmList); |
|
109 test(mtmList->Count() >= 3); |
|
110 TestMtmAvailable(sendas, mtmList, KMtmName1, EFalse); |
|
111 TestMtmAvailable(sendas, mtmList, KMtmName2, EFalse); |
|
112 TestMtmAvailable(sendas, mtmList, KMtmName3, ETrue); |
|
113 TestMtmAvailable(sendas, mtmList, KMtmName4, ETrue); |
|
114 TestMtmAvailable(sendas, mtmList, KMtmName5, ETrue); |
|
115 |
|
116 // reset |
|
117 User::LeaveIfError(sendas.ResetMessageFilter()); |
|
118 sendas.FilteredMessageTypesL(*mtmList); |
|
119 test(mtmList->Count() >= KNumberOfTestMtmsCanSend); |
|
120 TestMtmAvailable(sendas, mtmList, KMtmName1, ETrue); |
|
121 TestMtmAvailable(sendas, mtmList, KMtmName2, EFalse); |
|
122 TestMtmAvailable(sendas, mtmList, KMtmName3, ETrue); |
|
123 TestMtmAvailable(sendas, mtmList, KMtmName4, ETrue); |
|
124 TestMtmAvailable(sendas, mtmList, KMtmName5, ETrue); |
|
125 |
|
126 // 16bit body |
|
127 User::LeaveIfError(sendas.FilterAgainstCapability(KUidMtmQuerySupportedBody, KMtm16BitBody, RSendAs::ESendAsBitwiseAnd)); |
|
128 sendas.FilteredMessageTypesL(*mtmList); |
|
129 test(mtmList->Count() >= 2); |
|
130 TestMtmAvailable(sendas, mtmList, KMtmName1, ETrue); |
|
131 TestMtmAvailable(sendas, mtmList, KMtmName2, EFalse); |
|
132 TestMtmAvailable(sendas, mtmList, KMtmName3, EFalse); |
|
133 TestMtmAvailable(sendas, mtmList, KMtmName4, EFalse); |
|
134 TestMtmAvailable(sendas, mtmList, KMtmName5, ETrue); |
|
135 |
|
136 // reset |
|
137 User::LeaveIfError(sendas.ResetMessageFilter()); |
|
138 sendas.FilteredMessageTypesL(*mtmList); |
|
139 test(mtmList->Count() >= KNumberOfTestMtmsCanSend); |
|
140 TestMtmAvailable(sendas, mtmList, KMtmName1, ETrue); |
|
141 TestMtmAvailable(sendas, mtmList, KMtmName2, EFalse); |
|
142 TestMtmAvailable(sendas, mtmList, KMtmName3, ETrue); |
|
143 TestMtmAvailable(sendas, mtmList, KMtmName4, ETrue); |
|
144 TestMtmAvailable(sendas, mtmList, KMtmName5, ETrue); |
|
145 |
|
146 // 0x1500 message size |
|
147 User::LeaveIfError(sendas.FilterAgainstCapability(KUidMtmQueryMaxTotalMsgSize, 0x1500, RSendAs::ESendAsGreaterThan)); |
|
148 sendas.FilteredMessageTypesL(*mtmList); |
|
149 test(mtmList->Count() >= 3); |
|
150 TestMtmAvailable(sendas, mtmList, KMtmName1, ETrue); |
|
151 TestMtmAvailable(sendas, mtmList, KMtmName2, EFalse); |
|
152 TestMtmAvailable(sendas, mtmList, KMtmName3, ETrue); |
|
153 TestMtmAvailable(sendas, mtmList, KMtmName4, EFalse); |
|
154 TestMtmAvailable(sendas, mtmList, KMtmName5, ETrue); |
|
155 |
|
156 // |
|
157 // recursive adding of capailities |
|
158 |
|
159 // reset |
|
160 User::LeaveIfError(sendas.ResetMessageFilter()); |
|
161 sendas.FilteredMessageTypesL(*mtmList); |
|
162 test(mtmList->Count() >= KNumberOfTestMtmsCanSend); |
|
163 TestMtmAvailable(sendas, mtmList, KMtmName1, ETrue); |
|
164 TestMtmAvailable(sendas, mtmList, KMtmName2, EFalse); |
|
165 TestMtmAvailable(sendas, mtmList, KMtmName3, ETrue); |
|
166 TestMtmAvailable(sendas, mtmList, KMtmName4, ETrue); |
|
167 TestMtmAvailable(sendas, mtmList, KMtmName5, ETrue); |
|
168 |
|
169 // 0x1500 message size |
|
170 User::LeaveIfError(sendas.FilterAgainstCapability(KUidMtmQueryMaxTotalMsgSize, 0x1500, RSendAs::ESendAsGreaterThan)); |
|
171 sendas.FilteredMessageTypesL(*mtmList); |
|
172 test(mtmList->Count() >= 3); |
|
173 TestMtmAvailable(sendas, mtmList, KMtmName1, ETrue); |
|
174 TestMtmAvailable(sendas, mtmList, KMtmName2, EFalse); |
|
175 TestMtmAvailable(sendas, mtmList, KMtmName3, ETrue); |
|
176 TestMtmAvailable(sendas, mtmList, KMtmName4, EFalse); |
|
177 TestMtmAvailable(sendas, mtmList, KMtmName5, ETrue); |
|
178 |
|
179 // 16bit body |
|
180 User::LeaveIfError(sendas.FilterAgainstCapability(KUidMtmQuerySupportedBody, KMtm16BitBody, RSendAs::ESendAsBitwiseAnd)); |
|
181 sendas.FilteredMessageTypesL(*mtmList); |
|
182 test(mtmList->Count() >= 2); |
|
183 TestMtmAvailable(sendas, mtmList, KMtmName1, ETrue); |
|
184 TestMtmAvailable(sendas, mtmList, KMtmName2, EFalse); |
|
185 TestMtmAvailable(sendas, mtmList, KMtmName3, EFalse); |
|
186 TestMtmAvailable(sendas, mtmList, KMtmName4, EFalse); |
|
187 TestMtmAvailable(sendas, mtmList, KMtmName5, ETrue); |
|
188 |
|
189 // 0x1000 body size |
|
190 User::LeaveIfError(sendas.FilterAgainstCapability(KUidMtmQueryMaxBodySize, 0x1000, RSendAs::ESendAsGreaterThan)); |
|
191 sendas.FilteredMessageTypesL(*mtmList); |
|
192 test(mtmList->Count() >= 1); |
|
193 TestMtmAvailable(sendas, mtmList, KMtmName1, EFalse); |
|
194 TestMtmAvailable(sendas, mtmList, KMtmName2, EFalse); |
|
195 TestMtmAvailable(sendas, mtmList, KMtmName3, EFalse); |
|
196 TestMtmAvailable(sendas, mtmList, KMtmName4, EFalse); |
|
197 TestMtmAvailable(sendas, mtmList, KMtmName5, ETrue); |
|
198 |
|
199 // support attachments |
|
200 User::LeaveIfError(sendas.FilterAgainstCapability(KUidMtmQuerySupportAttachments)); |
|
201 sendas.FilteredMessageTypesL(*mtmList); |
|
202 test(mtmList->Count() >= 0); |
|
203 |
|
204 // reset |
|
205 User::LeaveIfError(sendas.ResetMessageFilter()); |
|
206 sendas.FilteredMessageTypesL(*mtmList); |
|
207 test(mtmList->Count() >= KNumberOfTestMtmsCanSend); |
|
208 |
|
209 // support rendering |
|
210 User::LeaveIfError(sendas.FilterAgainstCapability(KUidMtmQuerySendAsRequiresRenderedImage, ETrue, RSendAs::ESendAsEquals)); |
|
211 sendas.FilteredMessageTypesL(*mtmList); |
|
212 test(mtmList->Count() >= 1); |
|
213 TestMtmAvailable(sendas, mtmList, KMtmName1, EFalse); |
|
214 TestMtmAvailable(sendas, mtmList, KMtmName2, EFalse); |
|
215 TestMtmAvailable(sendas, mtmList, KMtmName3, EFalse); |
|
216 TestMtmAvailable(sendas, mtmList, KMtmName4, ETrue); |
|
217 TestMtmAvailable(sendas, mtmList, KMtmName5, EFalse); |
|
218 |
|
219 // reset |
|
220 User::LeaveIfError(sendas.ResetMessageFilter()); |
|
221 sendas.FilteredMessageTypesL(*mtmList); |
|
222 test(mtmList->Count() >= KNumberOfTestMtmsCanSend); |
|
223 |
|
224 // does not support rendering |
|
225 User::LeaveIfError(sendas.FilterAgainstCapability(KUidMtmQuerySendAsRequiresRenderedImage, EFalse, RSendAs::ESendAsEquals)); |
|
226 sendas.FilteredMessageTypesL(*mtmList); |
|
227 test(mtmList->Count() >= 1); |
|
228 TestMtmAvailable(sendas, mtmList, KMtmName1, EFalse); |
|
229 TestMtmAvailable(sendas, mtmList, KMtmName2, EFalse); |
|
230 TestMtmAvailable(sendas, mtmList, KMtmName3, EFalse); |
|
231 TestMtmAvailable(sendas, mtmList, KMtmName4, EFalse); |
|
232 TestMtmAvailable(sendas, mtmList, KMtmName5, ETrue); |
|
233 |
|
234 CleanupStack::PopAndDestroy(2, &sendas); // mtmList, sendas |
|
235 } |
|
236 |
|
237 void doTestsL() |
|
238 { |
|
239 theUtils->Start(_L("Mtm capability filtering")); |
|
240 TestMtmSelectionL(); // Qualified: no leavescan error |
|
241 theUtils->Complete(); |
|
242 } |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |