telephonyserverplugins/common_tsy/test/component/src/cctsyphonecapabilityfu.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 PhoneCapability in the Common TSY.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file 
       
    20 */
       
    21 
       
    22 #include "cctsyphonecapabilityfu.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 "MmTsy_conf.h"
       
    30 
       
    31 CTestSuite* CCTsyPhoneCapabilityFU::CreateSuiteL(const TDesC& aName)
       
    32 	{
       
    33 	SUB_SUITE;
       
    34 
       
    35 	ADD_TEST_STEP_ISO_CPP(CCTsyPhoneCapabilityFU, TestNotifyCapsChange0001L);
       
    36 	ADD_TEST_STEP_ISO_CPP(CCTsyPhoneCapabilityFU, TestNotifyCapsChange0001aL);
       
    37 	ADD_TEST_STEP_ISO_CPP(CCTsyPhoneCapabilityFU, TestNotifyCapsChange0001bL);
       
    38 	ADD_TEST_STEP_ISO_CPP(CCTsyPhoneCapabilityFU, TestNotifyCapsChange0001cL);
       
    39 	ADD_TEST_STEP_ISO_CPP(CCTsyPhoneCapabilityFU, TestNotifyCapsChange0002L);
       
    40 	ADD_TEST_STEP_ISO_CPP(CCTsyPhoneCapabilityFU, TestNotifyCapsChange0004L);
       
    41 	ADD_TEST_STEP_ISO_CPP(CCTsyPhoneCapabilityFU, TestGetMultimodeCaps0001L);
       
    42 
       
    43 	END_SUITE;
       
    44 	}
       
    45 
       
    46 
       
    47 //
       
    48 // Actual test cases
       
    49 //
       
    50 
       
    51 
       
    52 /**
       
    53 @SYMTestCaseID BA-CTSY-PCAP-PCC-0001
       
    54 @SYMComponent  telephony_ctsy
       
    55 @SYMTestCaseDesc Test support in CTSY for RPhone::NotifyCapsChange
       
    56 @SYMTestPriority High
       
    57 @SYMTestActions Invokes RPhone::NotifyCapsChange
       
    58 @SYMTestExpectedResults Pass
       
    59 @SYMTestType CT
       
    60 */
       
    61 void CCTsyPhoneCapabilityFU::TestNotifyCapsChange0001L()
       
    62 	{
       
    63 
       
    64 	OpenEtelServerL(EUseExtendedError);
       
    65 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
    66 	OpenPhoneL();
       
    67 
       
    68 	// invoke caps change, invoke completion of not requested NotifyCapsChange
       
    69 	RLine line;
       
    70 	TInt err = line.Open(iPhone, KMmTsyVoice1LineName);
       
    71 	ASSERT_EQUALS(KErrNone, err)
       
    72     line.Close();
       
    73 
       
    74 	RLine line2;
       
    75 
       
    76 	//-------------------------------------------------------------------------
       
    77 	// TEST C: Successful completion request of
       
    78 	// RPhone::NotifyCapsChange.
       
    79  	//-------------------------------------------------------------------------
       
    80 
       
    81 	TRequestStatus status;
       
    82 	RPhone::TCaps caps;
       
    83 	iPhone.NotifyCapsChange(status, caps);
       
    84 
       
    85 	// invoke caps change (open data line)
       
    86 	err = line.Open(iPhone, KMmTsyDataLineName);
       
    87 	ASSERT_EQUALS(KErrNone, err);
       
    88 	
       
    89 	// check results
       
    90 	User::WaitForRequest(status);
       
    91 	ASSERT_EQUALS(KErrNone, status.Int());
       
    92 	AssertMockLtsyStatusL();
       
    93 	ASSERT_EQUALS(static_cast<TUint>(
       
    94 			RPhone::KCapsData |
       
    95 			RPhone::KCapsEventModemDetection |
       
    96 			RPhone::KCapsStealCommPort),
       
    97 			caps.iFlags);
       
    98 
       
    99 	iPhone.NotifyCapsChange(status, caps);
       
   100 
       
   101 	// invoke caps change (open auxilliary voice line)
       
   102 	err = line2.Open(iPhone, KMmTsyVoice2LineName);
       
   103 	ASSERT_EQUALS(KErrNone, err)
       
   104 
       
   105 
       
   106 	// check results
       
   107 	User::WaitForRequest(status);
       
   108 	ASSERT_EQUALS(KErrNone, status.Int());
       
   109 	AssertMockLtsyStatusL();
       
   110 	ASSERT_EQUALS(static_cast<TUint>(
       
   111 	           RPhone::KCapsData |
       
   112 	           RPhone::KCapsEventModemDetection |
       
   113 	           RPhone::KCapsStealCommPort |
       
   114 	           RPhone::KCapsVoice) ,
       
   115 	            caps.iFlags);
       
   116 	
       
   117 	iPhone.NotifyCapsChange(status, caps);
       
   118 
       
   119 	// invoke caps change
       
   120     line.Close();
       
   121 
       
   122 	// check results
       
   123 	User::WaitForRequest(status);
       
   124 	ASSERT_EQUALS(KErrNone, status.Int());
       
   125 	AssertMockLtsyStatusL();
       
   126 	ASSERT_EQUALS(static_cast<TUint>(RPhone::KCapsVoice), caps.iFlags);
       
   127 
       
   128 	iPhone.NotifyCapsChange(status, caps);
       
   129 
       
   130 	line2.Close();
       
   131 
       
   132 	// check results
       
   133 	User::WaitForRequest(status);
       
   134 	ASSERT_EQUALS(KErrNone, status.Int());
       
   135 	AssertMockLtsyStatusL();
       
   136 	ASSERT_EQUALS(static_cast<TUint>(0), caps.iFlags);
       
   137 
       
   138 	CleanupStack::PopAndDestroy(this);
       
   139 	
       
   140 	}
       
   141 
       
   142 
       
   143 /**
       
   144 @SYMTestCaseID BA-CTSY-PCAP-PCC-0001a
       
   145 @SYMComponent  telephony_ctsy
       
   146 @SYMTestCaseDesc Test support in CTSY for RPhone::NotifyCapsChange for voice calls
       
   147 @SYMTestPriority High
       
   148 @SYMTestActions Invokes RPhone::NotifyCapsChange for voice calls
       
   149 @SYMTestExpectedResults Pass
       
   150 @SYMTestType CT
       
   151 */
       
   152 void CCTsyPhoneCapabilityFU::TestNotifyCapsChange0001aL()
       
   153 	{
       
   154 
       
   155 	OpenEtelServerL(EUseExtendedError);
       
   156 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   157 	OpenPhoneL();
       
   158 
       
   159 	RLine line;
       
   160 
       
   161 	//-------------------------------------------------------------------------
       
   162 	// TEST C: Successful completion request of
       
   163 	// RPhone::NotifyCapsChange.
       
   164  	//-------------------------------------------------------------------------
       
   165 
       
   166 	TRequestStatus status;
       
   167 	RPhone::TCaps caps;
       
   168 	iPhone.NotifyCapsChange(status, caps);
       
   169 
       
   170 	// invoke caps change
       
   171 	TInt err = line.Open(iPhone, KMmTsyVoice1LineName);
       
   172 	ASSERT_EQUALS(KErrNone, err)
       
   173 
       
   174 	// check results
       
   175 	User::WaitForRequest(status);
       
   176 	ASSERT_EQUALS(KErrNone, status.Int());
       
   177 	AssertMockLtsyStatusL();
       
   178 	ASSERT_EQUALS(static_cast<TUint>(RPhone::KCapsVoice), caps.iFlags);
       
   179 
       
   180 	iPhone.NotifyCapsChange(status, caps);
       
   181 
       
   182 	// invoke caps change
       
   183     line.Close();
       
   184     
       
   185 	// check results
       
   186 	User::WaitForRequest(status);
       
   187 	ASSERT_EQUALS(KErrNone, status.Int());
       
   188 	AssertMockLtsyStatusL();
       
   189 	ASSERT_EQUALS(static_cast<TUint>(0), caps.iFlags);
       
   190 
       
   191 	iPhone.NotifyCapsChange(status, caps);
       
   192 	
       
   193 	// invoke caps change
       
   194 	// now we open auxilliary voice line
       
   195 	err = line.Open(iPhone, KMmTsyVoice2LineName);
       
   196 	ASSERT_EQUALS(KErrNone, err)
       
   197 
       
   198 	// check results
       
   199 	User::WaitForRequest(status);
       
   200 	ASSERT_EQUALS(KErrNone, status.Int());
       
   201 	AssertMockLtsyStatusL();
       
   202 	ASSERT_EQUALS(static_cast<TUint>(RPhone::KCapsVoice), caps.iFlags);
       
   203 
       
   204 	iPhone.NotifyCapsChange(status, caps);
       
   205 
       
   206 	// invoke caps change
       
   207     line.Close();
       
   208 
       
   209 	// check results
       
   210 	User::WaitForRequest(status);
       
   211 	ASSERT_EQUALS(KErrNone, status.Int());
       
   212 	AssertMockLtsyStatusL();
       
   213 	ASSERT_EQUALS(static_cast<TUint>(0), caps.iFlags);
       
   214 
       
   215 	CleanupStack::PopAndDestroy(this);
       
   216 	
       
   217 	}
       
   218 
       
   219 
       
   220 /**
       
   221 @SYMTestCaseID BA-CTSY-PCAP-PCC-0001b
       
   222 @SYMComponent  telephony_ctsy
       
   223 @SYMTestCaseDesc Test support in CTSY for RPhone::NotifyCapsChange for data calls
       
   224 @SYMTestPriority High
       
   225 @SYMTestActions Invokes RPhone::NotifyCapsChange for data calls
       
   226 @SYMTestExpectedResults Pass
       
   227 @SYMTestType CT
       
   228 */
       
   229 void CCTsyPhoneCapabilityFU::TestNotifyCapsChange0001bL()
       
   230 	{
       
   231 
       
   232 	OpenEtelServerL(EUseExtendedError);
       
   233 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   234 	OpenPhoneL();
       
   235 
       
   236 	RLine line;
       
   237 
       
   238 	//-------------------------------------------------------------------------
       
   239 	// TEST C: Successful completion request of
       
   240 	// RPhone::NotifyCapsChange.
       
   241  	//-------------------------------------------------------------------------
       
   242 
       
   243 	TRequestStatus status;
       
   244 	RPhone::TCaps caps;
       
   245 	iPhone.NotifyCapsChange(status, caps);
       
   246 
       
   247 	// invoke caps change
       
   248 	TInt err = line.Open(iPhone, KMmTsyDataLineName);
       
   249 	ASSERT_EQUALS(KErrNone, err);
       
   250 
       
   251 	// check results
       
   252 	User::WaitForRequest(status);
       
   253 	ASSERT_EQUALS(KErrNone, status.Int());
       
   254 	AssertMockLtsyStatusL();
       
   255 	ASSERT_EQUALS(static_cast<TUint>(
       
   256 			RPhone::KCapsData |
       
   257 			RPhone::KCapsEventModemDetection |
       
   258 			RPhone::KCapsStealCommPort),
       
   259 			caps.iFlags);
       
   260 
       
   261 	iPhone.NotifyCapsChange(status, caps);
       
   262 
       
   263 	// invoke caps change
       
   264     line.Close();
       
   265 
       
   266 	// check results
       
   267 	User::WaitForRequest(status);
       
   268 	ASSERT_EQUALS(KErrNone, status.Int());
       
   269 	AssertMockLtsyStatusL();
       
   270 	ASSERT_EQUALS(static_cast<TUint>(0), caps.iFlags);
       
   271 
       
   272 	CleanupStack::PopAndDestroy(this);
       
   273 	
       
   274 	}
       
   275 
       
   276 
       
   277 /**
       
   278 @SYMTestCaseID BA-CTSY-PCAP-PCC-0001c
       
   279 @SYMComponent  telephony_ctsy
       
   280 @SYMTestCaseDesc Test support in CTSY for RPhone::NotifyCapsChange for fax calls
       
   281 @SYMTestPriority High
       
   282 @SYMTestActions Invokes RPhone::NotifyCapsChange for fax calls
       
   283 @SYMTestExpectedResults Pass
       
   284 @SYMTestType CT
       
   285 */
       
   286 void CCTsyPhoneCapabilityFU::TestNotifyCapsChange0001cL()
       
   287 	{
       
   288 
       
   289 	OpenEtelServerL(EUseExtendedError);
       
   290 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   291 	OpenPhoneL();
       
   292 
       
   293 	RLine line;
       
   294 	RLine line2;
       
   295 
       
   296 	//-------------------------------------------------------------------------
       
   297 	// TEST C: Successful completion request of
       
   298 	// RPhone::NotifyCapsChange.
       
   299  	//-------------------------------------------------------------------------
       
   300 
       
   301 	TRequestStatus status;
       
   302 	RPhone::TCaps caps;
       
   303 	iPhone.NotifyCapsChange(status, caps);
       
   304 
       
   305 	// open fax line
       
   306 	TInt err = line.Open(iPhone, KMmTsyFaxLineName);
       
   307 	ASSERT_EQUALS(KErrNone, err);
       
   308 	// open voice line
       
   309 	err = line2.Open(iPhone, KMmTsyVoice1LineName);
       
   310 	ASSERT_EQUALS(KErrNone, err);
       
   311 
       
   312 	// check results
       
   313 	User::WaitForRequest(status);
       
   314 	ASSERT_EQUALS(KErrNone, status.Int());
       
   315 	AssertMockLtsyStatusL();
       
   316 	// fax line availability does not have sense for phone capabilities in CTSY
       
   317 	// so request completes after voice line is opened with RPhone::KCapsVoice
       
   318 	ASSERT_EQUALS(static_cast<TUint>(RPhone::KCapsVoice), caps.iFlags);
       
   319 
       
   320 	iPhone.NotifyCapsChange(status, caps);
       
   321 
       
   322 	// close fax line
       
   323     line.Close();
       
   324 	// close voice line
       
   325     line2.Close();
       
   326 
       
   327 	// check results
       
   328 	User::WaitForRequest(status);
       
   329 	ASSERT_EQUALS(KErrNone, status.Int());
       
   330 	AssertMockLtsyStatusL();
       
   331 	// fax line availability does not have sense for phone capabilities in CTSY
       
   332 	// so request completes after closing voice line
       
   333 	ASSERT_EQUALS(static_cast<TUint>(0), caps.iFlags);
       
   334 
       
   335 	CleanupStack::PopAndDestroy(this);
       
   336 	
       
   337 	}
       
   338 
       
   339 
       
   340 /**
       
   341 @SYMTestCaseID BA-CTSY-PCAP-PCC-0002
       
   342 @SYMComponent  telephony_ctsy
       
   343 @SYMTestCaseDesc Test support in CTSY for cancelling of RPhone::NotifyCapsChange
       
   344 @SYMTestPriority High
       
   345 @SYMTestActions Invokes cancelling of RPhone::NotifyCapsChange
       
   346 @SYMTestExpectedResults Pass
       
   347 @SYMTestType CT
       
   348 */
       
   349 void CCTsyPhoneCapabilityFU::TestNotifyCapsChange0002L()
       
   350 	{
       
   351 
       
   352 	OpenEtelServerL(EUseExtendedError);
       
   353 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   354 	OpenPhoneL();
       
   355 
       
   356  	//-------------------------------------------------------------------------
       
   357 	// Test cancelling of RPhone::NotifyCapsChange
       
   358  	//-------------------------------------------------------------------------
       
   359  	
       
   360 	TRequestStatus status;
       
   361 	RPhone::TCaps caps;
       
   362 	iPhone.NotifyCapsChange(status, caps);
       
   363 
       
   364 	iPhone.NotifyCapsChangeCancel();
       
   365 
       
   366 	User::WaitForRequest(status);
       
   367 	ASSERT_EQUALS(KErrCancel, status.Int());
       
   368 	AssertMockLtsyStatusL();
       
   369 
       
   370 	CleanupStack::PopAndDestroy(this);
       
   371 	
       
   372 	}
       
   373 
       
   374 
       
   375 /**
       
   376 @SYMTestCaseID BA-CTSY-PCAP-PCC-0004
       
   377 @SYMComponent  telephony_ctsy
       
   378 @SYMTestCaseDesc Test support in CTSY for multiple client requests to RPhone::NotifyCapsChange
       
   379 @SYMTestPriority High
       
   380 @SYMTestActions Invokes multiple client requests to RPhone::NotifyCapsChange
       
   381 @SYMTestExpectedResults Pass
       
   382 @SYMTestType CT
       
   383 */
       
   384 void CCTsyPhoneCapabilityFU::TestNotifyCapsChange0004L()
       
   385 	{
       
   386 
       
   387 	OpenEtelServerL(EUseExtendedError);
       
   388 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   389 	OpenPhoneL();
       
   390 
       
   391 	// Open second client
       
   392 	RTelServer telServer2;
       
   393 	TInt ret = telServer2.Connect();
       
   394 	ASSERT_EQUALS(KErrNone, ret);
       
   395 	CleanupClosePushL(telServer2);
       
   396 
       
   397 	RMobilePhone phone2;
       
   398 	ret = phone2.Open(telServer2,KMmTsyPhoneName);
       
   399 	ASSERT_EQUALS(KErrNone, ret);
       
   400 	CleanupClosePushL(phone2);
       
   401 
       
   402 	// open voice line
       
   403 	RLine line;
       
   404 	TInt err = line.Open(iPhone, KMmTsyVoice1LineName);
       
   405 	ASSERT_EQUALS(KErrNone, err)
       
   406 
       
   407 	//-------------------------------------------------------------------------
       
   408 	// Test A: Test multiple clients requesting RPhone::NotifyCapsChange
       
   409  	//-------------------------------------------------------------------------
       
   410 
       
   411 	// request notifys
       
   412 	TRequestStatus status;
       
   413 	RPhone::TCaps caps;
       
   414 	iPhone.NotifyCapsChange(status, caps);
       
   415 
       
   416 	TRequestStatus status2;
       
   417 	RPhone::TCaps caps2;
       
   418 	phone2.NotifyCapsChange(status2, caps2);
       
   419 
       
   420 	// invoke caps change
       
   421     line.Close();
       
   422 
       
   423 	// check results
       
   424 	User::WaitForRequest(status);
       
   425 	ASSERT_EQUALS(KErrNone, status.Int());
       
   426 	TUint expCaps(0);
       
   427 	ASSERT_EQUALS(expCaps, caps.iFlags);
       
   428 
       
   429 	User::WaitForRequest(status2);
       
   430 	ASSERT_EQUALS(KErrNone, status2.Int());
       
   431 	ASSERT_EQUALS(expCaps, caps2.iFlags);
       
   432 
       
   433 	AssertMockLtsyStatusL();
       
   434 
       
   435 	CleanupStack::PopAndDestroy(3, this); // phone2, telServer2, this
       
   436 
       
   437 	}
       
   438 
       
   439 
       
   440 /**
       
   441 @SYMTestCaseID BA-CTSY-PCAP-MGMC-0001
       
   442 @SYMComponent  telephony_ctsy
       
   443 @SYMTestCaseDesc Test support in CTSY for RMobilePhone::GetMultimodeCaps
       
   444 @SYMTestPriority High
       
   445 @SYMTestActions Invokes RMobilePhone::GetMultimodeCaps
       
   446 @SYMTestExpectedResults Pass
       
   447 @SYMTestType CT
       
   448 */
       
   449 void CCTsyPhoneCapabilityFU::TestGetMultimodeCaps0001L()
       
   450 	{
       
   451 
       
   452 	OpenEtelServerL(EUseExtendedError);
       
   453 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   454 	OpenPhoneL();
       
   455 
       
   456  	//-------------------------------------------------------------------------
       
   457 	// TEST: Successful completion request of RMobilePhone::GetMultimodeCaps.
       
   458  	//-------------------------------------------------------------------------
       
   459 
       
   460 	TUint32 caps;
       
   461 	TInt err = iPhone.GetMultimodeCaps(caps);
       
   462 	ASSERT_EQUALS(KErrNone, err);
       
   463 	// CTSY allways returns KMultimodeCaps
       
   464 	TUint32 expCaps(KMultimodeCaps);
       
   465 	ASSERT_EQUALS(expCaps, caps);
       
   466 
       
   467 	AssertMockLtsyStatusL();
       
   468 	CleanupStack::PopAndDestroy(this);
       
   469 	
       
   470 	}