os/kernelhwsrv/kerneltest/e32test/power/t_lddpowerseqtest.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_lddpowerseqtest.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,123 @@
     1.4 +// Copyright (c) 2006-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_lddpowerseqtest.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include <e32test.h>
    1.22 +#include <e32hal.h>
    1.23 +#include "d_lddpowerseqtest.h"
    1.24 +#include <e32power.h>
    1.25 +
    1.26 +_LIT(KLddFileName, "D_LDDPOWERSEQTEST.LDD");
    1.27 +
    1.28 +RLddTest1 ldd;
    1.29 +GLDEF_D RTest test(_L("T_LDDPOWERSEQTEST"));
    1.30 +
    1.31 +void DoTests()
    1.32 +	{
    1.33 +	TInt r;
    1.34 +	TInt timeInterval = 3;
    1.35 +	//time stamp for power up and powerdown of handlers
    1.36 +	TUint time_power1up = 0, time_power1down = 0;
    1.37 +	TUint time_power2up = 10, time_power2down = 0;
    1.38 +	TRequestStatus statuspowerdown1;
    1.39 +	TRequestStatus statuspowerdown2;
    1.40 +	TRequestStatus statuspowerup1;
    1.41 +	TRequestStatus statuspowerup2;
    1.42 +	RTimer timer;
    1.43 +	TRequestStatus tstatus;
    1.44 +
    1.45 +	test.Printf(_L("Loading logical device \n"));
    1.46 +	r=User::LoadLogicalDevice(KLddFileName);
    1.47 +	test(r == KErrNone);
    1.48 +
    1.49 +	test.Printf(_L("Opening of logical device\n"));
    1.50 +	r = ldd.Open();
    1.51 +	test(r == KErrNone);
    1.52 +
    1.53 +	//Send asynchronouse request for power status and time stamp during powerdown.
    1.54 +	ldd.Test_power1down(statuspowerdown1, time_power1down);
    1.55 +	ldd.Test_power2down(statuspowerdown2, time_power2down);
    1.56 +	ldd.Test_power1up(statuspowerup1, time_power1up);
    1.57 +	ldd.Test_power2up(statuspowerup2, time_power2up);
    1.58 +	
    1.59 +	//Set the sleep time
    1.60 +	r = ldd.Test_setSleepTime(timeInterval);
    1.61 +	test(r == KErrNone);
    1.62 +        
    1.63 +
    1.64 +	r = timer.CreateLocal();
    1.65 +	test (r == KErrNone);
    1.66 +
    1.67 + 	TTime wakeup;
    1.68 +	wakeup.HomeTime();
    1.69 +	wakeup += TTimeIntervalMicroSeconds(5000000);
    1.70 +	timer.At(tstatus, wakeup);
    1.71 +
    1.72 +	test.Printf(_L("Enable wakeup power events to standby\n"));
    1.73 +	r = Power::EnableWakeupEvents(EPwStandby);
    1.74 +	test (r == KErrNone);
    1.75 +
    1.76 +	test.Printf(_L("Powerdown\n"));
    1.77 +	r = Power::PowerDown();
    1.78 +	test (r == KErrNone);
    1.79 +
    1.80 +	test.Printf(_L("Waiting for power down request completion of handler1\n"));
    1.81 +	User::WaitForRequest(statuspowerdown1);
    1.82 +	test(statuspowerdown1.Int() == KErrNone);
    1.83 +
    1.84 +	test.Printf(_L("Waiting for power up request completion of handler1\n"));
    1.85 +	User::WaitForRequest(statuspowerdown2);
    1.86 +	test(statuspowerdown2.Int() == KErrNone);
    1.87 +
    1.88 +	test.Printf(_L("Waiting for power down request completion of handler2\n"));
    1.89 +	User::WaitForRequest(statuspowerup1);
    1.90 +	test(statuspowerup1.Int() == KErrNone);
    1.91 +
    1.92 +	test.Printf(_L("Waiting for power up request completion of handler2\n"));
    1.93 +	User::WaitForRequest(statuspowerup2);
    1.94 +	test(statuspowerup2.Int() == KErrNone);
    1.95 +
    1.96 +	test.Printf(_L("Waiting for time request completion\n"));;
    1.97 +	User::WaitForRequest(tstatus);
    1.98 +	test(tstatus.Int() == KErrNone);
    1.99 +
   1.100 +	timer.Close();
   1.101 +
   1.102 +	test(time_power2down >= time_power1down + timeInterval);
   1.103 +	test(time_power1up >= time_power2up + timeInterval);
   1.104 +	test.Printf(_L("Verified power up and power down sequence -- OK \n"));
   1.105 +
   1.106 +	test.Printf(_L("Closing the channel\n"));
   1.107 +	ldd.Close();
   1.108 +
   1.109 +	test.Printf(_L("Freeing logical device\n"));
   1.110 +	r = User::FreeLogicalDevice(KLddFileName);;
   1.111 +	test(r==KErrNone);
   1.112 +	User::After(100000);
   1.113 +
   1.114 +	test.End();
   1.115 +	test.Close();
   1.116 +	}
   1.117 +
   1.118 +GLDEF_C TInt E32Main()
   1.119 +//
   1.120 +// Test LDD power sequence
   1.121 +//
   1.122 +    {
   1.123 +	test.Start(_L("Test power up and power down sequence"));
   1.124 +	DoTests();
   1.125 + 	return(KErrNone);
   1.126 +    }