CTC++ Coverage Report - Execution Profile    #9/10

Directory Summary | Files Summary | Functions Summary | Execution Profile
To files: First | Previous | Next | Last | Index | No Index


File: N:\myprogram\forrrelease1\oodmonitor\tsrc\ut_oodmonitor\src\ut_oodmonitorcases.cpp
Instrumentation mode: function
TER: 100 % ( 0/ 0)

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 <driveinfo.h>
  24 #include <disknotifyhandler.h>
  25 #include "outofdiskglobalnote.h"
  26 #include "outofdiskmonitor.h"
  27 #include "utoutofdiskpsobserver.h"
  28 #include "outofdisknotifyobserver.h"
  29 #include "MockShutdownEventObserver.h"
  30 #endif //STIF_UNIT_INCLUDE_SECTION_END
  31 
  32 /**
  33  * GLOBAL VARIABLES SECTION
  34  */
  35 #ifdef TEST_VAR_DECLARATIONS
  36      CActiveScheduler* scheduler;
  37      const TInt64 KWarningThreshold = 2048;
  38      const TInt64 KCriticalThreshold = 1024;
  39 #endif
  40 /**
  41  * END OF GLOBAL VARIABLES SECTION
  42  */
  43 
  44 
  45 /**
  46  * TEST CASES SECTION
  47  */
  48 #ifdef TEST_CASES
  49 /**
  50  * STIF_SETUP defines activities needed before every test case.
  51  */
  52 STIF_SETUP
  53 {
  54 // instance and install, but not started
  55 scheduler = new (ELeave) CActiveScheduler();
  56 CleanupStack::PushL(scheduler);
  57 CActiveScheduler::Install(scheduler);
  58 }
  59 
  60 /**
  61  * STIF_TEARDOWN defines activities needed after every test case
  62  */
  63 STIF_TEARDOWN
  64 {
  65 CActiveScheduler::Install(NULL);
  66 CleanupStack::PopAndDestroy(scheduler);
  67 }
  68 
  69 /**
  70  * @SYMTestCaseID              GAPS-OODMONITOR-GLOBALNOTE-001
  71  * @SYMTestCaseDesc            Unit test for COutOfDiskGlobalNote.
  72  * @SYMTestPriority            Medium
  73  * @SYMTestActions             1. Connect file server.
  74  *                             2. Construct a COutOfDiskMonitor object.
  75  *                             3. Construct a COutOfDiskGlobalNote object.
  76  *                             4. Get note info.
  77  *                             5. NoteOnDisplay.
  78  *                             6. Display a message.
  79  *                             7. MessageBoxClosed.
  80  *                             8. Destroy the COutOfDiskGlobalNote object.
  81  *                             9. Destroy the mock COutOfDiskMonitor object
  82  *                             10. Destroy the RFs object.
  83  * @SYMTestExpectedResults     1. File server was connected.
  84  *                             2. COutOfDiskMonitor object was constructed.
  85  *                             3. COutOfDiskGlobalNote object was constructed.
  86  *                             4. NoteInfo was correct.
  87  *                             5. Property was defined.
  88  *                             6. Message was displayed.
  89  *                             7. No error.
  90  *                             8. The COutOfDiskGlobalNote object was destroyed.
  91  *                             9. The COutOfDiskMonitor object was destroyed.
  92  *                             10. The RFs object was closed.
  93  * @SYMTestType                Unit Test
  94  * @SYMCreationDate            23-08-2010
  95  */
  96 STIF_TESTDEFINE(GAPS-OODMONITOR-GLOBALNOTE-001)
  97 {
  98     TestModuleIf().SetBehavior(CTestModuleIf::ETestLeaksHandles);
  99     
  100     STIF_LOG("1. Connect file server.");
  101     RFs fileServer;
  102     STIF_ASSERT_EQUALS(KErrNone, fileServer.Connect());
  103     CleanupClosePushL(fileServer);
  104     
  105     STIF_LOG("2. Construct a COutOfDiskMonitor object.");
  106     MShutdownEventObserver* shutdownEventObserver = NULL;
  107     COutOfDiskMonitor* outOfDiskMonitor = COutOfDiskMonitor::NewL(*shutdownEventObserver);
  108     CleanupStack::PushL(outOfDiskMonitor);
  109     
  110     STIF_LOG("3. Construct a COutOfDiskGlobalNote object.");
  111     COutOfDiskGlobalNote* outOfDiskGlobalNote = COutOfDiskGlobalNote::NewL(outOfDiskMonitor, fileServer);
  112     CleanupStack::PushL(outOfDiskGlobalNote);
  113     
  114     STIF_LOG("4. Get note info.");
  115     TNoteInfo noteInfo = outOfDiskGlobalNote->GetNoteInfo();
  116     STIF_ASSERT_EQUALS(KErrNotFound, noteInfo.iNoteId);
  117     STIF_ASSERT_EQUALS(DISK_SPACE_OK, noteInfo.iStatus);
  118     STIF_ASSERT_EQUALS(KErrNotFound, noteInfo.iDrive);
  119     
  120     STIF_LOG("5. NoteOnDisplay.");
  121     STIF_ASSERT_FALSE(outOfDiskGlobalNote->NoteOnDisplay());
  122     
  123     STIF_LOG("6. Display a message.");
  124     outOfDiskGlobalNote->DisplayL(_L("Display a message."));
  125     
  126     STIF_LOG("7. MessageBoxClosed.");
  127     outOfDiskGlobalNote->MessageBoxClosed(NULL, CHbDeviceMessageBoxSymbian::EAcceptButton);
  128     
  129     STIF_LOG("8. Destroy the COutOfDiskGlobalNote object.");
  130     CleanupStack::PopAndDestroy(outOfDiskGlobalNote);
  131     
  132     STIF_LOG("9. Destroy the COutOfDiskMonitor object.");
  133     CleanupStack::PopAndDestroy(outOfDiskMonitor);
  134     
  135     STIF_LOG("10. Destroy the RFs object.");
  136     CleanupStack::PopAndDestroy(&fileServer);
  137 }
  138 
  139 /**
  140  * @SYMTestCaseID              GAPS-OODMONITOR-PSOBSERVER-001
  141  * @SYMTestCaseDesc            Unit test for COutOfDiskPSObserver.
  142  * @SYMTestPriority            Medium
  143  * @SYMTestActions             1. Construct a COutOfDiskMonitor object.
  144  *                             2. Construct a COutOfDiskPSObserver object.
  145  *                             3. Handle property change. Category is KPSUidUikon, and Key is KUikGlobalNotesAllowed.
  146  *                             4. Handle property change. Category is KPSUidCoreApplicationUIs, and Key is KCoreAppUIsAutolockStatus.
  147  *                             5. Destroy the COutOfDiskPSObserver object.
  148  *                             6. Destroy the COutOfDiskMonitor object
  149  * @SYMTestExpectedResults     1. Mock COutOfDiskMonitor object was constructed.
  150  *                             2. COutOfDiskPSObserver object was constructed.
  151  *                             3. Property change was handled successfully.
  152  *                             4. Property change was handled successfully.
  153  *                             5. The COutOfDiskPSObserver object was destroyed.
  154  *                             6. The COutOfDiskMonitor object was destroyed.
  155  * @SYMTestType                Unit Test
  156  * @SYMCreationDate            23-08-2010
  157  */
  158 STIF_TESTDEFINE(GAPS-OODMONITOR-PSOBSERVER-001)
  159 {    
  160     STIF_LOG("1. Construct a COutOfDiskMonitor object.");
  161     MShutdownEventObserver* shutdownEventObserver = NULL;
  162     COutOfDiskMonitor* outOfDiskMonitor = COutOfDiskMonitor::NewL(*shutdownEventObserver);
  163     CleanupStack::PushL(outOfDiskMonitor);
  164     
  165     STIF_LOG("2. Construct a COutOfDiskPSObserver object.");
  166     CUTOutOfDiskPSObserver* outOfDiskPSObserver = CUTOutOfDiskPSObserver::NewL(outOfDiskMonitor);
  167     CleanupStack::PushL(outOfDiskPSObserver);
  168     
  169     STIF_LOG("3. Handle property change. Category is KPSUidUikon, and Key is KUikGlobalNotesAllowed.");
  170     outOfDiskPSObserver->HandlePropertyChangedL(KPSUidUikon, KUikGlobalNotesAllowed);
  171     
  172     STIF_LOG("4. Handle property change. Category is KPSUidCoreApplicationUIs, and Key is KCoreAppUIsAutolockStatus.");
  173     outOfDiskPSObserver->HandlePropertyChangedL(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus);
  174     
  175     STIF_LOG("5. Destroy the COutOfDiskPSObserver object.");
  176     CleanupStack::PopAndDestroy(outOfDiskPSObserver);
  177     
  178     STIF_LOG("6. Destroy the COutOfDiskMonitor object.");
  179     CleanupStack::PopAndDestroy(outOfDiskMonitor);
  180 }
  181 
  182 /**
  183  * @SYMTestCaseID              GAPS-OODMONITOR-OUTOFDISKMONITOR-001
  184  * @SYMTestCaseDesc            Unit test for COutOfDiskMonitor.
  185  * @SYMTestPriority            Medium
  186  * @SYMTestActions             1. Construct a COutOfDiskMonitor object.
  187  *                             2. ShowGlobalQueryIfNeededL.
  188  *                             3. Get C Drive Status.
  189  *                             4. SetAsDisplayedL.
  190  *                             5. SetGlobalNotesAllowed to ETrue.
  191  *                             6. GetGlobalNotesAllowed.
  192  *                             7. SetGlobalNotesAllowed to EFalse.
  193  *                             8. GetGlobalNotesAllowed.
  194  *                             9. GetDefaultPhoneMemory.
  195  *                             10. GetDefaultMassStorage.
  196  *                             11. GetDefaultRomDrive.
  197  *                             12. Destroy the COutOfDiskMonitor object.
  198  * @SYMTestExpectedResults     1. The COutOfDiskMonitor object was constructed.
  199  *                             2. No error.
  200  *                             3. DISK_SPACE_OK was returned.
  201  *                             4. Set successfully.
  202  *                             5. Set successfully.
  203  *                             6. The value set by step5 was returned.
  204  *                             7. Set successfully.
  205  *                             8. The value set by step7 was returned.
  206  *                             9. DefaultPhoneMemory was correctly gotten.
  207  *                             10. DefaultMassStorage was correctly gotten.
  208  *                             11. DefaultRomDrive was correctly gotten.
  209  *                             12. The COutOfDiskMonitor object was destroyed.
  210  * @SYMTestType                Unit Test
  211  * @SYMCreationDate            23-08-2010
  212  */
  213 STIF_TESTDEFINE(GAPS-OODMONITOR-OUTOFDISKMONITOR-001)
  214 {  
  215     STIF_LOG("1. Construct a COutOfDiskMonitor object.");
  216     MShutdownEventObserver* shutdownEventObserver = NULL;
  217     COutOfDiskMonitor* outOfDiskMonitor = COutOfDiskMonitor::NewL(*shutdownEventObserver);
  218     CleanupStack::PushL(outOfDiskMonitor);
  219 
  220     STIF_LOG("2. ShowGlobalQueryIfNeededL.");
  221     outOfDiskMonitor->ShowGlobalQueryIfNeededL();
  222     
  223     STIF_LOG("3. Get C Drive Status.");
  224     STIF_ASSERT_EQUALS(DISK_SPACE_OK, outOfDiskMonitor->GetDriveStatus(EDriveC));
  225     
  226     // GetThreshold is called by GetDriveStatis.
  227     // SaveDriveStatus is called by ConstructL.
  228     // ResetDisplayedStatus is called by SaveDriveStatus.
  229     // AllowedToReset is called by RestDisplayedStatus.
  230     // GetTopPriorityDrive is called by ShowGlobalQueryIfNeededL.
  231     
  232     STIF_LOG("4. SetAsDisplayedL.");
  233     outOfDiskMonitor->SetAsDisplayedL(EDriveC, DISK_SPACE_OK);
  234     
  235     STIF_LOG("5. SetGlobalNotesAllowed to ETrue.");
  236     outOfDiskMonitor->SetGlobalNotesAllowed(ETrue);
  237     
  238     STIF_LOG("6. GetGlobalNotesAllowed.");
  239     STIF_ASSERT_TRUE(outOfDiskMonitor->GetGlobalNotesAllowed());
  240     
  241     STIF_LOG("7. SetGlobalNotesAllowed to EFalse.");
  242     outOfDiskMonitor->SetGlobalNotesAllowed(EFalse);
  243     
  244     STIF_LOG("8. GetGlobalNotesAllowed.");
  245     STIF_ASSERT_FALSE(outOfDiskMonitor->GetGlobalNotesAllowed());
  246     
  247     STIF_LOG("9. GetDefaultPhoneMemory.");
  248     TInt defaultPhoneMemory = 0;
  249     DriveInfo::GetDefaultDrive( DriveInfo::EDefaultPhoneMemory, defaultPhoneMemory );
  250     STIF_ASSERT_EQUALS(defaultPhoneMemory, outOfDiskMonitor->GetDefaultPhoneMemory());
  251     
  252     STIF_LOG("10. GetDefaultMassStorage.");
  253     TInt defaultMassStorage = 0;
  254     DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, defaultMassStorage );
  255     STIF_ASSERT_EQUALS(defaultMassStorage, outOfDiskMonitor->GetDefaultMassStorage());
  256     
  257     STIF_LOG("11. GetDefaultRomDrive.");
  258     // Actually COutOfDiskMonitor doesn't set iDefaultRomDrive, so that I don't need to check the result.
  259     TInt defaultRomDrive = outOfDiskMonitor->GetDefaultRomDrive();
  260     
  261     STIF_LOG("12. Destroy the COutOfDiskMonitor object.");
  262     CleanupStack::PopAndDestroy(outOfDiskMonitor);
  263 }
  264 
  265 /**
  266  * @SYMTestCaseID              GAPS-OOD-LAFSHUT-001
  267  * @SYMTestCaseDesc            Unit test for lafshut.cpp
  268  * @SYMTestPriority            Medium
  269  * @SYMTestActions             1. Create ShutdownEventObserver object.
  270  *                             2. Create CLafShutdownManagerBase object.
  271  *                             3. Call SaveFromViewSwitch();
  272  *                             4. Call SaveFromAppSwitch();
  273  *                             5. Delete CLafShutdownManagerBase object.
  274  * @SYMTestExpectedResults     1. ShutdownEventObserver object is created.
  275  *                             2. CLafShutdownManagerBase object is create successfully.
  276  *                             3. SaveFromViewSwitch() return expected value.
  277  *                             4. SaveFromAppSwitch(); return expected value.
  278  *                             5. CLafShutdownManagerBase object is deleted.
  279  * @SYMTestType                Unit Test
  280  * @SYMCreationDate            03-09-2010
  281  */
  282 STIF_TESTDEFINE(GAPS-OOD-LAFSHUT-001)
  283 {
  284     STIF_LOG("1. Create ShutdownEventObserver object.");       
  285     TshutdownEventObserver shutdownEventObserver;   
  286     
  287     STIF_LOG("2. Create CLafShutdownManagerBase object.");
  288     CLafShutdownManagerBase* shutdownManager = LafShutdown::CreateShutdownManager(shutdownEventObserver);
  289     STIF_ASSERT_NOT_NULL(shutdownManager);
  290     
  291     STIF_LOG("3. Call SaveFromViewSwitch();");
  292     MSaveObserver::TSaveType type = LafShutdown::SaveFromViewSwitch();
  293     STIF_ASSERT_EQUALS(MSaveObserver::ESaveNone, type);
  294  
  295     STIF_LOG("4. Call SaveFromAppSwitch();");
  296     type = LafShutdown::SaveFromAppSwitch();
  297     STIF_ASSERT_EQUALS(MSaveObserver::ESaveNone, type);
  298     
  299     STIF_LOG("5. Delete CLafShutdownManagerBase object.");
  300     delete shutdownManager;
  301 }
  302 
  303 /**
  304  * @SYMTestCaseID              GAPS-OODMONITOR-OUTOFDISKNOTIFYOBSERVER-001
  305  * @SYMTestCaseDesc            Unit test for COutOfDiskNotifyObserver.
  306  * @SYMTestPriority            Medium
  307  * @SYMTestActions             1. Construct a COutOfDiskMonitor object.
  308  *                             2. COutOfDiskNotifyObserver::NotifyDiskSpace
  309  *                             3. COutOfDiskNotifyObserver::HandleNotifyDisk.
  310  *                             4. COutOfDiskNotifyObserver::HandleNotifyDismount
  311  *                             5. COutOfDiskNotifyObserver::HandleNotifyDiskSpace
  312  *                             6. COutOfDiskNotifyObserver::HandleNotifyEntry
  313  *                             7. Destroy the COutOfDiskMonitor object.
  314  * @SYMTestExpectedResults     1. The COutOfDiskMonitor object was constructed.
  315  *                             2. Function returned successfully.
  316  *                             3. Function returned successfully.
  317  *                             4. Function returned successfully.
  318  *                             5. Function returned successfully.
  319  *                             6. Function returned successfully.
  320  *                             7. The COutOfDiskMonitor object was destroyed.
  321  * @SYMTestType                Unit Test
  322  * @SYMCreationDate            09-09-2010
  323  */
  324 STIF_TESTDEFINE(GAPS-OODMONITOR-OUTOFDISKNOTIFYOBSERVER-001)
  325 {
  326     STIF_LOG("1. Construct a COutOfDiskMonitor object.");
  327     MShutdownEventObserver* shutdownEventObserver = NULL;
  328     COutOfDiskMonitor* outOfDiskMonitor = COutOfDiskMonitor::NewL(*shutdownEventObserver);
  329     CleanupStack::PushL(outOfDiskMonitor);
  330     
  331     STIF_LOG("2. NotifyDiskSpace");
  332     outOfDiskMonitor->iOutOfDiskNotifyObserver->NotifyDiskSpace(KWarningThreshold, KCriticalThreshold, EDriveF);
  333     
  334     STIF_LOG("3. HandleNotifyDisk");
  335     MDiskNotifyHandlerCallback::TDiskEvent diskEvent;
  336     diskEvent.iDrive = EDriveF;
  337     
  338     diskEvent.iType = MDiskNotifyHandlerCallback::EDiskAdded;
  339     outOfDiskMonitor->iOutOfDiskNotifyObserver->HandleNotifyDisk(KErrNone, diskEvent);
  340     
  341     diskEvent.iType = MDiskNotifyHandlerCallback::EDiskError;
  342     outOfDiskMonitor->iOutOfDiskNotifyObserver->HandleNotifyDisk(KErrNone, diskEvent);
  343     
  344     diskEvent.iType = MDiskNotifyHandlerCallback::EDiskRemoved;
  345     outOfDiskMonitor->iOutOfDiskNotifyObserver->HandleNotifyDisk(KErrNone, diskEvent);
  346     
  347     diskEvent.iType = MDiskNotifyHandlerCallback::EDiskStatusChanged;
  348     outOfDiskMonitor->iOutOfDiskNotifyObserver->HandleNotifyDisk(KErrNone, diskEvent);
  349     
  350     STIF_LOG("4. HandleNotifyDismount");
  351     MDiskNotifyHandlerCallback::TDismountEvent dismountEvent;
  352     dismountEvent.iDrive = EDriveF;
  353     outOfDiskMonitor->iOutOfDiskNotifyObserver->HandleNotifyDismount(KErrNone, dismountEvent);
  354     
  355     STIF_LOG("5. HandleNotifyDiskSpace");
  356     MDiskNotifyHandlerCallback::TDiskSpaceEvent diskSpaceEvent;
  357     diskSpaceEvent.iDrive = EDriveF;
  358     outOfDiskMonitor->iOutOfDiskNotifyObserver->HandleNotifyDiskSpace(KErrNone, diskSpaceEvent);
  359     
  360     STIF_LOG("6. HandleNotifyEntry");
  361     MDiskNotifyHandlerCallback::TEntryEvent entryEvent;
  362     outOfDiskMonitor->iOutOfDiskNotifyObserver->HandleNotifyEntry(KErrNone, entryEvent);
  363     
  364     STIF_LOG("7. Destroy the COutOfDiskMonitor object.");
  365     CleanupStack::PopAndDestroy(outOfDiskMonitor);
  366 }
  367 
  368 #endif
  369 /**
  370  * END OF TEST CASES SECTION
  371  */
  372 
  373 // End of File
***TER 100% (0/0) of SOURCE FILE ut_oodmonitorcases.cpp

Directory Summary | Files Summary | Functions Summary | Execution Profile
To files: First | Previous | Next | Last | Top | Index | No Index