stif/TestCombiner/src/TestCombiner.cpp
branchRCL_3
changeset 10 381827f66490
parent 6 ecff51f1e7fb
child 16 8f8df8006c40
--- a/stif/TestCombiner/src/TestCombiner.cpp	Wed Apr 14 17:35:04 2010 +0300
+++ b/stif/TestCombiner/src/TestCombiner.cpp	Tue Apr 27 18:14:33 2010 +0300
@@ -2445,8 +2445,21 @@
 */
 void CTestRunner::ConstructL()
     {
-    
-    iPauseTimer.CreateLocal();
+    TInt ret;
+    
+    ret = iPauseTimer.CreateLocal();
+    if(ret != KErrNone)
+        {
+        __TRACE( KError, (_L("Unable to create RTimer: iPauseTimer [%d] "), ret));
+        User::Leave(ret);
+        }
+        
+    ret = iPauseCombTimer.CreateLocal();
+    if(ret != KErrNone)
+        {
+        __TRACE( KError, (_L("Unable to create RTimer: iPauseCombTimer [%d] "), ret));
+        User::Leave(ret);
+        }
     
     iRemoteTimer = CRemoteTimer::NewL( iTestCombiner );
     
@@ -2515,6 +2528,8 @@
     iLine = 0;
     
     iPauseTimer.Close();
+    
+    iPauseCombTimer.Close();
          
     }
 
@@ -2550,8 +2565,34 @@
         User::Leave( KErrGeneral );
         }
         
-    TBool continueTask = EFalse; 
+    TBool continueTask = EFalse;
+    
+    // Check if there is still some time for combiner pause and we need to 
+    // continue pausing
+    if(iPauseCombRemainingTime > 0)
+        {           
+        // Maximum time for one RTimer::After request                   
+        TInt maximumTime = KMaxTInt / 1000;                       
+        
+        __TRACE( KMessage, (_L("CTestRunner::RunL: Going to reissue PauseCombiner request ") ) );           
+        __TRACE( KMessage, (_L("CTestRunner::RunL: iRemainingTimeValue = %d"), iPauseCombRemainingTime ) );        
         
+        if( iPauseCombRemainingTime < maximumTime )
+            {                           
+            iPauseCombTimer.After(iStatus, (iPauseCombRemainingTime * 1000));
+            iPauseCombRemainingTime = 0;
+            }
+        else
+            {            
+            iPauseCombRemainingTime -= maximumTime;
+            iPauseCombTimer.After(iStatus, (maximumTime * 1000));        
+            }     
+            
+        SetActive();
+        return;
+        }     
+ 
+    // Handling runner states
     switch( iState )
         {
         case ERunnerWaitTimeout:
@@ -2695,6 +2736,8 @@
     __TRACE( KMessage, (_L("CTestRunner::DoCancel")));
     iTestCombiner->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), _L("DoCancel"));
     
+    iPauseCombTimer.Cancel();
+    
     switch( iState )
         {
         case ERunnerWaitTimeout:
@@ -3397,7 +3440,7 @@
 	_LIT( KErrMsgPauseTimeoutNotDefined, "PauseCombiner : No timeout value given or value has invalid format" );
 	_LIT( KErrMsgPauseTimeoutNotPositive, "PauseCombiner : Timeout value can't be <0" );
 
-    TBool continueTask = ETrue;
+    TBool continueTask = EFalse;
     TInt pauseTime;
     TInt ret = KErrNone;
     
@@ -3416,12 +3459,31 @@
         User::Leave( KErrArgument );
         }    
     
-    //Time given by End User should be given in miliseconds
-    pauseTime*=1000;
-
-    __TRACE( KMessage, (_L("time=%d"), pauseTime ) );
-
-    User::After( pauseTime );
+    
+    // Maximum time for one RTimer::After request
+    TInt maximumTime = KMaxTInt / 1000;
+
+    // Check if pause value is suitable for RTimer::After
+    if(pauseTime < maximumTime)
+        {
+        iPauseCombTimer.After(iStatus, pauseTime * 1000);
+        iPauseCombRemainingTime = 0;
+        }
+    else
+        {
+        // Given pause value after multiplication with 1000 is
+        // larger than KMaxTInt, so we need to split it and 
+        // re-request After with remaining value from RunL
+
+        iPauseCombRemainingTime = pauseTime - maximumTime;
+        iPauseCombTimer.After(iStatus, maximumTime * 1000);
+        }
+
+    SetActive();
+
+    __TRACE(KMessage, (_L("Executing pause, time=[%d]"), pauseTime));
+    
+    iState = ERunnerRunning;
     
     return continueTask;
 }