telephonyserverplugins/simtsy/test/Te_SimSS/Te_SimSSTestStepBase.cpp
changeset 0 3553901f7fa8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/telephonyserverplugins/simtsy/test/Te_SimSS/Te_SimSSTestStepBase.cpp	Tue Feb 02 01:41:59 2010 +0200
@@ -0,0 +1,120 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "Te_SimSSTestStepBase.h"
+
+TVerdict CSimSSTestStepBase::doTestStepPreambleL()
+	{
+	__UHEAP_MARK;
+
+	TInt ret = iTelServer.Connect();
+	if (ret!=KErrNone)
+		{
+		INFO_PRINTF1(_L("Failed to connect to telephony server"));
+		User::Leave(ret);
+		}
+   	ret=iTelServer.LoadPhoneModule(KSimtsyName);
+	if (ret!=KErrNone)
+		{
+		INFO_PRINTF1(_L("Failed to load phone module"));
+		iTelServer.Close();
+		User::Leave(ret);
+		}
+
+	ret=iPhone.Open(iTelServer,KPhoneName) ;
+	if (ret!=KErrNone)
+		{
+		INFO_PRINTF1(_L("Failed to open phone module"));
+		iTelServer.UnloadPhoneModule(KSimtsyName);
+		iTelServer.Close();
+		User::Leave(ret);
+		}
+	ret=iPhone.Initialise();
+	if (ret!=KErrNone)
+		{
+		INFO_PRINTF1(_L("Failed to initialise the phone"));
+		iPhone.Close();
+		iTelServer.UnloadPhoneModule(KSimtsyName);
+		iTelServer.Close();
+		User::Leave(ret);
+		}
+
+	RPhone::TCaps phoneCaps;
+	ret = iPhone.GetCaps(phoneCaps) ;
+	if ((KErrNone != ret) || !(phoneCaps.iFlags & RPhone::KCapsVoice))
+		{
+		INFO_PRINTF2(_L("This phone does not support Voice Calls (caps=0x%x)"), phoneCaps.iFlags);
+		iPhone.Close();
+		iTelServer.UnloadPhoneModule(KSimtsyName);
+		iTelServer.Close();
+		User::Leave(ret);
+		}
+
+	return TestStepResult();
+	}
+
+TVerdict CSimSSTestStepBase::doTestStepPostambleL()
+	{
+	iPhone.Close();
+	iTelServer.UnloadPhoneModule(KSimtsyName);
+	iTelServer.Close();
+
+	__UHEAP_MARKEND;
+	return TestStepResult();
+	}
+
+void CSimSSTestStepBase::CleanUp(TAny *aPtr)
+/**
+*  Calls iLine.Close() & iCall.Close in  leave case.
+* @param this poiter pass cleanup stack when calls the function
+*/
+	{
+	 CSimSSTestStepBase* ptr = ((CSimSSTestStepBase*)aPtr) ;
+	 ptr->iCall.Close() ;
+	 ptr->iLine.Close() ;
+	}
+	
+void CSimSSTestStepBase::SetTestNumberL(TInt aTestNumber)
+  	{
+  	iPhone.Close();
+
+	INFO_PRINTF2(_L("Changing the Test Number to %d"),aTestNumber);		
+	
+	TInt ret = RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, aTestNumber);
+	if (ret != KErrNone)
+		{
+		INFO_PRINTF1(_L("Failed setting test number"));
+		User::Leave(ret);
+		}
+
+	ret=iPhone.Open(iTelServer,KPhoneName) ;
+	if (ret!=KErrNone)
+		{
+		INFO_PRINTF1(_L("Failed to open phone module"));
+		iTelServer.UnloadPhoneModule(KSimtsyName);
+		iTelServer.Close();
+		User::Leave(ret);
+		}
+ 	ret=iPhone.Initialise();
+	if (ret!=KErrNone)
+		{
+		INFO_PRINTF1(_L("Failed to initialise the phone"));
+		iPhone.Close();
+		iTelServer.UnloadPhoneModule(KSimtsyName);
+		iTelServer.Close();
+		User::Leave(ret);
+		}
+  	}
+