psmservices/psmserver/tsrc/PsmTestModule/src/PSMTestBlocks.cpp
branchRCL_3
changeset 22 8cb079868133
parent 21 ccb4f6b3db21
equal deleted inserted replaced
21:ccb4f6b3db21 22:8cb079868133
    26 #include <psmsettings.h>
    26 #include <psmsettings.h>
    27 #include <psmtypes.h>
    27 #include <psmtypes.h>
    28 
    28 
    29 #include <psmsrvdomaincrkeys.h>
    29 #include <psmsrvdomaincrkeys.h>
    30 #include <centralrepository.h>
    30 #include <centralrepository.h>
    31 #include "psmclientimpl.h"
    31 
    32 #include "PSMTest.h"
    32 #include "PSMTest.h"
    33 
    33 
    34 
    34 
    35     // CONSTANT DEFINITIONS
    35     // CONSTANT DEFINITIONS
    36 
    36 
   124         ENTRY( "OpenClosePerformanceRequest", CPSMTest::OpenClosePerformanceRequest ),
   124         ENTRY( "OpenClosePerformanceRequest", CPSMTest::OpenClosePerformanceRequest ),
   125         ENTRY( "OpenClosePerformanceCancel", CPSMTest::OpenClosePerformanceCancel ),
   125         ENTRY( "OpenClosePerformanceCancel", CPSMTest::OpenClosePerformanceCancel ),
   126         ENTRY( "OpenClosePerformanceChange", CPSMTest::OpenClosePerformanceChange ),
   126         ENTRY( "OpenClosePerformanceChange", CPSMTest::OpenClosePerformanceChange ),
   127         ENTRY( "OpenClosePerformanceEnd", CPSMTest::OpenClosePerformanceEnd ),
   127         ENTRY( "OpenClosePerformanceEnd", CPSMTest::OpenClosePerformanceEnd ),
   128         ENTRY( "ChangePsmPerformance", CPSMTest::ChangePsmPerformance ),
   128         ENTRY( "ChangePsmPerformance", CPSMTest::ChangePsmPerformance ),
   129 
   129         ENTRY( "ChangeSettingsPerformance", CPSMTest::ChangeSettingsPerformance )
   130 #ifdef _DEBUG 
       
   131         //OOM tests for psm server
       
   132         ENTRY( "OOMChangePsmInit", CPSMTest::OOMNotifyPowerSaveModeChangeInitL ),
       
   133         ENTRY( "OOMCancelPsm", CPSMTest::OOMCancelPowerSaveModeChangeL ),
       
   134         ENTRY( "OOMBackupAndGetSettings", CPSMTest::OOMPsmBackupAndGetSettingsL ),
       
   135         ENTRY( "OOMGetSettings", CPSMTest::OOMPsmGetSettingsL ),
       
   136         ENTRY( "OOMBackupSettings", CPSMTest::OOMPsmBackupSettingsL ),
       
   137 #endif  //_DEBUG       
       
   138         ENTRY( "ChangeSettingsPerformance", CPSMTest::ChangeSettingsPerformance )    
       
   139         };
   130         };
   140 
   131 
   141     const TInt count = sizeof( KFunctions ) / 
   132     const TInt count = sizeof( KFunctions ) / 
   142                         sizeof( TStifFunctionInfo );
   133                         sizeof( TStifFunctionInfo );
   143 
   134 
  1249 // CPSMTest::NotifyPowerSaveModeChange
  1240 // CPSMTest::NotifyPowerSaveModeChange
  1250 // -----------------------------------------------------------------------------
  1241 // -----------------------------------------------------------------------------
  1251 //
  1242 //
  1252 CPSMTestObserver::~CPSMTestObserver()
  1243 CPSMTestObserver::~CPSMTestObserver()
  1253     {
  1244     {
  1254     }   
  1245     }
  1255 */
  1246 */
  1256 #ifdef _DEBUG 
       
  1257 // -----------------------------------------------------------------------------
       
  1258 // CPSMTest::OOMNotifyPowerSaveModeChangeInit
       
  1259 // -----------------------------------------------------------------------------
       
  1260 //
       
  1261 TInt CPSMTest::OOMNotifyPowerSaveModeChangeInitL(CStifItemParser& /*aItem*/)
       
  1262     {    
       
  1263     CPsmClient* psmClient = CPsmClient::NewL( *this );
       
  1264     CleanupStack::PushL(psmClient);
       
  1265     CPsmClientImpl* psmImpl = static_cast<CPsmClientImpl*> (psmClient);
       
  1266 	psmImpl->HeapReset();
       
  1267 	psmImpl->HeapMark();
       
  1268     for (TInt allocFailRate = 1;; allocFailRate++)
       
  1269         {        
       
  1270         psmImpl->SetHeapFailure( allocFailRate );                
       
  1271         psmImpl->ChangePowerSaveMode(1);
       
  1272         // Wait for mode to change
       
  1273         iSchedulerWait.Start();
       
  1274         
       
  1275         if (iErrorCode == KErrNone)
       
  1276             {
       
  1277             iErrorCode = KErrNone;            
       
  1278             break;            
       
  1279             }     
       
  1280         }
       
  1281 	psmImpl->HeapMarkEnd();
       
  1282 	psmImpl->HeapReset();   
       
  1283     CleanupStack::PopAndDestroy(psmClient);
       
  1284     return KErrNone;  
       
  1285     }
       
  1286 
       
  1287 // -----------------------------------------------------------------------------
       
  1288 // CPSMTest::OOMCancelPowerSaveModeChange
       
  1289 // -----------------------------------------------------------------------------
       
  1290 //
       
  1291 TInt CPSMTest::OOMCancelPowerSaveModeChangeL( CStifItemParser& /*aItem*/ )
       
  1292     {
       
  1293     CPsmClient* psmClient = CPsmClient::NewL( *this );
       
  1294     CleanupStack::PushL(psmClient);
       
  1295     CPsmClientImpl* psmImpl = static_cast<CPsmClientImpl*> (psmClient);
       
  1296     psmImpl->ChangePowerSaveMode(0);
       
  1297     for (TInt allocFailRate = 1;; allocFailRate++)
       
  1298         {
       
  1299         psmImpl->HeapReset();
       
  1300         psmImpl->SetHeapFailure( allocFailRate );
       
  1301         psmImpl->HeapMark();        
       
  1302         psmImpl->CancelPowerSaveModeChange();        
       
  1303         // Wait for mode to change
       
  1304         iSchedulerWait.Start();
       
  1305         psmImpl->HeapMarkEnd();
       
  1306         if (iErrorCode == KErrNone )
       
  1307             {
       
  1308             iErrorCode = KErrNone;
       
  1309             psmImpl->HeapReset();  
       
  1310             break;            
       
  1311             }       
       
  1312         }
       
  1313     CleanupStack::PopAndDestroy(psmClient); 
       
  1314     return KErrNone;  
       
  1315     }
       
  1316 
       
  1317 
       
  1318 // -----------------------------------------------------------------------------
       
  1319 // CPSMTest::OOMPsmBackupAndGetSettings
       
  1320 // -----------------------------------------------------------------------------
       
  1321 //
       
  1322 TInt CPSMTest::OOMPsmBackupAndGetSettingsL( CStifItemParser& /*aItem*/ )
       
  1323     {
       
  1324     CPsmClient* psmClient = CPsmClient::NewL( *this );
       
  1325     CleanupStack::PushL(psmClient);
       
  1326    
       
  1327     CPsmClientImpl* psmImpl = static_cast<CPsmClientImpl*> (psmClient);
       
  1328     psmImpl->HeapReset();
       
  1329     psmImpl->HeapMark(); 
       
  1330     for (TInt allocFailRate = 1;; allocFailRate++)
       
  1331         {
       
  1332         
       
  1333         psmImpl->SetHeapFailure( allocFailRate );
       
  1334               
       
  1335         TInt err = psmImpl->PsmSettings().BackupAndGetSettings( iPsmConfigArray, KCenRepUid2 );
       
  1336        
       
  1337         if (err == KErrNone)
       
  1338             {
       
  1339             
       
  1340             break;            
       
  1341             }         
       
  1342         }
       
  1343     psmImpl->HeapMarkEnd();
       
  1344     psmImpl->HeapReset();  
       
  1345     CleanupStack::PopAndDestroy(psmClient);
       
  1346     return KErrNone;  
       
  1347     }
       
  1348 
       
  1349 // -----------------------------------------------------------------------------
       
  1350 // CPSMTest::OOMPsmGetSettings
       
  1351 // -----------------------------------------------------------------------------
       
  1352 //
       
  1353 TInt CPSMTest::OOMPsmGetSettingsL( CStifItemParser& /*aItem*/ )
       
  1354     {
       
  1355     CPsmClient* psmClient = CPsmClient::NewL( *this );
       
  1356     CleanupStack::PushL(psmClient);
       
  1357     CPsmClientImpl* psmImpl = static_cast<CPsmClientImpl*> (psmClient);
       
  1358 
       
  1359     for (TInt allocFailRate = 1;; allocFailRate++)
       
  1360         {
       
  1361         psmImpl->HeapReset();
       
  1362         psmImpl->SetHeapFailure( allocFailRate );
       
  1363         psmImpl->HeapMark();       
       
  1364         TInt err = psmImpl->PsmSettings().GetSettings( iPsmConfigArray, KCenRepUid2 );
       
  1365         psmImpl->HeapMarkEnd();
       
  1366         if (err == KErrNone)
       
  1367             {
       
  1368             psmImpl->HeapReset();  
       
  1369             break;            
       
  1370             }         
       
  1371         }
       
  1372     CleanupStack::PopAndDestroy(psmClient);
       
  1373     return KErrNone;  
       
  1374     }
       
  1375 
       
  1376 // -----------------------------------------------------------------------------
       
  1377 // CPSMTest::OOMPsmBackupSettings
       
  1378 // -----------------------------------------------------------------------------
       
  1379 //
       
  1380 TInt CPSMTest::OOMPsmBackupSettingsL( CStifItemParser& /*aItem*/ )
       
  1381     {
       
  1382     CPsmClient* psmClient = CPsmClient::NewL( *this );
       
  1383     CleanupStack::PushL(psmClient);
       
  1384     CPsmClientImpl* psmImpl = static_cast<CPsmClientImpl*> (psmClient);
       
  1385 	//IGNORE the error of Powersave mode request. If Powersave mode is not enabled the Backupsettings will fail with KErrWrite.
       
  1386     psmImpl->ChangePowerSaveMode(1);
       
  1387     iSchedulerWait.Start();    
       
  1388     RConfigInfoArray psmConfigArray;
       
  1389     GenerateConfigArray( psmConfigArray, EPsmsrvModePowerSave, 0 ); 
       
  1390     psmImpl->HeapReset();
       
  1391     psmImpl->HeapMark();
       
  1392     for (TInt allocFailRate = 1;; allocFailRate++)
       
  1393         {       
       
  1394         psmImpl->SetHeapFailure( allocFailRate );
       
  1395         TInt err = psmImpl->PsmSettings().BackupSettings( psmConfigArray, KCenRepUid2 );
       
  1396         iLog->Log( _L("PSMTest: BackupSettings- iPsmConfigArray.Count(): %d"), psmConfigArray.Count() );
       
  1397         if (err == KErrNone)
       
  1398             {            
       
  1399             break;            
       
  1400             }      
       
  1401         }
       
  1402     psmImpl->HeapMarkEnd();
       
  1403     psmImpl->HeapReset(); 
       
  1404     psmConfigArray.Close();   
       
  1405     CleanupStack::PopAndDestroy(psmClient);
       
  1406     return KErrNone; 
       
  1407     }
       
  1408 
       
  1409 #endif //_DEBUG     
       
  1410 //  End of File
  1247 //  End of File