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 <caknfilenamepromptdialog.h> |
|
29 #include <MAknFileSelectionObserver.h> |
|
30 #include <MaknFileFilter.h> |
|
31 |
|
32 #include "BCTestFileNameDlg.h" |
|
33 #include "BCTestCmDlg.hrh" |
|
34 #include "streamlogger.h" |
|
35 |
|
36 // ======== MEMBER FUNCTIONS ======== |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // Symbian 2nd static Constructor |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CBCTestFileNameDlg* CBCTestFileNameDlg::NewL() |
|
43 { |
|
44 CBCTestFileNameDlg* self = new( ELeave ) CBCTestFileNameDlg(); |
|
45 CleanupStack::PushL( self ); |
|
46 self->ConstructL(); |
|
47 CleanupStack::Pop( self ); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // C++ default constructor |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CBCTestFileNameDlg::CBCTestFileNameDlg():iDlg(0) |
|
56 { |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // Destructor |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 CBCTestFileNameDlg::~CBCTestFileNameDlg() |
|
64 { |
|
65 delete iDlg; |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // Symbian 2nd Constructor |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 void CBCTestFileNameDlg::ConstructL() |
|
73 { |
|
74 BuildScriptL(); |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CBCTestFileNameDlg::BuildScriptL |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 void CBCTestFileNameDlg::BuildScriptL() |
|
82 { |
|
83 AddTestL( DELAY(1), TEND); |
|
84 |
|
85 // Add script as your need. |
|
86 for(int i=0; i<EBCTestCmdFileNameDlgEnd - EBCTestCmdFileNameDlgBegin -1; ++i) |
|
87 { |
|
88 AddTestL( LeftCBA, REP(Down, 3), Right, TEND ); |
|
89 for(int j=0; j<i; ++j) |
|
90 AddTestL( Down, TEND); |
|
91 AddTestL( LeftCBA, TEND ); |
|
92 AddCancelL(); //OK may enter a folder and ask user to select more. |
|
93 } |
|
94 } |
|
95 |
|
96 void CBCTestFileNameDlg::AddOKL() |
|
97 { |
|
98 // add dlg response sciprts |
|
99 for(int i=0; i<1; ++i) |
|
100 AddTestL( WAIT(5), KeyOK, TEND); |
|
101 } |
|
102 |
|
103 void CBCTestFileNameDlg::AddCancelL() |
|
104 { |
|
105 // add dlg response sciprts |
|
106 for(int i=0; i<1; ++i) |
|
107 AddTestL( WAIT(5), RightCBA, TEND); |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // CBCTestFileNameDlg::RunL |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 void CBCTestFileNameDlg::RunL( TInt aCmd ) |
|
115 { |
|
116 SetupL(); |
|
117 switch(aCmd){ |
|
118 case EBCTestCmdFileNameDlgCreate: |
|
119 TestCreateL(); |
|
120 break; |
|
121 case EBCTestCmdFileNameDlgCreateRes: |
|
122 TestCreateL(0); // 0 is default res id |
|
123 break; |
|
124 case EBCTestCmdFileNameDlgQuickCreate: |
|
125 TestQuickCreateL(); |
|
126 break; |
|
127 case EBCTestCmdFileNameDlgQuickCreateTitle: |
|
128 TestQuickCreateL(_L("a title")); |
|
129 break; |
|
130 case EBCTestCmdFileNameDlgQuickCreateRes: |
|
131 TestQuickCreateL(0); // 0 is the default res id |
|
132 break; |
|
133 case EBCTestCmdFileNameDlgSettings: |
|
134 TestSettingsL(); |
|
135 break; |
|
136 default: |
|
137 break; |
|
138 } |
|
139 Teardown(); |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // CBCTestFileNameDlg::ReleaseCaseL |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 void CBCTestFileNameDlg::Teardown() |
|
147 { |
|
148 delete iDlg; |
|
149 iDlg = NULL; |
|
150 } |
|
151 |
|
152 void CBCTestFileNameDlg::TestCreateL() |
|
153 { |
|
154 TFileName emptyFileName(KNullDesC); |
|
155 iDlg = CAknFileNamePromptDialog::NewL(); |
|
156 TInt returnValue = iDlg->ExecuteL( emptyFileName ); |
|
157 TFileName msg; |
|
158 msg.Format(_L("create User hit %d, filename: %s"), returnValue, &emptyFileName ); |
|
159 msg.ZeroTerminate(); |
|
160 AssertTrueL(ETrue, msg); |
|
161 } |
|
162 |
|
163 void CBCTestFileNameDlg::TestCreateL(TInt aResID) |
|
164 { |
|
165 TFileName emptyFileName(KNullDesC); |
|
166 iDlg = CAknFileNamePromptDialog::NewL(aResID); |
|
167 TInt returnValue = iDlg->ExecuteL( emptyFileName ); |
|
168 AssertTrueL(ETrue, _L("Create by res ID")); |
|
169 } |
|
170 |
|
171 void CBCTestFileNameDlg::TestQuickCreateL() |
|
172 { |
|
173 _LIT(KRootPath, "C:\\Nokia\\Data"); |
|
174 TFileName defaultFileName; |
|
175 TInt returnValue = CAknFileNamePromptDialog::RunDlgLD( defaultFileName, KRootPath ); |
|
176 AssertTrueL(ETrue, _L("RunDlgLD invoked")); |
|
177 } |
|
178 |
|
179 void CBCTestFileNameDlg::TestQuickCreateL(const TDesC &aTitle) |
|
180 { |
|
181 _LIT(KRootPath, "C:\\Nokia\\Data"); |
|
182 TFileName defaultFileName; |
|
183 TInt returnValue = CAknFileNamePromptDialog::RunDlgLD( defaultFileName, KRootPath, aTitle ); |
|
184 AssertTrueL(ETrue, _L("RunDlgLD invoked")); |
|
185 } |
|
186 |
|
187 void CBCTestFileNameDlg::TestQuickCreateL(TInt aResID) |
|
188 { |
|
189 _LIT(KRootPath, "C:\\Nokia\\Data"); |
|
190 TFileName defaultFileName; |
|
191 TInt returnValue = CAknFileNamePromptDialog::RunDlgLD( defaultFileName, KRootPath, aResID ); |
|
192 AssertTrueL(ETrue, _L("RunDlgLD invoked")); |
|
193 } |
|
194 |
|
195 void CBCTestFileNameDlg::SetupL() |
|
196 { |
|
197 } |
|
198 |
|
199 |
|
200 void CBCTestFileNameDlg::TestSettingsL() |
|
201 { |
|
202 iDlg = CAknFileNamePromptDialog::NewL(); |
|
203 iDlg->SetPathL(_L("C:\\")); |
|
204 AssertTrueL(ETrue, _L("path set")); |
|
205 |
|
206 iDlg->SetTitleL(_L("a title")); |
|
207 AssertTrueL(ETrue, _L("title set")); |
|
208 |
|
209 iDlg->SetLeftSoftkeyL(_L("left key")); |
|
210 AssertTrueL(ETrue, _L("left soft key set")); |
|
211 |
|
212 iDlg->SetRightSoftkeyL(_L("right key")); |
|
213 AssertTrueL(ETrue, _L("right soft key set")); |
|
214 |
|
215 //Add fileter and set Observer |
|
216 struct MonkObserver: public MAknFileSelectionObserver{ |
|
217 TBool OkToExitL( const TDesC& /*aDriveAndPath*/, const TEntry& /*aEntry*/ ){ |
|
218 return ETrue; |
|
219 } |
|
220 } monkObserver; |
|
221 |
|
222 iDlg->SetObserver(&monkObserver); |
|
223 AssertTrueL(ETrue, _L("Observer set")); |
|
224 |
|
225 TFileName filename; |
|
226 iDlg->ExecuteL(filename); |
|
227 } |
|