commsconfig/commsdatabaseshim/TE_commdb/src/Step_021_xx.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 // This contains CommDb Unit Test Cases 021.XX
       
    19 
       
    20 // EPOC includes
       
    21 #include <e32base.h>
       
    22 #include <commdb.h>
       
    23 #include <d32comm.h>
       
    24 
       
    25 // Test system includes
       
    26 #include "Teststepcommdb.h"
       
    27 #include "Step_021_xx.h"
       
    28 
       
    29 
       
    30 /////////////////////
       
    31 //	Test step 021.01
       
    32 /////////////////////
       
    33 
       
    34 // constructor
       
    35 CCommDbTest021_01::CCommDbTest021_01()
       
    36 	{
       
    37 	// store the name of this test case
       
    38 	SetTestStepName(_L("step_021_01"));
       
    39 	}
       
    40 
       
    41 // destructor
       
    42 CCommDbTest021_01::~CCommDbTest021_01()
       
    43 	{
       
    44 	}
       
    45 
       
    46 
       
    47 TVerdict CCommDbTest021_01::doTestStepPreambleL()
       
    48 	{
       
    49 	// Have a temp copy of database
       
    50 	openDbL();
       
    51         SetTestStepResult(EPass);	return TestStepResult();
       
    52 	}
       
    53 
       
    54 TInt CCommDbTest021_01::executeStepL()
       
    55 	{
       
    56 	TInt ret=KErrGeneral;
       
    57 
       
    58 	//Sets and verifies the client timeout
       
    59 
       
    60 	//Set up the agent first
       
    61 	_LIT(KAgent1,"Agent1");
       
    62 	_LIT(KAgentExt,"Csd");
       
    63 	TRAPD(r1,iTheDb->SetAgentL(TPtrC(DIAL_OUT_ISP),KAgent1));
       
    64 	TRAPD(r2,iTheDb->SetAgentExtL(TPtrC(DIAL_OUT_ISP),KAgentExt));
       
    65 
       
    66 	TUint timeout = 6;
       
    67 	TInt value(0);
       
    68 
       
    69 	TRAPD(r3,iTheDb->SetAgentClientTimeoutL(TPtrC(DIAL_OUT_ISP),timeout));
       
    70 	TRAPD(r4,value = iTheDb->GetAgentClientTimeoutL(TPtrC(DIAL_OUT_ISP)));
       
    71 
       
    72 	if(r1==KErrNotSupported && r2==KErrNotSupported && r3==KErrNotSupported
       
    73 		&& (r4==KErrNotSupported || value==KErrNotSupported))
       
    74 		{
       
    75 		return KErrNotSupported;
       
    76 		}
       
    77 	
       
    78 	return ret;
       
    79 	}
       
    80 
       
    81 
       
    82 
       
    83 TVerdict CCommDbTest021_01::doTestStepL( )
       
    84 	{
       
    85 	INFO_PRINTF1(_L("Step 021.01 called "));
       
    86 
       
    87 
       
    88 	if ( executeStepL() == KErrNotSupported )
       
    89 		SetTestStepResult(EPass);	else
       
    90 		SetTestStepResult(EFail);
       
    91 	return TestStepResult();
       
    92 	}
       
    93 
       
    94 
       
    95 /////////////////////
       
    96 //	Test step 021.02
       
    97 /////////////////////
       
    98 
       
    99 // constructor
       
   100 CCommDbTest021_02::CCommDbTest021_02()
       
   101 	{
       
   102 	// store the name of this test case
       
   103 	SetTestStepName(_L("step_021_02"));
       
   104 	}
       
   105 
       
   106 // destructor
       
   107 CCommDbTest021_02::~CCommDbTest021_02()
       
   108 	{
       
   109 	}
       
   110 
       
   111 
       
   112 TVerdict CCommDbTest021_02::doTestStepPreambleL()
       
   113 	{	
       
   114 	openDbL();
       
   115         SetTestStepResult(EPass);	return TestStepResult();
       
   116 	}
       
   117 
       
   118 TInt CCommDbTest021_02::executeStepL()
       
   119 	{
       
   120 	TInt ret=KErrGeneral;
       
   121 
       
   122 	//Try to set the timeout for an incorrect table
       
   123 
       
   124 	//Set up the agent first
       
   125 	_LIT(KAgent1,"Agent1");
       
   126 	_LIT(KAgentExt,"Csd");
       
   127 	TRAPD(r1,iTheDb->SetAgentL(TPtrC(DIAL_OUT_ISP),KAgent1));
       
   128 	TRAPD(r2,iTheDb->SetAgentExtL(TPtrC(DIAL_OUT_ISP),KAgentExt));
       
   129 
       
   130 	TUint timeout = 0x100;
       
   131 	TRAPD(r3, iTheDb->SetAgentClientTimeoutL(TPtrC(LOCATION), timeout));
       
   132 
       
   133 	if(r1==KErrNotSupported && r2==KErrNotSupported && r3==KErrNotSupported)
       
   134 		{
       
   135 		return KErrNotSupported;
       
   136 		}
       
   137 		
       
   138 	return ret;
       
   139 	}
       
   140 
       
   141 
       
   142 
       
   143 TVerdict CCommDbTest021_02::doTestStepL( )
       
   144 	{
       
   145 	INFO_PRINTF1(_L("Step 021.02 called "));
       
   146 
       
   147 
       
   148 	if ( executeStepL() == KErrNotSupported )
       
   149 		SetTestStepResult(EPass);	else
       
   150 		SetTestStepResult(EFail);
       
   151 	return TestStepResult();
       
   152 	}
       
   153 
       
   154 /////////////////////
       
   155 //	Test step 021.03
       
   156 /////////////////////
       
   157 
       
   158 // constructor
       
   159 CCommDbTest021_03::CCommDbTest021_03()
       
   160 	{
       
   161 	// store the name of this test case
       
   162 	SetTestStepName(_L("step_021_03"));
       
   163 	}
       
   164 
       
   165 // destructor
       
   166 CCommDbTest021_03::~CCommDbTest021_03()
       
   167 	{
       
   168 	}
       
   169 
       
   170 
       
   171 TVerdict CCommDbTest021_03::doTestStepPreambleL()
       
   172 	{	
       
   173 	openDbL();
       
   174         SetTestStepResult(EPass);	return TestStepResult();
       
   175 	}
       
   176 
       
   177 TInt CCommDbTest021_03::executeStepL()
       
   178 	{
       
   179 	TInt ret=KErrGeneral;
       
   180 
       
   181 	//Sets and verifies the routet timeout
       
   182 
       
   183 	//Set up the agent first
       
   184 	_LIT(KAgent1,"Agent1");
       
   185 	_LIT(KAgentExt,"Csd");
       
   186 	TRAPD(r1,iTheDb->SetAgentL(TPtrC(DIAL_OUT_ISP),KAgent1));
       
   187 	TRAPD(r2,iTheDb->SetAgentExtL(TPtrC(DIAL_OUT_ISP),KAgentExt));
       
   188 
       
   189 	TUint timeout = 0x100;
       
   190 	TInt value(0);
       
   191 
       
   192 	TRAPD(r3,iTheDb->SetAgentRouteTimeoutL(TPtrC(DIAL_OUT_ISP),timeout));
       
   193 	TRAPD(r4,value = iTheDb->GetAgentRouteTimeoutL(TPtrC(DIAL_OUT_ISP)));
       
   194 
       
   195 	if(r1==KErrNotSupported && r2==KErrNotSupported && r3==KErrNotSupported
       
   196 		&& (r4==KErrNotSupported || value==KErrNotSupported))
       
   197 		{
       
   198 		return KErrNotSupported;
       
   199 		}
       
   200 	
       
   201 	return ret;
       
   202 	}
       
   203 
       
   204 
       
   205 
       
   206 TVerdict CCommDbTest021_03::doTestStepL( )
       
   207 	{
       
   208 	INFO_PRINTF1(_L("Step 021.03 called "));
       
   209 
       
   210 
       
   211 	if ( executeStepL() == KErrNotSupported )
       
   212 		SetTestStepResult(EPass);	else
       
   213 		SetTestStepResult(EFail);
       
   214 	return TestStepResult();
       
   215 	}
       
   216 
       
   217 
       
   218 /////////////////////
       
   219 //	Test step 021.04
       
   220 /////////////////////
       
   221 
       
   222 // constructor
       
   223 CCommDbTest021_04::CCommDbTest021_04()
       
   224 	{
       
   225 	// store the name of this test case
       
   226 	SetTestStepName(_L("step_021_04"));
       
   227 	}
       
   228 
       
   229 // destructor
       
   230 CCommDbTest021_04::~CCommDbTest021_04()
       
   231 	{
       
   232 	}
       
   233 
       
   234 
       
   235 TVerdict CCommDbTest021_04::doTestStepPreambleL()
       
   236 	{	
       
   237 	openDbL();
       
   238         SetTestStepResult(EPass);	return TestStepResult();
       
   239 	}
       
   240 
       
   241 TInt CCommDbTest021_04::executeStepL()
       
   242 	{
       
   243 	TInt ret=KErrGeneral;
       
   244 
       
   245 	//Try to set the timeout for an incorrect table
       
   246 
       
   247 	//Set up the agent first
       
   248 	_LIT(KAgent1,"Agent1");
       
   249 	_LIT(KAgentExt,"Csd");
       
   250 	TRAPD(r1,iTheDb->SetAgentL(TPtrC(DIAL_OUT_ISP),KAgent1));
       
   251 	TRAPD(r2,iTheDb->SetAgentExtL(TPtrC(DIAL_OUT_ISP),KAgentExt));
       
   252 
       
   253 	TUint timeout = 0x100;
       
   254 	
       
   255 	TRAPD(r3, iTheDb->SetAgentRouteTimeoutL(TPtrC(LOCATION), timeout) );
       
   256 
       
   257 	if(r1==KErrNotSupported && r2==KErrNotSupported && r3==KErrNotSupported)
       
   258 		{
       
   259 		return KErrNotSupported;
       
   260 		}
       
   261 	
       
   262 	return ret;
       
   263 	}
       
   264 
       
   265 
       
   266 
       
   267 TVerdict CCommDbTest021_04::doTestStepL( )
       
   268 	{
       
   269 	INFO_PRINTF1(_L("Step 021.04 called "));
       
   270 
       
   271 
       
   272 	if ( executeStepL() == KErrNotSupported )
       
   273 		SetTestStepResult(EPass);	else
       
   274 		SetTestStepResult(EFail);
       
   275 	return TestStepResult();
       
   276 	}
       
   277 
       
   278 
       
   279 
       
   280 
       
   281 /////////////////////
       
   282 //	Test step 021.05
       
   283 /////////////////////
       
   284 
       
   285 // constructor
       
   286 CCommDbTest021_05::CCommDbTest021_05()
       
   287 	{
       
   288 	// store the name of this test case
       
   289 	SetTestStepName(_L("step_021_05"));
       
   290 	}
       
   291 
       
   292 // destructor
       
   293 CCommDbTest021_05::~CCommDbTest021_05()
       
   294 	{
       
   295 	}
       
   296 
       
   297 TVerdict CCommDbTest021_05::doTestStepL( )
       
   298 	{
       
   299 	INFO_PRINTF1(_L("Step 021.05 called "));
       
   300 
       
   301 	SetTestStepResult(EPass);
       
   302 		// Heap test for 021.01
       
   303 
       
   304 	CCommDbTest021_01* step021_01 = new(ELeave) CCommDbTest021_01;
       
   305 	CleanupStack::PushL(step021_01);
       
   306 	if ( doTestStepWithHeapFailureL( *step021_01, KErrNotSupported) == EFail )
       
   307 		SetTestStepResult(EFail);	CleanupStack::PopAndDestroy(step021_01);
       
   308 
       
   309 
       
   310 		// Heap test for 021.02
       
   311 
       
   312 	CCommDbTest021_02* step021_02 = new CCommDbTest021_02;
       
   313 	CleanupStack::PushL(step021_02);
       
   314 	if ( doTestStepWithHeapFailureL( *step021_02, KErrNotSupported) == EFail )
       
   315 		SetTestStepResult(EFail);	CleanupStack::PopAndDestroy(step021_02);
       
   316 
       
   317 		// Heap test for 021.03
       
   318 
       
   319 	CCommDbTest021_03* step021_03 = new CCommDbTest021_03;
       
   320 	CleanupStack::PushL(step021_03);
       
   321 	if ( doTestStepWithHeapFailureL( *step021_03, KErrNotSupported) == EFail )
       
   322 		SetTestStepResult(EFail);	CleanupStack::PopAndDestroy(step021_03);
       
   323 
       
   324 
       
   325 		// Heap test for 021.04
       
   326 
       
   327 	CCommDbTest021_04* step021_04 = new CCommDbTest021_04;
       
   328 	CleanupStack::PushL(step021_04);
       
   329 	if ( doTestStepWithHeapFailureL( *step021_04, KErrNotSupported) == EFail )
       
   330 		SetTestStepResult(EFail);	CleanupStack::PopAndDestroy(step021_04);
       
   331 
       
   332 
       
   333 
       
   334 	return TestStepResult();	
       
   335 
       
   336 }