1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 /* |
2 // All rights reserved. |
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
3 // This component and the accompanying materials are made available |
3 * All rights reserved. |
4 // under the terms of "Eclipse Public License v1.0" |
4 * This component and the accompanying materials are made available |
5 // which accompanies this distribution, and is available |
5 * under the terms of "Eclipse Public License v1.0" |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 * which accompanies this distribution, and is available |
7 // |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 // Initial Contributors: |
8 * |
9 // Nokia Corporation - initial contribution. |
9 * Initial Contributors: |
10 // |
10 * Nokia Corporation - initial contribution. |
11 // Contributors: |
11 * |
12 // |
12 * Contributors: |
13 // Description: |
13 * |
14 // |
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
15 |
18 |
16 /** |
19 /** |
17 @file |
20 @file |
18 @publishedAll |
21 @publishedAll |
19 @released |
22 @released |
20 */ |
23 */ |
21 #include <e32math.h> |
24 #include <e32math.h> |
22 #include "CCntDbManager.h" |
25 #include "ccntdbmanager.h" |
23 #include "LowDiskSpaceStep.h" |
26 #include "lowdiskspacestep.h" |
24 #include "PerformanceFunctionalityDefs.h" |
27 #include "performancefunctionalitydefs.h" |
25 |
28 |
26 _LIT( KTest1, "CRUD tests" ); |
29 _LIT( KTest1, "CRUD tests" ); |
27 _LIT( KTest2, "Database tests" ); |
30 _LIT( KTest2, "Database tests" ); |
28 _LIT( KTest3, "Other Miscellaneous apis tests" ); |
31 _LIT( KTest3, "Other Miscellaneous apis tests" ); |
29 _LIT( KTest4, "Transaction commit failure test"); |
32 _LIT( KTest4, "Transaction commit failure test"); |
42 |
45 |
43 _LIT(KCleanup, "cleanup"); |
46 _LIT(KCleanup, "cleanup"); |
44 _LIT(KDiskSize, "size: %LD, free space: %LD"); |
47 _LIT(KDiskSize, "size: %LD, free space: %LD"); |
45 _LIT(KStars,"*******************************"); |
48 _LIT(KStars,"*******************************"); |
46 |
49 |
|
50 |
47 // how much empty space will be made available on disk, in bytes |
51 // how much empty space will be made available on disk, in bytes |
48 const static TInt KMinusFull = KLowDiskThreshold - 8000; |
52 const static TInt KMinusFull = KLowDiskThreshold - 8000; |
49 #define KNumberOfContacts 200 |
53 #define KNumberOfContacts 200 |
50 |
54 |
51 CLowDiskSpaceStep::CLowDiskSpaceStep(CPerformanceFunctionalityTestsSuite &aParent) : CPerformanceFunctionalityBase( KNumberOfContacts, aParent ), |
55 CLowDiskSpaceStep::CLowDiskSpaceStep(CPerformanceFunctionalityTestsSuite &aParent) : CPerformanceFunctionalityBase( KNumberOfContacts, aParent ), |
52 iExpectedError( KErrDiskFull ) |
56 iExpectedError( KErrDiskFull ) |
53 { |
57 { |
54 SetTestStepName(KLowDiskSpaceStep); |
58 SetTestStepName(KLowDiskSpaceStep); |
55 } |
59 } |
56 |
60 |
57 #ifndef __WINSCW__ |
61 |
58 void CLowDiskSpaceStep::CLowDiskSpaceActive::RunL() |
62 void CLowDiskSpaceStep::CLowDiskSpaceActive::RunL() |
59 { |
63 { |
60 const static TInt numberOfTests = iStep->iTests->Count(); |
64 const static TInt numberOfTests = iStep->iTests->Count(); |
61 if( iStep->iNextTest >= numberOfTests )//have we run all the tests |
65 if( iStep->iNextTest >= numberOfTests )//have we run all the tests |
62 { |
66 { |
128 if( iTests ) |
130 if( iTests ) |
129 { |
131 { |
130 iTests->Close(); |
132 iTests->Close(); |
131 CLEAR(iTests); |
133 CLEAR(iTests); |
132 } |
134 } |
133 #endif |
|
134 return CPerformanceFunctionalityBase::doTestStepPostambleL(); |
135 return CPerformanceFunctionalityBase::doTestStepPostambleL(); |
135 } |
136 } |
136 |
137 |
137 #ifndef __WINSCW__ |
|
138 void CLowDiskSpaceStep::InitializeL() |
138 void CLowDiskSpaceStep::InitializeL() |
139 { |
139 { |
140 CPerformanceFunctionalityBase::InitializeL(); |
140 CPerformanceFunctionalityBase::InitializeL(); |
141 iGroup = iContactsDatabase->CreateContactGroupL(); |
141 iGroup = iContactsDatabase->CreateContactGroupL(); |
142 iCustomTemplate = iContactsDatabase->CreateContactCardTemplateL(KCntDB); |
142 iCustomTemplate = iContactsDatabase->CreateContactCardTemplateL(KCntDB); |
148 { |
148 { |
149 CLEAR( iGroup ); |
149 CLEAR( iGroup ); |
150 CLEAR( iCustomTemplate ); |
150 CLEAR( iCustomTemplate ); |
151 CPerformanceFunctionalityBase::Cleanup(); |
151 CPerformanceFunctionalityBase::Cleanup(); |
152 } |
152 } |
153 #endif |
|
154 |
153 |
155 void CLowDiskSpaceStep::PreTestL() |
154 void CLowDiskSpaceStep::PreTestL() |
156 { |
155 { |
157 #ifndef __WINSCW__ |
|
158 iConfigSection = &ConfigSection(); |
156 iConfigSection = &ConfigSection(); |
159 iMyActive = new (ELeave) CLowDiskSpaceStep::CLowDiskSpaceActive( this ); |
157 iMyActive = new (ELeave) CLowDiskSpaceStep::CLowDiskSpaceActive( this ); |
160 iCleanup = (KCleanup() == *iConfigSection); |
158 iCleanup = (KCleanup() == *iConfigSection); |
161 |
159 |
162 User::LeaveIfError( iParent->Fs().Connect() ); |
160 User::LeaveIfError( iParent->Fs().Connect() ); |
193 iTests->AppendL( &CLowDiskSpaceStep::StartHighdiskModeL ); |
191 iTests->AppendL( &CLowDiskSpaceStep::StartHighdiskModeL ); |
194 iTests->AppendL( &CLowDiskSpaceStep::CrudTestL ); |
192 iTests->AppendL( &CLowDiskSpaceStep::CrudTestL ); |
195 iTests->AppendL( &CLowDiskSpaceStep::MiscDbTestsL ); |
193 iTests->AppendL( &CLowDiskSpaceStep::MiscDbTestsL ); |
196 iTests->AppendL( &CLowDiskSpaceStep::DatabaseTestsL ); |
194 iTests->AppendL( &CLowDiskSpaceStep::DatabaseTestsL ); |
197 } |
195 } |
198 #endif |
196 } |
199 } |
197 |
200 |
|
201 TVerdict CLowDiskSpaceStep::doTestStepL() |
198 TVerdict CLowDiskSpaceStep::doTestStepL() |
202 { |
199 { |
203 #ifndef __WINSCW__ |
|
204 if(iCleanup) |
200 if(iCleanup) |
205 { |
201 { |
206 ClearDiskL(); |
202 ClearDiskL(); |
207 } |
203 } |
208 else |
204 else |
215 iMyActive->Activate(); |
211 iMyActive->Activate(); |
216 CActiveScheduler::Start(); |
212 CActiveScheduler::Start(); |
217 Cleanup(); |
213 Cleanup(); |
218 __UHEAP_MARKEND; |
214 __UHEAP_MARKEND; |
219 } |
215 } |
220 #endif |
|
221 return TestStepResult(); |
216 return TestStepResult(); |
222 } |
217 } |
223 |
218 |
224 #ifndef __WINSCW__ |
|
225 /** |
219 /** |
226 populates the disk so that only a very small amount of disk space is available, |
220 populates the disk so that only a very small amount of disk space is available, |
227 invoking low disk notification within cntsrv |
221 invoking low disk notification within cntsrv |
228 */ |
222 */ |
229 void CLowDiskSpaceStep::FillDiskL() |
223 void CLowDiskSpaceStep::FillDiskL() |
230 { |
224 { |
|
225 |
231 TVolumeInfo tv; |
226 TVolumeInfo tv; |
232 User::LeaveIfError( iParent->Fs().Volume(tv) ); |
227 User::LeaveIfError( iParent->Fs().Volume(tv) ); |
233 |
228 |
234 INFO_PRINTF3(KDiskSize, tv.iSize, tv.iFree); |
229 INFO_PRINTF3(KDiskSize, tv.iSize, tv.iFree); |
235 TInt frees = 0; |
230 TInt frees = 0; |