commsconfig/commsdatabaseshim/TE_commdb/te_connpref/src/TE_ConnPrefSteps.cpp
changeset 72 ae47d0499bee
equal deleted inserted replaced
68:5da8188e392b 72:ae47d0499bee
       
     1 //
       
     2 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 // All rights reserved.
       
     4 // This component and the accompanying materials are made available
       
     5 // under the terms of "Eclipse Public License v1.0"
       
     6 // which accompanies this distribution, and is available
       
     7 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 //
       
     9 // Initial Contributors:
       
    10 // Nokia Corporation - initial contribution.
       
    11 //
       
    12 // Contributors:
       
    13 //
       
    14 // Description:
       
    15 //
       
    16 //
       
    17 
       
    18 // TE_ConnPrefSteps.cpp
       
    19 //
       
    20 //
       
    21 
       
    22 #include <commdbconnpref.h>
       
    23 #include <e32test.h>
       
    24 
       
    25 #include "TE_ConnPrefSteps.h"
       
    26 
       
    27 CTE_ConstructAndVersion::CTE_ConstructAndVersion()
       
    28 	{
       
    29 	SetTestStepName(KConstructAndVersion);
       
    30 	}
       
    31 
       
    32 CTE_ConstructAndVersion::~CTE_ConstructAndVersion()
       
    33 	{	
       
    34 	}
       
    35 
       
    36 enum TVerdict CTE_ConstructAndVersion::doTestStepL()
       
    37 	{
       
    38 
       
    39 	TCommDbConnPref connPref;
       
    40 
       
    41 	Test(connPref.ExtensionId() == TConnPref::EConnPrefCommDb);		
       
    42 	TVersion ver = connPref.Version();
       
    43 	Test(ver.iMajor == TCommDbConnPref::KMajorVersionNumber);		
       
    44 	Test(ver.iMinor == TCommDbConnPref::KMinorVersionNumber);		
       
    45 	Test(ver.iBuild == TCommDbConnPref::KBuildVersionNumber);
       
    46 	Test(connPref.BearerSet() == KCommDbBearerUnknown);		
       
    47 	Test(connPref.DialogPreference() == ECommDbDialogPrefUnknown);		
       
    48 	Test(connPref.Direction() == ECommDbConnectionDirectionUnknown);
       
    49 	Test(connPref.IapId() == 0);		
       
    50 	Test(connPref.NetId() == 0);
       
    51 	
       
    52         SetTestStepResult(EPass);	return TestStepResult();
       
    53 	}
       
    54 
       
    55 CTE_SetAndGetConnPrefs::CTE_SetAndGetConnPrefs()
       
    56 	{
       
    57 	SetTestStepName(KSetAndGetConnPrefs); 
       
    58 	}
       
    59 
       
    60 CTE_SetAndGetConnPrefs::~CTE_SetAndGetConnPrefs()
       
    61 	{	
       
    62 	}
       
    63 
       
    64 enum TVerdict CTE_SetAndGetConnPrefs::doTestStepL()
       
    65 	{
       
    66 
       
    67 	TCommDbConnPref connPref;
       
    68 
       
    69 	connPref.SetBearerSet((KCommDbBearerWcdma | KCommDbBearerLAN));
       
    70 	Test(connPref.BearerSet() == (KCommDbBearerWcdma | KCommDbBearerLAN));
       
    71 
       
    72 	connPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
       
    73 	Test(connPref.DialogPreference() == ECommDbDialogPrefDoNotPrompt);
       
    74 
       
    75 	connPref.SetDirection(ECommDbConnectionDirectionOutgoing);
       
    76 	Test(connPref.Direction() == ECommDbConnectionDirectionOutgoing);
       
    77 
       
    78 	connPref.SetIapId(123);
       
    79 	Test(connPref.IapId() == 123);
       
    80 
       
    81 	connPref.SetNetId(456);
       
    82 	Test(connPref.NetId() == 456);
       
    83 
       
    84         SetTestStepResult(EPass);	return TestStepResult();
       
    85 	}
       
    86 
       
    87 
       
    88 CTE_ComparePrefs::CTE_ComparePrefs()
       
    89 	{
       
    90 	SetTestStepName(KComparePrefs); 
       
    91 	}
       
    92 
       
    93 CTE_ComparePrefs::~CTE_ComparePrefs()
       
    94 	{	
       
    95 	}
       
    96 
       
    97 enum TVerdict CTE_ComparePrefs::doTestStepL()
       
    98 	{
       
    99 	
       
   100 	TCommDbConnPref connPref1;
       
   101 	connPref1.SetBearerSet((KCommDbBearerWcdma | KCommDbBearerLAN));
       
   102 	connPref1.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
       
   103 	connPref1.SetDirection(ECommDbConnectionDirectionOutgoing);
       
   104 	connPref1.SetIapId(123);
       
   105 	connPref1.SetNetId(456);
       
   106 
       
   107 	TCommDbConnPref connPref2;
       
   108 	connPref2.SetBearerSet((KCommDbBearerWcdma | KCommDbBearerLAN));
       
   109 	connPref2.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
       
   110 	connPref2.SetDirection(ECommDbConnectionDirectionOutgoing);
       
   111 	connPref2.SetIapId(123);
       
   112 	connPref2.SetNetId(456);
       
   113 
       
   114 	TCommDbConnPref connPref3;
       
   115 	connPref3.SetBearerSet(KCommDbBearerCSD);
       
   116 	connPref3.SetDialogPreference(ECommDbDialogPrefWarn);
       
   117 	connPref3.SetDirection(ECommDbConnectionDirectionIncoming);
       
   118 	connPref3.SetIapId(987);
       
   119 	connPref3.SetNetId(654);
       
   120 
       
   121 	TCommDbConnPref connPref4;
       
   122 	connPref4.SetBearerSet(KCommDbBearerCSD);
       
   123 	connPref4.SetDirection(ECommDbConnectionDirectionIncoming);
       
   124 	connPref4.SetNetId(654);	
       
   125 
       
   126 	Test(connPref2.Compare(connPref1) == 0);
       
   127 	Test(connPref2 == connPref1);
       
   128 
       
   129 	Test(connPref1.Compare(connPref2) == 0);
       
   130 	Test(connPref1 == connPref2);
       
   131 
       
   132 	Test(connPref1.Compare(connPref1) == 0);
       
   133 	Test(connPref1 == connPref1);
       
   134 
       
   135 	Test(connPref3.Compare(connPref1) != 0);
       
   136 	Test(connPref3 != connPref1);
       
   137 
       
   138 	Test(connPref1.Compare(connPref3) != 0);
       
   139 	Test(connPref1 != connPref3);
       
   140 
       
   141 	Test(connPref4 == connPref3);
       
   142 	Test(connPref3 == connPref4);
       
   143 
       
   144 	Test(connPref4 != connPref2);
       
   145 	Test(connPref2 != connPref4);
       
   146 
       
   147         SetTestStepResult(EPass);	return TestStepResult();
       
   148 	}
       
   149 
       
   150 CTE_AssignAndCopyConstruct::CTE_AssignAndCopyConstruct()
       
   151 	{
       
   152 	SetTestStepName(KAssignAndCopyConstruct); 
       
   153 	}
       
   154 
       
   155 CTE_AssignAndCopyConstruct::~CTE_AssignAndCopyConstruct()
       
   156 	{	
       
   157 	}
       
   158 
       
   159 enum TVerdict CTE_AssignAndCopyConstruct::doTestStepL()
       
   160 	{
       
   161 
       
   162 	TCommDbConnPref connPref1;
       
   163 	connPref1.SetBearerSet((KCommDbBearerWcdma | KCommDbBearerLAN));
       
   164 	connPref1.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
       
   165 	connPref1.SetDirection(ECommDbConnectionDirectionOutgoing);
       
   166 	connPref1.SetIapId(123);
       
   167 	connPref1.SetNetId(456);
       
   168 
       
   169 	TCommDbConnPref connPref2(connPref1);
       
   170 	Test(connPref2.Compare(connPref1) == 0);
       
   171 	Test(connPref1.Compare(connPref2) == 0);
       
   172 
       
   173 	TCommDbConnPref connPref3 = connPref1;
       
   174 	Test(connPref3.Compare(connPref1) == 0);
       
   175 	Test(connPref1.Compare(connPref3) == 0);
       
   176 
       
   177 	TCommDbConnPref connPref4;
       
   178 	connPref4 = connPref1;
       
   179 	Test(connPref4.Compare(connPref1) == 0);
       
   180 	Test(connPref1.Compare(connPref4) == 0);
       
   181 
       
   182         SetTestStepResult(EPass);	return TestStepResult();
       
   183 	}
       
   184 
       
   185 CTE_ExtensionIdAndCast::CTE_ExtensionIdAndCast()
       
   186 	{
       
   187 	SetTestStepName(KExtensionIdAndCast); 
       
   188 	}
       
   189 
       
   190 CTE_ExtensionIdAndCast::~CTE_ExtensionIdAndCast()
       
   191 	{	
       
   192 	}
       
   193 
       
   194 enum TVerdict CTE_ExtensionIdAndCast::doTestStepL()
       
   195 	{
       
   196 
       
   197 	TCommDbConnPref commdbPref1;
       
   198 	commdbPref1.SetBearerSet((KCommDbBearerWcdma | KCommDbBearerLAN));
       
   199 	commdbPref1.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
       
   200 	commdbPref1.SetDirection(ECommDbConnectionDirectionOutgoing);
       
   201 	commdbPref1.SetIapId(123);
       
   202 	commdbPref1.SetNetId(456);
       
   203 
       
   204 	TConnPref basePref(commdbPref1);
       
   205 	Test(basePref.ExtensionId() == TConnPref::EConnPrefCommDb);
       
   206 
       
   207 	TCommDbConnPref commdbPref2 = TCommDbConnPref::Cast(basePref);
       
   208 	Test(commdbPref2 == commdbPref1);
       
   209 	
       
   210         SetTestStepResult(EPass);	return TestStepResult();
       
   211 	}
       
   212 
       
   213 
       
   214 CTE_MultiConnPref::CTE_MultiConnPref()
       
   215 	{
       
   216 	SetTestStepName(KMultiConnPref); 
       
   217 	}
       
   218 
       
   219 CTE_MultiConnPref::~CTE_MultiConnPref()
       
   220 	{	
       
   221 	}
       
   222 
       
   223 enum TVerdict CTE_MultiConnPref::doTestStepL()
       
   224 	{
       
   225 
       
   226 	TCommDbConnPref connPref1;
       
   227 	connPref1.SetBearerSet((KCommDbBearerWcdma | KCommDbBearerLAN));
       
   228 	connPref1.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
       
   229 	connPref1.SetDirection(ECommDbConnectionDirectionOutgoing);
       
   230 	connPref1.SetIapId(123);
       
   231 	connPref1.SetNetId(456);
       
   232 
       
   233 	TCommDbConnPref connPref2;
       
   234 	connPref2.SetBearerSet(KCommDbBearerCSD);
       
   235 	connPref2.SetDialogPreference(ECommDbDialogPrefWarn);
       
   236 	connPref2.SetDirection(ECommDbConnectionDirectionIncoming);
       
   237 	connPref2.SetIapId(987);
       
   238 	connPref2.SetNetId(654);
       
   239 
       
   240 	TCommDbMultiConnPref multiPref;
       
   241 	TInt err(KErrNone);
       
   242 
       
   243 	err = multiPref.SetPreference(0, connPref1);
       
   244 	Test(err == KErrArgument);
       
   245 	
       
   246 	err = multiPref.SetPreference(1, connPref1);
       
   247 	Test(err == KErrNone);
       
   248 
       
   249 	err = multiPref.SetPreference(2, connPref2);
       
   250 	Test(err == KErrNone);
       
   251 
       
   252 	err = multiPref.SetPreference(3, connPref2);
       
   253 	Test(err == KErrArgument);
       
   254 
       
   255 	TCommDbConnPref connPref3;
       
   256 
       
   257 	err = multiPref.GetPreference(0, connPref3);
       
   258 	Test(err == KErrArgument);
       
   259 
       
   260 	err = multiPref.GetPreference(1, connPref3);
       
   261 	Test(err == KErrNone);
       
   262 	Test(connPref3 == connPref1);
       
   263 
       
   264 	err = multiPref.GetPreference(2, connPref3);
       
   265 	Test(err == KErrNone);
       
   266 	Test(connPref3 == connPref2);
       
   267 
       
   268 	err = multiPref.GetPreference(3, connPref3);
       
   269 	Test(err == KErrArgument);
       
   270 
       
   271 	TConnPref basePref(multiPref);
       
   272 	Test(basePref.ExtensionId() == TConnPref::EConnPrefCommDbMulti);
       
   273 
       
   274 	TCommDbMultiConnPref multiPref2;	
       
   275 	TCommDbConnPref connPref4;
       
   276 	err = multiPref2.GetPreference(1, connPref4);
       
   277 	Test(err == KErrNone);
       
   278 	Test(connPref4 == connPref1);
       
   279 
       
   280 	TCommDbConnPref connPref5;
       
   281 	err = multiPref2.GetPreference(2, connPref5);
       
   282 	Test(err == KErrNone);
       
   283 	Test(connPref5 == connPref2);
       
   284 
       
   285 	Test(multiPref.ConnectionAttempts()==TCommDbMultiConnPref::KMaxMultiConnPrefCount);
       
   286 
       
   287 	multiPref.SetConnectionAttempts(0);
       
   288 	Test(multiPref.ConnectionAttempts()==TCommDbMultiConnPref::KMaxMultiConnPrefCount);
       
   289 
       
   290 	multiPref.SetConnectionAttempts(1);
       
   291 	Test(multiPref.ConnectionAttempts()==1);
       
   292 
       
   293 	multiPref.SetConnectionAttempts(2);
       
   294 	Test(multiPref.ConnectionAttempts()==2);
       
   295 
       
   296 	multiPref.SetConnectionAttempts(TCommDbMultiConnPref::KMaxMultiConnPrefCount+1);
       
   297 	Test(multiPref.ConnectionAttempts()==TCommDbMultiConnPref::KMaxMultiConnPrefCount);
       
   298 
       
   299         SetTestStepResult(EPass);	return TestStepResult();
       
   300 	}
       
   301 
       
   302 ////////////////////////////////////////
       
   303 //	Test step CTE_MultiConnPrefVersion
       
   304 /////////////////////////////////////////
       
   305 
       
   306 // constructor
       
   307 CTE_MultiConnPrefVersion::CTE_MultiConnPrefVersion()
       
   308 	{
       
   309 	// store the name of this test case
       
   310 	SetTestStepName(KMultiConnPrefVersion);
       
   311 	}
       
   312 
       
   313 // destructor
       
   314 CTE_MultiConnPrefVersion::~CTE_MultiConnPrefVersion()
       
   315 	{
       
   316 	}
       
   317 
       
   318 // do Test step CTE_MultiConnPrefVersion
       
   319 TVerdict CTE_MultiConnPrefVersion::doTestStepL()
       
   320 	{
       
   321 	INFO_PRINTF1(_L("CTE_MultiConnPrefVersion called "));
       
   322 	SetTestStepResult(EFail);    TCommDbMultiConnPref pref;	
       
   323 	TVersion dbVersion = pref.Version();
       
   324 	INFO_PRINTF4(_L("TCommDbMultiConnPref::Version -> Major=%d, Minor=%d, Build=%d"), TCommDbConnPref::KMajorVersionNumber, TCommDbConnPref::KMinorVersionNumber, TCommDbConnPref::KBuildVersionNumber);	
       
   325 	//Test for the expected return value
       
   326 	if ( dbVersion.iMinor == TCommDbConnPref::KMinorVersionNumber && 
       
   327          dbVersion.iMajor == TCommDbConnPref::KMajorVersionNumber && 
       
   328          dbVersion.iBuild == TCommDbConnPref::KBuildVersionNumber )
       
   329 		{
       
   330 		SetTestStepResult(EPass);
       
   331 		}
       
   332     return TestStepResult();
       
   333 	}
       
   334 	
       
   335 
       
   336 ///////////////////////////////////////////
       
   337 //	Test step CTE_MultiConnectionAttempts
       
   338 ////////////////////////////////////////////
       
   339 
       
   340 // constructor
       
   341 CTE_MultiConnectionAttempts::CTE_MultiConnectionAttempts()
       
   342 	{
       
   343 	// store the name of this test case
       
   344 	SetTestStepName(KMultiConnectionAttempts);
       
   345 	}
       
   346 
       
   347 // destructor
       
   348 CTE_MultiConnectionAttempts::~CTE_MultiConnectionAttempts()
       
   349 	{
       
   350 	}	
       
   351 	
       
   352 // do Test step CTE_MultiConnectionAttempts
       
   353 TVerdict CTE_MultiConnectionAttempts::doTestStepL( )
       
   354 	{
       
   355 	INFO_PRINTF1(_L("Step CTE_MultiConnectionAttempts called "));
       
   356 	SetTestStepResult(EFail);
       
   357 	TCommDbMultiConnPref prefPtr;	
       
   358 	TInt numAttempts = prefPtr.ConnectionAttempts();
       
   359 	INFO_PRINTF3(_L("Expected NumAttempts:= %d, Actual NumAttempts:=%d"), TCommDbMultiConnPref::KMaxMultiConnPrefCount,numAttempts);
       
   360 	if(numAttempts != TCommDbMultiConnPref::KMaxMultiConnPrefCount )
       
   361 		{
       
   362 		return TestStepResult();
       
   363 		}
       
   364 	numAttempts	 = 3 ;
       
   365 	prefPtr.SetConnectionAttempts(numAttempts);
       
   366 	TInt attempsCheck = prefPtr.ConnectionAttempts();
       
   367 	INFO_PRINTF3(_L("Expected NumAttempts:= %d, Actual NumAttempts:=%d"), TCommDbMultiConnPref::KMaxMultiConnPrefCount,attempsCheck);
       
   368 	INFO_PRINTF1(_L("This test fails because  no. of attempts is > 2"));
       
   369 	if(numAttempts == attempsCheck )
       
   370 		{
       
   371 		SetTestStepResult(EFail);
       
   372 		}
       
   373 	return TestStepResult();
       
   374 	}
       
   375 	
       
   376 	
       
   377 	
       
   378