telephonyserverplugins/common_tsy/test/component/src/cctsyphonestorefu.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 PhoneStore in the Common TSY.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file 
       
    20 */
       
    21 
       
    22 #include "cctsyphonestorefu.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* CCTsyPhoneStoreFU::CreateSuiteL(const TDesC& aName)
       
    32 	{
       
    33 	SUB_SUITE;
       
    34 
       
    35 	ADD_TEST_STEP_ISO_CPP(CCTsyPhoneStoreFU, TestGetPhoneStoreInfo0001L);
       
    36 	ADD_TEST_STEP_ISO_CPP(CCTsyPhoneStoreFU, TestGetPhoneStoreInfo0002L);
       
    37 	ADD_TEST_STEP_ISO_CPP(CCTsyPhoneStoreFU, TestGetPhoneStoreInfo0003L);
       
    38 	ADD_TEST_STEP_ISO_CPP(CCTsyPhoneStoreFU, TestGetPhoneStoreInfo0004L);
       
    39 	ADD_TEST_STEP_ISO_CPP(CCTsyPhoneStoreFU, TestGetPhoneStoreInfo0005L);
       
    40 
       
    41 	END_SUITE;
       
    42 	}
       
    43 
       
    44 
       
    45 //
       
    46 // Actual test cases
       
    47 //
       
    48 void CCTsyPhoneStoreFU::TestUnsupportedPhoneBookL(const TDesC& aUnsupportedPhbk)
       
    49 	{
       
    50 	// result storage	
       
    51 	RMobilePhoneStore::TMobilePhoneStoreInfoV1 info;
       
    52 	RMobilePhoneStore::TMobilePhoneStoreInfoV1Pckg infoPckg(info);
       
    53 
       
    54 	TRequestStatus status;
       
    55 	iPhone.GetPhoneStoreInfo(status, infoPckg, aUnsupportedPhbk);
       
    56 	User::WaitForRequest(status);
       
    57 	ASSERT_EQUALS(KErrNotSupported, status.Int())
       
    58 	AssertMockLtsyStatusL();
       
    59 	}
       
    60 
       
    61 
       
    62 /**
       
    63 @SYMTestCaseID BA-CTSY-PSTR-MGPSI-0001
       
    64 @SYMComponent  telephony_ctsy
       
    65 @SYMTestCaseDesc Test support in CTSY for RMobilePhone::GetPhoneStoreInfo
       
    66 @SYMTestPriority High
       
    67 @SYMTestActions Invokes RMobilePhone::GetPhoneStoreInfo
       
    68 @SYMTestExpectedResults Pass
       
    69 @SYMTestType CT
       
    70 */
       
    71 void CCTsyPhoneStoreFU::TestGetPhoneStoreInfo0001L()
       
    72 	{
       
    73 	OpenEtelServerL();
       
    74 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
    75 	OpenPhoneL();
       
    76 
       
    77  	//-------------------------------------------------------------------------
       
    78 	// TEST A: failure to dispatch request to LTSY
       
    79  	//-------------------------------------------------------------------------
       
    80 
       
    81 	// Test A for this API consists of two tests
       
    82 
       
    83 	// CASE 1 - client supplies an unsupported phonebook.
       
    84 	// No need for Expect / Complete, as never reaches LTSY
       
    85 	// try ALL unsupported phonebooks to improve code coverage
       
    86 	
       
    87 	TestUnsupportedPhoneBookL(KETelMeAdnPhoneBook);
       
    88 	TestUnsupportedPhoneBookL(KETelMeDialledPhoneBook);
       
    89 	TestUnsupportedPhoneBookL(KETelMeMissedPhoneBook);
       
    90 	TestUnsupportedPhoneBookL(KETelMeReceivedPhoneBook);
       
    91 	TestUnsupportedPhoneBookL(KETelCombinedAdnPhoneBook);
       
    92 	TestUnsupportedPhoneBookL(KETelCombinedSmsStore);
       
    93 	TestUnsupportedPhoneBookL(KETelMeSmsStore);
       
    94 
       
    95 	// CASE 2 - client supplies a supported phonebook but
       
    96 	// LTSY completes with an error immediately
       
    97 
       
    98 	// prepare "ExpectL" data
       
    99 	RMobilePhone::TMobileName fdnPbkName(KETelIccFdnPhoneBook);
       
   100 	TPckg<RMobilePhone::TMobileName> expectData(fdnPbkName);
       
   101 	
       
   102 	// prepare "CompleteL" data
       
   103 	RMobilePhoneStore::TMobilePhoneStoreInfoV1 storeInfo;
       
   104 	storeInfo.iType = RMobilePhoneStore::EPhoneBookStore;
       
   105 	storeInfo.iTotalEntries = 50;
       
   106 	storeInfo.iUsedEntries = 20;
       
   107 	storeInfo.iName = fdnPbkName;
       
   108 
       
   109 	RMobilePhoneStore::TMobilePhoneStoreInfoV1Pckg completeData(storeInfo);
       
   110 
       
   111 	// result storage	
       
   112 	RMobilePhoneStore::TMobilePhoneStoreInfoV1 info;
       
   113 	RMobilePhoneStore::TMobilePhoneStoreInfoV1Pckg infoPckg(info);
       
   114 
       
   115 	TRequestStatus status;
       
   116 
       
   117 	iMockLTSY.ExpectL(EMobilePhoneGetPhoneStoreInfo, expectData, KErrNotSupported);
       
   118 	iPhone.GetPhoneStoreInfo(status, infoPckg, fdnPbkName);
       
   119 	User::WaitForRequest(status);
       
   120 	AssertMockLtsyStatusL();
       
   121 	ASSERT_EQUALS(KErrNotSupported, status.Int())
       
   122 
       
   123 	//-------------------------------------------------------------------------
       
   124 	// TEST B: failure on completion of pending request from LTSY->CTSY
       
   125  	//-------------------------------------------------------------------------
       
   126 	
       
   127 	iMockLTSY.ExpectL(EMobilePhoneGetPhoneStoreInfo, expectData);
       
   128 	iMockLTSY.CompleteL(EMobilePhoneGetPhoneStoreInfo,KErrGeneral, completeData);
       
   129 	iPhone.GetPhoneStoreInfo(status,infoPckg,fdnPbkName);
       
   130 	User::WaitForRequest(status);
       
   131 	AssertMockLtsyStatusL();
       
   132 	ASSERT_EQUALS(KErrGeneral, status.Int())
       
   133 
       
   134  	//-------------------------------------------------------------------------
       
   135 	// TEST C: Successful completion request of
       
   136 	// RMobilePhone::GetPhoneStoreInfo when result is not cached.
       
   137  	//-------------------------------------------------------------------------
       
   138 
       
   139 	// CASE 1: completion request of RMobilePhone::GetPhoneStoreInfo taking 3 arguments
       
   140 	iMockLTSY.ExpectL(EMobilePhoneGetPhoneStoreInfo,expectData);
       
   141 	iMockLTSY.CompleteL(EMobilePhoneGetPhoneStoreInfo,KErrNone, completeData);
       
   142 	iPhone.GetPhoneStoreInfo(status,infoPckg,fdnPbkName);
       
   143 	User::WaitForRequest(status);
       
   144 
       
   145 	ASSERT_EQUALS(KErrNone, status.Int())
       
   146 	ASSERT_EQUALS(storeInfo.iTotalEntries, info.iTotalEntries)
       
   147 	ASSERT_EQUALS(storeInfo.iUsedEntries, info.iUsedEntries)
       
   148 	ASSERT_EQUALS(storeInfo.iType, info.iType)
       
   149 	ASSERT_TRUE(0 == storeInfo.iName.Compare(info.iName))
       
   150 	AssertMockLtsyStatusL();
       
   151 
       
   152  	//-------------------------------------------------------------------------
       
   153 	// TEST E: Unsolicited completion of RMobilePhone::GetPhoneStoreInfo
       
   154 	// from LTSY.
       
   155  	//-------------------------------------------------------------------------
       
   156 	TRequestStatus mockLtsyStatus;
       
   157 
       
   158 	iMockLTSY.NotifyTerminated(mockLtsyStatus); 
       
   159 	iMockLTSY.CompleteL(EMobilePhoneGetPhoneStoreInfo,KErrNone, completeData);
       
   160 	User::WaitForRequest(mockLtsyStatus);
       
   161 	ASSERT_EQUALS(KErrNone,mockLtsyStatus.Int())
       
   162 	AssertMockLtsyStatusL();
       
   163 
       
   164  	//-------------------------------------------------------------------------
       
   165 	// TEST C: Successful completion request of
       
   166 	// RMobilePhone::GetPhoneStoreInfo when result is not cached.
       
   167  	//-------------------------------------------------------------------------
       
   168 
       
   169 	// CASE 2: completion request of RMobilePhone::GetPhoneStoreInfo taking 4 arguments
       
   170 	iPhone.GetPhoneStoreInfo(status, infoPckg, KETelIccAdnPhoneBook,KEtelGsmPhoneBookType);
       
   171 	User::WaitForRequest(status);
       
   172 	
       
   173 	// Overloaded RMobilePhone::GetPhoneStoreInfo(TRequestStatus &aStatus, 
       
   174 	// TDes8 &aInfo, const TDesC &aStoreName, const TDesC &aMode) method is not 
       
   175 	// supported by CTSY.
       
   176 	ASSERT_EQUALS(KErrNotSupported, status.Int())
       
   177 
       
   178 	CleanupStack::PopAndDestroy(this);
       
   179 	}
       
   180 
       
   181 /**
       
   182 @SYMTestCaseID BA-CTSY-PSTR-MGPSI-0002
       
   183 @SYMComponent  telephony_ctsy
       
   184 @SYMTestCaseDesc Test support in CTSY for cancelling of RMobilePhone::GetPhoneStoreInfo
       
   185 @SYMTestPriority High
       
   186 @SYMTestActions Invokes cancelling of RMobilePhone::GetPhoneStoreInfo
       
   187 @SYMTestExpectedResults Pass
       
   188 @SYMTestType CT
       
   189 */
       
   190 void CCTsyPhoneStoreFU::TestGetPhoneStoreInfo0002L()
       
   191 	{
       
   192 	OpenEtelServerL();
       
   193 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   194 	OpenPhoneL();
       
   195 
       
   196 	RMobilePhone::TMobileName adnPbkName(KETelIccAdnPhoneBook);
       
   197 	TPckg<RMobilePhone::TMobileName> expectData(adnPbkName);
       
   198 
       
   199 	RMobilePhoneStore::TMobilePhoneStoreInfoV1 storeInfo;
       
   200 	storeInfo.iType = RMobilePhoneStore::EPhoneBookStore;
       
   201 	storeInfo.iTotalEntries = 50;
       
   202 	storeInfo.iUsedEntries = 20;
       
   203 	storeInfo.iName = adnPbkName;
       
   204 
       
   205 	RMobilePhoneStore::TMobilePhoneStoreInfoV1Pckg completeData(storeInfo);
       
   206 
       
   207 	TRequestStatus mockLtsyStatus;
       
   208 	iMockLTSY.NotifyTerminated(mockLtsyStatus); 
       
   209 
       
   210 	iMockLTSY.ExpectL(EMobilePhoneGetPhoneStoreInfo,expectData);
       
   211 	iMockLTSY.CompleteL(EMobilePhoneGetPhoneStoreInfo, KErrNone, completeData, 10);
       
   212 
       
   213 	TRequestStatus status;
       
   214 
       
   215 	RMobilePhoneStore::TMobilePhoneStoreInfoV1 info;
       
   216 	RMobilePhoneStore::TMobilePhoneStoreInfoV1Pckg infoPckg(info);
       
   217 
       
   218 	iPhone.GetPhoneStoreInfo(status,infoPckg,adnPbkName);
       
   219 	iPhone.CancelAsyncRequest(EMobilePhoneGetPhoneStoreInfo); 
       
   220 	
       
   221 	User::WaitForRequest(status);
       
   222 	User::WaitForRequest(mockLtsyStatus);
       
   223 	ASSERT_EQUALS(KErrCancel,status.Int())
       
   224 	ASSERT_EQUALS(KErrNone,mockLtsyStatus.Int())
       
   225 	
       
   226 	AssertMockLtsyStatusL();
       
   227 	CleanupStack::PopAndDestroy(this); // this
       
   228 	}
       
   229 
       
   230 
       
   231 /**
       
   232 @SYMTestCaseID BA-CTSY-PSTR-MGPSI-0003
       
   233 @SYMComponent  telephony_ctsy
       
   234 @SYMTestCaseDesc Test support in CTSY for RMobilePhone::GetPhoneStoreInfo with bad parameter data
       
   235 @SYMTestPriority High
       
   236 @SYMTestActions Invokes RMobilePhone::GetPhoneStoreInfo with bad parameter data
       
   237 @SYMTestExpectedResults Pass
       
   238 @SYMTestType CT
       
   239 */
       
   240 void CCTsyPhoneStoreFU::TestGetPhoneStoreInfo0003L()
       
   241 	{
       
   242 	OpenEtelServerL(EUseExtendedError);
       
   243 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   244 	OpenPhoneL();
       
   245 
       
   246 	RMobilePhone::TMobileName adnPbkName(KETelIccAdnPhoneBook);
       
   247 
       
   248 	TRequestStatus status;
       
   249 	
       
   250 	// Try to pass aInfo twice smaller than RMobilePhoneStore::TMobilePhoneStoreInfoV1
       
   251 	TBuf8<sizeof(RMobilePhoneStore::TMobilePhoneStoreInfoV1) / 2> badParam;
       
   252 
       
   253 	iPhone.GetPhoneStoreInfo(status,badParam,adnPbkName);
       
   254 	User::WaitForRequest(status);
       
   255 	ASSERT_EQUALS(KErrArgument,status.Int())
       
   256 
       
   257 	CleanupStack::PopAndDestroy(this); // this
       
   258 	}
       
   259 
       
   260 /**
       
   261 @SYMTestCaseID BA-CTSY-PSTR-MGPSI-0004
       
   262 @SYMComponent  telephony_ctsy
       
   263 @SYMTestCaseDesc Test support in CTSY for multiple client requests to RMobilePhone::GetPhoneStoreInfo
       
   264 @SYMTestPriority High
       
   265 @SYMTestActions Invokes multiple client requests to RMobilePhone::GetPhoneStoreInfo
       
   266 @SYMTestExpectedResults Pass
       
   267 @SYMTestType CT
       
   268 */
       
   269 void CCTsyPhoneStoreFU::TestGetPhoneStoreInfo0004L()
       
   270 	{
       
   271 	OpenEtelServerL(EUseExtendedError);
       
   272 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   273 	OpenPhoneL();
       
   274 
       
   275 	// Open second client
       
   276 	RTelServer telServer2;
       
   277 	TInt ret = telServer2.Connect();
       
   278 	ASSERT_EQUALS(KErrNone, ret)
       
   279 	CleanupClosePushL(telServer2);
       
   280 
       
   281 	RMobilePhone phone2;
       
   282 	ret = phone2.Open(telServer2,KMmTsyPhoneName);
       
   283 	ASSERT_EQUALS(KErrNone, ret)
       
   284 	CleanupClosePushL(phone2);
       
   285 
       
   286 	// prepare "ExpectL" data 1
       
   287 	RMobilePhone::TMobileName pbkName1(KETelIccAdnPhoneBook);
       
   288 	TPckg<RMobilePhone::TMobileName> expectData1(pbkName1);
       
   289 
       
   290 	// prepare "ExpectL" data 2
       
   291 	RMobilePhone::TMobileName pbkName2(KETelIccFdnPhoneBook);
       
   292 	TPckg<RMobilePhone::TMobileName> expectData2(pbkName2);
       
   293 
       
   294 	// prepare "CompleteL" data 1
       
   295 	RMobilePhoneStore::TMobilePhoneStoreInfoV1 store1;
       
   296 	store1.iType = RMobilePhoneStore::EPhoneBookStore;
       
   297 	store1.iTotalEntries = 50;
       
   298 	store1.iUsedEntries = 20;
       
   299 	store1.iCaps = RMobilePhoneStore::KCapsDeleteAll;
       
   300 	store1.iName = pbkName1;
       
   301 
       
   302 	RMobilePhoneStore::TMobilePhoneStoreInfoV1Pckg completeData1(store1);
       
   303 
       
   304 	// prepare "CompleteL" data 2
       
   305 	RMobilePhoneStore::TMobilePhoneStoreInfoV1 store2;
       
   306 	store2.iType = RMobilePhoneStore::EPhoneStoreTypeUnknown;
       
   307 	store2.iTotalEntries = 20;
       
   308 	store2.iUsedEntries = 10;
       
   309 	store2.iCaps = RMobilePhoneStore::KCapsWholeStore;
       
   310 	store2.iName = pbkName2;
       
   311 
       
   312 	RMobilePhoneStore::TMobilePhoneStoreInfoV1Pckg completeData2(store2);
       
   313 
       
   314 	// create two EMobilePhoneGetPhoneStoreInfo events
       
   315 	iMockLTSY.ExpectL(EMobilePhoneGetPhoneStoreInfo,expectData1);
       
   316 	iMockLTSY.CompleteL(EMobilePhoneGetPhoneStoreInfo,KErrNone, completeData1);
       
   317 	iMockLTSY.ExpectL(EMobilePhoneGetPhoneStoreInfo,expectData2);
       
   318 	iMockLTSY.CompleteL(EMobilePhoneGetPhoneStoreInfo,KErrNone, completeData2);
       
   319 
       
   320 	// issue two simulteneous requests
       
   321 
       
   322 	RMobilePhoneStore::TMobilePhoneStoreInfoV1 storeInfo1;
       
   323 	TPckg<RMobilePhoneStore::TMobilePhoneStoreInfoV1> storeInfoPckg1(storeInfo1);
       
   324 
       
   325 	RMobilePhoneStore::TMobilePhoneStoreInfoV1 storeInfo2;
       
   326 	TPckg<RMobilePhoneStore::TMobilePhoneStoreInfoV1> storeInfoPckg2(storeInfo2);
       
   327 
       
   328 	TRequestStatus status1;
       
   329 	TRequestStatus status2;
       
   330 
       
   331 	iPhone.GetPhoneStoreInfo(status1,storeInfoPckg1,pbkName1);
       
   332 	phone2.GetPhoneStoreInfo(status2,storeInfoPckg2,pbkName2);
       
   333 
       
   334 	User::WaitForRequest(status1);
       
   335 	User::WaitForRequest(status2);
       
   336 
       
   337 	ASSERT_EQUALS(KErrNone,status1.Int())
       
   338 	ASSERT_EQUALS(store1.iType,storeInfo1.iType)
       
   339 	ASSERT_EQUALS(store1.iTotalEntries,storeInfo1.iTotalEntries)
       
   340 	ASSERT_EQUALS(store1.iUsedEntries,storeInfo1.iUsedEntries)
       
   341 	ASSERT_EQUALS(store1.iCaps,storeInfo1.iCaps)
       
   342 	ASSERT_TRUE(0 == store1.iName.Compare(storeInfo1.iName))
       
   343 
       
   344 	ASSERT_EQUALS(KErrNone,status2.Int())
       
   345 	ASSERT_EQUALS(store2.iType,storeInfo2.iType)
       
   346 	ASSERT_EQUALS(store2.iTotalEntries,storeInfo2.iTotalEntries)
       
   347 	ASSERT_EQUALS(store2.iUsedEntries,storeInfo2.iUsedEntries)
       
   348 	ASSERT_EQUALS(store2.iCaps,storeInfo2.iCaps)
       
   349 	ASSERT_TRUE(0 == store2.iName.Compare(storeInfo2.iName))
       
   350 	
       
   351 	AssertMockLtsyStatusL();
       
   352 
       
   353 	CleanupStack::PopAndDestroy(3,this);//phone2, telServer2, this
       
   354 
       
   355 	}
       
   356 
       
   357 /**
       
   358 @SYMTestCaseID BA-CTSY-PSTR-MGPSI-0005
       
   359 @SYMComponent  telephony_ctsy
       
   360 @SYMTestCaseDesc Test support in CTSY for RMobilePhone::GetPhoneStoreInfo with timeout
       
   361 @SYMTestPriority High
       
   362 @SYMTestActions Invokes RMobilePhone::GetPhoneStoreInfo and tests for timeout
       
   363 @SYMTestExpectedResults Pass
       
   364 @SYMTestType CT
       
   365 */
       
   366 void CCTsyPhoneStoreFU::TestGetPhoneStoreInfo0005L()
       
   367 	{
       
   368 	// *************************************************************************************************
       
   369 	// * Note: script timeout should be set to a value greater than KMmPhoneGetPhoneStoreInfoTimeOut !!!
       
   370 	// *************************************************************************************************
       
   371 	OpenEtelServerL(EUseExtendedError);
       
   372 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   373 	OpenPhoneL();
       
   374 
       
   375 	//-------------------------------------------------------------------------
       
   376 	// Test A: Test timeout of RMobilePhone::GetPhoneStoreInfo
       
   377  	//-------------------------------------------------------------------------
       
   378  	
       
   379 	RMobilePhone::TMobileName adnPbkName(KETelIccAdnPhoneBook);
       
   380 	TPckg<RMobilePhone::TMobileName> expectData(adnPbkName);
       
   381 
       
   382 	RMobilePhoneStore::TMobilePhoneStoreInfoV1 info;
       
   383 	RMobilePhoneStore::TMobilePhoneStoreInfoV1Pckg infoPckg(info);
       
   384 
       
   385 	TRequestStatus status;
       
   386 
       
   387 	// Call the Etel API without doing the CompleteL
       
   388 	iMockLTSY.ExpectL(EMobilePhoneGetPhoneStoreInfo,expectData);	
       
   389 	iPhone.GetPhoneStoreInfo(status,infoPckg,adnPbkName);
       
   390 	User::WaitForRequest(status);
       
   391 
       
   392 	// Check status is KErrTimedOut
       
   393 	ASSERT_EQUALS(KErrTimedOut, status.Int())
       
   394 
       
   395 	AssertMockLtsyStatusL();
       
   396 
       
   397 	CleanupStack::PopAndDestroy(this); // this
       
   398 	}
       
   399 
       
   400 
       
   401