kerneltest/e32test/power/t_switchoff.cpp
changeset 0 a41df078684a
child 286 48e57fb1237e
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // e32test\power\t_switchoff.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <e32event.h>
       
    19 #include <e32event_private.h>
       
    20 #include <e32svr.h>
       
    21 #include <e32test.h>
       
    22 
       
    23 LOCAL_D RTest test(_L(" T_SWITCHOFF "));
       
    24 
       
    25 void SetAbsoluteTimeout(RTimer& aTimer, TUint aUs, TRequestStatus& aStatus)
       
    26 	{
       
    27 	TTime wakeup;
       
    28 	wakeup.HomeTime();
       
    29 	wakeup += TTimeIntervalMicroSeconds(aUs);
       
    30 	aTimer.At(aStatus, wakeup);
       
    31 	}
       
    32 
       
    33 void SwittchOffTests()
       
    34 	{
       
    35 	test.Next(_L("test sending ESwitchOff event"));
       
    36 
       
    37 	for (int i = 0; i < 4; ++i)
       
    38 		{
       
    39 		test.Printf(_L(" %d "), i);
       
    40 		// Arm an absolute timer wakeup event after 5 sec
       
    41 		TRequestStatus absstatus;
       
    42 		RTimer abstimer;
       
    43 		TInt r = abstimer.CreateLocal();
       
    44 		test (r == KErrNone);
       
    45 		SetAbsoluteTimeout(abstimer, 5000000, absstatus); // 5 sec
       
    46 
       
    47 		// Go to standby through sending a ESwitchOff event (uses domain manager)
       
    48 		TRawEvent e;
       
    49 		e.Set(TRawEvent::ESwitchOff);
       
    50 		r = UserSvr::AddEvent(e);
       
    51 		test (r == KErrNone);
       
    52 		User::WaitForRequest(absstatus);
       
    53 		abstimer.Close();
       
    54 		}
       
    55 	test.Printf(_L(" OK\n"));
       
    56 	}
       
    57 
       
    58 
       
    59 GLDEF_C TInt E32Main()
       
    60 	{
       
    61 	test.Title();
       
    62 	test.Start(_L("Testing"));
       
    63 
       
    64 	SwittchOffTests();
       
    65 
       
    66 	test.End();
       
    67 
       
    68 	return KErrNone;
       
    69 	}