| 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 | #include <e32property.h> | |||
| 24 | #include "utoodsubscriberconst.h" | |||
| 25 | #include "outofdiskmonitor.h" | |||
| 26 | #include "outofdiskpsobserver.h" | |||
| 27 | #include "outofdisksubscriber.h" | |||
| 28 | #endif //STIF_UNIT_INCLUDE_SECTION_END | |||
| 29 | ||||
| 30 | /** | |||
| 31 | * GLOBAL VARIABLES SECTION | |||
| 32 | */ | |||
| 33 | #ifdef TEST_VAR_DECLARATIONS | |||
| 34 | CActiveScheduler* scheduler; | |||
| 35 | #endif | |||
| 36 | /** | |||
| 37 | * END OF GLOBAL VARIABLES SECTION | |||
| 38 | */ | |||
| 39 | ||||
| 40 | ||||
| 41 | /** | |||
| 42 | * TEST CASES SECTION | |||
| 43 | */ | |||
| 44 | #ifdef TEST_CASES | |||
| 45 | /** | |||
| 46 | * STIF_SETUP defines activities needed before every test case. | |||
| 47 | */ | |||
| 48 | STIF_SETUP | |||
| 49 | { | |||
| 50 | RProperty::Define(KUTOODPropertyCategory, KUTOODStubKey, | |||
| 51 | RProperty::EInt, KAllowAllPolicy, KAllowAllPolicy); | |||
| 52 | } | |||
| 53 | ||||
| 54 | /** | |||
| 55 | * STIF_TEARDOWN defines activities needed after every test case | |||
| 56 | */ | |||
| 57 | STIF_TEARDOWN | |||
| 58 | { | |||
| 59 | RProperty::Delete(KUTOODPropertyCategory, KUTOODStubKey); | |||
| 60 | } | |||
| 61 | ||||
| 62 | /** | |||
| 63 | * @SYMTestCaseID GAPS-OODMONITOR-SUBSCRIBER-001 | |||
| 64 | * @SYMTestCaseDesc Unit test for COutOfDiskSubscriber. | |||
| 65 | * @SYMTestPriority Medium | |||
| 66 | * @SYMTestActions 1. Construct a mock COutOfDiskMonitor object. | |||
| 67 | * 2. Construct a mock COutOfDiskPSObserver object. | |||
| 68 | * 3. Construct a COutOfDiskSubscriber object. | |||
| 69 | * 4. Subscribe | |||
| 70 | * 5. Set property value. | |||
| 71 | * 6. Start activescheduler | |||
| 72 | * 7. Directly call RunError | |||
| 73 | * @SYMTestExpectedResults 1. Mock COutOfDiskMonitor object was constructed. | |||
| 74 | * 2. Mock COutOfDiskPSObserver object was constructed. | |||
| 75 | * 3. COutOfDiskSubscriber object was constructed. | |||
| 76 | * 4. COutOfDiskSubscriber object was set active. | |||
| 77 | * 5. Property was set. | |||
| 78 | * 6. ActiveScheduler was started. | |||
| 79 | * 7. RunError returns error code. | |||
| 80 | * @SYMTestType Unit Test | |||
| 81 | * @SYMCreationDate 23-08-2010 | |||
| 82 | */ | |||
| 83 | STIF_TESTDEFINE(GAPS-OODMONITOR-SUBSCRIBER-001) | |||
| 84 | { | |||
| 85 | // instance and install, but not started | |||
| 86 | scheduler = new (ELeave) CActiveScheduler(); | |||
| 87 | CleanupStack::PushL(scheduler); | |||
| 88 | CActiveScheduler::Install(scheduler); | |||
| 89 | ||||
| 90 | STIF_LOG("1. Construct a mock COutOfDiskMonitor object."); | |||
| 91 | MShutdownEventObserver* shutdownEventObserver = NULL; | |||
| 92 | COutOfDiskMonitor* outOfDiskMonitor = COutOfDiskMonitor::NewL(*shutdownEventObserver); | |||
| 93 | CleanupStack::PushL(outOfDiskMonitor); | |||
| 94 | ||||
| 95 | STIF_LOG("2. Construct a mock COutOfDiskPSObserver object."); | |||
| 96 | COutOfDiskPSObserver* outOfDiskPSObserver = COutOfDiskPSObserver::NewL(outOfDiskMonitor); | |||
| 97 | CleanupStack::PushL(outOfDiskPSObserver); | |||
| 98 | ||||
| 99 | STIF_LOG("3. Construct a COutOfDiskSubscriber object."); | |||
| 100 | COutOfDiskSubscriber* outOfDiskSubscriber = COutOfDiskSubscriber::NewL(*outOfDiskPSObserver, KUTOODPropertyCategory, KUTOODStubKey); | |||
| 101 | CleanupStack::PushL(outOfDiskSubscriber); | |||
| 102 | ||||
| 103 | STIF_LOG("4. Subscribe."); | |||
| 104 | outOfDiskSubscriber->Subscribe(); | |||
| 105 | ||||
| 106 | STIF_LOG("5. Set property value."); | |||
| 107 | RProperty::Set(KUTOODPropertyCategory, KUTOODStubKey, KNotTouched); | |||
| 108 | ||||
| 109 | STIF_LOG("6. Start activescheduler"); | |||
| 110 | CActiveScheduler::Start(); | |||
| 111 | ||||
| 112 | STIF_LOG("7. Directly call RunError."); | |||
| 113 | STIF_ASSERT_EQUALS(KErrNoMemory, outOfDiskSubscriber->RunError(KErrNoMemory)); | |||
| 114 | ||||
| 115 | CleanupStack::PopAndDestroy(outOfDiskSubscriber); | |||
| 116 | CleanupStack::PopAndDestroy(outOfDiskPSObserver); | |||
| 117 | CleanupStack::PopAndDestroy(outOfDiskMonitor); | |||
| 118 | ||||
| 119 | CActiveScheduler::Install(NULL); | |||
| 120 | CleanupStack::PopAndDestroy(scheduler); | |||
| 121 | } | |||
| 122 | ||||
| 123 | #endif | |||
| 124 | /** | |||
| 125 | * END OF TEST CASES SECTION | |||
| 126 | */ | |||
| 127 | ||||
| 128 | // End of File | |||
| ***TER 100% (0/0) of SOURCE FILE ut_oodsubscribercases.cpp | ||||