telephonyserverplugins/common_tsy/test/component/src/cctsyfaxfu.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2007-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 // The TEFUnit test suite for Fax in the Common TSY.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file 
       
    20 */
       
    21 
       
    22 #include "cctsyfaxfu.h"
       
    23 #include <etel.h>
       
    24 #include <etelmm.h>
       
    25 #include <et_clsvr.h>
       
    26 #include <ctsy/mmtsy_names.h>
       
    27 #include <ctsy/serviceapi/mmtsy_ipcdefs.h>
       
    28 #include "tmockltsydata.h"
       
    29 #include <ctsy/serviceapi/gsmerror.h>
       
    30 
       
    31 CTestSuite* CCTsyFaxFU::CreateSuiteL(const TDesC& aName)
       
    32 	{
       
    33 	SUB_SUITE;
       
    34 
       
    35 	ADD_TEST_STEP_ISO_CPP(CCTsyFaxFU, TestWaitForEndOfPage0001L);
       
    36 	ADD_TEST_STEP_ISO_CPP(CCTsyFaxFU, TestTerminateFaxSession0001L);
       
    37 	ADD_TEST_STEP_ISO_CPP(CCTsyFaxFU, TestGetFaxSettings0001L);
       
    38 	ADD_TEST_STEP_ISO_CPP(CCTsyFaxFU, TestSetFaxSettings0001L);
       
    39 	ADD_TEST_STEP_ISO_CPP(CCTsyFaxFU, TestAdoptFaxSharedHeaderFile0001L);
       
    40 	ADD_TEST_STEP_ISO_CPP(CCTsyFaxFU, TestRead0001L);
       
    41 	ADD_TEST_STEP_ISO_CPP(CCTsyFaxFU, TestWrite0001L);
       
    42 
       
    43 	END_SUITE;
       
    44 	}
       
    45 	
       
    46 CCTsyFaxFU::~CCTsyFaxFU()
       
    47 	{
       
    48 	RFs fs;
       
    49 	if(fs.Connect() == KErrNone)
       
    50 		{
       
    51 		_LIT(KFileName, "C:\\file.txt");
       
    52 		fs.Delete(KFileName);
       
    53 		fs.Close();
       
    54 		}
       
    55 	}
       
    56 	
       
    57 void CCTsyFaxFU::OpenFaxL()
       
    58 	{
       
    59 	RFax  fax;
       
    60 	RLine line;
       
    61 	RCall call;
       
    62 	
       
    63 	OpenCallFaxLC(line, call);
       
    64 	CleanupClosePushL(call);
       
    65 	
       
    66 	TInt res = fax.Open(call);
       
    67 	ASSERT_EQUALS(KErrNone, res);
       
    68 	CleanupClosePushL(fax);
       
    69 	
       
    70 	CleanupStack::PopAndDestroy(1); // fax
       
    71 	
       
    72 	RMobilePhone::TMobileService mobileService = RMobilePhone::EVoiceService;
       
    73 	CloseIncomingCallL(call, 1, mobileService);
       
    74 
       
    75 	CleanupStack::PopAndDestroy(2); // call, ;ine
       
    76 	}
       
    77 
       
    78 void CCTsyFaxFU::OpenCallVoiceLC(RLine& aLine, RCall& aCall)
       
    79 	{
       
    80 	TInt errorCode = KErrNone;
       
    81     TBuf<128> name;
       
    82 	
       
    83 	RMobilePhone::TMobileService mobileService = RMobilePhone::EVoiceService;
       
    84 	RMobileCall::TMobileCallStatus callStatus = RMobileCall::EStatusConnected;
       
    85 	
       
    86 	OpenLineVoiceLC(aLine);
       
    87 	CreateIncomingCallL(aLine, 1, KMmTsyDataLineName, name, mobileService, callStatus);
       
    88    	errorCode = aCall.OpenExistingCall(aLine, name);
       
    89    	ASSERT_EQUALS(KErrNone, errorCode);
       
    90 	}
       
    91 
       
    92 void CCTsyFaxFU::OpenLineVoiceLC(RLine& aLine)
       
    93 	{
       
    94 	TInt errorCode = aLine.Open(iPhone, KMmTsyVoice1LineName);
       
    95 	ASSERT_EQUALS(KErrNone, errorCode)
       
    96 	CleanupClosePushL(aLine);
       
    97 	}
       
    98 
       
    99 void CCTsyFaxFU::OpenCallFaxLC(RLine& aLine, RCall& aCall)
       
   100 	{
       
   101 	TInt errorCode = KErrNone;
       
   102     TBuf<128> name;
       
   103 	
       
   104 	RMobilePhone::TMobileService mobileService = RMobilePhone::EFaxService;
       
   105 	RMobileCall::TMobileCallStatus callStatus = RMobileCall::EStatusConnected;
       
   106 	
       
   107 	OpenLineFaxLC(aLine);
       
   108 	CreateIncomingCallL(aLine, 1, KMmTsyDataLineName, name, mobileService, callStatus);
       
   109    	errorCode = aCall.OpenExistingCall(aLine, name);
       
   110    	ASSERT_EQUALS(KErrNone, errorCode);
       
   111 	}
       
   112 
       
   113 void CCTsyFaxFU::OpenLineFaxLC(RLine& aLine)
       
   114 	{
       
   115 	TInt errorCode = aLine.Open(iPhone, KMmTsyFaxLineName);
       
   116 	ASSERT_EQUALS(KErrNone, errorCode)
       
   117 	CleanupClosePushL(aLine);
       
   118 	}
       
   119 
       
   120 void CCTsyFaxFU::OpenCallDataLC(RLine& aLine, RCall& aCall)
       
   121 	{
       
   122 	TInt errorCode = KErrNone;
       
   123     TBuf<128> name;
       
   124 	
       
   125 	RMobilePhone::TMobileService mobileService = RMobilePhone::ECircuitDataService;
       
   126 	RMobileCall::TMobileCallStatus callStatus = RMobileCall::EStatusConnected;
       
   127 	
       
   128 	OpenLineDataLC(aLine);
       
   129 	CreateIncomingCallL(aLine, 1, KMmTsyDataLineName, name, mobileService, callStatus);
       
   130    	errorCode = aCall.OpenExistingCall(aLine, name);
       
   131    	ASSERT_EQUALS(KErrNone, errorCode);
       
   132 	}
       
   133 
       
   134 void CCTsyFaxFU::OpenLineDataLC(RLine& aLine)
       
   135 	{
       
   136 	TInt errorCode = aLine.Open(iPhone, KMmTsyDataLineName);
       
   137 	ASSERT_EQUALS(KErrNone, errorCode)
       
   138 	CleanupClosePushL(aLine);
       
   139 	}
       
   140 
       
   141 //
       
   142 // Actual test cases
       
   143 //
       
   144 
       
   145 /**
       
   146 @SYMTestCaseID BA-CTSY-FAX-FWFEOP-0001
       
   147 @SYMComponent  telephony_ctsy
       
   148 @SYMTestCaseDesc Test support in CTSY for RFax::WaitForEndOfPage
       
   149 @SYMTestPriority High
       
   150 @SYMTestActions Invokes RFax::WaitForEndOfPage
       
   151 @SYMTestExpectedResults Pass
       
   152 @SYMTestType CT
       
   153 */
       
   154 void CCTsyFaxFU::TestWaitForEndOfPage0001L()
       
   155 	{
       
   156 	OpenEtelServerL(EUseExtendedError);
       
   157 	CleanupStack::PushL(TCleanupItem(Cleanup, this));
       
   158 	OpenPhoneL();
       
   159 	
       
   160 	RFax  fax;
       
   161 	RLine line;
       
   162 	RCall call;
       
   163 	
       
   164 	OpenCallFaxLC(line, call);
       
   165 	CleanupClosePushL(call);
       
   166 	
       
   167 	TInt res = fax.Open(call);
       
   168 	CleanupClosePushL(fax);
       
   169 	
       
   170 	// Test can not be completed until RFax::Open is implemented
       
   171 	ERR_PRINTF2(_L("<font color=Orange>$CTSYKnownFailure: defect id = %d</font>"), 250101);
       
   172 	ASSERT_EQUALS(KErrNotSupported, res)
       
   173 
       
   174 	RMobilePhone::TMobileService mobileService = RMobilePhone::EFaxService;
       
   175 	CloseIncomingCallL(call, 1, mobileService);
       
   176 
       
   177 	AssertMockLtsyStatusL();
       
   178 	CleanupStack::PopAndDestroy(4, this); // fax, call, line, this
       
   179 	}
       
   180 
       
   181 /**
       
   182 @SYMTestCaseID BA-CTSY-FAX-FTFS-0001
       
   183 @SYMComponent  telephony_ctsy
       
   184 @SYMTestCaseDesc Test support in CTSY for RFax::TerminateFaxSession
       
   185 @SYMTestPriority High
       
   186 @SYMTestActions Invokes RFax::TerminateFaxSession
       
   187 @SYMTestExpectedResults Pass
       
   188 @SYMTestType CT
       
   189 */
       
   190 void CCTsyFaxFU::TestTerminateFaxSession0001L()
       
   191 	{
       
   192 	OpenEtelServerL(EUseExtendedError);
       
   193 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   194 	OpenPhoneL();
       
   195 
       
   196 	RFax  fax;
       
   197 	RLine line;
       
   198 	RCall call;
       
   199 	
       
   200 	OpenCallFaxLC(line, call);
       
   201 	CleanupClosePushL(call);
       
   202 	
       
   203 	TInt res = fax.Open(call);
       
   204 	CleanupClosePushL(fax);
       
   205 	
       
   206 	// Test can not be completed until RFax::Open is implemented
       
   207 	ERR_PRINTF2(_L("<font color=Orange>$CTSYKnownFailure: defect id = %d</font>"), 250101);
       
   208 	ASSERT_EQUALS(KErrNotSupported, res)
       
   209 
       
   210 	RMobilePhone::TMobileService mobileService = RMobilePhone::EFaxService;
       
   211 	CloseIncomingCallL(call, 1, mobileService);
       
   212 
       
   213 	AssertMockLtsyStatusL();
       
   214 	CleanupStack::PopAndDestroy(4, this); // fax, call, line, this
       
   215 	}
       
   216 
       
   217 /**
       
   218 @SYMTestCaseID BA-CTSY-FAX-CGFS-0001
       
   219 @SYMComponent  telephony_ctsy
       
   220 @SYMTestCaseDesc Test support in CTSY for RCall::GetFaxSettings for voice calls
       
   221 @SYMTestPriority High
       
   222 @SYMTestActions Invokes RCall::GetFaxSettings for voice calls
       
   223 @SYMTestExpectedResults Pass
       
   224 @SYMTestType CT
       
   225 */
       
   226 void CCTsyFaxFU::TestGetFaxSettings0001L()
       
   227 	{
       
   228 	OpenEtelServerL(EUseExtendedError);
       
   229 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   230 	OpenPhoneL();
       
   231 
       
   232 	RLine line;
       
   233 	RCall call;
       
   234 	
       
   235 	OpenCallVoiceLC(line, call);
       
   236 	CleanupClosePushL(call);
       
   237 	
       
   238 	RCall::TFaxSessionSettings faxSettings;
       
   239 	
       
   240 	TInt res = call.GetFaxSettings(faxSettings);
       
   241 	ASSERT_EQUALS(KErrNotSupported, res) // GetFaxSettings is not supported.
       
   242 
       
   243 	RMobilePhone::TMobileService mobileService = RMobilePhone::EVoiceService;
       
   244 	CloseIncomingCallL(call, 1, mobileService);
       
   245 
       
   246 	AssertMockLtsyStatusL();
       
   247 	CleanupStack::PopAndDestroy(3, this); // this, call, line
       
   248 	}
       
   249 
       
   250 /**
       
   251 @SYMTestCaseID BA-CTSY-FAX-CSFS-0001
       
   252 @SYMComponent  telephony_ctsy
       
   253 @SYMTestCaseDesc Test support in CTSY for RCall::SetFaxSettings for voice calls
       
   254 @SYMTestPriority High
       
   255 @SYMTestActions Invokes RCall::SetFaxSettings for voice calls
       
   256 @SYMTestExpectedResults Pass
       
   257 @SYMTestType CT
       
   258 */
       
   259 void CCTsyFaxFU::TestSetFaxSettings0001L()
       
   260 	{
       
   261 	OpenEtelServerL(EUseExtendedError);
       
   262 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   263 	OpenPhoneL();
       
   264 
       
   265 	RLine line; 
       
   266 	RCall call;
       
   267 	
       
   268 	OpenCallVoiceLC(line, call);
       
   269 	CleanupClosePushL(call);
       
   270 	
       
   271 	_LIT(KFaxId, "FaxId");
       
   272 	RCall::TFaxSessionSettings faxSettings;
       
   273 	faxSettings.iFaxId.Copy(KFaxId);
       
   274 	
       
   275 	TInt res = call.SetFaxSettings(faxSettings);
       
   276 	ASSERT_EQUALS(KErrNotSupported, res) // SetFaxSettings is not supported.
       
   277 
       
   278 	RMobilePhone::TMobileService mobileService = RMobilePhone::EVoiceService;
       
   279 	CloseIncomingCallL(call, 1, mobileService);
       
   280 
       
   281 	AssertMockLtsyStatusL();
       
   282 	CleanupStack::PopAndDestroy(3, this); // this, line, call
       
   283 	}
       
   284 
       
   285 /**
       
   286 @SYMTestCaseID BA-CTSY-FAX-CAFSHF-0001
       
   287 @SYMComponent  telephony_ctsy
       
   288 @SYMTestCaseDesc Test support in CTSY for RCall::AdoptFaxSharedHeaderFile for voice calls
       
   289 @SYMTestPriority High
       
   290 @SYMTestActions Invokes RCall::AdoptFaxSharedHeaderFile for voice calls
       
   291 @SYMTestExpectedResults Pass
       
   292 @SYMTestType CT
       
   293 */
       
   294 void CCTsyFaxFU::TestAdoptFaxSharedHeaderFile0001L()
       
   295 	{
       
   296 	OpenEtelServerL(EUseExtendedError);
       
   297 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   298 	OpenPhoneL();
       
   299 
       
   300 	RLine line; 
       
   301 	RCall call;
       
   302 	
       
   303 	OpenCallVoiceLC(line, call);
       
   304 	CleanupClosePushL(call);
       
   305 	
       
   306 	RFs fs;
       
   307 	TInt res = fs.Connect();
       
   308 	CleanupClosePushL(fs);
       
   309 	RFile file;
       
   310 	_LIT(KFileName, "C:\\file.txt");
       
   311 	if(res == KErrNone)
       
   312 		{
       
   313 		TInt shareRes = fs.ShareProtected();
       
   314 		if(shareRes == KErrNone)
       
   315 			{
       
   316 			res = file.Create(fs, KFileName, EFileRead | EFileWrite | EFileShareAny); // This file will be deleted in the destructor of the test suite.
       
   317 			if(res == KErrNone)
       
   318 				{
       
   319 				res = call.AdoptFaxSharedHeaderFile(file);
       
   320 				/* 
       
   321 				AdoptFaxSharedHeaderFile returns KErrNotSupported because
       
   322 				function CCallBase::SetFaxSharedHeaderFile always returns KErrNotSupported.
       
   323 				(see "TInt CCallBase::Service(const RMessage2& aMessage,CReqEntry* aReqEntry)", 
       
   324 				case EEtelAdoptFaxSharedHeaderFile, in file ET_CORE.CPP)
       
   325 				*/
       
   326 				ASSERT_EQUALS(KErrNotSupported, res)
       
   327 				}
       
   328 			}
       
   329 		}
       
   330 	RMobilePhone::TMobileService mobileService = RMobilePhone::EVoiceService;
       
   331 	CloseIncomingCallL(call, 1, mobileService);
       
   332 
       
   333 	AssertMockLtsyStatusL();
       
   334 	CleanupStack::PopAndDestroy(4, this); // fs, this, call, line
       
   335 	}
       
   336 
       
   337 /**
       
   338 @SYMTestCaseID BA-CTSY-FAX-FR-0001
       
   339 @SYMComponent  telephony_ctsy
       
   340 @SYMTestCaseDesc Test support in CTSY for RFax::Read
       
   341 @SYMTestPriority High
       
   342 @SYMTestActions Invokes RFax::Read
       
   343 @SYMTestExpectedResults Pass
       
   344 @SYMTestType CT
       
   345 */
       
   346 void CCTsyFaxFU::TestRead0001L()
       
   347 	{
       
   348 	OpenEtelServerL(EUseExtendedError);
       
   349 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   350 	OpenPhoneL();
       
   351 
       
   352 	RFax  fax;
       
   353 	RLine line;
       
   354 	RCall call;
       
   355 	
       
   356 	OpenCallFaxLC(line, call);
       
   357 	CleanupClosePushL(call);
       
   358 	
       
   359 	TInt res = fax.Open(call);
       
   360 	CleanupClosePushL(fax);
       
   361 	
       
   362 	// Test can not be completed until RFax::Open is implemented
       
   363 	ERR_PRINTF2(_L("<font color=Orange>$CTSYKnownFailure: defect id = %d</font>"), 250101);
       
   364 	ASSERT_EQUALS(KErrNotSupported, res)
       
   365 
       
   366 	RMobilePhone::TMobileService mobileService = RMobilePhone::EFaxService;
       
   367 	CloseIncomingCallL(call, 1, mobileService);
       
   368 
       
   369 	AssertMockLtsyStatusL();
       
   370 	CleanupStack::PopAndDestroy(4, this); // fax, call, line, this
       
   371 	}
       
   372 
       
   373 /**
       
   374 @SYMTestCaseID BA-CTSY-FAX-FW-0001
       
   375 @SYMComponent  telephony_ctsy
       
   376 @SYMTestCaseDesc Test support in CTSY for RFax::Write
       
   377 @SYMTestPriority High
       
   378 @SYMTestActions Invokes RFax::Write
       
   379 @SYMTestExpectedResults Pass
       
   380 @SYMTestType CT
       
   381 */
       
   382 void CCTsyFaxFU::TestWrite0001L()
       
   383 	{
       
   384 	OpenEtelServerL(EUseExtendedError);
       
   385 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   386 	OpenPhoneL();
       
   387 
       
   388 	RFax  fax;
       
   389 	RLine line;
       
   390 	RCall call;
       
   391 	
       
   392 	OpenCallFaxLC(line, call);
       
   393 	CleanupClosePushL(call);
       
   394 	
       
   395 	TInt res = fax.Open(call);
       
   396 	CleanupClosePushL(fax);
       
   397 	
       
   398 	// Test can not be completed until RFax::Open is implemented
       
   399 	ERR_PRINTF2(_L("<font color=Orange>$CTSYKnownFailure: defect id = %d</font>"), 250101);
       
   400 	ASSERT_EQUALS(KErrNotSupported, res)
       
   401 
       
   402 	RMobilePhone::TMobileService mobileService = RMobilePhone::EFaxService;
       
   403 	CloseIncomingCallL(call, 1, mobileService);
       
   404 
       
   405 	AssertMockLtsyStatusL();
       
   406 	CleanupStack::PopAndDestroy(4, this); // fax, call, line, this
       
   407 	}
       
   408