telephonyserverplugins/simtsy/test/Te_Sim/Te_SimBatteryChargerTest.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2005-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 "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 //
       
    15 
       
    16 #include "Te_SimBatteryChargerTest.h"
       
    17 
       
    18 CSimBatteryChargerTest::CSimBatteryChargerTest() 
       
    19 	{ 
       
    20 	SetTestStepName(_L("BatteryChargerTest"));
       
    21 	}
       
    22 
       
    23 TVerdict CSimBatteryChargerTest::doTestStepL()
       
    24 	{
       
    25 	INFO_PRINTF1(_L("BatteryCharger Functionality"));
       
    26 
       
    27  	CreateConfigFileL(_L("c:\\config3.txt"));
       
    28  	SetTestNumberL(0);
       
    29 
       
    30 	TInt ret = iPhone.Open(iTelServer,KPhoneName); 
       
    31 	INFO_PRINTF2(_L("Result: %d"),ret); 
       
    32 	TESTL(ret == KErrNone); 
       
    33 	INFO_PRINTF1(_L("Opened phone object"));
       
    34 	TESTL(iPhone.Initialise()==KErrNone);
       
    35 	
       
    36 	TUint32 chargerCaps;
       
    37 	TRequestStatus stat;
       
    38 	RMobilePhone::TMobilePhoneBatteryInfoV1 batteryInfoV1;
       
    39 
       
    40 	INFO_PRINTF1(_L("Getting the battery charger Caps"));
       
    41 	iPhone.GetBatteryCaps(chargerCaps);
       
    42 	TESTL(chargerCaps==TInt(KBatteryChargerCaps));
       
    43 
       
    44 	INFO_PRINTF1(_L("Getting the battery charger info..."));
       
    45 	iPhone.GetBatteryInfo(stat, batteryInfoV1);
       
    46 	User::WaitForRequest(stat);
       
    47 	TESTL(batteryInfoV1.iStatus==0);
       
    48 	TESTL(batteryInfoV1.iChargeLevel ==0);
       
    49 	
       
    50 	INFO_PRINTF1(_L("Testing battery charger notification"));
       
    51 	iPhone.NotifyBatteryInfoChange(stat, batteryInfoV1);
       
    52 	User::WaitForRequest(stat);
       
    53 	TESTL(batteryInfoV1.iStatus==1);
       
    54 	TESTL(batteryInfoV1.iChargeLevel ==3);
       
    55 
       
    56 	INFO_PRINTF1(_L("Testing again battery charger notification"));
       
    57 	iPhone.NotifyBatteryInfoChange(stat, batteryInfoV1);
       
    58 	User::WaitForRequest(stat);
       
    59 	TESTL(batteryInfoV1.iStatus==2);
       
    60 	TESTL(batteryInfoV1.iChargeLevel ==5);
       
    61 
       
    62 	INFO_PRINTF1(_L("Testing again battery charger notification"));
       
    63 	iPhone.NotifyBatteryInfoChange(stat, batteryInfoV1);
       
    64 	User::WaitForRequest(stat);
       
    65 	TESTL(batteryInfoV1.iStatus==1);
       
    66 	TESTL(batteryInfoV1.iChargeLevel ==3);
       
    67 
       
    68 	INFO_PRINTF1(_L("Testing a final Get Current battery charger info "));
       
    69 	iPhone.GetBatteryInfo(stat, batteryInfoV1);
       
    70 	User::WaitForRequest(stat);
       
    71 	TESTL(batteryInfoV1.iStatus==1);
       
    72 	TESTL(batteryInfoV1.iChargeLevel ==3);
       
    73 
       
    74 	iPhone.Close();
       
    75 	ASSERT(RThread().RequestCount()==0);
       
    76 
       
    77 	return TestStepResult();
       
    78 	}
       
    79