os/kernelhwsrv/kerneltest/e32test/power/t_lddpowerseqtest.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2006-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_lddpowerseqtest.cpp
    15 // 
    16 //
    17 
    18 #include <e32test.h>
    19 #include <e32hal.h>
    20 #include "d_lddpowerseqtest.h"
    21 #include <e32power.h>
    22 
    23 _LIT(KLddFileName, "D_LDDPOWERSEQTEST.LDD");
    24 
    25 RLddTest1 ldd;
    26 GLDEF_D RTest test(_L("T_LDDPOWERSEQTEST"));
    27 
    28 void DoTests()
    29 	{
    30 	TInt r;
    31 	TInt timeInterval = 3;
    32 	//time stamp for power up and powerdown of handlers
    33 	TUint time_power1up = 0, time_power1down = 0;
    34 	TUint time_power2up = 10, time_power2down = 0;
    35 	TRequestStatus statuspowerdown1;
    36 	TRequestStatus statuspowerdown2;
    37 	TRequestStatus statuspowerup1;
    38 	TRequestStatus statuspowerup2;
    39 	RTimer timer;
    40 	TRequestStatus tstatus;
    41 
    42 	test.Printf(_L("Loading logical device \n"));
    43 	r=User::LoadLogicalDevice(KLddFileName);
    44 	test(r == KErrNone);
    45 
    46 	test.Printf(_L("Opening of logical device\n"));
    47 	r = ldd.Open();
    48 	test(r == KErrNone);
    49 
    50 	//Send asynchronouse request for power status and time stamp during powerdown.
    51 	ldd.Test_power1down(statuspowerdown1, time_power1down);
    52 	ldd.Test_power2down(statuspowerdown2, time_power2down);
    53 	ldd.Test_power1up(statuspowerup1, time_power1up);
    54 	ldd.Test_power2up(statuspowerup2, time_power2up);
    55 	
    56 	//Set the sleep time
    57 	r = ldd.Test_setSleepTime(timeInterval);
    58 	test(r == KErrNone);
    59         
    60 
    61 	r = timer.CreateLocal();
    62 	test (r == KErrNone);
    63 
    64  	TTime wakeup;
    65 	wakeup.HomeTime();
    66 	wakeup += TTimeIntervalMicroSeconds(5000000);
    67 	timer.At(tstatus, wakeup);
    68 
    69 	test.Printf(_L("Enable wakeup power events to standby\n"));
    70 	r = Power::EnableWakeupEvents(EPwStandby);
    71 	test (r == KErrNone);
    72 
    73 	test.Printf(_L("Powerdown\n"));
    74 	r = Power::PowerDown();
    75 	test (r == KErrNone);
    76 
    77 	test.Printf(_L("Waiting for power down request completion of handler1\n"));
    78 	User::WaitForRequest(statuspowerdown1);
    79 	test(statuspowerdown1.Int() == KErrNone);
    80 
    81 	test.Printf(_L("Waiting for power up request completion of handler1\n"));
    82 	User::WaitForRequest(statuspowerdown2);
    83 	test(statuspowerdown2.Int() == KErrNone);
    84 
    85 	test.Printf(_L("Waiting for power down request completion of handler2\n"));
    86 	User::WaitForRequest(statuspowerup1);
    87 	test(statuspowerup1.Int() == KErrNone);
    88 
    89 	test.Printf(_L("Waiting for power up request completion of handler2\n"));
    90 	User::WaitForRequest(statuspowerup2);
    91 	test(statuspowerup2.Int() == KErrNone);
    92 
    93 	test.Printf(_L("Waiting for time request completion\n"));;
    94 	User::WaitForRequest(tstatus);
    95 	test(tstatus.Int() == KErrNone);
    96 
    97 	timer.Close();
    98 
    99 	test(time_power2down >= time_power1down + timeInterval);
   100 	test(time_power1up >= time_power2up + timeInterval);
   101 	test.Printf(_L("Verified power up and power down sequence -- OK \n"));
   102 
   103 	test.Printf(_L("Closing the channel\n"));
   104 	ldd.Close();
   105 
   106 	test.Printf(_L("Freeing logical device\n"));
   107 	r = User::FreeLogicalDevice(KLddFileName);;
   108 	test(r==KErrNone);
   109 	User::After(100000);
   110 
   111 	test.End();
   112 	test.Close();
   113 	}
   114 
   115 GLDEF_C TInt E32Main()
   116 //
   117 // Test LDD power sequence
   118 //
   119     {
   120 	test.Start(_L("Test power up and power down sequence"));
   121 	DoTests();
   122  	return(KErrNone);
   123     }