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 #include <MAknFileSelectionObserver.h> |
|
29 #include <MaknFileFilter.h> |
|
30 |
|
31 #include "BCTestFileSelDlg.h" |
|
32 #include "BCTestCmDlg.hrh" |
|
33 #include "streamlogger.h" |
|
34 |
|
35 // ======== MEMBER FUNCTIONS ======== |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // Symbian 2nd static Constructor |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 CBCTestFileSelDlg* CBCTestFileSelDlg::NewL() |
|
42 { |
|
43 CBCTestFileSelDlg* self = new( ELeave ) CBCTestFileSelDlg(); |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL(); |
|
46 CleanupStack::Pop( self ); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // C++ default constructor |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 CBCTestFileSelDlg::CBCTestFileSelDlg():iDlg(0) |
|
55 { |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // Destructor |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 CBCTestFileSelDlg::~CBCTestFileSelDlg() |
|
63 { |
|
64 delete iDlg; |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // Symbian 2nd Constructor |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 void CBCTestFileSelDlg::ConstructL() |
|
72 { |
|
73 BuildScriptL(); |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // CBCTestFileSelDlg::BuildScriptL |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 void CBCTestFileSelDlg::BuildScriptL() |
|
81 { |
|
82 AddTestL( DELAY(1), TEND); |
|
83 |
|
84 // Add script as your need. |
|
85 for(int i=0; i<EBCTestCmdFileSelDlgEnd - EBCTestCmdFileSelDlgBegin -1; ++i) |
|
86 { |
|
87 AddTestL( LeftCBA, REP(Down, 2), Right, TEND ); |
|
88 for(int j=0; j<i; ++j) |
|
89 AddTestL( Down, TEND); |
|
90 AddTestL( LeftCBA, TEND ); |
|
91 AddCancelL(); //OK may enter a folder and ask user to select more. |
|
92 } |
|
93 } |
|
94 |
|
95 void CBCTestFileSelDlg::AddOKL() |
|
96 { |
|
97 // add dlg response sciprts |
|
98 for(int i=0; i<1; ++i) |
|
99 AddTestL( WAIT(5), KeyOK, TEND); |
|
100 } |
|
101 |
|
102 void CBCTestFileSelDlg::AddCancelL() |
|
103 { |
|
104 // add dlg response sciprts |
|
105 for(int i=0; i<1; ++i) |
|
106 AddTestL( WAIT(5), RightCBA, TEND); |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // CBCTestFileSelDlg::RunL |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 void CBCTestFileSelDlg::RunL( TInt aCmd ) |
|
114 { |
|
115 SetupL(); |
|
116 switch(aCmd){ |
|
117 case EBCTestCmdFileSelDlgCreate: |
|
118 TestCreateL(); |
|
119 break; |
|
120 case EBCTestCmdFileSelDlgCreateRes: |
|
121 TestCreateL(0); // 0 is default res id |
|
122 break; |
|
123 case EBCTestCmdFileSelDlgQuickCreate: |
|
124 TestQuickCreateL(); |
|
125 break; |
|
126 case EBCTestCmdFileSelDlgQuickCreateTitle: |
|
127 TestQuickCreateL(_L("a title")); |
|
128 break; |
|
129 case EBCTestCmdFileSelDlgQuickCreateRes: |
|
130 TestQuickCreateL(0); // 0 is the default res id |
|
131 break; |
|
132 case EBCTestCmdFileSelDlgSettings: |
|
133 TestSettingsL(); |
|
134 break; |
|
135 default: |
|
136 break; |
|
137 } |
|
138 Teardown(); |
|
139 } |
|
140 |
|
141 // --------------------------------------------------------------------------- |
|
142 // CBCTestFileSelDlg::ReleaseCaseL |
|
143 // --------------------------------------------------------------------------- |
|
144 // |
|
145 void CBCTestFileSelDlg::Teardown() |
|
146 { |
|
147 delete iDlg; |
|
148 iDlg = NULL; |
|
149 } |
|
150 |
|
151 void CBCTestFileSelDlg::TestCreateL() |
|
152 { |
|
153 _LIT( KRootPath, "C:\\Data\\" ); |
|
154 TFileName rootFileName( KRootPath ); |
|
155 |
|
156 iDlg = CAknFileSelectionDialog::NewL( ECFDDialogTypeSelect ); |
|
157 AssertNotNullL(iDlg, _L("file sel dialog create")); |
|
158 TInt returnValue = iDlg->ExecuteL( rootFileName ); |
|
159 TFileName msg; |
|
160 msg.Format( _L("User hit: %d, selected file: "), returnValue ); |
|
161 msg.Append( rootFileName ); |
|
162 msg.ZeroTerminate(); |
|
163 AssertTrueL(ETrue, msg); |
|
164 } |
|
165 |
|
166 void CBCTestFileSelDlg::TestCreateL(TInt aResID) |
|
167 { |
|
168 _LIT( KRootPath, "C:\\Data\\" ); |
|
169 TFileName rootFileName( KRootPath ); |
|
170 |
|
171 iDlg = CAknFileSelectionDialog::NewL( ECFDDialogTypeSelect, aResID ); |
|
172 AssertNotNullL(iDlg, _L("file sel dialog create with Res ID")); |
|
173 TInt returnValue = iDlg->ExecuteL( rootFileName ); |
|
174 TFileName msg; |
|
175 msg.Format(_L("User hit: %d, selected file: "), returnValue ); |
|
176 msg.Append( rootFileName ); |
|
177 msg.ZeroTerminate(); |
|
178 AssertTrueL(ETrue, msg); |
|
179 } |
|
180 |
|
181 void CBCTestFileSelDlg::TestQuickCreateL() |
|
182 { |
|
183 TFileName filename; |
|
184 TFileName folder(_L("C:\\Data\\")); |
|
185 AssertTrueL(!CAknFileSelectionDialog::RunDlgLD(filename, folder), |
|
186 _L("Quick create, User hit Cancle")); |
|
187 } |
|
188 |
|
189 void CBCTestFileSelDlg::TestQuickCreateL(const TDesC &aTitle) |
|
190 { |
|
191 TFileName filename; |
|
192 TFileName folder(_L("C:\\Data\\")); |
|
193 AssertTrueL(!CAknFileSelectionDialog::RunDlgLD(filename, folder, aTitle), |
|
194 _L("Quick create, User hit Cancle")); |
|
195 } |
|
196 |
|
197 void CBCTestFileSelDlg::TestQuickCreateL(TInt aResID) |
|
198 { |
|
199 TFileName filename; |
|
200 TFileName folder(_L("C:\\Data\\")); |
|
201 AssertTrueL(!CAknFileSelectionDialog::RunDlgLD(filename, folder, aResID), |
|
202 _L("Quick create, User hit Cancle")); |
|
203 } |
|
204 |
|
205 void CBCTestFileSelDlg::SetupL() |
|
206 { |
|
207 } |
|
208 |
|
209 |
|
210 void CBCTestFileSelDlg::TestSettingsL() |
|
211 { |
|
212 iDlg = CAknFileSelectionDialog::NewL( ECFDDialogTypeSelect ); |
|
213 iDlg->SetDefaultFolderL(_L("C:\\")); |
|
214 AssertTrueL(ETrue, _L("default folder set")); |
|
215 |
|
216 iDlg->SetTitleL(_L("a title")); |
|
217 AssertTrueL(ETrue, _L("title set")); |
|
218 |
|
219 iDlg->SetLeftSoftkeyFileL(_L("left fkey")); |
|
220 AssertTrueL(ETrue, _L("left soft key file set")); |
|
221 |
|
222 iDlg->SetLeftSoftkeyFolderL(_L("left dkey")); |
|
223 AssertTrueL(ETrue, _L("left soft key folder set")); |
|
224 |
|
225 iDlg->SetRightSoftkeyRootFolderL(_L("right root")); |
|
226 AssertTrueL(ETrue, _L("right soft key root set")); |
|
227 |
|
228 iDlg->SetRightSoftkeySubfolderL(_L("right sdir")); |
|
229 AssertTrueL(ETrue, _L("right soft key sub folder set")); |
|
230 |
|
231 //Add fileter and set Observer |
|
232 struct MonkObserver: public MAknFileSelectionObserver{ |
|
233 TBool OkToExitL( const TDesC& /*aDriveAndPath*/, const TEntry& /*aEntry*/ ){ |
|
234 return ETrue; |
|
235 } |
|
236 } monkObserver; |
|
237 |
|
238 iDlg->SetObserver(&monkObserver); |
|
239 AssertTrueL(ETrue, _L("Observer set")); |
|
240 |
|
241 struct MonkFilter: public MAknFileFilter{ |
|
242 TBool Accept( const TDesC& /*aDriveAndPath*/, const TEntry& /*aEntry*/ ) const{ |
|
243 return ETrue; |
|
244 } |
|
245 }; |
|
246 |
|
247 iDlg->AddFilterL(new (ELeave) MonkFilter); //problems, should be push into stack |
|
248 AssertTrueL(ETrue, _L("Filter add")); |
|
249 |
|
250 TFileName filename; |
|
251 iDlg->ExecuteL(filename); |
|
252 } |
|