| Start/ | End/ | |||
| True | False | - | Line | Source |
| 1 | /* | |||
| 2 | * Copyright (c) 2010 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: This file contains STIFUnit implementation. | |||
| 15 | * | |||
| 16 | */ | |||
| 17 | ||||
| 18 | /** | |||
| 19 | * STIF_UNIT_INCLUDE SECTION - put all #includes between STIF_UNIT_INCLUDE_SECTION | |||
| 20 | * and STIF_UNIT_INCLUDE_SECTION_END | |||
| 21 | */ | |||
| 22 | #ifdef STIF_UNIT_INCLUDE_SECTION | |||
| 23 | ||||
| 24 | #include <barsc.h> | |||
| 25 | #include <barsread.h> | |||
| 26 | #include <bautils.h> | |||
| 27 | #include <data_caging_path_literals.hrh> | |||
| 28 | #include <e32debug.h> | |||
| 29 | #include <e32property.h> | |||
| 30 | #include <f32file.h> | |||
| 31 | #include <lafmemorywatcher.rsg> | |||
| 32 | #include <lafshut.h> | |||
| 33 | #include <savenotf.h> | |||
| 34 | #include <systemwarninglevels.hrh> | |||
| 35 | #include <UiklafInternalCRKeys.h> | |||
| 36 | #include <w32std.h> | |||
| 37 | ||||
| 38 | ||||
| 39 | #include "mockshutdowneventobserver.h" | |||
| 40 | #include "ut_oodmonitor_const.h" | |||
| 41 | #include "ut_oodmonitor_timer.h" | |||
| 42 | #include "Ood.h" | |||
| 43 | ||||
| 44 | #endif //STIF_UNIT_INCLUDE_SECTION_END | |||
| 45 | ||||
| 46 | /** | |||
| 47 | * GLOBAL VARIABLES SECTION | |||
| 48 | */ | |||
| 49 | #ifdef TEST_VAR_DECLARATIONS | |||
| 50 | ||||
| 51 | ||||
| 52 | #endif | |||
| 53 | /** | |||
| 54 | * END OF GLOBAL VARIABLES SECTION | |||
| 55 | */ | |||
| 56 | ||||
| 57 | ||||
| 58 | /** | |||
| 59 | * TEST CASES SECTION | |||
| 60 | */ | |||
| 61 | #ifdef TEST_CASES | |||
| 62 | /** | |||
| 63 | * STIF_SETUP defines activities needed before every test case. | |||
| 64 | */ | |||
| 65 | STIF_SETUP | |||
| 66 | { | |||
| 67 | // property for setting AccMode | |||
| 68 | RProperty::Define(KUTSysApPropertyCategory, KHandleShutdownEventKey, | |||
| 69 | RProperty::EInt, KAllowAllPolicy, KAllowAllPolicy); | |||
| 70 | RProperty::Define(KUTSysApPropertyCategory, KGetShutdownStateKey, | |||
| 71 | RProperty::EInt, KAllowAllPolicy, KAllowAllPolicy); | |||
| 72 | } | |||
| 73 | ||||
| 74 | /** | |||
| 75 | * STIF_TEARDOWN defines activities needed after every test case | |||
| 76 | */ | |||
| 77 | STIF_TEARDOWN | |||
| 78 | { | |||
| 79 | RProperty::Delete(KUTSysApPropertyCategory, KHandleShutdownEventKey); | |||
| 80 | RProperty::Delete(KUTSysApPropertyCategory, KGetShutdownStateKey); | |||
| 81 | } | |||
| 82 | ||||
| 83 | /** | |||
| 84 | * @SYMTestCaseID GAPS-OOD-SHUTDOWNMANAGER-001 | |||
| 85 | * @SYMTestCaseDesc Create CLafShutdownManager object then delete it. | |||
| 86 | * @SYMTestPriority Medium | |||
| 87 | * @SYMTestActions 1. Create scheduler. | |||
| 88 | * 2. Create friend class object of CLafShutdownManager. | |||
| 89 | * 3. Create CLafShutdownManager object. | |||
| 90 | * 4. Check all the proterties have been initialized. | |||
| 91 | * 5. Check subscribers have been initialized. | |||
| 92 | * 6. Check thresholds of OODWarning and OODCritical have been assigned correct value. | |||
| 93 | * 7. Check GlobalQueryActive has been initialized. | |||
| 94 | * 8. Check OODWarningWatcher and iOODCriticalWatcher has been initialized. | |||
| 95 | * @SYMTestExpectedResults 1. Sechduler is created. | |||
| 96 | * 2. Friend class object of CLafShutdownManager is created. | |||
| 97 | * 3. CLafShutdownManager object is created. | |||
| 98 | * 4. All the proterties can be accessed. | |||
| 99 | * 5. All the pointer of subscribers are not null. | |||
| 100 | * 6. The thresholds of OODWarning and OODCritical have been assigned correct value. | |||
| 101 | * 7. The pointer of GlobalQueryActive is not null. | |||
| 102 | * 8. Pointers to OODWarningWatcher and iOODCriticalWatcher are not null. | |||
| 103 | * @SYMTestType Unit Test | |||
| 104 | * @SYMCreationDate 09-09-2010 | |||
| 105 | */ | |||
| 106 | STIF_TESTDEFINE(GAPS-OOD-SHUTDOWNMANAGER-001) | |||
| 107 | { | |||
| 108 | iLog->Log(_L("CLafShutdownManager:: GAPS-OOD-SHUTDOWNMANAGER-001 start")); | |||
| 109 | // Create active scheduler (to run active objects) | |||
| 110 | CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); | |||
| 111 | CleanupStack::PushL(scheduler); | |||
| 112 | CActiveScheduler::Install(scheduler); | |||
| 113 | ||||
| 114 | Tut_LafShutdownManager friendClass; | |||
| 115 | ShutdownEventObserver shutdownEventObserver; | |||
| 116 | CLafShutdownManager* shutdownManager = CLafShutdownManager::NewL(shutdownEventObserver); | |||
| 117 | ||||
| 118 | // Check properties | |||
| 119 | TInt value; | |||
| 120 | TInt err; | |||
| 121 | RProperty diskStatusProperty = friendClass.GetDiskStatusProperty(shutdownManager); | |||
| 122 | err = diskStatusProperty.Get(value); | |||
| 123 | STIF_ASSERT_EQUALS(KErrNone, err); | |||
| 124 | ||||
| 125 | RProperty mmcStatusProperty = friendClass.GetMMCStatusProperty(shutdownManager); | |||
| 126 | err = mmcStatusProperty.Get(value); | |||
| 127 | STIF_ASSERT_EQUALS(KErrNone, err); | |||
| 128 | ||||
| 129 | RProperty canDisplayNotesProperty = friendClass.GetCanDisplayNotesProperty(shutdownManager); | |||
| 130 | err = canDisplayNotesProperty.Get(value); | |||
| 131 | iLog->Log(_L("CLafShutdownManager:: iDisplayNotesProperty=%d"), value); | |||
| 132 | STIF_ASSERT_EQUALS(KErrNone, err); | |||
| 133 | ||||
| 134 | RProperty autolockStatusProperty = friendClass.GetAutolockStatusProperty(shutdownManager); | |||
| 135 | err = autolockStatusProperty.Get(value); | |||
| 136 | iLog->Log(_L("CLafShutdownManager:: iAutolockStatusProperty=%d"), value); | |||
| 137 | STIF_ASSERT_EQUALS(KErrNone, err); | |||
| 138 | ||||
| 139 | RProperty enableMMCWatchProperty = friendClass.GetEnableMMCWatchProperty(shutdownManager); | |||
| 140 | err = enableMMCWatchProperty.Get(value); | |||
| 141 | STIF_ASSERT_EQUALS(KErrNone, err); | |||
| 142 | ||||
| 143 | // Check subscriber | |||
| 144 | CBase* pointer = friendClass.GetDisplayNotesSubscriber(shutdownManager); | |||
| 145 | STIF_ASSERT_NOT_NULL(pointer); | |||
| 146 | pointer = friendClass.GetAutolockStatusSubscriber(shutdownManager); | |||
| 147 | STIF_ASSERT_NOT_NULL(pointer); | |||
| 148 | pointer = friendClass.GetMMCWatchSubscriber(shutdownManager); | |||
| 149 | STIF_ASSERT_NOT_NULL(pointer); | |||
| 150 | ||||
| 151 | TInt oodWarningThreshold = friendClass.GetOODWarningThreshold(shutdownManager); | |||
| 152 | STIF_ASSERT_EQUALS(KDRIVECWARNINGTHRESHOLD, oodWarningThreshold); | |||
| 153 | TInt oodCriticalThreshold = friendClass.GetOODCriticalThreshold(shutdownManager); | |||
| 154 | STIF_ASSERT_EQUALS(KDRIVECCRITICALTHRESHOLD, oodCriticalThreshold); | |||
| 155 | ||||
| 156 | CLafShutdownManager::CGlobalQueryActive* globalQuaryActive = friendClass.GetGlobalQueryActive(shutdownManager); | |||
| 157 | iLog->Log(_L("CLafShutdownManager::iGlobalQueryActive=%d"), globalQuaryActive); | |||
| 158 | STIF_ASSERT_NOT_NULL(globalQuaryActive); | |||
| 159 | ||||
| 160 | RFs fs; | |||
| 161 | User::LeaveIfError(fs.Connect()); | |||
| 162 | CleanupClosePushL(fs); | |||
| 163 | ||||
| 164 | RResourceFile resFile; | |||
| 165 | TFileName filename(KDriveZ); | |||
| 166 | filename.Append(KDC_RESOURCE_FILES_DIR); | |||
| 167 | filename.Append(KOOMWatcherResourceFileName); | |||
| 168 | BaflUtils::NearestLanguageFile(fs, filename); | |||
| 169 | resFile.OpenL(fs, filename); | |||
| 170 | CleanupClosePushL(resFile); | |||
| 171 | ||||
| 172 | TResourceReader theReader; | |||
| 173 | ||||
| 174 | CLafShutdownManager::CGlobalQueryActive::CMessageInfo* messageInfoPointer = | |||
| 175 | friendClass.GetMessageInfoList(globalQuaryActive, CLafShutdownManager::CGlobalQueryActive::ECritical); | |||
| 176 | ||||
| 177 | HBufC8* message = resFile.AllocReadLC(R_QTN_MEMLO_MEMORY_FULL); | |||
| 178 | theReader.SetBuffer(message); | |||
| 179 | HBufC* criticalMessage = theReader.ReadHBufCL(); | |||
| 180 | ||||
| 181 | iLog->Log(_L("CLafShutdownManager::criticalMessage=%S"), criticalMessage); | |||
| 182 | iLog->Log(_L("CLafShutdownManager::criticalMessage1=%S"), messageInfoPointer->iMessage); | |||
| 183 | ||||
| 184 | TInt result = criticalMessage->Compare(*(messageInfoPointer->iMessage)); | |||
| 185 | iLog->Log(_L("CLafShutdownManager::result=%d"), result); | |||
| 186 | ||||
| 187 | STIF_ASSERT_TRUE(0 == result); | |||
| 188 | delete criticalMessage; | |||
| 189 | CleanupStack::PopAndDestroy(message); | |||
| 190 | ||||
| 191 | messageInfoPointer = | |||
| 192 | friendClass.GetMessageInfoList(globalQuaryActive, CLafShutdownManager::CGlobalQueryActive::EWarning); | |||
| 193 | message = resFile.AllocReadLC(R_QTN_MEMLO_MEMORY_RUNNING_OUT); | |||
| 194 | theReader.SetBuffer(message); | |||
| 195 | HBufC* warningMessage = theReader.ReadHBufCL(); | |||
| 196 | ||||
| 197 | iLog->Log(_L("CLafShutdownManager::warningMessage=%S"), warningMessage); | |||
| 198 | iLog->Log(_L("CLafShutdownManager::warningMessage1=%S"), messageInfoPointer->iMessage); | |||
| 199 | ||||
| 200 | result = warningMessage->Compare(*(messageInfoPointer->iMessage)); | |||
| 201 | iLog->Log(_L("CLafShutdownManager::result=%d"), result); | |||
| 202 | ||||
| 203 | STIF_ASSERT_TRUE(0 == result); | |||
| 204 | delete warningMessage; | |||
| 205 | CleanupStack::PopAndDestroy(message); | |||
| 206 | ||||
| 207 | messageInfoPointer = | |||
| 208 | friendClass.GetMessageInfoList(globalQuaryActive, CLafShutdownManager::CGlobalQueryActive::EWarningMMC); | |||
| 209 | message = resFile.AllocReadLC(R_QTN_MEMLO_MMC_MEMORY_RUNNING_OUT); | |||
| 210 | theReader.SetBuffer(message); | |||
| 211 | HBufC* warningMMCMessage = theReader.ReadHBufCL(); | |||
| 212 | ||||
| 213 | iLog->Log(_L("CLafShutdownManager::warningMMCMessage=%S"), warningMMCMessage); | |||
| 214 | iLog->Log(_L("CLafShutdownManager::warningMMCMessage1=%S"), messageInfoPointer->iMessage); | |||
| 215 | ||||
| 216 | result = warningMMCMessage->Compare(*(messageInfoPointer->iMessage)); | |||
| 217 | iLog->Log(_L("CLafShutdownManager::result=%d"), result); | |||
| 218 | ||||
| 219 | STIF_ASSERT_TRUE(0 == result); | |||
| 220 | delete warningMMCMessage; | |||
| 221 | CleanupStack::PopAndDestroy(message); | |||
| 222 | ||||
| 223 | messageInfoPointer = | |||
| 224 | friendClass.GetMessageInfoList(globalQuaryActive, CLafShutdownManager::CGlobalQueryActive::ECriticalMMC); | |||
| 225 | message = resFile.AllocReadLC(R_QTN_MEMLO_MMC_MEMORY_FULL); | |||
| 226 | theReader.SetBuffer(message); | |||
| 227 | HBufC* criticalMMCMessage = theReader.ReadHBufCL(); | |||
| 228 | ||||
| 229 | iLog->Log(_L("CLafShutdownManager::criticalMMCMessage=%S"), criticalMMCMessage); | |||
| 230 | iLog->Log(_L("CLafShutdownManager::criticalMMCMessage1=%S"), messageInfoPointer->iMessage); | |||
| 231 | ||||
| 232 | result = criticalMMCMessage->Compare(*(messageInfoPointer->iMessage)); | |||
| 233 | iLog->Log(_L("CLafShutdownManager::result=%d"), result); | |||
| 234 | ||||
| 235 | STIF_ASSERT_TRUE(0 == result); | |||
| 236 | delete criticalMMCMessage; | |||
| 237 | CleanupStack::PopAndDestroy(message); | |||
| 238 | ||||
| 239 | CleanupStack::PopAndDestroy(&resFile); | |||
| 240 | CleanupStack::PopAndDestroy(&fs); | |||
| 241 | ||||
| 242 | CActive* pointer1 = friendClass.GetOODWarningWatcher(shutdownManager); | |||
| 243 | iLog->Log(_L("CLafShutdownManager::iOODWarningWatcher=%d"), pointer1); | |||
| 244 | STIF_ASSERT_NOT_NULL(pointer1); | |||
| 245 | pointer1 = friendClass.GetOODCriticalWatcher(shutdownManager); | |||
| 246 | iLog->Log(_L("CLafShutdownManager::iOODCriticalWatcher=%d"), pointer1); | |||
| 247 | STIF_ASSERT_NOT_NULL(pointer1); | |||
| 248 | ||||
| 249 | delete shutdownManager; | |||
| 250 | ||||
| 251 | // Delete active scheduler | |||
| 252 | CleanupStack::PopAndDestroy(scheduler); | |||
| 253 | iLog->Log(_L("CLafShutdownManager:: GAPS-OOD-SHUTDOWNMANAGER-001 end")); | |||
| 254 | } | |||
| 255 | ||||
| 256 | /** | |||
| 257 | * @SYMTestCaseID GAPS-OOD-SHUTDOWNMANAGER-002 | |||
| 258 | * @SYMTestCaseDesc Test LafShutdown class. | |||
| 259 | * @SYMTestPriority Medium | |||
| 260 | * @SYMTestActions 1. Create scheduler. | |||
| 261 | * 2. Test LafShutdown::CreateShutdownManager(); | |||
| 262 | * 3. Test LafShutdown::SaveFromViewSwitch(); | |||
| 263 | * 4. Test LafShutdown::SaveFromAppSwitch(); | |||
| 264 | * 5. Delete CLafShutdownManagerBase object. | |||
| 265 | * 6. Delete scheduler. | |||
| 266 | * @SYMTestExpectedResults 1. Sechduler is created. | |||
| 267 | * 2. CLafShutdownManagerBase object is created. | |||
| 268 | * 3. LafShutdown::SaveFromViewSwitch(); return expected value. | |||
| 269 | * 4. LafShutdown::SaveFromAppSwitch(); return expected value. | |||
| 270 | * 5. CLafShutdownManagerBase object is deleted. | |||
| 271 | * 6. Scheduler is deleted. | |||
| 272 | * @SYMTestType Unit Test | |||
| 273 | * @SYMCreationDate 09-09-2010 | |||
| 274 | */ | |||
| 275 | STIF_TESTDEFINE(GAPS-OOD-SHUTDOWNMANAGER-002) | |||
| 276 | { | |||
| 277 | iLog->Log(_L("CLafShutdownManager:: GAPS-OOD-SHUTDOWNMANAGER-002 start")); | |||
| 278 | ||||
| 279 | // Create active scheduler (to run active objects) | |||
| 280 | CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); | |||
| 281 | CleanupStack::PushL(scheduler); | |||
| 282 | CActiveScheduler::Install(scheduler); | |||
| 283 | ||||
| 284 | ShutdownEventObserver shutdownEventObserver; | |||
| 285 | ||||
| 286 | CLafShutdownManagerBase* shutdownManager = LafShutdown::CreateShutdownManager(shutdownEventObserver); | |||
| 287 | STIF_ASSERT_NOT_NULL(shutdownManager); | |||
| 288 | ||||
| 289 | MSaveObserver::TSaveType type = LafShutdown::SaveFromViewSwitch(); | |||
| 290 | STIF_ASSERT_EQUALS(MSaveObserver::ESaveNone, type); | |||
| 291 | ||||
| 292 | type = LafShutdown::SaveFromAppSwitch(); | |||
| 293 | STIF_ASSERT_EQUALS(MSaveObserver::ESaveNone, type); | |||
| 294 | ||||
| 295 | delete shutdownManager; | |||
| 296 | ||||
| 297 | // Delete active scheduler | |||
| 298 | CleanupStack::PopAndDestroy(scheduler); | |||
| 299 | iLog->Log(_L("CLafShutdownManager:: GAPS-OOD-SHUTDOWNMANAGER-002 end")); | |||
| 300 | } | |||
| 301 | ||||
| 302 | /** | |||
| 303 | * @SYMTestCaseID GAPS-OOD-SHUTDOWNMANAGER-003 | |||
| 304 | * @SYMTestCaseDesc Test MMCWatchSubscriber | |||
| 305 | * @SYMTestPriority Medium | |||
| 306 | * @SYMTestActions 1. Create scheduler. | |||
| 307 | * 2. Create CLafShutdownManager object. | |||
| 308 | * 3. Create Cut_OODMonitor_Timer object. | |||
| 309 | * 4. Start scheduler. | |||
| 310 | * 5. Change enableMMCWatchProperty. | |||
| 311 | * 6. Change enableMMCWatchProperty after two seconds. | |||
| 312 | * 7. Stop shceduler. | |||
| 313 | * 8. Check mmcStatusProperty property. | |||
| 314 | * 9. Delete Cut_OODMonitor_Timer object and CLafShutdownManager object. | |||
| 315 | * 10. Delete scheduler. | |||
| 316 | * @SYMTestExpectedResults 1. Sechduler is created. | |||
| 317 | * 2. CLafShutdownManager object is created. | |||
| 318 | * 3. Cut_OODMonitor_Timer object is created. | |||
| 319 | * 4. Scheduler starts. | |||
| 320 | * 5. enableMMCWatchProperty changed; | |||
| 321 | * 6. enableMMCWatchProperty changed after two seconds. | |||
| 322 | * 7. Shceduler stoped. | |||
| 323 | * 8. mmcStatusProperty property is assign value as expected. | |||
| 324 | * 9. Cut_OODMonitor_Timer object and CLafShutdownManager object are deleted. | |||
| 325 | * 10. Scheduler is deleted. | |||
| 326 | * @SYMTestType Unit Test | |||
| 327 | * @SYMCreationDate 09-09-2010 | |||
| 328 | */ | |||
| 329 | STIF_TESTDEFINE(GAPS-OOD-SHUTDOWNMANAGER-003) | |||
| 330 | { | |||
| 331 | // Create active scheduler (to run active objects) | |||
| 332 | iLog->Log(_L("CLafShutdownManager:: GAPS-OOD-SHUTDOWNMANAGER-003 start")); | |||
| 333 | CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); | |||
| 334 | CleanupStack::PushL(scheduler); | |||
| 335 | CActiveScheduler::Install(scheduler); | |||
| 336 | ||||
| 337 | Tut_LafShutdownManager friendClass; | |||
| 338 | ShutdownEventObserver shutdownEventObserver; | |||
| 339 | CLafShutdownManager* shutdownManager = CLafShutdownManager::NewL(shutdownEventObserver); | |||
| 340 | ||||
| 341 | Cut_OODMonitor_Timer* oodMonitorTimer = Cut_OODMonitor_Timer::NewLC(shutdownManager, friendClass, EMMCTest); | |||
| 342 | CActiveScheduler::Start(); | |||
| 343 | ||||
| 344 | TInt value; | |||
| 345 | TInt err; | |||
| 346 | RProperty mmcStatusProperty = friendClass.GetMMCStatusProperty(shutdownManager); | |||
| 347 | err = mmcStatusProperty.Get(value); | |||
| 348 | iLog->Log(_L("CLafShutdownManager:: value=%d"),value); | |||
| 349 | STIF_ASSERT_EQUALS(KErrNone, err); | |||
| 350 | STIF_ASSERT_EQUALS(value, DISK_SPACE_OK); | |||
| 351 | ||||
| 352 | CleanupStack::PopAndDestroy(oodMonitorTimer); | |||
| 353 | delete shutdownManager; | |||
| 354 | ||||
| 355 | // Delete active scheduler | |||
| 356 | CleanupStack::PopAndDestroy(scheduler); | |||
| 357 | iLog->Log(_L("CLafShutdownManager:: GAPS-OOD-SHUTDOWNMANAGER-003 end")); | |||
| 358 | } | |||
| 359 | ||||
| 360 | /** | |||
| 361 | * @SYMTestCaseID GAPS-OOD-SHUTDOWNMANAGER-004 | |||
| 362 | * @SYMTestCaseDesc Test DisplayNotesSubscriber. | |||
| 363 | * @SYMTestPriority Medium | |||
| 364 | * @SYMTestActions 1. Create scheduler. | |||
| 365 | * 2. Create CLafShutdownManager object. | |||
| 366 | * 3. Create Cut_OODMonitor_Timer object. | |||
| 367 | * 4. Start scheduler. | |||
| 368 | * 5. Change canDisplayNotesProperty and fill the disk space to | |||
| 369 | * critical level. | |||
| 370 | * 6. Change canDisplayNotesProperty after two seconds. | |||
| 371 | * 7. Free disk space after two seconds. | |||
| 372 | * 8. Stop shceduler. | |||
| 373 | * 9. Check FreeDiskThresholdCrossedL() is called. | |||
| 374 | * 10. Delete Cut_OODMonitor_Timer object and CLafShutdownManager object. | |||
| 375 | * 11. Delete scheduler. | |||
| 376 | * @SYMTestExpectedResults 1. Sechduler is created. | |||
| 377 | * 2. CLafShutdownManager object is created. | |||
| 378 | * 3. Cut_OODMonitor_Timer object is created. | |||
| 379 | * 4. Scheduler start. | |||
| 380 | * 5. canDisplayNotesProperty changed and disk space is filled to | |||
| 381 | * critical level. | |||
| 382 | * 6. canDisplayNotesProperty changed after two seconds. | |||
| 383 | * 7. Disk space is freed after two seconds. | |||
| 384 | * 8. Stop shceduler. | |||
| 385 | * 9. FreeDiskThresholdCrossedL() is called. | |||
| 386 | * 10. Cut_OODMonitor_Timer object and CLafShutdownManager object are deleted. | |||
| 387 | * 11. Scheduler is deleted. | |||
| 388 | * @SYMTestType Unit Test | |||
| 389 | * @SYMCreationDate 09-09-2010 | |||
| 390 | */ | |||
| 391 | STIF_TESTDEFINE(GAPS-OOD-SHUTDOWNMANAGER-004) | |||
| 392 | { | |||
| 393 | iLog->Log(_L("CLafShutdownManager:: GAPS-OOD-SHUTDOWNMANAGER-004 start")); | |||
| 394 | ||||
| 395 | // Create active scheduler (to run active objects) | |||
| 396 | CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); | |||
| 397 | CleanupStack::PushL(scheduler); | |||
| 398 | CActiveScheduler::Install(scheduler); | |||
| 399 | ||||
| 400 | Tut_LafShutdownManager friendClass; | |||
| 401 | ShutdownEventObserver shutdownEventObserver; | |||
| 402 | CLafShutdownManager* shutdownManager = CLafShutdownManager::NewL(shutdownEventObserver); | |||
| 403 | ||||
| 404 | Cut_OODMonitor_Timer* oodMonitorTimer = Cut_OODMonitor_Timer::NewLC(shutdownManager, friendClass, EDisplayNotes); | |||
| 405 | CActiveScheduler::Start(); | |||
| 406 | ||||
| 407 | CLafShutdownManager::CGlobalQueryActive* globalQuaryActive = friendClass.GetGlobalQueryActive(shutdownManager); | |||
| 408 | iLog->Log(_L("CLafShutdownManager::iGlobalQueryActive=%d"), globalQuaryActive); | |||
| 409 | STIF_ASSERT_NOT_NULL(globalQuaryActive); | |||
| 410 | ||||
| 411 | CLafShutdownManager::CGlobalQueryActive::CMessageInfo* messageInfoPointer = | |||
| 412 | friendClass.GetMessageInfoList(globalQuaryActive, CLafShutdownManager::CGlobalQueryActive::ECritical); | |||
| 413 | ||||
| 414 | TInt locate = messageInfoPointer->iMessage->Des().Locate('s'); | |||
| 415 | iLog->Log(_L("CLafShutdownManager::locate=%d"), locate); | |||
| 416 | STIF_ASSERT_EQUALS(0, locate); | |||
| 417 | ||||
| 418 | ||||
| 419 | ||||
| 420 | CleanupStack::PopAndDestroy(oodMonitorTimer); | |||
| 421 | delete shutdownManager; | |||
| 422 | ||||
| 423 | // Delete active scheduler | |||
| 424 | CleanupStack::PopAndDestroy(scheduler); | |||
| 425 | iLog->Log(_L("CLafShutdownManager:: GAPS-OOD-SHUTDOWNMANAGER-004 end")); | |||
| 426 | } | |||
| 427 | ||||
| 428 | /** | |||
| 429 | * @SYMTestCaseID GAPS-OOD-SHUTDOWNMANAGER-005 | |||
| 430 | * @SYMTestCaseDesc Test AutolockStatusSubscriber. | |||
| 431 | * @SYMTestPriority Medium | |||
| 432 | * @SYMTestActions 1. Create scheduler. | |||
| 433 | * 2. Create CLafShutdownManager object. | |||
| 434 | * 3. Create Cut_OODMonitor_Timer object. | |||
| 435 | * 4. Start scheduler. | |||
| 436 | * 5. Change autolockStatusProperty and fill the disk space to | |||
| 437 | * warning level. | |||
| 438 | * 6. Change autolockStatusProperty after two seconds. | |||
| 439 | * 7. Free disk space after two seconds. | |||
| 440 | * 8. Stop shceduler. | |||
| 441 | * 9. Check FreeDiskThresholdCrossedL() is called. | |||
| 442 | * 10. Delete Cut_OODMonitor_Timer object. | |||
| 443 | * 11. Delete CLafShutdownManager object. | |||
| 444 | * 12. Delete scheduler. | |||
| 445 | * @SYMTestExpectedResults 1. Sechduler is created. | |||
| 446 | * 2. CLafShutdownManager object is created. | |||
| 447 | * 3. Cut_OODMonitor_Timer object is created. | |||
| 448 | * 4. Scheduler start. | |||
| 449 | * 5. autolockStatusProperty changed and disk space is filled to | |||
| 450 | * warning level. | |||
| 451 | * 6. autolockStatusProperty changed after two seconds. | |||
| 452 | * 7. Disk space is freed after two seconds. | |||
| 453 | * 8. Stop shceduler. | |||
| 454 | * 9. FreeDiskThresholdCrossedL() is called. | |||
| 455 | * 10. Cut_OODMonitor_Timer object is deleted. | |||
| 456 | * 11. CLafShutdownManager object is deleted. | |||
| 457 | * 12. Scheduler is deleted. | |||
| 458 | * @SYMTestType Unit Test | |||
| 459 | * @SYMCreationDate 09-09-2010 | |||
| 460 | */ | |||
| 461 | ||||
| 462 | STIF_TESTDEFINE(GAPS-OOD-SHUTDOWNMANAGER-005) | |||
| 463 | { | |||
| 464 | // Create active scheduler (to run active objects) | |||
| 465 | iLog->Log(_L("CLafShutdownManager:: GAPS-OOD-SHUTDOWNMANAGER-005 start")); | |||
| 466 | CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); | |||
| 467 | CleanupStack::PushL(scheduler); | |||
| 468 | CActiveScheduler::Install(scheduler); | |||
| 469 | ||||
| 470 | Tut_LafShutdownManager friendClass; | |||
| 471 | ShutdownEventObserver shutdownEventObserver; | |||
| 472 | CLafShutdownManager* shutdownManager = CLafShutdownManager::NewL(shutdownEventObserver); | |||
| 473 | ||||
| 474 | Cut_OODMonitor_Timer* oodMonitorTimer = Cut_OODMonitor_Timer::NewLC(shutdownManager, friendClass, EAutolock); | |||
| 475 | CActiveScheduler::Start(); | |||
| 476 | ||||
| 477 | CLafShutdownManager::CGlobalQueryActive* globalQuaryActive = friendClass.GetGlobalQueryActive(shutdownManager); | |||
| 478 | iLog->Log(_L("CLafShutdownManager::iGlobalQueryActive=%d"), globalQuaryActive); | |||
| 479 | STIF_ASSERT_NOT_NULL(globalQuaryActive); | |||
| 480 | ||||
| 481 | CLafShutdownManager::CGlobalQueryActive::CMessageInfo* messageInfoPointer = | |||
| 482 | friendClass.GetMessageInfoList(globalQuaryActive, CLafShutdownManager::CGlobalQueryActive::EWarning); | |||
| 483 | ||||
| 484 | TInt locate = messageInfoPointer->iMessage->Des().Locate('s'); | |||
| 485 | iLog->Log(_L("CLafShutdownManager::locate=%d"), locate); | |||
| 486 | STIF_ASSERT_EQUALS(0, locate); | |||
| 487 | ||||
| 488 | CleanupStack::PopAndDestroy(oodMonitorTimer); | |||
| 489 | delete shutdownManager; | |||
| 490 | ||||
| 491 | // Delete active scheduler | |||
| 492 | CleanupStack::PopAndDestroy(scheduler); | |||
| 493 | iLog->Log(_L("CLafShutdownManager:: GAPS-OOD-SHUTDOWNMANAGER-005 end")); | |||
| 494 | } | |||
| 495 | ||||
| 496 | /** | |||
| 497 | * @SYMTestCaseID GAPS-OOD-SHUTDOWNMANAGER-006 | |||
| 498 | * @SYMTestCaseDesc Test ReportEventL() and GetShutdownState(). | |||
| 499 | * @SYMTestPriority Medium | |||
| 500 | * @SYMTestActions 1. Create scheduler. | |||
| 501 | * 2. Create CLafShutdownManager object. | |||
| 502 | * 3. Call ReportEventL(). | |||
| 503 | * 4. Call GetShutdownState(). | |||
| 504 | * 5. Delete CLafShutdownManager object. | |||
| 505 | * 6. Delete scheduler. | |||
| 506 | * @SYMTestExpectedResults 1. Sechduler is created. | |||
| 507 | * 2. CLafShutdownManager object is created. | |||
| 508 | * 3. ReportEventL() is called correctly. | |||
| 509 | * 4. GetShutdownState is called correctly. | |||
| 510 | * 5. CLafShutdownManager object is deleted. | |||
| 511 | * 6. Scheduler is delted. | |||
| 512 | * @SYMTestType Unit Test | |||
| 513 | * @SYMCreationDate 09-09-2010 | |||
| 514 | */ | |||
| 515 | ||||
| 516 | STIF_TESTDEFINE(GAPS-OOD-SHUTDOWNMANAGER-006) | |||
| 517 | { | |||
| 518 | // Create active scheduler (to run active objects) | |||
| 519 | iLog->Log(_L("CLafShutdownManager:: GAPS-OOD-SHUTDOWNMANAGER-006 start")); | |||
| 520 | CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); | |||
| 521 | CleanupStack::PushL(scheduler); | |||
| 522 | CActiveScheduler::Install(scheduler); | |||
| 523 | ||||
| 524 | TInt err; | |||
| 525 | err=RProperty::Set(KUTSysApPropertyCategory, KHandleShutdownEventKey, KHandleShutdownEventValue0); | |||
| 526 | iLog->Log(_L("CLafShutdownManager:: err=%d"),err); | |||
| 527 | err=RProperty::Set(KUTSysApPropertyCategory, KGetShutdownStateKey, KGetShutdownStateValue0); | |||
| 528 | iLog->Log(_L("CLafShutdownManager:: err=%d"),err); | |||
| 529 | ||||
| 530 | ShutdownEventObserver shutdownEventObserver; | |||
| 531 | CLafShutdownManager* shutdownManager = CLafShutdownManager::NewL(shutdownEventObserver); | |||
| 532 | Tut_LafShutdownManager friendClass; | |||
| 533 | ||||
| 534 | // Check ReportEventL() | |||
| 535 | TBool boolValue = ETrue; | |||
| 536 | friendClass.CallReportEventL(shutdownManager, MSaveObserver::ESaveData, boolValue); | |||
| 537 | ||||
| 538 | TInt propertyValue; | |||
| 539 | RProperty::Get(KUTSysApPropertyCategory, KHandleShutdownEventKey, propertyValue); | |||
| 540 | iLog->Log(_L("CLafShutdownManager:: KHandleShutdownEventKey = %d"), propertyValue); | |||
| 541 | STIF_ASSERT_EQUALS(KHandleShutdownEventValue1, propertyValue); | |||
| 542 | ||||
| 543 | // Check GetShutdownState() | |||
| 544 | friendClass.CallGetShutdownState(shutdownManager, boolValue, boolValue); | |||
| 545 | ||||
| 546 | RProperty::Get(KUTSysApPropertyCategory, KGetShutdownStateKey, propertyValue); | |||
| 547 | iLog->Log(_L("CLafShutdownManager:: KGetShutdownStateKey = %d"), propertyValue); | |||
| 548 | STIF_ASSERT_EQUALS(KGetShutdownStateValue1, propertyValue); | |||
| 549 | ||||
| 550 | delete shutdownManager; | |||
| 551 | ||||
| 552 | // Delete active scheduler | |||
| 553 | CleanupStack::PopAndDestroy(scheduler); | |||
| 554 | iLog->Log(_L("CLafShutdownManager:: GAPS-OOD-SHUTDOWNMANAGER-006 end")); | |||
| 555 | } | |||
| 556 | ||||
| 557 | /** | |||
| 558 | * @SYMTestCaseID GAPS-OOD-SHUTDOWNMANAGER-007 | |||
| 559 | * @SYMTestCaseDesc Test CallGetDiskStatusL(). | |||
| 560 | * @SYMTestPriority Medium | |||
| 561 | * @SYMTestActions 1. Create scheduler. | |||
| 562 | * 2. Create CLafShutdownManager object. | |||
| 563 | * 3. Fill the disk space to critical level. | |||
| 564 | * 4. Call CallGetDiskStatusL(). | |||
| 565 | * 5. Free disk space. | |||
| 566 | * 6. Fill the disk space to warning level. | |||
| 567 | * 7. Call CallGetDiskStatusL(). | |||
| 568 | * 8. Free disk space. | |||
| 569 | * 9. Call CallGetDiskStatusL(). | |||
| 570 | * 10. Delete CLafShutdownManager object. | |||
| 571 | * 11. Delete scheduler. | |||
| 572 | * @SYMTestExpectedResults 1. Sechduler is created. | |||
| 573 | * 2. CLafShutdownManager object is created. | |||
| 574 | * 3. Disk space is filled to critical level. | |||
| 575 | * 4. CallGetDiskStatusL() return correct value. | |||
| 576 | * 5. Disk space is freed. | |||
| 577 | * 6. Disk space is filled to warning level. | |||
| 578 | * 7. CallGetDiskStatusL() return correct value. | |||
| 579 | * 8. Disk space is freed. | |||
| 580 | * 9. CallGetDiskStatusL() return correct value. | |||
| 581 | * 10. CLafShutdownManager object is deleted. | |||
| 582 | * 11. Scheduler is deleted. | |||
| 583 | * @SYMTestType Unit Test | |||
| 584 | * @SYMCreationDate 09-09-2010 | |||
| 585 | */ | |||
| 586 | ||||
| 587 | STIF_TESTDEFINE(GAPS-OOD-SHUTDOWNMANAGER-007) | |||
| 588 | { | |||
| 589 | // Create active scheduler (to run active objects) | |||
| 590 | iLog->Log(_L("CLafShutdownManager:: GAPS-OOD-SHUTDOWNMANAGER-007 start")); | |||
| 591 | CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); | |||
| 592 | CleanupStack::PushL(scheduler); | |||
| 593 | CActiveScheduler::Install(scheduler); | |||
| 594 | ||||
| 595 | ShutdownEventObserver shutdownEventObserver; | |||
| 596 | CLafShutdownManager* shutdownManager = CLafShutdownManager::NewL(shutdownEventObserver); | |||
| 597 | ||||
| 598 | CDesCArrayFlat* fileNameArray = new (ELeave) CDesCArrayFlat(KArraySize); | |||
| 599 | CleanupStack::PushL(fileNameArray); | |||
| 600 | ||||
| 601 | Tut_LafShutdownManager friendClass; | |||
| 602 | ||||
| 603 | // Critical | |||
| 604 | iLog->Log(_L("CLafShutdownManager:: Critical")); | |||
| 605 | friendClass.EatDiskL(fileNameArray, EDriveC, ECritical); | |||
| 606 | ||||
| 607 | TVolumeInfo volInfo; | |||
| 608 | ||||
| 609 | TInt value = friendClass.CallGetDiskStatusL(shutdownManager, volInfo, EDriveC); | |||
| 610 | iLog->Log(_L("CLafShutdownManager:: value=%d"),value); | |||
| 611 | STIF_ASSERT_TRUE(value == DISK_SPACE_CRITICAL); | |||
| 612 | ||||
| 613 | friendClass.FreeDiskL(fileNameArray); | |||
| 614 | ||||
| 615 | //Warning | |||
| 616 | iLog->Log(_L("CLafShutdownManager:: Warning")); | |||
| 617 | fileNameArray->Reset(); | |||
| 618 | friendClass.EatDiskL(fileNameArray, EDriveC, EWarning); | |||
| 619 | ||||
| 620 | value = friendClass.CallGetDiskStatusL(shutdownManager, volInfo, EDriveC); | |||
| 621 | iLog->Log(_L("CLafShutdownManager:: value=%d"),value); | |||
| 622 | STIF_ASSERT_TRUE(value == DISK_SPACE_WARNING) | |||
| 623 | ||||
| 624 | User::After(KTwoSecondInMicro); | |||
| 625 | friendClass.FreeDiskL(fileNameArray); | |||
| 626 | ||||
| 627 | // Normal | |||
| 628 | iLog->Log(_L("CLafShutdownManager:: Normal")); | |||
| 629 | value = friendClass.CallGetDiskStatusL(shutdownManager, volInfo, EDriveC); | |||
| 630 | iLog->Log(_L("CLafShutdownManager:: value=%d"),value); | |||
| 631 | STIF_ASSERT_TRUE(value == DISK_SPACE_OK) | |||
| 632 | ||||
| 633 | CleanupStack::PopAndDestroy(fileNameArray); | |||
| 634 | delete shutdownManager; | |||
| 635 | ||||
| 636 | //Delete active scheduler | |||
| 637 | CleanupStack::PopAndDestroy(scheduler); | |||
| 638 | iLog->Log(_L("CLafShutdownManager:: GAPS-OOD-SHUTDOWNMANAGER-007 end")); | |||
| 639 | } | |||
| 640 | ||||
| 641 | /** | |||
| 642 | * @SYMTestCaseID GAPS-OOD-SHUTDOWNMANAGER-008 | |||
| 643 | * @SYMTestCaseDesc Test OOD disk watcher. | |||
| 644 | * @SYMTestPriority Medium | |||
| 645 | * @SYMTestActions 1. Create scheduler. | |||
| 646 | * 2. Create CLafShutdownManager object. | |||
| 647 | * 3. Create Cut_OODMonitor_Timer object. | |||
| 648 | * 4. Start scheduler. | |||
| 649 | * 5. Fill the disk space to critical level. | |||
| 650 | * 6. Free disk space after two seconds. | |||
| 651 | * 7. Stop shceduler. | |||
| 652 | * 8. Check DiskStatusProperty. | |||
| 653 | * 9. Delete Cut_OODMonitor_Timer object and CLafShutdownManager object. | |||
| 654 | * 10. Delete scheduler. | |||
| 655 | * @SYMTestExpectedResults 1. Sechduler is created. | |||
| 656 | * 2. CLafShutdownManager object is created. | |||
| 657 | * 3. Cut_OODMonitor_Timer object is created. | |||
| 658 | * 4. Scheduler started. | |||
| 659 | * 5. Disk space is filled to critical level. | |||
| 660 | * 6. Disk space is freed after two seconds. | |||
| 661 | * 7. Shceduler stopped. | |||
| 662 | * 8. DiskStatusProperty is assigned value as expected. | |||
| 663 | * 9. Delete Cut_OODMonitor_Timer object and CLafShutdownManager object. | |||
| 664 | * 10. Delete scheduler. | |||
| 665 | * @SYMTestType Unit Test | |||
| 666 | * @SYMCreationDate 09-09-2010 | |||
| 667 | */ | |||
| 668 | ||||
| 669 | STIF_TESTDEFINE(GAPS-OOD-SHUTDOWNMANAGER-008) | |||
| 670 | { | |||
| 671 | // Create active scheduler (to run active objects) | |||
| 672 | iLog->Log(_L("CLafShutdownManager:: GAPS-OOD-SHUTDOWNMANAGER-008 start")); | |||
| 673 | CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); | |||
| 674 | CleanupStack::PushL(scheduler); | |||
| 675 | CActiveScheduler::Install(scheduler); | |||
| 676 | ||||
| 677 | ShutdownEventObserver shutdownEventObserver; | |||
| 678 | CLafShutdownManager* shutdownManager = CLafShutdownManager::NewL(shutdownEventObserver); | |||
| 679 | ||||
| 680 | Tut_LafShutdownManager friendClass; | |||
| 681 | ||||
| 682 | Cut_OODMonitor_Timer* oodMonitorTimer = Cut_OODMonitor_Timer::NewLC(shutdownManager, friendClass, EOODWatcher); | |||
| 683 | CActiveScheduler::Start(); | |||
| 684 | ||||
| 685 | TInt value; | |||
| 686 | TInt err; | |||
| 687 | RProperty diskStatusProperty = friendClass.GetDiskStatusProperty(shutdownManager); | |||
| 688 | err = diskStatusProperty.Get(value); | |||
| 689 | iLog->Log(_L("CLafShutdownManager:: value=%d"),value); | |||
| 690 | STIF_ASSERT_EQUALS(KErrNone, err); | |||
| 691 | STIF_ASSERT_EQUALS(value, DISK_SPACE_OK); | |||
| 692 | ||||
| 693 | CleanupStack::PopAndDestroy(oodMonitorTimer); | |||
| 694 | delete shutdownManager; | |||
| 695 | ||||
| 696 | //Delete active scheduler | |||
| 697 | CleanupStack::PopAndDestroy(scheduler); | |||
| 698 | iLog->Log(_L("CLafShutdownManager:: GAPS-OOD-SHUTDOWNMANAGER-008 end")); | |||
| 699 | } | |||
| 700 | #endif | |||
| 701 | /** | |||
| 702 | * END OF TEST CASES SECTION | |||
| 703 | */ | |||
| 704 | ||||
| 705 | // End of File | |||
| ***TER 100% (0/0) of SOURCE FILE ut_oodmonitorcases.cpp | ||||