|
1 /* |
|
2 * Copyright (c) 2006 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: CGlxCommandHandlerMoreInfo unit test cases |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // CLASS HEADER |
|
22 #include "t_glxcommandhandlermoreinfo.h" |
|
23 #include "glxcommandhandlermoreinfo.h" |
|
24 #include "ut_glxdummymedialist.h" |
|
25 |
|
26 #include <glxcommandhandlers.hrh> |
|
27 #include <mpxmediadrmdefs.h> |
|
28 #include <mpxmediageneraldefs.h> |
|
29 |
|
30 // EXTERNAL INCLUDES |
|
31 #include <digia/eunit/eunitmacros.h> |
|
32 #include <digia/eunit/eunitdecorators.h> |
|
33 |
|
34 |
|
35 CGlxCommandHandlerMoreInfoTester* CGlxCommandHandlerMoreInfoTester::NewL() |
|
36 { |
|
37 CGlxCommandHandlerMoreInfoTester* self = new(ELeave)CGlxCommandHandlerMoreInfoTester(); |
|
38 CleanupStack::PushL(self); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop(self); |
|
41 return self; |
|
42 } |
|
43 |
|
44 CGlxCommandHandlerMoreInfoTester::~CGlxCommandHandlerMoreInfoTester() |
|
45 { |
|
46 iMoreInfoHandler->Deactivate(); |
|
47 |
|
48 iCommandHandlerList.ResetAndDestroy(); |
|
49 iCommandHandlerList.Close(); |
|
50 |
|
51 delete iMediaList; |
|
52 } |
|
53 |
|
54 TBool CGlxCommandHandlerMoreInfoTester::ExecuteL(TInt aCommand) |
|
55 { |
|
56 return iCommandHandlerList[0]->ExecuteL( aCommand ); |
|
57 } |
|
58 |
|
59 void CGlxCommandHandlerMoreInfoTester::AddItemL(TInt aId, CGlxMedia* aMedia) |
|
60 { |
|
61 iMediaList->AppendL(aId, aMedia); |
|
62 } |
|
63 |
|
64 |
|
65 MGlxMediaList& CGlxCommandHandlerMoreInfoTester::MediaList() |
|
66 { |
|
67 return *iMediaList; |
|
68 } |
|
69 |
|
70 |
|
71 CGlxCommandHandlerMoreInfoTester::CGlxCommandHandlerMoreInfoTester() |
|
72 { |
|
73 |
|
74 } |
|
75 |
|
76 void CGlxCommandHandlerMoreInfoTester::ConstructL() |
|
77 { |
|
78 EUNIT_PRINT(_L("CGlxCommandHandlerMoreInfoTester::ConstructL")); |
|
79 // create 'dummy' media list |
|
80 iMediaList = new (ELeave) _CGlxTestMediaList; |
|
81 |
|
82 // create our command handler |
|
83 iMoreInfoHandler = CGlxCommandHandlerMoreInfo::NewL( this, EFalse ); |
|
84 |
|
85 iCommandHandlerList.AppendL( iMoreInfoHandler ); |
|
86 |
|
87 iMoreInfoHandler->ActivateL(0); |
|
88 } |
|
89 |
|
90 |
|
91 // CONSTRUCTION |
|
92 t_glxcommandhandlermoreinfo* t_glxcommandhandlermoreinfo::NewL() |
|
93 { |
|
94 t_glxcommandhandlermoreinfo* self = t_glxcommandhandlermoreinfo::NewLC(); |
|
95 CleanupStack::Pop(); |
|
96 |
|
97 return self; |
|
98 } |
|
99 |
|
100 t_glxcommandhandlermoreinfo* t_glxcommandhandlermoreinfo::NewLC() |
|
101 { |
|
102 t_glxcommandhandlermoreinfo* self = new( ELeave ) t_glxcommandhandlermoreinfo(); |
|
103 CleanupStack::PushL( self ); |
|
104 |
|
105 self->ConstructL(); |
|
106 |
|
107 return self; |
|
108 } |
|
109 |
|
110 // Destructor (virtual by CBase) |
|
111 t_glxcommandhandlermoreinfo::~t_glxcommandhandlermoreinfo() |
|
112 { |
|
113 } |
|
114 |
|
115 // Default constructor |
|
116 t_glxcommandhandlermoreinfo::t_glxcommandhandlermoreinfo() |
|
117 { |
|
118 } |
|
119 |
|
120 // Second phase construct |
|
121 void t_glxcommandhandlermoreinfo::ConstructL() |
|
122 { |
|
123 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
124 // It generates the test case table. |
|
125 CEUnitTestSuiteClass::ConstructL(); |
|
126 } |
|
127 |
|
128 // METHODS |
|
129 |
|
130 |
|
131 void t_glxcommandhandlermoreinfo::SetupL( ) |
|
132 { |
|
133 iTester = CGlxCommandHandlerMoreInfoTester::NewL(); |
|
134 } |
|
135 |
|
136 |
|
137 void t_glxcommandhandlermoreinfo::Teardown( ) |
|
138 { |
|
139 delete iTester; |
|
140 iTester = NULL; |
|
141 } |
|
142 |
|
143 |
|
144 void t_glxcommandhandlermoreinfo::T_TestL( ) |
|
145 { |
|
146 |
|
147 } |
|
148 |
|
149 void t_glxcommandhandlermoreinfo::T_TestExecutionL() |
|
150 { |
|
151 MGlxMediaList& mlist = iTester->MediaList(); |
|
152 |
|
153 // try to exe on empty list |
|
154 TBool exe = iTester->ExecuteL(EGlxCmdDrmMoreInfoOnline); |
|
155 EUNIT_ASSERT_DESC( exe == EFalse, "No items present, option should be disabled"); |
|
156 |
|
157 // create a couple of media items |
|
158 TGlxMediaId testId(12346); |
|
159 CGlxMedia* newMedia = new (ELeave) CGlxMedia(testId); |
|
160 CleanupStack::PushL(newMedia); |
|
161 |
|
162 |
|
163 iTester->AddItemL(123456, newMedia); |
|
164 |
|
165 CleanupStack::Pop(newMedia); |
|
166 |
|
167 TGlxMediaId testId2(12347); |
|
168 CGlxMedia* newMedia2 = new (ELeave) CGlxMedia(testId2); |
|
169 CleanupStack::PushL(newMedia2); |
|
170 |
|
171 newMedia2->SetTObjectValueL(KMPXMediaDrmProtected, ETrue); |
|
172 |
|
173 newMedia2->SetTObjectValueL(KMPXMediaGeneralCategory, EMPXImage); |
|
174 |
|
175 newMedia2->SetTextValueL(KMPXMediaGeneralUri, _L("DRM has info")); |
|
176 |
|
177 iTester->AddItemL(123457, newMedia2); |
|
178 |
|
179 CleanupStack::Pop(newMedia2); |
|
180 |
|
181 mlist.SetFocusL(NGlxListDefs::EAbsolute, 0); |
|
182 |
|
183 exe = iTester->ExecuteL(EGlxCmdDrmMoreInfoOnline); |
|
184 EUNIT_ASSERT_DESC( exe == EFalse, "Non DRM item, option should be disabled"); |
|
185 |
|
186 mlist.SetFocusL(NGlxListDefs::EAbsolute, 1); |
|
187 |
|
188 exe = iTester->ExecuteL(EGlxCmdDrmMoreInfoOnline); |
|
189 EUNIT_ASSERT_DESC( exe == ETrue, "Valid item"); |
|
190 |
|
191 newMedia2->SetTObjectValueL(KMPXMediaDrmProtected, EFalse); |
|
192 exe = iTester->ExecuteL(EGlxCmdDrmMoreInfoOnline); |
|
193 EUNIT_ASSERT_DESC( exe == EFalse, "Non DRM item, option should be disabled"); |
|
194 |
|
195 newMedia2->SetTObjectValueL(KMPXMediaDrmProtected, ETrue); |
|
196 newMedia2->SetTObjectValueL(KMPXMediaGeneralCategory, EMPXVideo); |
|
197 |
|
198 exe = iTester->ExecuteL(EGlxCmdDrmMoreInfoOnline); |
|
199 EUNIT_ASSERT_DESC( exe == EFalse, "Video, option should be disabled"); |
|
200 |
|
201 newMedia2->SetTObjectValueL(KMPXMediaGeneralCategory, EMPXImage); |
|
202 newMedia2->SetTextValueL(KMPXMediaGeneralUri, _L("No info!")); |
|
203 |
|
204 EUNIT_ASSERT_DESC( exe == EFalse, "No info"); |
|
205 |
|
206 exe = iTester->ExecuteL(EGlxCmdUpload); |
|
207 EUNIT_ASSERT_DESC( exe == EFalse, "Unsupported command"); |
|
208 } |
|
209 |
|
210 |
|
211 // TEST TABLE |
|
212 EUNIT_BEGIN_TEST_TABLE( |
|
213 t_glxcommandhandlermoreinfo, |
|
214 "Add test suite description here.", |
|
215 "UNIT" ) |
|
216 |
|
217 EUNIT_TEST( |
|
218 "Test0", |
|
219 "Test command handler construction, activation, deactivation", |
|
220 "Test0", |
|
221 "FUNCTIONALITY", |
|
222 SetupL, T_TestL, Teardown) |
|
223 |
|
224 EUNIT_TEST( |
|
225 "Test1", |
|
226 "Test command execution", |
|
227 "Test1", |
|
228 "FUNCTIONALITY", |
|
229 SetupL, T_TestExecutionL, Teardown) |
|
230 |
|
231 |
|
232 EUNIT_END_TEST_TABLE |
|
233 |
|
234 // END OF FILE |