sysstatemgmt/systemstatereferenceplugins/test/tintcustcmd/src/tcustcmd_step_deactivateemergencycall.cpp
changeset 0 4e1aa6a622a0
child 52 d6b9e89d80a3
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2008-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 "tcustcmd_step_deactivateemergencycall.h"
       
    17 
       
    18 
       
    19 CCustomCmdTestDeActivateEmergencyCall::~CCustomCmdTestDeActivateEmergencyCall()
       
    20 	{
       
    21 	delete iAsyncStopScheduler;
       
    22 	delete iActiveSchedulerWait;
       
    23 	delete iActiveScheduler;
       
    24 	}
       
    25 
       
    26 CCustomCmdTestDeActivateEmergencyCall::CCustomCmdTestDeActivateEmergencyCall()
       
    27 	{
       
    28 	SetTestStepName(KTCCustomCmdTestDeActivateEmergencyCall);
       
    29 	}
       
    30 
       
    31 TVerdict CCustomCmdTestDeActivateEmergencyCall::doTestStepPreambleL()
       
    32 	{
       
    33 	iActiveScheduler = new(ELeave) CActiveScheduler;
       
    34 	CActiveScheduler::Install (iActiveScheduler);
       
    35 
       
    36 	iActiveSchedulerWait = new(ELeave) CActiveSchedulerWait;
       
    37 
       
    38 	iAsyncStopScheduler = new(ELeave) CAsyncCallBack(CActive::EPriorityIdle);
       
    39 	
       
    40 	return TestStepResult();
       
    41 	}
       
    42 		
       
    43 TVerdict CCustomCmdTestDeActivateEmergencyCall::doTestStepL()
       
    44 	{
       
    45 	INFO_PRINTF1(_L("doTestStepL"));
       
    46 	TInt err = 0;
       
    47 	__UHEAP_MARK;
       
    48 	TRAP(err,TestHandleDeActivateEmergencyCallL());
       
    49 	TEST(KErrNone == err);
       
    50 	TRAP(err,TestHandleDeActivateEmergencyCallCancelL());
       
    51 	TEST(KErrNone == err);
       
    52 	return TestStepResult();
       
    53 	}
       
    54 
       
    55 /**
       
    56 Old Test CaseID 		APPFWK-CUSTCMD-0023
       
    57 New Test CaseID 		DEVSRVS-SSREFPLUGINS-CUSTCMD-0023
       
    58  */
       
    59 
       
    60 void CCustomCmdTestDeActivateEmergencyCall::TestHandleDeActivateEmergencyCallL()
       
    61 	{
       
    62 	INFO_PRINTF1(_L("TestHandleDeActivateEmergencyCallL"));
       
    63 	RSsmStateManager client;
       
    64 	const TInt connect = client.Connect();
       
    65 	TEST(KErrNone == connect);
       
    66 
       
    67 	// Create swps
       
    68 	INFO_PRINTF1(_L("Creating swp..."));
       
    69 	TSsmSwp swp(KTestSwp, 22);
       
    70 	RProperty property;
       
    71 	TInt ret = property.Define(KCustomcmdServerSID, swp.Key(), RProperty::EInt);
       
    72 	TEST(KErrNone == ret || KErrAlreadyExists == ret);
       
    73 
       
    74 	TEST(KErrNone == property.Set(KCustomcmdServerSID, swp.Key(), swp.Value()));
       
    75 	
       
    76 	//Ensure the environment is clean
       
    77 	TInt value = 0;
       
    78 	TEST(KErrNone == property.Get(KCustomcmdServerSID, swp.Key(), value));
       
    79 	TESTE(22 == value, value);
       
    80 
       
    81 	// Register mapping between keys and swp policy DLL (done once per ssmserver)
       
    82 	INFO_PRINTF1(_L("Registering swp..."));
       
    83 	ret = client.RegisterSwpMapping(KTestSwp, KTestSwpPolicyCustomCmd);
       
    84 	TEST(KErrNone == ret || KErrAlreadyExists == ret);
       
    85 
       
    86 	//Let client request swp changes
       
    87 	INFO_PRINTF1(_L("Request several swp changes"));
       
    88 	swp.Set(KTestSwp, -99);
       
    89 	TRequestStatus status;
       
    90 	client.RequestSwpChange(swp, status);				
       
    91 	TEST(status == KRequestPending);
       
    92 	User::WaitForRequest(status);
       
    93 	User::After(500000); // Wait for 0.5sec to allow transitions to fully complete
       
    94 	TEST(status.Int() == KErrNone);	
       
    95 	// clean-up
       
    96 	TEST(KErrNone == property.Delete(KCustomcmdServerSID, swp.Key()));
       
    97 	property.Close();
       
    98 	client.Close();
       
    99 	INFO_PRINTF3(_L("TestHandleDeActivateEmergencyCallL completed with %d, expected %d"),status.Int(),KErrNone);	
       
   100 	}
       
   101 
       
   102 /**
       
   103 Old Test CaseID 		APPFWK-CUSTCMD-0024
       
   104 New Test CaseID 		DEVSRVS-SSREFPLUGINS-CUSTCMD-0023
       
   105  */
       
   106 
       
   107 void CCustomCmdTestDeActivateEmergencyCall::TestHandleDeActivateEmergencyCallCancelL()
       
   108 	{
       
   109 	INFO_PRINTF1(_L("TestHandleDeActivateEmergencyCallCancelL"));
       
   110 	RSsmStateManager client;
       
   111 	const TInt connect = client.Connect();
       
   112 	TEST(KErrNone == connect);
       
   113 
       
   114 	// Create swps
       
   115 	INFO_PRINTF1(_L("Creating swp..."));
       
   116 	TSsmSwp swp(KTestSwp, 22);
       
   117 	RProperty property;
       
   118 	TInt ret = property.Define(KCustomcmdServerSID, swp.Key(), RProperty::EInt);
       
   119 	TEST(KErrNone == ret || KErrAlreadyExists == ret);
       
   120 	TEST(KErrNone == property.Set(KCustomcmdServerSID, swp.Key(), swp.Value()));
       
   121 	
       
   122 	//Ensure the environment is clean
       
   123 	TInt value = 0;
       
   124 	TEST(KErrNone == property.Get(KCustomcmdServerSID, swp.Key(), value));
       
   125 	TESTE(22 == value, value);
       
   126 
       
   127 	//Let client request swp changes
       
   128 	INFO_PRINTF1(_L("Request several swp changes "));
       
   129 	swp.Set(KTestSwp, -99);
       
   130 	TRequestStatus status;
       
   131 	client.RequestSwpChange(swp, status);		
       
   132 	TEST(status == KRequestPending);
       
   133 	client.RequestSwpChangeCancel();
       
   134 	User::WaitForRequest(status);
       
   135 	TEST(status.Int() == KErrCancel);
       
   136 	INFO_PRINTF3(_L("TestHandleDeActivateEmergencyCallCancelL completed with %d, expected %d"),status.Int(),KErrCancel);	
       
   137 	// clean-up
       
   138 	TEST(KErrNone == property.Delete(KCustomcmdServerSID, swp.Key()));
       
   139 	property.Close();
       
   140 	client.Close();
       
   141 	
       
   142 	}
       
   143 		
       
   144 
       
   145 
       
   146 TVerdict CCustomCmdTestDeActivateEmergencyCall::doTestStepPostambleL()
       
   147 	{
       
   148 	__UHEAP_MARKEND;
       
   149 	return TestStepResult();
       
   150 	}
       
   151