commsconfig/commsdatabaseshim/TE_commdb/src/Step_020_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 020.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_020_xx.h"
       
    28 
       
    29 /////////////////////
       
    30 //	Test step 020.01
       
    31 /////////////////////
       
    32 
       
    33 // constructor
       
    34 CCommDbTest020_01::CCommDbTest020_01()
       
    35 	{
       
    36 	// store the name of this test case
       
    37 	SetTestStepName(_L("step_020_01"));
       
    38 	}
       
    39 
       
    40 // destructor
       
    41 CCommDbTest020_01::~CCommDbTest020_01()
       
    42 	{
       
    43 	}
       
    44 
       
    45 
       
    46 TVerdict CCommDbTest020_01::doTestStepPreambleL()
       
    47 	{
       
    48 	openDbL();
       
    49         SetTestStepResult(EPass);	return TestStepResult();
       
    50 	}
       
    51 
       
    52 TInt CCommDbTest020_01::executeStepL()
       
    53 	{
       
    54 	TInt ret=KErrGeneral;
       
    55 	TBuf<64> buffer;
       
    56 
       
    57 	_LIT(KAgent,"Agent");
       
    58 
       
    59 	TRAPD(r1,iTheDb->SetAgentL(TPtrC(DIAL_OUT_ISP),KAgent));
       
    60 	TRAPD(r2,iTheDb->GetAgentL(TPtrC(DIAL_OUT_ISP),buffer));
       
    61 
       
    62 	if(r1==KErrNotSupported && r2==KErrNotSupported)
       
    63 		{
       
    64 		return KErrNotSupported;
       
    65 		}
       
    66 	
       
    67 	return ret;
       
    68 	}
       
    69 
       
    70 
       
    71 
       
    72 TVerdict CCommDbTest020_01::doTestStepL( )
       
    73 	{
       
    74 	INFO_PRINTF1(_L("Step 020.01 called "));
       
    75 
       
    76 
       
    77 	if ( executeStepL() == KErrNotSupported )
       
    78 		SetTestStepResult(EPass);	else
       
    79 		SetTestStepResult(EFail);
       
    80 	return TestStepResult();
       
    81 	}
       
    82 
       
    83 /////////////////////
       
    84 //	Test step 020.02
       
    85 /////////////////////
       
    86 
       
    87 // constructor
       
    88 CCommDbTest020_02::CCommDbTest020_02()
       
    89 	{
       
    90 	// store the name of this test case
       
    91 	SetTestStepName(_L("step_020_02"));
       
    92 	}
       
    93 
       
    94 // destructor
       
    95 CCommDbTest020_02::~CCommDbTest020_02()
       
    96 	{
       
    97 	}
       
    98 
       
    99 
       
   100 TVerdict CCommDbTest020_02::doTestStepPreambleL()
       
   101 	{	
       
   102 	openDbL();
       
   103         SetTestStepResult(EPass);	return TestStepResult();
       
   104 	}
       
   105 
       
   106 
       
   107 TInt CCommDbTest020_02::executeStepL()
       
   108 	{
       
   109 	TInt ret=KErrGeneral;
       
   110 	TBuf<64> buffer;
       
   111 
       
   112 	_LIT(KAgent1,"Agent1");
       
   113 	_LIT(KAgentExt,"Csd");
       
   114 
       
   115 	TRAPD(r1,iTheDb->SetAgentL(TPtrC(DIAL_OUT_ISP),KAgent1));
       
   116 
       
   117 	TRAPD(r2,iTheDb->SetAgentExtL(TPtrC(DIAL_OUT_ISP),KAgentExt));
       
   118 	TRAPD(r3,iTheDb->GetAgentExtL(TPtrC(DIAL_OUT_ISP),buffer));
       
   119 	if(r3 != KErrNone)
       
   120 		{
       
   121 		return r3;
       
   122 		}
       
   123 
       
   124 	if(r1==KErrNotSupported && r2==KErrNotSupported)
       
   125 		{
       
   126 		return KErrNotSupported;
       
   127 		}
       
   128 	
       
   129 	return ret;
       
   130 	}
       
   131 
       
   132 
       
   133 
       
   134 TVerdict CCommDbTest020_02::doTestStepL( )
       
   135 	{
       
   136 	INFO_PRINTF1(_L("Step 020.02 called "));
       
   137 
       
   138 
       
   139 	if ( executeStepL() == KErrNotSupported )
       
   140 		SetTestStepResult(EPass);	else
       
   141 		SetTestStepResult(EFail);
       
   142 	return TestStepResult();
       
   143 	}
       
   144 
       
   145 
       
   146 /////////////////////
       
   147 //	Test step 020.03
       
   148 /////////////////////
       
   149 
       
   150 // constructor
       
   151 CCommDbTest020_03::CCommDbTest020_03()
       
   152 	{
       
   153 	// store the name of this test case
       
   154 	SetTestStepName(_L("step_020_03"));
       
   155 	}
       
   156 
       
   157 // destructor
       
   158 CCommDbTest020_03::~CCommDbTest020_03()
       
   159 	{
       
   160 	}
       
   161 
       
   162 
       
   163 TVerdict CCommDbTest020_03::doTestStepPreambleL()
       
   164 	{	
       
   165 	openDbL();
       
   166         SetTestStepResult(EPass);	return TestStepResult();
       
   167 	}
       
   168 
       
   169 
       
   170 TInt CCommDbTest020_03::executeStepL()
       
   171 	{
       
   172 	TInt ret=KErrGeneral;
       
   173 
       
   174 	//Try to set the agent for a non-service table
       
   175 	_LIT(KAgent1,"Agent1");
       
   176 
       
   177 	TRAPD( r, iTheDb->SetAgentL(TPtrC(LOCATION),KAgent1) );
       
   178 	if (r==KErrNotSupported )
       
   179 		ret = r;
       
   180 	
       
   181 	return ret;
       
   182 	}
       
   183 
       
   184 
       
   185 
       
   186 TVerdict CCommDbTest020_03::doTestStepL( )
       
   187 	{
       
   188 	INFO_PRINTF1(_L("Step 020.03 called "));
       
   189 
       
   190 
       
   191 	if ( executeStepL() == KErrNotSupported )
       
   192 		SetTestStepResult(EPass);	else
       
   193 		SetTestStepResult(EFail);
       
   194 	return TestStepResult();
       
   195 	}
       
   196 
       
   197 
       
   198 
       
   199 /////////////////////
       
   200 //	Test step 020.04
       
   201 /////////////////////
       
   202 
       
   203 // constructor
       
   204 CCommDbTest020_04::CCommDbTest020_04()
       
   205 	{
       
   206 	// store the name of this test case
       
   207 	SetTestStepName(_L("step_020_04"));
       
   208 	}
       
   209 
       
   210 // destructor
       
   211 CCommDbTest020_04::~CCommDbTest020_04()
       
   212 	{
       
   213 	}
       
   214 
       
   215 
       
   216 TVerdict CCommDbTest020_04::doTestStepPreambleL()
       
   217 	{	
       
   218 	openDbL();
       
   219         SetTestStepResult(EPass);	return TestStepResult();
       
   220 	}
       
   221 
       
   222 
       
   223 TInt CCommDbTest020_04::executeStepL()
       
   224 	{
       
   225 	TInt ret=KErrGeneral;
       
   226 
       
   227 
       
   228 	//Try to set the agent extension for a non-service table
       
   229 
       
   230 	_LIT(KAgentExt,"Csd");
       
   231 
       
   232 	TRAPD(r, iTheDb->SetAgentExtL(TPtrC(LOCATION), KAgentExt) );
       
   233 	if ( r==KErrNotSupported )
       
   234 		ret = r;
       
   235 	
       
   236 	return ret;
       
   237 	}
       
   238 
       
   239 
       
   240 
       
   241 TVerdict CCommDbTest020_04::doTestStepL( )
       
   242 	{
       
   243 	INFO_PRINTF1(_L("Step 020.04 called "));
       
   244 
       
   245 
       
   246 	if ( executeStepL() == KErrNotSupported )
       
   247 		SetTestStepResult(EPass);	else
       
   248 		SetTestStepResult(EFail);
       
   249 	return TestStepResult();
       
   250 	}
       
   251 
       
   252 
       
   253 
       
   254 
       
   255 
       
   256 
       
   257 /////////////////////
       
   258 //	Test step 020.05
       
   259 /////////////////////
       
   260 
       
   261 // constructor
       
   262 CCommDbTest020_05::CCommDbTest020_05()
       
   263 	{
       
   264 	// store the name of this test case
       
   265 	SetTestStepName(_L("step_020_05"));
       
   266 	}
       
   267 
       
   268 // destructor
       
   269 CCommDbTest020_05::~CCommDbTest020_05()
       
   270 	{
       
   271 	}
       
   272 
       
   273 
       
   274 TVerdict CCommDbTest020_05::doTestStepPreambleL()
       
   275 	{	
       
   276 	openDbL();
       
   277         SetTestStepResult(EPass);	return TestStepResult();
       
   278 	}
       
   279 
       
   280 
       
   281 TInt CCommDbTest020_05::executeStepL()
       
   282 	{
       
   283 	TInt ret=KErrGeneral;
       
   284 
       
   285 	//Try to open a view on the agent table
       
   286 	
       
   287 	TRAPD(r, iTheView = iTheDb->OpenTableLC(_L("NonExisting")); CleanupStack::Pop(); );
       
   288 
       
   289 	if ( r==KErrNotFound )
       
   290 		ret = r;
       
   291 
       
   292 	return ret;
       
   293 	}
       
   294 
       
   295 
       
   296 
       
   297 TVerdict CCommDbTest020_05::doTestStepL( )
       
   298 	{
       
   299 
       
   300 	if ( executeStepL() == KErrNotFound )
       
   301 		SetTestStepResult(EPass);	else
       
   302 		SetTestStepResult(EFail);
       
   303 	return TestStepResult();
       
   304 	}
       
   305 
       
   306 
       
   307 
       
   308 /////////////////////
       
   309 //	Test step 020.06
       
   310 /////////////////////
       
   311 
       
   312 // constructor
       
   313 CCommDbTest020_06::CCommDbTest020_06()
       
   314 	{
       
   315 	// store the name of this test case
       
   316 	SetTestStepName(_L("step_020_06"));
       
   317 	}
       
   318 
       
   319 // destructor
       
   320 CCommDbTest020_06::~CCommDbTest020_06()
       
   321 	{
       
   322 	}
       
   323 
       
   324 
       
   325 TVerdict CCommDbTest020_06::doTestStepPreambleL()
       
   326 	{	
       
   327 	openDbL();
       
   328         SetTestStepResult(EPass);	return TestStepResult();
       
   329 	}
       
   330 
       
   331 TInt CCommDbTest020_06::executeStepL()
       
   332 	{
       
   333 	TInt ret=KErrGeneral;
       
   334 	TBuf<64> buffer;
       
   335 
       
   336 	//Check that the agent setting can be overridden
       
   337 
       
   338 	_LIT(KAgent1,"Agent1");
       
   339 	_LIT(KAgent2,"Agent2");
       
   340 
       
   341 	//Set the agent 
       
   342 	TRAPD(r1,iTheDb->SetAgentL(TPtrC(DIAL_OUT_ISP),KAgent1));
       
   343 	//Add a new agent and verify
       
   344 	TRAPD(r2,iTheDb->SetAgentL(TPtrC(DIAL_OUT_ISP),KAgent2));
       
   345 	TRAPD(r3,iTheDb->GetAgentL(TPtrC(DIAL_OUT_ISP),buffer));
       
   346 	if (r1==KErrNotSupported && r2==KErrNotSupported && r3==KErrNotSupported)
       
   347 		ret = KErrNotSupported;
       
   348 
       
   349 	return ret;
       
   350 	}
       
   351 
       
   352 
       
   353 
       
   354 TVerdict CCommDbTest020_06::doTestStepL( )
       
   355 	{
       
   356 	INFO_PRINTF1(_L("Step 020.06 called "));
       
   357 
       
   358 
       
   359 	if ( executeStepL() == KErrNotSupported )
       
   360 		SetTestStepResult(EPass);	else
       
   361 		SetTestStepResult(EFail);
       
   362 	return TestStepResult();
       
   363 	}
       
   364 
       
   365 
       
   366 /////////////////////
       
   367 //	Test step 020.07
       
   368 /////////////////////
       
   369 
       
   370 // constructor
       
   371 CCommDbTest020_07::CCommDbTest020_07()
       
   372 	{
       
   373 	// store the name of this test case
       
   374 	SetTestStepName(_L("step_020_07"));
       
   375 	}
       
   376 
       
   377 // destructor
       
   378 CCommDbTest020_07::~CCommDbTest020_07()
       
   379 	{
       
   380 	}
       
   381 
       
   382 
       
   383 TVerdict CCommDbTest020_07::doTestStepPreambleL()
       
   384 	{	
       
   385 	openDbL();
       
   386         SetTestStepResult(EPass);	return TestStepResult();
       
   387 	}
       
   388 
       
   389 TInt CCommDbTest020_07::executeStepL()
       
   390 	{
       
   391 	TInt ret=KErrGeneral;
       
   392 	TBuf<64> buffer;
       
   393 
       
   394 	//Check that the agent settings can be deleted
       
   395 
       
   396 	_LIT(KAgent,"Agent");
       
   397 	_LIT(KExtension,"psd");
       
   398 
       
   399 	//Set the agent 
       
   400 	TRAPD(r1,iTheDb->SetAgentL(TPtrC(DIAL_OUT_ISP),KAgent));
       
   401 	TRAPD(r2,iTheDb->SetAgentExtL(TPtrC(DIAL_OUT_ISP),KExtension));
       
   402 
       
   403 	//Clear the settings
       
   404 	TRAPD(r3,iTheDb->ClearAgentAndExtL( TPtrC(DIAL_OUT_ISP)));
       
   405 
       
   406 	//Now try to read the settings
       
   407 	TRAPD( r4, iTheDb->GetAgentL(TPtrC(DIAL_OUT_ISP),buffer) );
       
   408 	TRAPD( r5, iTheDb->GetAgentExtL(TPtrC(DIAL_OUT_ISP),buffer) );
       
   409 
       
   410 	if(r1==KErrNotSupported && r2==KErrNotSupported && r3==KErrNotSupported
       
   411 		&& r4==KErrNotSupported && r5==KErrNotSupported)
       
   412 		{
       
   413 		ret = KErrNotSupported;
       
   414 		}
       
   415 
       
   416 	return ret;
       
   417 	}
       
   418 
       
   419 
       
   420 
       
   421 TVerdict CCommDbTest020_07::doTestStepL( )
       
   422 	{
       
   423 	INFO_PRINTF1(_L("Step 020.07 called "));
       
   424 
       
   425 
       
   426 	if ( executeStepL() == KErrNotSupported )
       
   427 		SetTestStepResult(EPass);	else
       
   428 		SetTestStepResult(EFail);
       
   429 	return TestStepResult();
       
   430 	}
       
   431 
       
   432 
       
   433 
       
   434 /////////////////////
       
   435 //	Test step 020.08
       
   436 /////////////////////
       
   437 
       
   438 // constructor
       
   439 CCommDbTest020_08::CCommDbTest020_08()
       
   440 	{
       
   441 	// store the name of this test case
       
   442 	SetTestStepName(_L("step_020_08"));
       
   443 	}
       
   444 
       
   445 // destructor
       
   446 CCommDbTest020_08::~CCommDbTest020_08()
       
   447 	{
       
   448 	}
       
   449 
       
   450 TVerdict CCommDbTest020_08::doTestStepL( )
       
   451 	{
       
   452 	INFO_PRINTF1(_L("Step 020.08 called "));
       
   453 
       
   454 	SetTestStepResult(EPass);
       
   455 		// Heap test for 020.01
       
   456 
       
   457 	CCommDbTest020_01* step020_01 = new(ELeave) CCommDbTest020_01;
       
   458 	CleanupStack::PushL(step020_01);
       
   459 	if ( doTestStepWithHeapFailureL( *step020_01, KErrNotSupported) == EFail )
       
   460 		SetTestStepResult(EFail);	CleanupStack::PopAndDestroy(step020_01);
       
   461 
       
   462 
       
   463 		// Heap test for 020.02
       
   464 
       
   465 	CCommDbTest020_02* step020_02 = new CCommDbTest020_02;
       
   466 	CleanupStack::PushL(step020_02);
       
   467 	if ( doTestStepWithHeapFailureL( *step020_02, KErrNotSupported) == EFail )
       
   468 		SetTestStepResult(EFail);	CleanupStack::PopAndDestroy(step020_02);
       
   469 
       
   470 		// Heap test for 020.03
       
   471 
       
   472 	CCommDbTest020_03* step020_03 = new CCommDbTest020_03;
       
   473 	CleanupStack::PushL(step020_03);
       
   474 	if ( doTestStepWithHeapFailureL( *step020_03, KErrNotSupported) == EFail )
       
   475 		SetTestStepResult(EFail);	CleanupStack::PopAndDestroy(step020_03);
       
   476 
       
   477 
       
   478 		// Heap test for 020.04
       
   479 
       
   480 	CCommDbTest020_04* step020_04 = new CCommDbTest020_04;
       
   481 	CleanupStack::PushL(step020_04);
       
   482 	if ( doTestStepWithHeapFailureL( *step020_04, KErrNotSupported) == EFail )
       
   483 		SetTestStepResult(EFail);	CleanupStack::PopAndDestroy(step020_04);
       
   484 
       
   485 
       
   486 		// Heap test for 020.06
       
   487 
       
   488 	CCommDbTest020_06* step020_06 = new CCommDbTest020_06;
       
   489 	CleanupStack::PushL(step020_06);
       
   490 	if ( doTestStepWithHeapFailureL( *step020_06, KErrNotSupported) == EFail )
       
   491 		SetTestStepResult(EFail);	CleanupStack::PopAndDestroy(step020_06);
       
   492 
       
   493 
       
   494 
       
   495 		// Heap test for 020.07
       
   496 
       
   497 	CCommDbTest020_07* step020_07 = new CCommDbTest020_07;
       
   498 	CleanupStack::PushL(step020_07);
       
   499 	if ( doTestStepWithHeapFailureL( *step020_07, KErrNotSupported) == EFail )
       
   500 		SetTestStepResult(EFail);	CleanupStack::PopAndDestroy(step020_07);
       
   501 
       
   502 
       
   503 
       
   504 
       
   505 	return TestStepResult();	
       
   506 
       
   507 }