1 /* |
|
2 * Copyright (c) 2006-2007 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: Cropped thumbnail generation task unit tests. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // CLASS HEADER |
|
21 #include "ut_cglxtnzoomedimagetask.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 "glxtngeneratethumbnailtask.h" |
|
31 #include "dummytaskmanager.h" |
|
32 #include <glxtnfileinfo.h> |
|
33 #include "glxtnfileutility.h" |
|
34 #include "glxtnthumbnailrequest.h" |
|
35 #include "glxtnzoomedimagetask.h" |
|
36 #include <glxthumbnail.h> |
|
37 |
|
38 EUNIT_DECLARE_PRINTABLE_AS_TINT( TGlxThumbnailQuality ) |
|
39 |
|
40 const TUint KTestMediaId = 1; |
|
41 const TInt KTestWidth = 320; |
|
42 const TInt KTestHeight = 240; |
|
43 const TDisplayMode KTestThumbDisplayMode = KGlxThumbnailDisplayMode; |
|
44 |
|
45 _LIT(KTestImageUri, "C:\\TncTest\\test.jpg"); |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 |
|
49 // CONSTRUCTION |
|
50 UT_CGlxtnZoomedImageTask* UT_CGlxtnZoomedImageTask::NewL() |
|
51 { |
|
52 UT_CGlxtnZoomedImageTask* self = UT_CGlxtnZoomedImageTask::NewLC(); |
|
53 CleanupStack::Pop(); |
|
54 |
|
55 return self; |
|
56 } |
|
57 |
|
58 UT_CGlxtnZoomedImageTask* UT_CGlxtnZoomedImageTask::NewLC() |
|
59 { |
|
60 UT_CGlxtnZoomedImageTask* self = new( ELeave ) UT_CGlxtnZoomedImageTask(); |
|
61 CleanupStack::PushL( self ); |
|
62 |
|
63 self->ConstructL(); |
|
64 |
|
65 return self; |
|
66 } |
|
67 |
|
68 // Destructor (virtual by CBase) |
|
69 UT_CGlxtnZoomedImageTask::~UT_CGlxtnZoomedImageTask() |
|
70 { |
|
71 } |
|
72 |
|
73 // Default constructor |
|
74 UT_CGlxtnZoomedImageTask::UT_CGlxtnZoomedImageTask() |
|
75 { |
|
76 } |
|
77 |
|
78 // Second phase construct |
|
79 void UT_CGlxtnZoomedImageTask::ConstructL() |
|
80 { |
|
81 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
82 // It generates the test case table. |
|
83 CEUnitTestSuiteClass::ConstructL(); |
|
84 |
|
85 // Need to free ecom resources before running tests |
|
86 REComSession::FinalClose(); |
|
87 } |
|
88 |
|
89 // METHODS |
|
90 |
|
91 void UT_CGlxtnZoomedImageTask::ThumbnailFetchComplete( |
|
92 const TGlxMediaId& aItemId, TGlxThumbnailQuality aQuality, TInt aErrorCode) |
|
93 { |
|
94 EUNIT_ASSERT_EQUALS( KTestMediaId, aItemId.Value() ); |
|
95 iQuality = aQuality; |
|
96 iError = aErrorCode; |
|
97 } |
|
98 |
|
99 void UT_CGlxtnZoomedImageTask::ThumbnailDeletionComplete( |
|
100 const TGlxMediaId& /*aItemId*/, TInt /*aErrorCode*/) |
|
101 { |
|
102 EUNIT_FAIL_TEST("ThumbnailDeletionComplete() called"); |
|
103 } |
|
104 |
|
105 void UT_CGlxtnZoomedImageTask::FilterAvailableComplete( |
|
106 const RArray<TGlxMediaId>& /*aIdArray*/, TInt /*aErrorCode*/ ) |
|
107 { |
|
108 EUNIT_FAIL_TEST("FilterAvailableComplete() called"); |
|
109 } |
|
110 |
|
111 void UT_CGlxtnZoomedImageTask::FetchFileInfoL(CGlxtnFileInfo* aInfo, |
|
112 const TGlxMediaId& aItemId, TRequestStatus* aStatus) |
|
113 { |
|
114 EUNIT_ASSERT( NULL != aInfo ); |
|
115 EUNIT_ASSERT_EQUALS( KTestMediaId, aItemId.Value() ); |
|
116 aInfo->SetFilePathL(iUri); |
|
117 |
|
118 *aStatus = KRequestPending; |
|
119 User::RequestComplete(aStatus, KErrNone); |
|
120 } |
|
121 |
|
122 void UT_CGlxtnZoomedImageTask::CancelFetchUri(const TGlxMediaId& /*aItemId*/) |
|
123 { |
|
124 } |
|
125 |
|
126 MGlxtnThumbnailStorage* UT_CGlxtnZoomedImageTask::ThumbnailStorage() |
|
127 { |
|
128 return NULL; |
|
129 } |
|
130 |
|
131 void UT_CGlxtnZoomedImageTask::SetupL() |
|
132 { |
|
133 iFileUtility = CGlxtnFileUtility::NewL(); |
|
134 User::LeaveIfError(RFbsSession::Connect(iFileUtility->FsSession())); |
|
135 |
|
136 TGlxMediaId id(KTestMediaId); |
|
137 TSize size(KTestWidth, KTestHeight); |
|
138 TRect croppingRect(50, 50, 150, 150); |
|
139 |
|
140 iBitmap = new (ELeave) CFbsBitmap; |
|
141 User::LeaveIfError(iBitmap->Create(TSize(), KTestThumbDisplayMode)); |
|
142 |
|
143 TGlxThumbnailRequest request(id, size, |
|
144 TGlxThumbnailRequest::EPrioritizeQuality, iBitmap->Handle(), |
|
145 ETrue, croppingRect, EGlxThumbnailFilterNone); |
|
146 iZoomedImageTask = CGlxtnZoomedImageTask::NewL(request, |
|
147 *iFileUtility, *this); |
|
148 } |
|
149 |
|
150 void UT_CGlxtnZoomedImageTask::Teardown() |
|
151 { |
|
152 delete iZoomedImageTask; |
|
153 iZoomedImageTask = NULL; |
|
154 delete iBitmap; |
|
155 iBitmap = NULL; |
|
156 if ( RFbsSession::GetSession() ) |
|
157 { |
|
158 RFbsSession::Disconnect(); |
|
159 } |
|
160 delete iFileUtility; |
|
161 REComSession::FinalClose(); |
|
162 } |
|
163 |
|
164 void UT_CGlxtnZoomedImageTask::UT_CGlxtnZoomedImageTask_ConstructL() |
|
165 { |
|
166 // Check the task was correctly constructed |
|
167 EUNIT_ASSERT( NULL != iZoomedImageTask ); |
|
168 EUNIT_ASSERT_EQUALS( iZoomedImageTask->Id().Value(), KGlxtnTaskIdZoomedThumbnail ); |
|
169 EUNIT_ASSERT_EQUALS( iZoomedImageTask->ItemId().Value(), KTestMediaId ); |
|
170 } |
|
171 |
|
172 void UT_CGlxtnZoomedImageTask::UT_CGlxtnZoomedImageTask_GenerateL() |
|
173 { |
|
174 // NOTE: This test currently fails on the emulator, as the extended JPEG |
|
175 // codec is not present in the environment |
|
176 DoGenerateL(KTestImageUri); |
|
177 } |
|
178 |
|
179 void UT_CGlxtnZoomedImageTask::DoGenerateL(const TDesC& aUri) |
|
180 { |
|
181 iUri.Set(aUri); |
|
182 |
|
183 CDummyTaskManager* tm = new (ELeave) CDummyTaskManager(iZoomedImageTask); |
|
184 CleanupStack::PushL(tm); |
|
185 tm->StartTaskL(); |
|
186 User::LeaveIfError(iError); |
|
187 CleanupStack::PopAndDestroy(tm); |
|
188 |
|
189 EUNIT_ASSERT_EQUALS( iQuality, EGlxThumbnailQualityHigh ); |
|
190 } |
|
191 |
|
192 // TEST TABLE |
|
193 |
|
194 EUNIT_BEGIN_TEST_TABLE( |
|
195 UT_CGlxtnZoomedImageTask, |
|
196 "Unit tests for CGlxtnZoomedImageTask.", |
|
197 "UNIT" ) |
|
198 |
|
199 EUNIT_TEST( |
|
200 "Test construction of CGlxtnZoomedImageTask", |
|
201 "CGlxtnZoomedImageTask", |
|
202 "NewL", |
|
203 "FUNCTIONALITY", |
|
204 SetupL, UT_CGlxtnZoomedImageTask_ConstructL, Teardown) |
|
205 |
|
206 EUNIT_TEST( |
|
207 "Generate a cropped thumbnail", |
|
208 "CGlxtnZoomedImageTask", |
|
209 "HandleThumbnailTaskCompleteL", |
|
210 "FUNCTIONALITY", |
|
211 SetupL, UT_CGlxtnZoomedImageTask_GenerateL, Teardown) |
|
212 |
|
213 EUNIT_END_TEST_TABLE |
|
214 |
|
215 // END OF FILE |
|