kerneltest/e32test/active/t_ctimer.cpp
changeset 247 d8d70de2bd36
parent 0 a41df078684a
child 257 3e88ff8f41d5
equal deleted inserted replaced
201:43365a9b78a3 247:d8d70de2bd36
    26 // - Repeated timer is cancelled as expected.
    26 // - Repeated timer is cancelled as expected.
    27 // - Call relative timer's After function without adding it to the active scheduler 
    27 // - Call relative timer's After function without adding it to the active scheduler 
    28 // and check for panic.
    28 // and check for panic.
    29 // - Call absolute timer's At function without adding it to the active scheduler and 
    29 // - Call absolute timer's At function without adding it to the active scheduler and 
    30 // check for panic.
    30 // check for panic.
       
    31 // - Call 1s inactivity timer
    31 // - Check if heap has been corrupted by the tests.
    32 // - Check if heap has been corrupted by the tests.
    32 // Platforms/Drives/Compatibility:
    33 // Platforms/Drives/Compatibility:
    33 // All.
    34 // All.
    34 // Assumptions/Requirement/Pre-requisites:
    35 // Assumptions/Requirement/Pre-requisites:
    35 // Failures and causes:
    36 // Failures and causes:
    75 	TInt iCount;
    76 	TInt iCount;
    76 	static TInt iNum;
    77 	static TInt iNum;
    77 	static TInt iTotalCount;
    78 	static TInt iTotalCount;
    78 	};
    79 	};
    79 
    80 
       
    81 // for inactivity test
       
    82 class myInactTimer : public CTimer
       
    83 	{
       
    84 public:
       
    85 	myInactTimer(const TInt aPriority):CTimer(aPriority){;}
       
    86 	void RunL(void);	
       
    87 	void Start(void);
       
    88 	};
       
    89 
    80 TInt myTimer::iTotalCount;
    90 TInt myTimer::iTotalCount;
    81 TInt myTimer::iNum;
    91 TInt myTimer::iNum;
    82 
    92 
    83 void myTimer::RunL(void)
    93 void myTimer::RunL(void)
    84 //
    94 //
   102 //
   112 //
   103 // Start a timer going.
   113 // Start a timer going.
   104 //
   114 //
   105 	{
   115 	{
   106 
   116 
       
   117 	ConstructL();
       
   118 	CActiveScheduler::Add(this);
       
   119 	}
       
   120 
       
   121 void myInactTimer::RunL(void)
       
   122 //
       
   123 // Timer has completed
       
   124 //
       
   125 	{
       
   126 	CActiveScheduler::Stop();
       
   127 	}
       
   128 
       
   129 void myInactTimer::Start(void)
       
   130 //
       
   131 // Start a timer going.
       
   132 //
       
   133 	{
   107 	ConstructL();
   134 	ConstructL();
   108 	CActiveScheduler::Add(this);
   135 	CActiveScheduler::Add(this);
   109 	}
   136 	}
   110 
   137 
   111 LOCAL_D TInt ThreadEntry(TAny* aDirective)
   138 LOCAL_D TInt ThreadEntry(TAny* aDirective)
   195 	myTimer::SetNum(1);
   222 	myTimer::SetNum(1);
   196 	pTimer1->HighRes(1000000);
   223 	pTimer1->HighRes(1000000);
   197 	CActiveScheduler::Start();
   224 	CActiveScheduler::Start();
   198 	test(A[0]==ID1 && pTimer1->iStatus==KErrNone);
   225 	test(A[0]==ID1 && pTimer1->iStatus==KErrNone);
   199 //
   226 //
   200 
   227 	test.Next(_L("Inactivity 1s"));
       
   228 	User::ResetInactivityTime();
       
   229 	myInactTimer* pInactTimer=new myInactTimer(0);
       
   230 	pInactTimer->Start();
       
   231 	test.Printf(_L("inactivity..."));
       
   232 	pInactTimer->Inactivity(1);
       
   233 	CActiveScheduler::Start();
       
   234 	test.Printf(_L("...back"));
       
   235 	test(pInactTimer->iStatus==KErrNone);
       
   236 //
   201 	test.Next(_L("Destroy objects"));
   237 	test.Next(_L("Destroy objects"));
   202 	delete pTimer1;
   238 	delete pTimer1;
   203 	delete pTimer2;
   239 	delete pTimer2;
   204 	delete pTimer3;
   240 	delete pTimer3;
   205 	delete pRepeater;
   241 	delete pRepeater;
       
   242 	delete pInactTimer;
   206 //
   243 //
   207 	test.End();
   244 	test.End();
   208 	}
   245 	}
   209 
   246 
   210 void TestCTimer::Test2()
   247 void TestCTimer::Test2()