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.
sl@0
     1
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32test\power\t_lddpowerseqtest.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <e32test.h>
sl@0
    19
#include <e32hal.h>
sl@0
    20
#include "d_lddpowerseqtest.h"
sl@0
    21
#include <e32power.h>
sl@0
    22
sl@0
    23
_LIT(KLddFileName, "D_LDDPOWERSEQTEST.LDD");
sl@0
    24
sl@0
    25
RLddTest1 ldd;
sl@0
    26
GLDEF_D RTest test(_L("T_LDDPOWERSEQTEST"));
sl@0
    27
sl@0
    28
void DoTests()
sl@0
    29
	{
sl@0
    30
	TInt r;
sl@0
    31
	TInt timeInterval = 3;
sl@0
    32
	//time stamp for power up and powerdown of handlers
sl@0
    33
	TUint time_power1up = 0, time_power1down = 0;
sl@0
    34
	TUint time_power2up = 10, time_power2down = 0;
sl@0
    35
	TRequestStatus statuspowerdown1;
sl@0
    36
	TRequestStatus statuspowerdown2;
sl@0
    37
	TRequestStatus statuspowerup1;
sl@0
    38
	TRequestStatus statuspowerup2;
sl@0
    39
	RTimer timer;
sl@0
    40
	TRequestStatus tstatus;
sl@0
    41
sl@0
    42
	test.Printf(_L("Loading logical device \n"));
sl@0
    43
	r=User::LoadLogicalDevice(KLddFileName);
sl@0
    44
	test(r == KErrNone);
sl@0
    45
sl@0
    46
	test.Printf(_L("Opening of logical device\n"));
sl@0
    47
	r = ldd.Open();
sl@0
    48
	test(r == KErrNone);
sl@0
    49
sl@0
    50
	//Send asynchronouse request for power status and time stamp during powerdown.
sl@0
    51
	ldd.Test_power1down(statuspowerdown1, time_power1down);
sl@0
    52
	ldd.Test_power2down(statuspowerdown2, time_power2down);
sl@0
    53
	ldd.Test_power1up(statuspowerup1, time_power1up);
sl@0
    54
	ldd.Test_power2up(statuspowerup2, time_power2up);
sl@0
    55
	
sl@0
    56
	//Set the sleep time
sl@0
    57
	r = ldd.Test_setSleepTime(timeInterval);
sl@0
    58
	test(r == KErrNone);
sl@0
    59
        
sl@0
    60
sl@0
    61
	r = timer.CreateLocal();
sl@0
    62
	test (r == KErrNone);
sl@0
    63
sl@0
    64
 	TTime wakeup;
sl@0
    65
	wakeup.HomeTime();
sl@0
    66
	wakeup += TTimeIntervalMicroSeconds(5000000);
sl@0
    67
	timer.At(tstatus, wakeup);
sl@0
    68
sl@0
    69
	test.Printf(_L("Enable wakeup power events to standby\n"));
sl@0
    70
	r = Power::EnableWakeupEvents(EPwStandby);
sl@0
    71
	test (r == KErrNone);
sl@0
    72
sl@0
    73
	test.Printf(_L("Powerdown\n"));
sl@0
    74
	r = Power::PowerDown();
sl@0
    75
	test (r == KErrNone);
sl@0
    76
sl@0
    77
	test.Printf(_L("Waiting for power down request completion of handler1\n"));
sl@0
    78
	User::WaitForRequest(statuspowerdown1);
sl@0
    79
	test(statuspowerdown1.Int() == KErrNone);
sl@0
    80
sl@0
    81
	test.Printf(_L("Waiting for power up request completion of handler1\n"));
sl@0
    82
	User::WaitForRequest(statuspowerdown2);
sl@0
    83
	test(statuspowerdown2.Int() == KErrNone);
sl@0
    84
sl@0
    85
	test.Printf(_L("Waiting for power down request completion of handler2\n"));
sl@0
    86
	User::WaitForRequest(statuspowerup1);
sl@0
    87
	test(statuspowerup1.Int() == KErrNone);
sl@0
    88
sl@0
    89
	test.Printf(_L("Waiting for power up request completion of handler2\n"));
sl@0
    90
	User::WaitForRequest(statuspowerup2);
sl@0
    91
	test(statuspowerup2.Int() == KErrNone);
sl@0
    92
sl@0
    93
	test.Printf(_L("Waiting for time request completion\n"));;
sl@0
    94
	User::WaitForRequest(tstatus);
sl@0
    95
	test(tstatus.Int() == KErrNone);
sl@0
    96
sl@0
    97
	timer.Close();
sl@0
    98
sl@0
    99
	test(time_power2down >= time_power1down + timeInterval);
sl@0
   100
	test(time_power1up >= time_power2up + timeInterval);
sl@0
   101
	test.Printf(_L("Verified power up and power down sequence -- OK \n"));
sl@0
   102
sl@0
   103
	test.Printf(_L("Closing the channel\n"));
sl@0
   104
	ldd.Close();
sl@0
   105
sl@0
   106
	test.Printf(_L("Freeing logical device\n"));
sl@0
   107
	r = User::FreeLogicalDevice(KLddFileName);;
sl@0
   108
	test(r==KErrNone);
sl@0
   109
	User::After(100000);
sl@0
   110
sl@0
   111
	test.End();
sl@0
   112
	test.Close();
sl@0
   113
	}
sl@0
   114
sl@0
   115
GLDEF_C TInt E32Main()
sl@0
   116
//
sl@0
   117
// Test LDD power sequence
sl@0
   118
//
sl@0
   119
    {
sl@0
   120
	test.Start(_L("Test power up and power down sequence"));
sl@0
   121
	DoTests();
sl@0
   122
 	return(KErrNone);
sl@0
   123
    }