sl@0: // Copyright (c) 2006-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_lddpowerseqtest.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include "d_lddpowerseqtest.h" sl@0: #include sl@0: sl@0: _LIT(KLddFileName, "D_LDDPOWERSEQTEST.LDD"); sl@0: sl@0: RLddTest1 ldd; sl@0: GLDEF_D RTest test(_L("T_LDDPOWERSEQTEST")); sl@0: sl@0: void DoTests() sl@0: { sl@0: TInt r; sl@0: TInt timeInterval = 3; sl@0: //time stamp for power up and powerdown of handlers sl@0: TUint time_power1up = 0, time_power1down = 0; sl@0: TUint time_power2up = 10, time_power2down = 0; sl@0: TRequestStatus statuspowerdown1; sl@0: TRequestStatus statuspowerdown2; sl@0: TRequestStatus statuspowerup1; sl@0: TRequestStatus statuspowerup2; sl@0: RTimer timer; sl@0: TRequestStatus tstatus; sl@0: sl@0: test.Printf(_L("Loading logical device \n")); sl@0: r=User::LoadLogicalDevice(KLddFileName); sl@0: test(r == KErrNone); sl@0: sl@0: test.Printf(_L("Opening of logical device\n")); sl@0: r = ldd.Open(); sl@0: test(r == KErrNone); sl@0: sl@0: //Send asynchronouse request for power status and time stamp during powerdown. sl@0: ldd.Test_power1down(statuspowerdown1, time_power1down); sl@0: ldd.Test_power2down(statuspowerdown2, time_power2down); sl@0: ldd.Test_power1up(statuspowerup1, time_power1up); sl@0: ldd.Test_power2up(statuspowerup2, time_power2up); sl@0: sl@0: //Set the sleep time sl@0: r = ldd.Test_setSleepTime(timeInterval); sl@0: test(r == KErrNone); sl@0: sl@0: sl@0: r = timer.CreateLocal(); sl@0: test (r == KErrNone); sl@0: sl@0: TTime wakeup; sl@0: wakeup.HomeTime(); sl@0: wakeup += TTimeIntervalMicroSeconds(5000000); sl@0: timer.At(tstatus, wakeup); sl@0: sl@0: test.Printf(_L("Enable wakeup power events to standby\n")); sl@0: r = Power::EnableWakeupEvents(EPwStandby); sl@0: test (r == KErrNone); sl@0: sl@0: test.Printf(_L("Powerdown\n")); sl@0: r = Power::PowerDown(); sl@0: test (r == KErrNone); sl@0: sl@0: test.Printf(_L("Waiting for power down request completion of handler1\n")); sl@0: User::WaitForRequest(statuspowerdown1); sl@0: test(statuspowerdown1.Int() == KErrNone); sl@0: sl@0: test.Printf(_L("Waiting for power up request completion of handler1\n")); sl@0: User::WaitForRequest(statuspowerdown2); sl@0: test(statuspowerdown2.Int() == KErrNone); sl@0: sl@0: test.Printf(_L("Waiting for power down request completion of handler2\n")); sl@0: User::WaitForRequest(statuspowerup1); sl@0: test(statuspowerup1.Int() == KErrNone); sl@0: sl@0: test.Printf(_L("Waiting for power up request completion of handler2\n")); sl@0: User::WaitForRequest(statuspowerup2); sl@0: test(statuspowerup2.Int() == KErrNone); sl@0: sl@0: test.Printf(_L("Waiting for time request completion\n"));; sl@0: User::WaitForRequest(tstatus); sl@0: test(tstatus.Int() == KErrNone); sl@0: sl@0: timer.Close(); sl@0: sl@0: test(time_power2down >= time_power1down + timeInterval); sl@0: test(time_power1up >= time_power2up + timeInterval); sl@0: test.Printf(_L("Verified power up and power down sequence -- OK \n")); sl@0: sl@0: test.Printf(_L("Closing the channel\n")); sl@0: ldd.Close(); sl@0: sl@0: test.Printf(_L("Freeing logical device\n")); sl@0: r = User::FreeLogicalDevice(KLddFileName);; sl@0: test(r==KErrNone); sl@0: User::After(100000); sl@0: sl@0: test.End(); sl@0: test.Close(); sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: // sl@0: // Test LDD power sequence sl@0: // sl@0: { sl@0: test.Start(_L("Test power up and power down sequence")); sl@0: DoTests(); sl@0: return(KErrNone); sl@0: }