|
1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: Unit test case to test functionalities of CmdCheckUserDrive, |
|
14 // CCustomCmdClearStartupReason,CCustomCmdDeleteTempFiles,CCmdInitRamDrive and CCustomCmdValidateRTC custom commands. |
|
15 // |
|
16 |
|
17 /** |
|
18 @file |
|
19 @test |
|
20 @internalComponent - Internal Symbian test code |
|
21 */ |
|
22 |
|
23 #include "tcmd_step_execute.h" |
|
24 |
|
25 /** |
|
26 This function is wrapped in Callback and used to stop the CActiveScheduler |
|
27 when all other activities have been peformed |
|
28 */ |
|
29 static TInt StopScheduler(TAny* aCmdValidateRTCTest) |
|
30 { |
|
31 CTestCustomCmdExecute* cmdValidateRTCTest = static_cast<CTestCustomCmdExecute*>(aCmdValidateRTCTest); |
|
32 cmdValidateRTCTest->StopActiveScheduler(); |
|
33 return KErrNone; |
|
34 } |
|
35 |
|
36 void CTestCustomCmdExecute::StopActiveScheduler() |
|
37 { |
|
38 if(iStatus != KRequestPending) |
|
39 { |
|
40 CActiveScheduler::Stop(); |
|
41 } |
|
42 else |
|
43 { |
|
44 iAsyncStopScheduler->CallBack(); |
|
45 } |
|
46 } |
|
47 |
|
48 CTestCustomCmdExecute::~CTestCustomCmdExecute() |
|
49 { |
|
50 delete iCmdEnv; |
|
51 iFs.Close(); |
|
52 delete iAsyncStopScheduler; |
|
53 delete iActiveScheduler; |
|
54 } |
|
55 |
|
56 CTestCustomCmdExecute::CTestCustomCmdExecute() |
|
57 { |
|
58 SetTestStepName(KTestCustomCmdExecute); |
|
59 } |
|
60 |
|
61 /** |
|
62 Create common resources for this test |
|
63 Install CActiveScheduler necessary for the tests |
|
64 */ |
|
65 TVerdict CTestCustomCmdExecute::doTestStepPreambleL( ) |
|
66 { |
|
67 iActiveScheduler = new(ELeave) CActiveScheduler; |
|
68 CActiveScheduler::Install (iActiveScheduler ); |
|
69 |
|
70 iAsyncStopScheduler = new(ELeave) CAsyncCallBack(CActive::EPriorityIdle); |
|
71 TCallBack stop(StopScheduler, this); |
|
72 iAsyncStopScheduler->Set (stop ); |
|
73 |
|
74 User::LeaveIfError(iFs.Connect()); |
|
75 |
|
76 iCmdEnv = CSsmCustomCommandEnv::NewL(iFs); |
|
77 |
|
78 return CTestStep::doTestStepPreambleL ( ); |
|
79 } |
|
80 |
|
81 /** |
|
82 Test CaseID DEVSRVS-SSREFPLUGINS-CUSTCMD-0028 |
|
83 */ |
|
84 void CTestCustomCmdExecute::TestCustomCmdValidateRTC() |
|
85 { |
|
86 INFO_PRINTF1(_L("TestCustomCmdValidateRTC started")); |
|
87 //Create ValidateRTC custom command |
|
88 MSsmCustomCommand* customCmdValidateRTC = SsmCustomCmdFactory::CmdValidateRTCNewL(); |
|
89 customCmdValidateRTC->Initialize(iCmdEnv); |
|
90 ExecuteCommand(customCmdValidateRTC); |
|
91 TEST(KErrNotSupported == iStatus.Int()); |
|
92 ExecuteCommand(customCmdValidateRTC); |
|
93 customCmdValidateRTC->ExecuteCancel(); |
|
94 TEST(KErrNotSupported == iStatus.Int()); |
|
95 //Close the command |
|
96 customCmdValidateRTC->Close(); |
|
97 //Releasing the comand will delete itself. |
|
98 customCmdValidateRTC->Release(); |
|
99 INFO_PRINTF3(_L("TestCustomCmdValidateRTC completed with %d Expected %d"),iStatus.Int(),KErrNotSupported); |
|
100 } |
|
101 |
|
102 /** |
|
103 Test CaseID DEVSRVS-SSREFPLUGINS-CUSTCMD-0028 |
|
104 */ |
|
105 void CTestCustomCmdExecute::TestCustomCmdCheckUserDrive() |
|
106 { |
|
107 INFO_PRINTF1(_L("TestCustomCmdCheckUserDriveL started")); |
|
108 //Create ChectUserDrive custom command |
|
109 MSsmCustomCommand* customCmdCheckUserDrive = SsmCustomCmdFactory::CmdCheckUserDriveNewL(); |
|
110 customCmdCheckUserDrive->Initialize(iCmdEnv); |
|
111 ExecuteCommand(customCmdCheckUserDrive); |
|
112 TEST(KErrNone == iStatus.Int()); |
|
113 ExecuteCommand(customCmdCheckUserDrive); |
|
114 customCmdCheckUserDrive->ExecuteCancel(); |
|
115 TEST(KErrNone == iStatus.Int()); |
|
116 //Close the command |
|
117 customCmdCheckUserDrive->Close(); |
|
118 //Delete the custom command |
|
119 customCmdCheckUserDrive->Release(); |
|
120 INFO_PRINTF3(_L("TestCustomCmdCheckUserDriveL completed with %d Expected %d"),iStatus.Int(),KErrNone); |
|
121 } |
|
122 |
|
123 /** |
|
124 Test CaseID DEVSRVS-SSREFPLUGINS-CUSTCMD-0028 |
|
125 */ |
|
126 void CTestCustomCmdExecute::TestCustomCmdClearStartupReason() |
|
127 { |
|
128 INFO_PRINTF1(_L("TestCustomCmdClearStartupReason started")); |
|
129 //Create ClearStartupReason custom command |
|
130 MSsmCustomCommand* customCmdClearStartupReason = SsmCustomCmdFactory::CmdClearStartupReasonNewL(); |
|
131 customCmdClearStartupReason->Initialize(iCmdEnv); |
|
132 ExecuteCommand(customCmdClearStartupReason); |
|
133 TEST(KErrNone == iStatus.Int()); |
|
134 ExecuteCommand(customCmdClearStartupReason); |
|
135 customCmdClearStartupReason->ExecuteCancel(); |
|
136 TEST(KErrNone == iStatus.Int()); |
|
137 //Close the command |
|
138 customCmdClearStartupReason->Close(); |
|
139 customCmdClearStartupReason->Release(); |
|
140 INFO_PRINTF3(_L("TestCustomCmdClearStartupReason completed with %d Expected %d"),iStatus.Int(),KErrNone); |
|
141 } |
|
142 |
|
143 /** |
|
144 Test CaseID DEVSRVS-SSREFPLUGINS-CUSTCMD-0028 |
|
145 */ |
|
146 void CTestCustomCmdExecute::TestCustomCmdDeleteTempFiles() |
|
147 { |
|
148 INFO_PRINTF1(_L("TestCustomCmdDeleteTempFilesL started")); |
|
149 //Create DeleteTempFiles custom command |
|
150 MSsmCustomCommand* customCmdDeleteTempFiles = SsmCustomCmdFactory::CmdDeleteTempFilesNewL(); |
|
151 customCmdDeleteTempFiles->Initialize(iCmdEnv); |
|
152 ExecuteCommand(customCmdDeleteTempFiles); |
|
153 TEST(KErrNone == iStatus.Int()); |
|
154 ExecuteCommand(customCmdDeleteTempFiles); |
|
155 customCmdDeleteTempFiles->ExecuteCancel(); |
|
156 TEST(KErrNone == iStatus.Int()); |
|
157 //Close the command |
|
158 customCmdDeleteTempFiles->Close(); |
|
159 //Delete the custom command |
|
160 customCmdDeleteTempFiles->Release(); |
|
161 INFO_PRINTF3(_L("TestCustomCmdDeleteTempFilesL completed with %d Expected %d"),iStatus.Int(),KErrNone); |
|
162 } |
|
163 |
|
164 /** |
|
165 Test CaseID DEVSRVS-SSREFPLUGINS-CUSTCMD-0028 |
|
166 */ |
|
167 void CTestCustomCmdExecute::TestCustomCmdInitRamDrive() |
|
168 { |
|
169 INFO_PRINTF1(_L("TestCustomCmdInitRamDrive started")); |
|
170 //Create InitRamDrive custom command |
|
171 MSsmCustomCommand* customCmdInitRamDrive = SsmCustomCmdFactory::CmdInitRamDriveNewL(); |
|
172 customCmdInitRamDrive->Initialize(iCmdEnv); |
|
173 ExecuteCommand(customCmdInitRamDrive); |
|
174 TEST(KErrNone == iStatus.Int()); |
|
175 ExecuteCommand(customCmdInitRamDrive); |
|
176 customCmdInitRamDrive->ExecuteCancel(); |
|
177 TEST(KErrNone == iStatus.Int()); |
|
178 //Close the command |
|
179 customCmdInitRamDrive->Close(); |
|
180 //Delete the custom command |
|
181 customCmdInitRamDrive->Release(); |
|
182 INFO_PRINTF3(_L("TestCustomCmdInitRamDrive completed with %d Expected %d"),iStatus.Int(),KErrNone); |
|
183 } |
|
184 |
|
185 void CTestCustomCmdExecute::ExecuteCommand(MSsmCustomCommand *aCustCmd) |
|
186 { |
|
187 TBufC8<1> dummy; |
|
188 //Command parameter is not used inside the Execute. So passing any dummy data should be fine |
|
189 //Execute the command |
|
190 aCustCmd->Execute(dummy, iStatus); |
|
191 //this callback will not run until the test is finished because it has priority idle |
|
192 iAsyncStopScheduler->CallBack ( ); |
|
193 //run custom command |
|
194 iActiveScheduler->Start( ); |
|
195 } |
|
196 |
|
197 /** |
|
198 Clean up if necessary |
|
199 */ |
|
200 TVerdict CTestCustomCmdExecute::doTestStepPostambleL( ) |
|
201 { |
|
202 return CTestStep::doTestStepPostambleL ( ); |
|
203 } |
|
204 |
|
205 TVerdict CTestCustomCmdExecute::doTestStepL() |
|
206 { |
|
207 __UHEAP_MARK; |
|
208 TestCustomCmdInitRamDrive(); |
|
209 TestCustomCmdDeleteTempFiles(); |
|
210 TestCustomCmdCheckUserDrive(); |
|
211 TestCustomCmdClearStartupReason(); |
|
212 TestCustomCmdValidateRTC(); |
|
213 __UHEAP_MARKEND; |
|
214 return TestStepResult(); |
|
215 } |