os/kernelhwsrv/kerneltest/e32test/misc/t_alive.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/misc/t_alive.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,123 @@
     1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32test\misc\t_alive.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include <e32test.h>
    1.22 +#include <e32base.h>
    1.23 +#include <e32base_private.h>
    1.24 +#include <e32svr.h>
    1.25 +
    1.26 +RTest test(_L("T_ALIVE"));
    1.27 +
    1.28 +class CTim : public CActive
    1.29 +	{
    1.30 +public:
    1.31 +	static CTim* New();
    1.32 +	CTim() : CActive(EPriorityStandard) {}
    1.33 +	void RunL();
    1.34 +	void DoCancel() {}
    1.35 +public:
    1.36 +	RTimer iTimer;
    1.37 +	};
    1.38 +
    1.39 +class CTest : public CActive
    1.40 +	{
    1.41 +public:
    1.42 +	CTest() : CActive(EPriorityUserInput) {}
    1.43 +	static CTest* New();
    1.44 +	void RunL();
    1.45 +	void DoCancel() {}
    1.46 +	void Start();
    1.47 +	};
    1.48 +
    1.49 +LOCAL_C void DisplayProcesses()
    1.50 +	{
    1.51 +	TFindProcess fp(_L("*"));
    1.52 +	TFullName fn;
    1.53 +	while(fp.Next(fn)==KErrNone)
    1.54 +		{
    1.55 +		RDebug::Print(_L("%S"),&fn);
    1.56 +		}
    1.57 +	}
    1.58 +
    1.59 +
    1.60 +CTim* CTim::New()
    1.61 +	{
    1.62 +	CTim* pC=new CTim;
    1.63 +	if (pC)
    1.64 +		{
    1.65 +		TInt r=pC->iTimer.CreateLocal();
    1.66 +		if (r!=KErrNone)
    1.67 +			{
    1.68 +			delete pC;
    1.69 +			pC=NULL;
    1.70 +			}
    1.71 +		}
    1.72 +	return pC;
    1.73 +	}
    1.74 +
    1.75 +void CTim::RunL()
    1.76 +	{
    1.77 +	DisplayProcesses();
    1.78 +	iTimer.HighRes(iStatus,2100000);
    1.79 +	SetActive();
    1.80 +	}
    1.81 +
    1.82 +CTest* CTest::New()
    1.83 +	{
    1.84 +	return new CTest;
    1.85 +	}
    1.86 +
    1.87 +void CTest::Start()
    1.88 +	{
    1.89 +	test.Console()->Read(iStatus);
    1.90 +	SetActive();
    1.91 +	}
    1.92 +
    1.93 +void CTest::RunL()
    1.94 +	{
    1.95 +	TKeyCode k=test.Console()->KeyCode();
    1.96 +	TChar c=(TUint)k;
    1.97 +	TBuf<1> b;
    1.98 +	b.SetLength(1);
    1.99 +	b[0]=(TText)c;
   1.100 +	RDebug::Print(_L("%S"),&b);
   1.101 +	if (c!='0')
   1.102 +		Start();
   1.103 +	else
   1.104 +		CActiveScheduler::Stop();
   1.105 +	}
   1.106 +
   1.107 +GLDEF_C TInt E32Main()
   1.108 +	{
   1.109 +	test.Title();
   1.110 +	CActiveScheduler* pS=new CActiveScheduler;
   1.111 +	if (!pS)
   1.112 +		User::Panic(_L("SCHED"),0);
   1.113 +	CActiveScheduler::Install(pS);
   1.114 +	CTim* pT2=CTim::New();
   1.115 +	if (!pT2)
   1.116 +		User::Panic(_L("TIM2"),0);
   1.117 +	CActiveScheduler::Add(pT2);
   1.118 +	CTest* pTest=CTest::New();
   1.119 +	if (!pTest)
   1.120 +		User::Panic(_L("TEST"),0);
   1.121 +	CActiveScheduler::Add(pTest);
   1.122 +	pT2->RunL();
   1.123 +	pTest->Start();
   1.124 +	CActiveScheduler::Start();
   1.125 +	return 0;
   1.126 +	}