sl@0: // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\power\t_switchoff.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: LOCAL_D RTest test(_L(" T_SWITCHOFF ")); sl@0: sl@0: void SetAbsoluteTimeout(RTimer& aTimer, TUint aUs, TRequestStatus& aStatus) sl@0: { sl@0: TTime wakeup; sl@0: wakeup.HomeTime(); sl@0: wakeup += TTimeIntervalMicroSeconds(aUs); sl@0: aTimer.At(aStatus, wakeup); sl@0: } sl@0: sl@0: void SwittchOffTests() sl@0: { sl@0: test.Next(_L("test sending ESwitchOff event")); sl@0: sl@0: for (int i = 0; i < 4; ++i) sl@0: { sl@0: test.Printf(_L(" %d "), i); sl@0: // Arm an absolute timer wakeup event after 5 sec sl@0: TRequestStatus absstatus; sl@0: RTimer abstimer; sl@0: TInt r = abstimer.CreateLocal(); sl@0: test (r == KErrNone); sl@0: SetAbsoluteTimeout(abstimer, 5000000, absstatus); // 5 sec sl@0: sl@0: // Go to standby through sending a ESwitchOff event (uses domain manager) sl@0: TRawEvent e; sl@0: e.Set(TRawEvent::ESwitchOff); sl@0: r = UserSvr::AddEvent(e); sl@0: test (r == KErrNone); sl@0: User::WaitForRequest(absstatus); sl@0: abstimer.Close(); sl@0: } sl@0: test.Printf(_L(" OK\n")); sl@0: } sl@0: sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: test.Title(); sl@0: test.Start(_L("Testing")); sl@0: sl@0: SwittchOffTests(); sl@0: sl@0: test.End(); sl@0: sl@0: return KErrNone; sl@0: }