os/kernelhwsrv/kerneltest/e32test/power/t_switchoff.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/power/t_switchoff.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,69 @@
     1.4 +// Copyright (c) 2002-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\power\t_switchoff.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include <e32event.h>
    1.22 +#include <e32event_private.h>
    1.23 +#include <e32svr.h>
    1.24 +#include <e32test.h>
    1.25 +
    1.26 +LOCAL_D RTest test(_L(" T_SWITCHOFF "));
    1.27 +
    1.28 +void SetAbsoluteTimeout(RTimer& aTimer, TUint aUs, TRequestStatus& aStatus)
    1.29 +	{
    1.30 +	TTime wakeup;
    1.31 +	wakeup.HomeTime();
    1.32 +	wakeup += TTimeIntervalMicroSeconds(aUs);
    1.33 +	aTimer.At(aStatus, wakeup);
    1.34 +	}
    1.35 +
    1.36 +void SwittchOffTests()
    1.37 +	{
    1.38 +	test.Next(_L("test sending ESwitchOff event"));
    1.39 +
    1.40 +	for (int i = 0; i < 4; ++i)
    1.41 +		{
    1.42 +		test.Printf(_L(" %d "), i);
    1.43 +		// Arm an absolute timer wakeup event after 5 sec
    1.44 +		TRequestStatus absstatus;
    1.45 +		RTimer abstimer;
    1.46 +		TInt r = abstimer.CreateLocal();
    1.47 +		test (r == KErrNone);
    1.48 +		SetAbsoluteTimeout(abstimer, 5000000, absstatus); // 5 sec
    1.49 +
    1.50 +		// Go to standby through sending a ESwitchOff event (uses domain manager)
    1.51 +		TRawEvent e;
    1.52 +		e.Set(TRawEvent::ESwitchOff);
    1.53 +		r = UserSvr::AddEvent(e);
    1.54 +		test (r == KErrNone);
    1.55 +		User::WaitForRequest(absstatus);
    1.56 +		abstimer.Close();
    1.57 +		}
    1.58 +	test.Printf(_L(" OK\n"));
    1.59 +	}
    1.60 +
    1.61 +
    1.62 +GLDEF_C TInt E32Main()
    1.63 +	{
    1.64 +	test.Title();
    1.65 +	test.Start(_L("Testing"));
    1.66 +
    1.67 +	SwittchOffTests();
    1.68 +
    1.69 +	test.End();
    1.70 +
    1.71 +	return KErrNone;
    1.72 +	}