1 /* |
|
2 * Copyright (c) 2006-2009 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: test case |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 #include <w32std.h> |
|
27 #include <coecntrl.h> |
|
28 |
|
29 #include "BCTestCmDlgcase.h" |
|
30 #include "BCTestCmDlgcontainer.h" |
|
31 #include "BCTestCmDlg.hrh" |
|
32 #include "streamlogger.h" |
|
33 |
|
34 // ======== MEMBER FUNCTIONS ======== |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // Symbian 2nd static Constructor |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 CBCTestCmDlgCase* CBCTestCmDlgCase::NewL() |
|
41 { |
|
42 CBCTestCmDlgCase* self = new( ELeave ) CBCTestCmDlgCase(); |
|
43 CleanupStack::PushL( self ); |
|
44 self->ConstructL(); |
|
45 CleanupStack::Pop( self ); |
|
46 return self; |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // C++ default constructor |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CBCTestCmDlgCase::CBCTestCmDlgCase():iDlg(0) |
|
54 { |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // Destructor |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 CBCTestCmDlgCase::~CBCTestCmDlgCase() |
|
62 { |
|
63 delete iDlg; |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // Symbian 2nd Constructor |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 void CBCTestCmDlgCase::ConstructL() |
|
71 { |
|
72 BuildScriptL(); |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // CBCTestCmDlgCase::BuildScriptL |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 void CBCTestCmDlgCase::BuildScriptL() |
|
80 { |
|
81 // Add script as your need. |
|
82 AddTestL( DELAY(1), TEND); |
|
83 |
|
84 for(int i=0; i<EBCTestCmdMemSelDlgEnd - EBCTestCmdMemSelDlgBegin -1; ++i) |
|
85 { |
|
86 AddTestL( LeftCBA, Right, TEND ); |
|
87 for(int j=0; j<i; ++j) |
|
88 AddTestL( Down, TEND); |
|
89 AddTestL( LeftCBA, TEND ); |
|
90 AddOKL(); |
|
91 } |
|
92 } |
|
93 |
|
94 void CBCTestCmDlgCase::AddOKL() |
|
95 { |
|
96 // add dlg response sciprts |
|
97 for(int i=0; i<1; ++i) |
|
98 AddTestL( WAIT(5), KeyOK, TEND); |
|
99 } |
|
100 |
|
101 void CBCTestCmDlgCase::AddCancelL() |
|
102 { |
|
103 // add dlg response sciprts |
|
104 for(int i=0; i<1; ++i) |
|
105 AddTestL( WAIT(5), RightCBA, TEND); |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // CBCTestCmDlgCase::RunL |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 void CBCTestCmDlgCase::RunL( TInt aCmd ) |
|
113 { |
|
114 SetupL(); |
|
115 switch(aCmd){ |
|
116 case EBCTestCmdMemSelDlgCreate: |
|
117 TestCreateL(); |
|
118 break; |
|
119 case EBCTestCmdMemSelDlgCreateWithRes: |
|
120 TestCreateL(0); //0 indicate to default res |
|
121 break; |
|
122 case EBCTestCmdMemSelDlgWithRoot: |
|
123 TestWithRootL(); |
|
124 break; |
|
125 case EBCTestCmdMemSelDlgQuick: |
|
126 TestQuickCreateL(); |
|
127 break; |
|
128 case EBCTestCmdMemSelDlgQuickTitle: |
|
129 TestQuickCreateL(_L("a title")); |
|
130 break; |
|
131 case EBCTestCmdMemSelDlgQuickRes: |
|
132 TestQuickCreateL(0); //0 means default res |
|
133 break; |
|
134 case EBCTestCmdMemSelDlgSetting: |
|
135 TestSettingsL(); |
|
136 break; |
|
137 default: |
|
138 break; |
|
139 } |
|
140 |
|
141 Teardown(); |
|
142 } |
|
143 |
|
144 // --------------------------------------------------------------------------- |
|
145 // CBCTestCmDlgCase::ReleaseCaseL |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 void CBCTestCmDlgCase::Teardown() |
|
149 { |
|
150 delete iDlg; |
|
151 iDlg = NULL; |
|
152 } |
|
153 |
|
154 void CBCTestCmDlgCase::TestCreateL() |
|
155 { |
|
156 iDlg = CAknMemorySelectionDialog::NewL( ECFDDialogTypeNormal, EFalse ); |
|
157 |
|
158 AssertNotNullL(iDlg, _L("mem sel dlg created")); |
|
159 AssertTrueL(iDlg->ExecuteL( iMemory ), _L("User Hit OK")); |
|
160 AssertIntL( CAknMemorySelectionDialog::EPhoneMemory, iMemory, _L("Phone memory created")); |
|
161 } |
|
162 |
|
163 void CBCTestCmDlgCase::TestCreateL(TInt aResID) |
|
164 { |
|
165 iDlg = CAknMemorySelectionDialog::NewL( ECFDDialogTypeNormal, aResID, EFalse ); |
|
166 |
|
167 AssertNotNullL(iDlg, _L("mem sel dlg with resID created")); |
|
168 AssertTrueL(CAknMemorySelectionDialog::RunDlgLD(iMemory), _L("Quick create, User hit OK")); |
|
169 AssertIntL( CAknMemorySelectionDialog::EPhoneMemory, iMemory, _L("Phone memroy created")); |
|
170 } |
|
171 |
|
172 void CBCTestCmDlgCase::TestQuickCreateL() |
|
173 { |
|
174 AssertTrueL(CAknMemorySelectionDialog::RunDlgLD(iMemory), _L("Quick create, User hit OK")); |
|
175 AssertIntL( CAknMemorySelectionDialog::EPhoneMemory, iMemory, _L("Phone memroy created")); |
|
176 } |
|
177 |
|
178 void CBCTestCmDlgCase::TestQuickCreateL(const TDesC &aTitle) |
|
179 { |
|
180 AssertTrueL(CAknMemorySelectionDialog::RunDlgLD(iMemory, aTitle), _L("Quick create with title, User hit OK")); |
|
181 AssertIntL( CAknMemorySelectionDialog::EPhoneMemory, iMemory, _L("Phone memroy created")); |
|
182 } |
|
183 |
|
184 void CBCTestCmDlgCase::TestQuickCreateL(TInt aResID) |
|
185 { |
|
186 AssertTrueL(CAknMemorySelectionDialog::RunDlgLD(iMemory, aResID), _L("Quick create with ResID, User hit OK")); |
|
187 AssertIntL( CAknMemorySelectionDialog::EPhoneMemory, iMemory, _L("Phone memroy created")); |
|
188 } |
|
189 |
|
190 void CBCTestCmDlgCase::SetupL() |
|
191 { |
|
192 iMemory = CAknMemorySelectionDialog::EPhoneMemory; |
|
193 } |
|
194 |
|
195 void CBCTestCmDlgCase::TestWithRootL() |
|
196 { |
|
197 _LIT( KRootPath, "C:\\Nokia\\Images\\" ); |
|
198 _LIT( KDefaultFileName, "DynamicFilename.jpg" ); |
|
199 TFileName rootFileName( KRootPath ); |
|
200 TFileName defaultFileName( KDefaultFileName ); |
|
201 iDlg = CAknMemorySelectionDialog::NewL( ECFDDialogTypeNormal, EFalse ); |
|
202 if(TInt res = iDlg->ExecuteL(iMemory, &rootFileName, &defaultFileName)) |
|
203 { |
|
204 TFileName msg(_L("default root: ")); |
|
205 msg.Append(rootFileName); |
|
206 msg.Append(_L(" default file: ")); |
|
207 msg.Append(defaultFileName); |
|
208 msg.ZeroTerminate(); |
|
209 AssertTrueL(res, msg); |
|
210 } |
|
211 } |
|
212 |
|
213 void CBCTestCmDlgCase::TestSettingsL() |
|
214 { |
|
215 iDlg = CAknMemorySelectionDialog::NewL( ECFDDialogTypeNormal, EFalse ); |
|
216 |
|
217 iDlg->SetObserver(NULL); |
|
218 AssertTrueL(ETrue, _L("Null Observer set")); |
|
219 |
|
220 iDlg->SetTitleL(_L("a title")); |
|
221 AssertTrueL(ETrue, _L("title set")); |
|
222 |
|
223 iDlg->SetLeftSoftkeyL(_L("left key")); |
|
224 AssertTrueL(ETrue, _L("left key text set")); |
|
225 |
|
226 iDlg->SetRightSoftkeyL(_L("right key")); |
|
227 AssertTrueL(ETrue, _L("right key text set")); |
|
228 if(iDlg->ExecuteL(iMemory)) |
|
229 { |
|
230 //get |
|
231 TFileName emptyFileName( KNullDesC ); |
|
232 iDlg->GetItem( iMemory, emptyFileName ); |
|
233 TFileName msg(_L("item got: ")); |
|
234 msg.Append(emptyFileName); |
|
235 msg.ZeroTerminate(); |
|
236 AssertTrueL(ETrue, msg); |
|
237 |
|
238 _LIT( KRootPath, "C:\\Nokia\\Images\\" ); |
|
239 _LIT( KDefaultFileName, "DynamicFilename.jpg" ); |
|
240 TFileName rootFileName( KRootPath ); |
|
241 TFileName defaultFileName( KDefaultFileName ); |
|
242 iDlg->GetMemories(iMemory, &rootFileName, &defaultFileName); |
|
243 |
|
244 msg = (_L("memory got, root: ")); |
|
245 msg.Append(rootFileName); |
|
246 msg.Append(_L(" default file: ")); |
|
247 msg.Append(defaultFileName); |
|
248 msg.ZeroTerminate(); |
|
249 AssertTrueL(ETrue, msg); |
|
250 } |
|
251 } |
|
252 |
|
253 |
|
254 // EOF |
|