|
1 /* |
|
2 * Copyright (c) 2006-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: Thumbnail availability filter task unit tests. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // CLASS HEADER |
|
21 #include "ut_cglxtnfilteravailabletask.h" |
|
22 |
|
23 // EXTERNAL INCLUDES |
|
24 #include <EUnitMacros.h> |
|
25 #include <EUnitDecorators.h> |
|
26 #include <fbs.h> |
|
27 #include <Ecom\ECom.h> |
|
28 |
|
29 // INTERNAL INCLUDES |
|
30 #include "glxtnfilteravailabletask.h" |
|
31 #include "dummytaskmanager.h" |
|
32 |
|
33 const TUint KGlxMediaIdWithThumbnail = 1; |
|
34 const TUint KGlxMediaIdWithoutThumbnail = 2; |
|
35 const TInt KTestSizeWidth = 320; |
|
36 const TInt KTestSizeHeight = 240; |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 |
|
40 // CONSTRUCTION |
|
41 UT_CGlxtnFilterAvailableTask* UT_CGlxtnFilterAvailableTask::NewL() |
|
42 { |
|
43 UT_CGlxtnFilterAvailableTask* self = UT_CGlxtnFilterAvailableTask::NewLC(); |
|
44 CleanupStack::Pop(); |
|
45 |
|
46 return self; |
|
47 } |
|
48 |
|
49 UT_CGlxtnFilterAvailableTask* UT_CGlxtnFilterAvailableTask::NewLC() |
|
50 { |
|
51 UT_CGlxtnFilterAvailableTask* self = new( ELeave ) UT_CGlxtnFilterAvailableTask(); |
|
52 CleanupStack::PushL( self ); |
|
53 |
|
54 self->ConstructL(); |
|
55 |
|
56 return self; |
|
57 } |
|
58 |
|
59 // Destructor (virtual by CBase) |
|
60 UT_CGlxtnFilterAvailableTask::~UT_CGlxtnFilterAvailableTask() |
|
61 { |
|
62 } |
|
63 |
|
64 // Default constructor |
|
65 UT_CGlxtnFilterAvailableTask::UT_CGlxtnFilterAvailableTask() |
|
66 { |
|
67 } |
|
68 |
|
69 // Second phase construct |
|
70 void UT_CGlxtnFilterAvailableTask::ConstructL() |
|
71 { |
|
72 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
73 // It generates the test case table. |
|
74 CEUnitTestSuiteClass::ConstructL(); |
|
75 } |
|
76 |
|
77 // METHODS |
|
78 |
|
79 void UT_CGlxtnFilterAvailableTask::ThumbnailFetchComplete( |
|
80 const TGlxMediaId& /*aItemId*/, TGlxThumbnailQuality /*aQuality*/, TInt /*aErrorCode*/) |
|
81 { |
|
82 EUNIT_FAIL_TEST("ThumbnailFetchComplete() called"); |
|
83 } |
|
84 |
|
85 void UT_CGlxtnFilterAvailableTask::ThumbnailDeletionComplete( |
|
86 const TGlxMediaId& /*aItemId*/, TInt /*aErrorCode*/) |
|
87 { |
|
88 EUNIT_FAIL_TEST("ThumbnailDeletionComplete() called"); |
|
89 } |
|
90 |
|
91 void UT_CGlxtnFilterAvailableTask::FilterAvailableComplete( |
|
92 const RArray<TGlxMediaId>& aIdArray, TInt aErrorCode ) |
|
93 { |
|
94 EUNIT_ASSERT( KErrNotFound == aIdArray.Find( |
|
95 TGlxMediaId(KGlxMediaIdWithThumbnail)) ); |
|
96 EUNIT_ASSERT( KErrNotFound != aIdArray.Find( |
|
97 TGlxMediaId(KGlxMediaIdWithoutThumbnail)) ); |
|
98 iError = aErrorCode; |
|
99 } |
|
100 |
|
101 void UT_CGlxtnFilterAvailableTask::FetchFileInfoL(CGlxtnFileInfo* /*aInfo*/, |
|
102 const TGlxMediaId& /*aItemId*/, TRequestStatus* aStatus) |
|
103 { |
|
104 *aStatus = KRequestPending; |
|
105 User::RequestComplete(aStatus, KErrNone); |
|
106 } |
|
107 |
|
108 void UT_CGlxtnFilterAvailableTask::CancelFetchUri(const TGlxMediaId& /*aItemId*/) |
|
109 { |
|
110 } |
|
111 |
|
112 MGlxtnThumbnailStorage* UT_CGlxtnFilterAvailableTask::ThumbnailStorage() |
|
113 { |
|
114 return this; |
|
115 } |
|
116 |
|
117 void UT_CGlxtnFilterAvailableTask::LoadThumbnailDataL(HBufC8*& /*aData*/, TGlxImageDataFormat& /*aFormat*/, |
|
118 const TGlxMediaId& /*aId*/, const CGlxtnFileInfo& /*aFileInfo*/, |
|
119 const TSize& /*aSize*/, TRequestStatus* /*aStatus*/) |
|
120 { |
|
121 EUNIT_FAIL_TEST("FilterAvailableComplete() called"); |
|
122 } |
|
123 |
|
124 void UT_CGlxtnFilterAvailableTask::SaveThumbnailDataL(const TDesC8& /*aData*/, |
|
125 TGlxImageDataFormat /*aFormat*/, const TGlxMediaId& /*aId*/, |
|
126 const CGlxtnFileInfo& /*aFileInfo*/, const TSize& /*aSize*/, |
|
127 TRequestStatus* /*aStatus*/) |
|
128 { |
|
129 EUNIT_FAIL_TEST("FilterAvailableComplete() called"); |
|
130 } |
|
131 |
|
132 void UT_CGlxtnFilterAvailableTask::DeleteThumbnailsL(const TGlxMediaId& /*aId*/, |
|
133 const CGlxtnFileInfo& /*aFileInfo*/, TRequestStatus* /*aStatus*/) |
|
134 { |
|
135 EUNIT_FAIL_TEST("FilterAvailableComplete() called"); |
|
136 } |
|
137 |
|
138 void UT_CGlxtnFilterAvailableTask::CleanupThumbnailsL(TRequestStatus* /*aStatus*/) |
|
139 { |
|
140 EUNIT_FAIL_TEST("FilterAvailableComplete() called"); |
|
141 } |
|
142 |
|
143 void UT_CGlxtnFilterAvailableTask::IsThumbnailAvailableL(const TGlxMediaId& aId, |
|
144 const CGlxtnFileInfo& /*aFileInfo*/, |
|
145 const TSize& aSize, TRequestStatus* aStatus) |
|
146 { |
|
147 TInt result = (KGlxMediaIdWithThumbnail == aId.Value()) |
|
148 ? KGlxThumbnailAvailable : KGlxThumbnailNotAvailable; |
|
149 EUNIT_ASSERT_EQUALS( aSize, iSize ); |
|
150 *aStatus = KRequestPending; |
|
151 User::RequestComplete(aStatus, result); |
|
152 } |
|
153 |
|
154 void UT_CGlxtnFilterAvailableTask::StorageCancel() |
|
155 { |
|
156 } |
|
157 |
|
158 void UT_CGlxtnFilterAvailableTask::NotifyBackgroundError( |
|
159 const TGlxMediaId& /*aId*/, TInt /*aError*/) |
|
160 { |
|
161 EUNIT_FAIL_TEST("NotifyBackgroundError() called"); |
|
162 } |
|
163 |
|
164 void UT_CGlxtnFilterAvailableTask::SetupL() |
|
165 { |
|
166 iSize.SetSize(KTestSizeWidth, KTestSizeHeight); |
|
167 |
|
168 RArray<TGlxMediaId> array; |
|
169 CleanupClosePushL(array); |
|
170 array.AppendL(TGlxMediaId(KGlxMediaIdWithThumbnail)); |
|
171 array.AppendL(TGlxMediaId(KGlxMediaIdWithoutThumbnail)); |
|
172 iFilterAvailableTask = CGlxtnFilterAvailableTask::NewL(array.Array(), |
|
173 iSize, *this); |
|
174 CleanupStack::PopAndDestroy(&array); |
|
175 } |
|
176 |
|
177 void UT_CGlxtnFilterAvailableTask::Teardown() |
|
178 { |
|
179 delete iFilterAvailableTask; |
|
180 } |
|
181 |
|
182 void UT_CGlxtnFilterAvailableTask::UT_CGlxtnFilterAvailableTask_ConstructL() |
|
183 { |
|
184 // Check the task was correctly constructed |
|
185 EUNIT_ASSERT( NULL != iFilterAvailableTask ); |
|
186 EUNIT_ASSERT_EQUALS( iFilterAvailableTask->Id().Value(), KGlxtnTaskIdFilterAvailable ); |
|
187 EUNIT_ASSERT_EQUALS( iFilterAvailableTask->Storage(), this ); |
|
188 } |
|
189 |
|
190 void UT_CGlxtnFilterAvailableTask::UT_CGlxtnFilterAvailableTask_FilterL() |
|
191 { |
|
192 CDummyTaskManager* tm = new (ELeave) CDummyTaskManager(iFilterAvailableTask); |
|
193 CleanupStack::PushL(tm); |
|
194 tm->StartTaskL(); |
|
195 User::LeaveIfError(iError); |
|
196 CleanupStack::PopAndDestroy(tm); |
|
197 } |
|
198 |
|
199 // TEST TABLE |
|
200 |
|
201 EUNIT_BEGIN_TEST_TABLE( |
|
202 UT_CGlxtnFilterAvailableTask, |
|
203 "Unit tests for CGlxtnFilterAvailableTask.", |
|
204 "UNIT" ) |
|
205 |
|
206 EUNIT_TEST( |
|
207 "Test construction of CGlxtnFilterAvailableTask", |
|
208 "CGlxtnFilterAvailableTask", |
|
209 "NewL", |
|
210 "FUNCTIONALITY", |
|
211 SetupL, UT_CGlxtnFilterAvailableTask_ConstructL, Teardown) |
|
212 |
|
213 EUNIT_TEST( |
|
214 "Test filtering of ID array", |
|
215 "CGlxtnFilterAvailableTask", |
|
216 "StartL", |
|
217 "FUNCTIONALITY", |
|
218 SetupL, UT_CGlxtnFilterAvailableTask_FilterL, Teardown) |
|
219 |
|
220 EUNIT_ALLOC_TEST( |
|
221 "Test alloc failures", |
|
222 "CGlxtnFilterAvailableTask", |
|
223 "StartL", |
|
224 "ERRORHANDLING", |
|
225 SetupL, UT_CGlxtnFilterAvailableTask_FilterL, Teardown) |
|
226 |
|
227 EUNIT_END_TEST_TABLE |
|
228 |
|
229 // END OF FILE |