|
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: Thumbnail saver for CommandHandler UPnP unit test |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // CLASS HEADER |
|
22 #include "t_cglxthumbnailsaver.h" |
|
23 |
|
24 // EXTERNAL INCLUDES |
|
25 #include <digia/eunit/eunitmacros.h> |
|
26 #include <digia/eunit/eunitdecorators.h> |
|
27 #include <fbs.h> |
|
28 #include <bitdev.h> |
|
29 #include <gdi.h> |
|
30 |
|
31 // INTERNAL INCLUDES |
|
32 |
|
33 |
|
34 // CONSTRUCTION |
|
35 t_cglxthumbnailsaver* t_cglxthumbnailsaver::NewL() |
|
36 { |
|
37 t_cglxthumbnailsaver* self = t_cglxthumbnailsaver::NewLC(); |
|
38 CleanupStack::Pop(); |
|
39 |
|
40 return self; |
|
41 } |
|
42 |
|
43 t_cglxthumbnailsaver* t_cglxthumbnailsaver::NewLC() |
|
44 { |
|
45 t_cglxthumbnailsaver* self = new( ELeave ) t_cglxthumbnailsaver(); |
|
46 CleanupStack::PushL( self ); |
|
47 |
|
48 self->ConstructL(); |
|
49 |
|
50 return self; |
|
51 } |
|
52 |
|
53 // Destructor (virtual by CBase) |
|
54 t_cglxthumbnailsaver::~t_cglxthumbnailsaver() |
|
55 { |
|
56 } |
|
57 |
|
58 // Default constructor |
|
59 t_cglxthumbnailsaver::t_cglxthumbnailsaver() |
|
60 { |
|
61 } |
|
62 |
|
63 // Second phase construct |
|
64 void t_cglxthumbnailsaver::ConstructL() |
|
65 { |
|
66 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
67 // It generates the test case table. |
|
68 CEUnitTestSuiteClass::ConstructL(); |
|
69 } |
|
70 |
|
71 // METHODS |
|
72 |
|
73 |
|
74 void t_cglxthumbnailsaver::SetupL( ) |
|
75 { |
|
76 EUNIT_PRINT(_L("Entering t_cglxthumbnailsaver::SetupL")); |
|
77 if(!RFbsSession::GetSession()) |
|
78 { |
|
79 EUNIT_PRINT(_L("t_cglxthumbnailsaver::GetSession")); |
|
80 User::LeaveIfError(RFbsSession::Connect()); |
|
81 EUNIT_PRINT(_L("t_cglxthumbnailsaver::FbsSession:: Connected")); |
|
82 // iData->iFbsCreated = ETrue; |
|
83 } |
|
84 iThumbnail = NULL; |
|
85 iThumbnailSaver = NULL; |
|
86 iThumbnailSaver = CGlxThumbnailSaver::NewL(this); |
|
87 |
|
88 EUNIT_PRINT(_L("Exiting t_cglxthumbnailsaver::SetupL")); |
|
89 } |
|
90 |
|
91 |
|
92 void t_cglxthumbnailsaver::Teardown( ) |
|
93 { |
|
94 EUNIT_PRINT(_L("t_cglxthumbnailsaver::Teardown")); |
|
95 // if (iData && iData->iFbsCreated) // just not to close session owned by ccoeenv / application |
|
96 RFbsSession::Disconnect(); |
|
97 |
|
98 if(iThumbnail) |
|
99 { |
|
100 EUNIT_PRINT(_L("t_cglxthumbnailsaver::iThumbnail")); |
|
101 delete iThumbnail; |
|
102 } |
|
103 if(iThumbnailSaver) |
|
104 { |
|
105 EUNIT_PRINT(_L("t_cglxthumbnailsaver::iThumbnailSaver")); |
|
106 delete iThumbnailSaver; |
|
107 } |
|
108 EUNIT_PRINT(_L("Exiting t_cglxthumbnailsaver::Teardown")); |
|
109 } |
|
110 |
|
111 |
|
112 void t_cglxthumbnailsaver::T_TestL( ) |
|
113 { |
|
114 EUNIT_ASSERT_DESC( iThumbnailSaver, "ThumbnailSaver Creation Failed"); |
|
115 } |
|
116 |
|
117 void t_cglxthumbnailsaver::T_CreateVideoIconL() |
|
118 { |
|
119 EUNIT_PRINT(_L("Entering t_cglxthumbnailsaver::T_CreateVideoIconL")); |
|
120 iThumbnail = new (ELeave) CFbsBitmap; |
|
121 EUNIT_PRINT(_L("T_CreateVideoIconL::iThumbnail instance created")); |
|
122 User::LeaveIfError(iThumbnail->Create(TSize(), EColor64K)); |
|
123 EUNIT_PRINT(_L("T_CreateVideoIconL::iThumbnail create Succeeded")); |
|
124 |
|
125 iThumbnailSaver->CreateVideoIconL(iThumbnail); |
|
126 EUNIT_PRINT(_L("T_CreateVideoIconL::Aftr CreateVideoIconL")); |
|
127 CActiveScheduler::Start(); |
|
128 EUNIT_PRINT(_L("Exiting t_cglxthumbnailsaver::T_CreateVideoIconL")); |
|
129 } |
|
130 //Cancel the request |
|
131 void t_cglxthumbnailsaver::T_CreateVideoIconL_Cancel( ) |
|
132 { |
|
133 EUNIT_PRINT(_L("Entering t_cglxthumbnailsaver::T_CreateVideoIconL_Cancel")); |
|
134 iThumbnail = new (ELeave) CFbsBitmap; |
|
135 EUNIT_PRINT(_L("T_CreateVideoIconL_Cancel::iThumbnail instance created")); |
|
136 User::LeaveIfError(iThumbnail->Create(TSize(), EColor64K)); |
|
137 EUNIT_PRINT(_L("T_CreateVideoIconL_Cancel::iThumbnail create failed")); |
|
138 |
|
139 iThumbnailSaver->CreateVideoIconL(iThumbnail); |
|
140 |
|
141 iThumbnailSaver->Cancel(); |
|
142 |
|
143 // We can at least test that DoCancel cancels the outstanding asynchronous |
|
144 // request, and that Cancel behaves in an orderly way. |
|
145 |
|
146 EUNIT_ASSERT( iThumbnailSaver->iStatus == KErrCancel || iThumbnailSaver->iStatus == KErrNone ); |
|
147 EUNIT_ASSERT( !iThumbnailSaver->IsActive() ); |
|
148 EUNIT_PRINT(_L("Exiting t_cglxthumbnailsaver::T_CreateVideoIconL_Cancel")); |
|
149 } |
|
150 |
|
151 void t_cglxthumbnailsaver::T_CreateDefaultVideoIconL() |
|
152 { |
|
153 EUNIT_PRINT(_L("Entering t_cglxthumbnailsaver::T_CreateDefaultVideoIconL")); |
|
154 //iThumbnailSaver->CreateDefaultVideoIconL(); |
|
155 } |
|
156 |
|
157 //From MGlxThumbnailSaveComplete |
|
158 void t_cglxthumbnailsaver::HandleFileSaveCompleteL(const TDesC& /*aPath*/) |
|
159 { |
|
160 |
|
161 CActiveScheduler::Stop(); |
|
162 } |
|
163 |
|
164 // TEST TABLE |
|
165 EUNIT_BEGIN_TEST_TABLE( |
|
166 t_cglxthumbnailsaver, |
|
167 "Thumbnail Saver", |
|
168 "UNIT" ) |
|
169 |
|
170 EUNIT_TEST( |
|
171 "Craetion of Thumbnial", |
|
172 "NewL", |
|
173 "CGlxThumbnailSaver", |
|
174 "UNIT", |
|
175 SetupL, T_TestL, Teardown) |
|
176 |
|
177 /*EUNIT_TEST( |
|
178 "Video", |
|
179 "CreateVideoIconL", |
|
180 "CGlxThumbnailSaver", |
|
181 "UNIT", |
|
182 SetupL, T_CreateVideoIconL, Teardown) |
|
183 |
|
184 EUNIT_TEST( |
|
185 "Video", |
|
186 "CreateVideoIconL_Cancel", |
|
187 "CGlxThumbnailSaver", |
|
188 "UNIT", |
|
189 SetupL, T_CreateVideoIconL_Cancel, Teardown)*/ |
|
190 |
|
191 EUNIT_TEST( |
|
192 "Video", |
|
193 "CreateDefaultVideoIconL", |
|
194 "CGlxThumbnailSaver", |
|
195 "UNIT", |
|
196 SetupL, T_CreateDefaultVideoIconL, Teardown) |
|
197 |
|
198 |
|
199 EUNIT_END_TEST_TABLE |
|
200 |
|
201 // END OF FILE |