|
1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: EUnit unit test class for CAiStateProvider |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <e32base.h> |
|
20 #include <e32cmn.h> |
|
21 #include <digia/eunit/eunitmacros.h> |
|
22 #include <digia/eunit/teunitassertioninfo.h> |
|
23 #include <liwservicehandler.h> |
|
24 |
|
25 // User includes |
|
26 #include "ut_aicpsexecuteparam.h" |
|
27 |
|
28 #include "aicpsexecuteparam.h" |
|
29 |
|
30 // Constants |
|
31 _LIT8( KPublisherId, "publisher" ); |
|
32 _LIT8( KContentType, "content_type" ); |
|
33 _LIT8( KContentId, "content_id" ); |
|
34 _LIT( KWRTPublisher, "wrt_publisher"); |
|
35 _LIT( KTemplateWidget,"ai3templatedwidget"); |
|
36 _LIT( KContentIdValue, "com.accuweather.widget.touchNG" ); |
|
37 _LIT8( KAction, "active" ); |
|
38 _LIT( KAction16, "active" ); |
|
39 _LIT( KPubData, "publisher" ); |
|
40 _LIT8( KFilter, "filter" ); |
|
41 _LIT8( KActionTrigger, "action_trigger" ); |
|
42 _LIT8( KType, "type"); |
|
43 |
|
44 // ======== LOCAL FUNCTIONS ======== |
|
45 |
|
46 // ======== MEMBER FUNCTIONS ======= |
|
47 // ---------------------------------------------------------------------------- |
|
48 // UT_AiCpsExecuteParam::NewL() |
|
49 // |
|
50 // ---------------------------------------------------------------------------- |
|
51 // |
|
52 UT_AiCpsExecuteParam* UT_AiCpsExecuteParam::NewL() |
|
53 { |
|
54 UT_AiCpsExecuteParam* self = UT_AiCpsExecuteParam::NewLC(); |
|
55 CleanupStack::Pop( self ); |
|
56 return self; |
|
57 } |
|
58 |
|
59 // ---------------------------------------------------------------------------- |
|
60 // UT_AiCpsExecuteParam::NewLC() |
|
61 // |
|
62 // ---------------------------------------------------------------------------- |
|
63 // |
|
64 UT_AiCpsExecuteParam* UT_AiCpsExecuteParam::NewLC() |
|
65 { |
|
66 UT_AiCpsExecuteParam* self = new ( ELeave ) UT_AiCpsExecuteParam(); |
|
67 CleanupStack::PushL( self ); |
|
68 self->ConstructL(); |
|
69 return self; |
|
70 } |
|
71 |
|
72 // ---------------------------------------------------------------------------- |
|
73 // UT_AiCpsExecuteParam::~UT_AiCpsExecuteParam() |
|
74 // |
|
75 // ---------------------------------------------------------------------------- |
|
76 // |
|
77 UT_AiCpsExecuteParam::~UT_AiCpsExecuteParam() |
|
78 { |
|
79 } |
|
80 |
|
81 // ---------------------------------------------------------------------------- |
|
82 // UT_AiCpsExecuteParam::UT_AiCpsExecuteParam() |
|
83 // |
|
84 // ---------------------------------------------------------------------------- |
|
85 // |
|
86 UT_AiCpsExecuteParam::UT_AiCpsExecuteParam() |
|
87 { |
|
88 } |
|
89 |
|
90 // ---------------------------------------------------------------------------- |
|
91 // UT_AiCpsExecuteParam::ConstructL() |
|
92 // |
|
93 // ---------------------------------------------------------------------------- |
|
94 // |
|
95 void UT_AiCpsExecuteParam::ConstructL() |
|
96 { |
|
97 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
98 // It generates the test case table. |
|
99 CEUnitTestSuiteClass::ConstructL(); |
|
100 } |
|
101 |
|
102 // ---------------------------------------------------------------------------- |
|
103 // UT_AiCpsExecuteParam::SetupL() |
|
104 // |
|
105 // ---------------------------------------------------------------------------- |
|
106 // |
|
107 void UT_AiCpsExecuteParam::SetupL() |
|
108 { |
|
109 iExecuteParam = CAiCpsExecuteParam::NewL(); |
|
110 } |
|
111 |
|
112 // ---------------------------------------------------------------------------- |
|
113 // UT_AiCpsExecuteParam::Teardown() |
|
114 // |
|
115 // ---------------------------------------------------------------------------- |
|
116 // |
|
117 void UT_AiCpsExecuteParam::Teardown() |
|
118 { |
|
119 delete iExecuteParam; |
|
120 iExecuteParam = NULL; |
|
121 } |
|
122 |
|
123 // ---------------------------------------------------------------------------- |
|
124 // UT_AiCpsExecuteParam::PluginId() |
|
125 // |
|
126 // ---------------------------------------------------------------------------- |
|
127 // |
|
128 void UT_AiCpsExecuteParam::PluginId() |
|
129 { |
|
130 _LIT( KPluginId, "123" ); |
|
131 iExecuteParam->SetPluginIdL( KPluginId ); |
|
132 EUNIT_ASSERT_EQUALS( iExecuteParam->PluginId(), KPluginId ); |
|
133 } |
|
134 |
|
135 // ---------------------------------------------------------------------------- |
|
136 // UT_AiCpsExecuteParam::InParamMapL() |
|
137 // |
|
138 // ---------------------------------------------------------------------------- |
|
139 // |
|
140 void UT_AiCpsExecuteParam::InParamMapL() |
|
141 { |
|
142 CLiwDefaultMap* filter = CLiwDefaultMap::NewLC(); |
|
143 iExecuteParam->SetFilterL(filter); |
|
144 filter->InsertL( KPublisherId, TLiwVariant( KWRTPublisher )); |
|
145 filter->InsertL( KContentType, TLiwVariant( KTemplateWidget )); |
|
146 filter->InsertL( KContentId, TLiwVariant( KContentIdValue )); |
|
147 |
|
148 iExecuteParam->SetPluginIdL(_L("1")); |
|
149 iExecuteParam->SetRegistryTypeL( KPubData ); |
|
150 iExecuteParam->SetFilterL(filter); |
|
151 iExecuteParam->AddActionL( KAction ); |
|
152 |
|
153 CLiwDefaultMap* map = iExecuteParam->InParamMapLC(); |
|
154 |
|
155 TLiwVariant tempVariant; |
|
156 tempVariant.PushL(); |
|
157 |
|
158 // check map |
|
159 if ( map->FindL( KType, tempVariant ) ) |
|
160 { |
|
161 EUNIT_ASSERT_EQUALS( tempVariant.AsDes(), KPubData ); |
|
162 map->Remove( KType ); |
|
163 } |
|
164 if ( map->FindL( KFilter, tempVariant ) ) |
|
165 { |
|
166 CLiwDefaultMap* filter2 = CLiwDefaultMap::NewLC(); |
|
167 if ( tempVariant.Get( *filter2 ) ) |
|
168 { |
|
169 if ( filter2->FindL( KPublisherId, tempVariant ) ) |
|
170 { |
|
171 EUNIT_ASSERT_EQUALS( tempVariant.AsDes(), KWRTPublisher ); |
|
172 filter2->Remove( KPublisherId ); |
|
173 } |
|
174 if ( filter2->FindL( KContentType, tempVariant ) ) |
|
175 { |
|
176 EUNIT_ASSERT_EQUALS( tempVariant.AsDes(), KTemplateWidget ); |
|
177 filter2->Remove( KContentType ); |
|
178 } |
|
179 if ( filter2->FindL( KContentId, tempVariant ) ) |
|
180 { |
|
181 EUNIT_ASSERT_EQUALS( tempVariant.AsDes(), KContentIdValue ); |
|
182 filter2->Remove( KContentId ); |
|
183 } |
|
184 if ( filter2->FindL( KActionTrigger, tempVariant ) ) |
|
185 { |
|
186 CLiwDefaultList* actionsToLaunch = CLiwDefaultList::NewLC(); |
|
187 if ( tempVariant.Get( *actionsToLaunch ) ) |
|
188 { |
|
189 if ( actionsToLaunch->AtL( 0, tempVariant ) ) |
|
190 { |
|
191 EUNIT_ASSERT_EQUALS( tempVariant.AsData(), KAction ); |
|
192 actionsToLaunch->Remove( 0 ); |
|
193 //make sure actionsToLaunch is empty |
|
194 EUNIT_ASSERT_EQUALS ( actionsToLaunch->Count(), 0 ); |
|
195 } |
|
196 |
|
197 } |
|
198 CleanupStack::PopAndDestroy( actionsToLaunch ); |
|
199 filter2->Remove( KActionTrigger ); |
|
200 } |
|
201 } |
|
202 //make sure filter is empty |
|
203 EUNIT_ASSERT_EQUALS ( filter2->Count(), 0 ); |
|
204 CleanupStack::PopAndDestroy( filter2 ); |
|
205 |
|
206 map->Remove( KFilter ); |
|
207 } |
|
208 |
|
209 //make sure map is empty |
|
210 EUNIT_ASSERT_EQUALS ( map->Count(), 0 ); |
|
211 |
|
212 CleanupStack::Pop(&tempVariant); |
|
213 tempVariant.Reset(); |
|
214 CleanupStack::PopAndDestroy( 2,filter ); |
|
215 } |
|
216 |
|
217 //------------------------------------------------------------------------------ |
|
218 // Test case table |
|
219 // |
|
220 //------------------------------------------------------------------------------ |
|
221 // |
|
222 EUNIT_BEGIN_TEST_TABLE( |
|
223 UT_AiCpsExecuteParam, |
|
224 "Unit test suite for CAiCpsExecuteParam", |
|
225 "UNIT" ) |
|
226 |
|
227 EUNIT_TEST( |
|
228 "PluginId", |
|
229 "CAiCpsExecuteParam", |
|
230 "", |
|
231 "FUNCTIONALITY", |
|
232 SetupL, PluginId, Teardown ) |
|
233 |
|
234 EUNIT_TEST( |
|
235 "InParamMap", |
|
236 "CAiCpsExecuteParam", |
|
237 "", |
|
238 "FUNCTIONALITY", |
|
239 SetupL, InParamMapL, Teardown ) |
|
240 |
|
241 EUNIT_END_TEST_TABLE |
|
242 |
|
243 // End of file |