sysresmonitoring/oommonitor/tsrc/ut_oom_closeapp/src/ut_oom_closeappCases.cpp
changeset 77 b01c07dfcf84
equal deleted inserted replaced
74:1505405bc645 77:b01c07dfcf84
       
     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 "oomconstants.hrh"
       
    24 #include "oomcloseapp.h"
       
    25 #include "oomappclosetimer.h"
       
    26 #include "oomappclosewatcher.h"
       
    27 #include "moc_oomactionlist.h"
       
    28 #include "oomactionref.h"
       
    29 #include "oommemorymonitor.h"
       
    30 #include <apgwgnam.h> 
       
    31 #include <oomwindowgrouplist.h>
       
    32 #include <oomwserveventreceiver.h>
       
    33 #include <mytimer.h>
       
    34 #include <e32debug.h>
       
    35 #endif //STIF_UNIT_INCLUDE_SECTION_END
       
    36 
       
    37 /**
       
    38  * GLOBAL VARIABLES SECTION
       
    39  */
       
    40 #ifdef TEST_VAR_DECLARATIONS
       
    41     CActiveScheduler* scheduler;
       
    42 #endif
       
    43 /**
       
    44  * END OF GLOBAL VARIABLES SECTION
       
    45  */
       
    46 
       
    47 
       
    48 /**
       
    49  * TEST CASES SECTION
       
    50  */
       
    51 #ifdef TEST_CASES
       
    52 /**
       
    53  * STIF_SETUP defines activities needed before every test case.
       
    54  */
       
    55 STIF_SETUP
       
    56 {
       
    57     // Install active scheduler at start up
       
    58     scheduler = new (ELeave) CActiveScheduler();
       
    59     CleanupStack::PushL(scheduler);
       
    60     CActiveScheduler::Install(scheduler);
       
    61 }
       
    62 
       
    63 /**
       
    64  * STIF_TEARDOWN defines activities needed after every test case
       
    65  */
       
    66 STIF_TEARDOWN
       
    67 {
       
    68     // Delete active scheduler at last
       
    69     CActiveScheduler::Install(NULL);
       
    70     CleanupStack::PopAndDestroy(scheduler);
       
    71 }
       
    72 
       
    73 /**
       
    74  * @SYMTestCaseID              GAPS-OOM-WINDOWGROUPLIST-001
       
    75  * @SYMTestCaseDesc            Verify the behaviors of oomwindowgrouplist.
       
    76  * @SYMTestPriority            Medium
       
    77  * @SYMTestActions             1. Get the list of window group of current system.
       
    78  *                             2. Create appfortest process.
       
    79  *                             3. Get the list of window group of current system.
       
    80  *                             4. Get the wgID of appfortest process.
       
    81  *                             5. Create COomWindowGroupList object.
       
    82  *                             6. Get window group name.
       
    83  *                             7. Get index from app ID.
       
    84  *                             8. Get app ID from index.
       
    85  *                             9. Get Idle time 1 of appfortest.
       
    86  *                             10. Wait 1 second.
       
    87  *                             11. Get Idle time 2 of appfortest.
       
    88  *                             12. Compare Idle times.
       
    89  *                             13. Set appfortest priority busy.
       
    90  *                             14. Check appfortest priority.
       
    91  *                             15. Set appfortest priority high.
       
    92  *                             16. Check appfortest priority.
       
    93  *                             17. Set appfortest priority normal.
       
    94  *                             18. Check appfortest priority.
       
    95  * @SYMTestExpectedResults     1. Get the window group list of current system successfully.
       
    96  *                             2. Create appfortest process successfully.
       
    97  *                             3. Get the window group list of current system successfully.
       
    98  *                             4. Get the wgID of appfortest process successfully.
       
    99  *                             5. Create COomWindowGroupList object successfully.
       
   100  *                             6. Get window group name successfully.
       
   101  *                             7. Get index from app ID successfully.
       
   102  *                             8. Get app ID from index successfully.
       
   103  *                             9. Get Idle time 1 of appfortest successfully.
       
   104  *                             10. Wait 1 second.
       
   105  *                             11. Get Idle time of appfortest successfully.
       
   106  *                             12. Idle time 2 greater than or equal to idle time 1.
       
   107  *                             13. Set appfortest priority busy successfully.
       
   108  *                             14. Appfortest priority is set to busy.
       
   109  *                             15. Set appfortest priority high successfully.
       
   110  *                             16. Appfortest priority is set to high.
       
   111  *                             17. Set appfortest priority normal successfully.
       
   112  *                             18. Appfortest priority is set to normal.
       
   113  * @SYMTestType                Unit Test
       
   114  * @SYMCreationDate            20-07-2010
       
   115  */
       
   116 
       
   117 STIF_TESTDEFINE(GAPS-OOM-WINDOWGROUPLIST-001)
       
   118 {
       
   119     TInt retrunValue=KErrNone;
       
   120         
       
   121     RWsSession wsSession;
       
   122     CleanupClosePushL(wsSession);
       
   123     User::LeaveIfError(wsSession.Connect());
       
   124     TInt numGroups = wsSession.NumWindowGroups(0);
       
   125     
       
   126     //Get the wgID list before appfortest.exe start
       
   127     RArray<RWsSession::TWindowGroupChainInfo> wgIds;
       
   128     wgIds.ReserveL(numGroups);
       
   129     User::LeaveIfError(wsSession.WindowGroupList(0, &wgIds));
       
   130     
       
   131     //Create appfortest.exe process
       
   132     RProcess process;
       
   133     CleanupClosePushL(process);
       
   134     User::LeaveIfError(process.Create(KExeName, KNullDesC) );      
       
   135     process.Resume();   
       
   136     User::After(5000000);   // wait process start...
       
   137     
       
   138     // Get the app id of appfortest.exe
       
   139     TSecureId AppSecuID=process.SecureId();
       
   140     
       
   141     // Check wgNumber
       
   142     TInt numGroups1 = wsSession.NumWindowGroups(0);    
       
   143     // STIF_ASSERT_EQUALS(numGroups+1, numGroups1);
       
   144     
       
   145     //Get the wgID list after appfortest.exe started
       
   146     RArray<RWsSession::TWindowGroupChainInfo> wgIds1;
       
   147     wgIds1.ReserveL(numGroups1);
       
   148     User::LeaveIfError(wsSession.WindowGroupList(0, &wgIds1));  
       
   149     
       
   150     // Get teh wgID of appfortest.exe
       
   151     for(TInt count=0; count<numGroups; count++)
       
   152         {
       
   153         TInt position=wgIds1.Find(wgIds[count]);
       
   154         wgIds1.Remove(position);
       
   155         }
       
   156 
       
   157     TInt wgID=-1;
       
   158     if(1 == wgIds1.Count())
       
   159         {
       
   160         wgID=wgIds1[0].iId;
       
   161         }
       
   162     else
       
   163         {
       
   164         iLog->Log(_L("Failed to get wgID of appfortest.exe!\n"));
       
   165         retrunValue = KErrNotFound;
       
   166         }
       
   167     
       
   168     if(KErrNone == retrunValue)
       
   169         {
       
   170         // Create wsSession object
       
   171         COomWindowGroupList* oomWindowGroupList = COomWindowGroupList::NewL(wsSession);
       
   172         CleanupStack::PushL(oomWindowGroupList);
       
   173         
       
   174         // Test WgName
       
   175         CApaWindowGroupName* wgName=oomWindowGroupList->WgName();
       
   176         TPtrC potint=wgName->WindowGroupName();      
       
   177         if(wgName->WindowGroupName()==KDummyWgName)
       
   178             {
       
   179             iLog->Log(_L("Get WgName successfully!\n"));
       
   180                         }
       
   181         else
       
   182             {
       
   183             iLog->Log(_L("Failed to get windowgroup name!\n"));
       
   184             retrunValue = KErrGeneral;
       
   185             }
       
   186         
       
   187         // Test GetIndexFromAppId and AppID
       
   188         TInt index=oomWindowGroupList->GetIndexFromAppId(AppSecuID.iId);
       
   189         
       
   190         TUint appID=oomWindowGroupList->AppId(index, ETrue);
       
   191         if(AppSecuID.iId==appID)
       
   192             {
       
   193             iLog->Log(_L("Get AppID successfully!\n"));
       
   194             }
       
   195         else
       
   196             {
       
   197             iLog->Log(_L("Failed to get AppID!\n"));
       
   198             retrunValue = KErrGeneral;
       
   199             }
       
   200         
       
   201         // Test IdleTime
       
   202         TTimeIntervalSeconds time1=oomWindowGroupList->IdleTime(index);
       
   203         User::After(1000000);
       
   204         TTimeIntervalSeconds time2=oomWindowGroupList->IdleTime(index);
       
   205         if(time2>=time1)
       
   206             {
       
   207             iLog->Log(_L("IdleTime test passed!\n"));
       
   208             }
       
   209         else
       
   210             {
       
   211             iLog->Log(_L("IdleTime test failed!\n"));
       
   212             retrunValue = KErrGeneral;
       
   213             }
       
   214         
       
   215         // Test priority
       
   216         oomWindowGroupList->SetPriorityBusy(wgID);
       
   217         if(!oomWindowGroupList->IsDynamicHighPriority(index) && oomWindowGroupList->IsBusy(index))
       
   218             {
       
   219             iLog->Log(_L("Test priority passed 1!\n"));
       
   220             }
       
   221         else
       
   222             {
       
   223             iLog->Log(_L("Test priority failed 1!\n"));
       
   224             retrunValue = KErrGeneral;
       
   225             }
       
   226         
       
   227         oomWindowGroupList->SetPriorityHigh(wgID);
       
   228         if(!oomWindowGroupList->IsBusy(index) && oomWindowGroupList->IsDynamicHighPriority(index))
       
   229             {
       
   230             iLog->Log(_L("Test priority passed 2!\n"));
       
   231             }
       
   232         else
       
   233             {
       
   234             iLog->Log(_L("Test priority failed 2!\n"));
       
   235             retrunValue = KErrGeneral;
       
   236             }
       
   237        
       
   238         oomWindowGroupList->SetPriorityNormal(wgID);
       
   239         if(!oomWindowGroupList->IsBusy(index) && !oomWindowGroupList->IsDynamicHighPriority(index))
       
   240             {
       
   241             iLog->Log(_L("Test priority passed 3!\n"));
       
   242             }
       
   243         else
       
   244             {
       
   245             iLog->Log(_L("Test priority failed 3!\n"));
       
   246             retrunValue = KErrGeneral;
       
   247             }
       
   248         CleanupStack::PopAndDestroy(oomWindowGroupList);
       
   249         }
       
   250 
       
   251     wgIds.Close();
       
   252     wgIds1.Close();
       
   253     process.Kill(KErrNone);
       
   254     
       
   255     User::After(5000000);   // waiting to kill process ...
       
   256     CleanupStack::PopAndDestroy(&process);
       
   257     CleanupStack::PopAndDestroy(&wsSession);
       
   258 
       
   259     STIF_ASSERT_EQUALS(retrunValue, KErrNone);
       
   260 }
       
   261 
       
   262 /**
       
   263  * @SYMTestCaseID              GAPS-OOM-WINDOWGROUPLIST-001
       
   264  * @SYMTestCaseDesc            Verify the behaviors of oomwserveventreceiver.cpp.
       
   265  * @SYMTestPriority            Medium
       
   266  * @SYMTestActions             1. Create and install CActiveScheduler object.
       
   267  *                             2. Create RWsSession object.
       
   268  *                             3. Create CWservEventReceiver object and add it into ActiveScheduler.
       
   269  *                             4. Create CMyTimer object.
       
   270  *                             5. Start ActiveScheduler.
       
   271  *                             6. Create appfortest.exe process.
       
   272  *                             7. Close appfortest.exe process. Call the cancel method of CTimer object.
       
   273  *                             8. Create appfortest.exe process.
       
   274  *                             9. Close appfortest.exe process.
       
   275  *                             10. Stop CActiveScheduler.
       
   276  * @SYMTestExpectedResults     1. Create and install CActiveScheduler object successfully.
       
   277  *                             2. Create RWsSession object successfully.
       
   278  *                             3. Create CWservEventReceiver object and add it into ActiveScheduler successfully.
       
   279  *                             4. Create CMyTimer object successfully.
       
   280  *                             5. Start ActiveScheduler successfully.
       
   281  *                             6. Create appfortest.exe process successfully. WservEventReceiver received focus change event.
       
   282  *                             7. Close appfortest.exe process successfully. cancel method is called.
       
   283  *                             8. Create CMyTimer object successfully. WservEventReceiver will not receive focus change event.
       
   284  *                             9. Close appfortest.exe process successfully.
       
   285  *                             10. Stop CActiveScheduler successfully.
       
   286  * @SYMTestType                Unit Test
       
   287  * @SYMCreationDate            20-07-2010
       
   288  */
       
   289 STIF_TESTDEFINE(GAPS-OOM-WSERVEVENTRECEIVER-001)
       
   290 {   
       
   291     iLog->Log(_L("Start oomwserveventreceiver.cpp test!\n"));
       
   292     TInt Count=0;
       
   293     Dll::SetTls(&Count);
       
   294         
       
   295     RWsSession wsSession;
       
   296     CleanupClosePushL(wsSession);
       
   297     User::LeaveIfError(wsSession.Connect());
       
   298     
       
   299     CMemoryMonitor* oom=NULL;
       
   300     CWservEventReceiver* winServEventReceiver = new(ELeave) CWservEventReceiver(*oom, wsSession);
       
   301     CleanupStack::PushL(winServEventReceiver);
       
   302     winServEventReceiver->ConstructL();
       
   303     
       
   304     CMyTimer* timer=CMyTimer::NewLC(winServEventReceiver);
       
   305     iLog->Log(_L("Start CActiveScheduler!\n"));
       
   306     CActiveScheduler::Start();
       
   307 
       
   308     iLog->Log(_L("CActiveScheduler stopped!\n"));
       
   309     
       
   310     CleanupStack::PopAndDestroy(3, &wsSession);
       
   311         
       
   312     TInt* pointer=(int*)(Dll::Tls());
       
   313     TInt* Count1=STATIC_CAST(TInt*, pointer);   
       
   314     iLog->Log(_L("count=%d\n"),*Count1);
       
   315     
       
   316     STIF_ASSERT_EQUALS(*Count1, 2);
       
   317     iLog->Log(_L("End of oomwserveventreceiver.cpp test!\n"));
       
   318 }
       
   319 
       
   320 /**
       
   321  * @SYMTestCaseID              GAPS-OOM-CLOSEAPP-001
       
   322  * @SYMTestCaseDesc            Unit test for COomCloseApp, COomAppCloseTimer, and COomAppCloseWatcher. Given process is data caged.
       
   323  * @SYMTestPriority            Medium
       
   324  * @SYMTestActions             1. Connect window session.
       
   325  *                             2. Get the wgID list before appfortest.exe start.
       
   326  *                             3. Create appfortest.exe process.
       
   327  *                             4. Get the app id of eshell.
       
   328  *                             5. Get the wgID list after appfortest.exe started.
       
   329  *                             6. Get teh wgID of appfortest.exe.
       
   330  *                             7. Construct a COomCloseApp object.
       
   331  *                             8. Reconfigure the reference to an action.
       
   332  *                             9. Close the application in order to free memory.
       
   333  *                             10.Close windows group list
       
   334  * @SYMTestExpectedResults     1. Windows session connected.
       
   335  *                             2. wgID list was got.
       
   336  *                             3. appfortest was created.
       
   337  *                             4. App id was got.
       
   338  *                             5. wgID list was got again.
       
   339  *                             6. wgID of appfortest.exe was got.
       
   340  *                             7. COomCloseApp object was constructed.
       
   341  *                             8. The reference to an action was reconfigured.
       
   342  *                             9. appfortest was closed.
       
   343  *                             10. Windows group list was closed.
       
   344  * @SYMTestType                Unit Test
       
   345  * @SYMCreationDate            03-08-2010
       
   346  */
       
   347 STIF_TESTDEFINE(GAPS-OOM-CLOSEAPP-001)
       
   348 {    
       
   349     STIF_LOG("1. Connect window session.");
       
   350     RWsSession wsSession;
       
   351     CleanupClosePushL(wsSession);
       
   352     User::LeaveIfError(wsSession.Connect());
       
   353     TInt numGroups = wsSession.NumWindowGroups(0);
       
   354 
       
   355     STIF_LOG("2. Get the wgID list before appfortest.exe start.");
       
   356     RArray<RWsSession::TWindowGroupChainInfo> wgIds;
       
   357     CleanupClosePushL(wgIds);
       
   358     wgIds.ReserveL(numGroups);
       
   359     User::LeaveIfError(wsSession.WindowGroupList(0, &wgIds));
       
   360 
       
   361     STIF_LOG("3. Create appfortest.exe process.");
       
   362     RProcess process;
       
   363     CleanupClosePushL(process);
       
   364     User::LeaveIfError(process.Create(KExeName, KArguments) );      
       
   365     process.Resume();   
       
   366     User::After(5000000);   // wait process start...
       
   367     
       
   368     STIF_LOG("4. Get the app id of eshell.");
       
   369     TSecureId AppSecuID=process.SecureId();
       
   370     
       
   371     CleanupStack::PopAndDestroy(&process);
       
   372 
       
   373     TInt numGroups1 = wsSession.NumWindowGroups(0);    
       
   374     
       
   375     STIF_LOG("5. Get the wgID list after appfortest.exe started.");
       
   376     RArray<RWsSession::TWindowGroupChainInfo> wgIds1;
       
   377     CleanupClosePushL(wgIds1);
       
   378     wgIds1.ReserveL(numGroups1);
       
   379     User::LeaveIfError(wsSession.WindowGroupList(0, &wgIds1));  
       
   380 
       
   381     STIF_LOG("6. Get teh wgID of appfortest.exe.");
       
   382     for(TInt count=0; count<numGroups; count++)
       
   383         {
       
   384         TInt position=wgIds1.Find(wgIds[count]);
       
   385         wgIds1.Remove(position);
       
   386         }
       
   387 
       
   388     TInt wgID=-1;
       
   389     if(1 == wgIds1.Count())
       
   390         {
       
   391         wgID=wgIds1[0].iId;
       
   392         }
       
   393     else
       
   394         {
       
   395         STIF_LOG("Failed to get wgID of appfortest.exe.");
       
   396         User::Leave(KErrNotFound);
       
   397         }
       
   398     
       
   399     CMemoryMonitor* memoryMonitor = CMemoryMonitor::NewL();
       
   400     CleanupStack::PushL(memoryMonitor);
       
   401     
       
   402     CMoc_COomActionList* oomActList = new (ELeave) CMoc_COomActionList();
       
   403     CleanupStack::PushL(oomActList);
       
   404 
       
   405     STIF_LOG("7. Construct a COomCloseApp object.");
       
   406     COomCloseApp* oomCloseApp = COomCloseApp::NewL(*oomActList, wsSession);
       
   407     CleanupStack::PushL(oomCloseApp);
       
   408     
       
   409     // 
       
   410     STIF_LOG("8. Reconfigure the reference to an action.");
       
   411     const TInt KBytesInMegabyte = 1024;
       
   412     TActionRef actionRef(TActionRef::EAppClose, KOomPriorityInfinate, EContinue, KBytesInMegabyte, wgID, 1);
       
   413     
       
   414     oomCloseApp->Reconfigure(actionRef);
       
   415     
       
   416     STIF_LOG("9. Close the application in order to free memory.");
       
   417     oomCloseApp->FreeMemory(0, ETrue);
       
   418 
       
   419     CleanupStack::PopAndDestroy(oomCloseApp);
       
   420     CleanupStack::PopAndDestroy(oomActList);
       
   421     CleanupStack::PopAndDestroy(memoryMonitor);
       
   422     
       
   423     STIF_LOG("10. Close windows group list.");
       
   424 
       
   425     CleanupStack::PopAndDestroy(&wgIds1);
       
   426     CleanupStack::PopAndDestroy(&wgIds);
       
   427     
       
   428     User::After(5000000);   // wait resource cleaning...
       
   429     
       
   430     CleanupStack::PopAndDestroy(&wsSession);
       
   431 }
       
   432 
       
   433 /**
       
   434  * @SYMTestCaseID              GAPS-OOM-CLOSEAPP-002
       
   435  * @SYMTestCaseDesc            Unit test for COomCloseApp, COomAppCloseTimer, and COomAppCloseWatcher. Given process is not data caged.
       
   436  * @SYMTestPriority            Medium
       
   437  * @SYMTestActions             1. Connect window session.
       
   438  *                             2. Get the wgID list before appfortest.exe start.
       
   439  *                             3. Create appfortest.exe process.
       
   440  *                             4. Get the app id of eshell.
       
   441  *                             5. Get the wgID list after appfortest.exe started.
       
   442  *                             6. Get teh wgID of appfortest.exe.
       
   443  *                             7. Construct a COomCloseApp object.
       
   444  *                             8. Reconfigure the reference to an action.
       
   445  *                             9. Close the application in order to free memory.
       
   446  *                             10.Close windows group list
       
   447  * @SYMTestExpectedResults     1. Windows session connected.
       
   448  *                             2. wgID list was got.
       
   449  *                             3. appfortest was created.
       
   450  *                             4. App id was got.
       
   451  *                             5. wgID list was got again.
       
   452  *                             6. wgID of appfortest.exe was got.
       
   453  *                             7. COomCloseApp object was constructed.
       
   454  *                             8. The reference to an action was reconfigured.
       
   455  *                             9. appfortest was closed.
       
   456  *                             10. Windows group list was closed.
       
   457  * @SYMTestType                Unit Test
       
   458  * @SYMCreationDate            03-08-2010
       
   459  */
       
   460 STIF_TESTDEFINE(GAPS-OOM-CLOSEAPP-002)
       
   461 {    
       
   462     STIF_LOG("1. Connect window session.");
       
   463     RWsSession wsSession;
       
   464     CleanupClosePushL(wsSession);
       
   465     User::LeaveIfError(wsSession.Connect());
       
   466     TInt numGroups = wsSession.NumWindowGroups(0);
       
   467 
       
   468     STIF_LOG("2. Get the wgID list before appfortest.exe start.");
       
   469     RArray<RWsSession::TWindowGroupChainInfo> wgIds;
       
   470     CleanupClosePushL(wgIds);
       
   471     wgIds.ReserveL(numGroups);
       
   472     User::LeaveIfError(wsSession.WindowGroupList(0, &wgIds));
       
   473 
       
   474     STIF_LOG("3. Create appfortest.exe process.");
       
   475     RProcess process;
       
   476     CleanupClosePushL(process);
       
   477     User::LeaveIfError(process.Create(KExeName, KArguments) );      
       
   478     process.Resume();   
       
   479     User::After(5000000);   // wait process start...
       
   480     
       
   481     STIF_LOG("4. Get the app id of eshell.");
       
   482     TSecureId AppSecuID=process.SecureId();
       
   483     
       
   484     CleanupStack::PopAndDestroy(&process);
       
   485 
       
   486     TInt numGroups1 = wsSession.NumWindowGroups(0);    
       
   487     
       
   488     STIF_LOG("5. Get the wgID list after appfortest.exe started.");
       
   489     RArray<RWsSession::TWindowGroupChainInfo> wgIds1;
       
   490     CleanupClosePushL(wgIds1);
       
   491     wgIds1.ReserveL(numGroups1);
       
   492     User::LeaveIfError(wsSession.WindowGroupList(0, &wgIds1));  
       
   493 
       
   494     STIF_LOG("6. Get teh wgID of appfortest.exe.");
       
   495     for(TInt count=0; count<numGroups; count++)
       
   496         {
       
   497         TInt position=wgIds1.Find(wgIds[count]);
       
   498         wgIds1.Remove(position);
       
   499         }
       
   500 
       
   501     TInt wgID=-1;
       
   502     if(1 == wgIds1.Count())
       
   503         {
       
   504         wgID=wgIds1[0].iId;
       
   505         }
       
   506     else
       
   507         {
       
   508         STIF_LOG("Failed to get wgID of appfortest.exe.");
       
   509         User::Leave(KErrNotFound);
       
   510         }
       
   511     
       
   512     CMemoryMonitor* memoryMonitor = CMemoryMonitor::NewL();
       
   513     CleanupStack::PushL(memoryMonitor);
       
   514     
       
   515     CMoc_COomActionList* oomActList = new (ELeave) CMoc_COomActionList();
       
   516     CleanupStack::PushL(oomActList);
       
   517 
       
   518     STIF_LOG("7. Construct a COomCloseApp object.");
       
   519     COomCloseApp* oomCloseApp = COomCloseApp::NewL(*oomActList, wsSession);
       
   520     CleanupStack::PushL(oomCloseApp);
       
   521     
       
   522     // 
       
   523     STIF_LOG("8. Reconfigure the reference to an action.");
       
   524     const TInt KBytesInMegabyte = 1024;
       
   525     TActionRef actionRef(TActionRef::EAppClose, KOomPriorityInfinate, EContinue, KBytesInMegabyte, wgID, 1);
       
   526     
       
   527     oomCloseApp->Reconfigure(actionRef);
       
   528     
       
   529     STIF_LOG("9. Close the application in order to free memory.");
       
   530     oomCloseApp->FreeMemory(0, EFalse);
       
   531 
       
   532     CleanupStack::PopAndDestroy(oomCloseApp);
       
   533     CleanupStack::PopAndDestroy(oomActList);
       
   534     CleanupStack::PopAndDestroy(memoryMonitor);
       
   535     
       
   536     STIF_LOG("10. Close windows group list.");
       
   537 
       
   538     CleanupStack::PopAndDestroy(&wgIds1);
       
   539     CleanupStack::PopAndDestroy(&wgIds);
       
   540     
       
   541     User::After(5000000);   // wait resource cleaning...
       
   542     
       
   543     CleanupStack::PopAndDestroy(&wsSession);
       
   544 }
       
   545 
       
   546 #endif
       
   547 /**
       
   548  * END OF TEST CASES SECTION
       
   549  */
       
   550 
       
   551 // End of File