commsconfig/commsdatabaseshim/ts_commdb/Step_018_xx.cpp
changeset 72 ae47d0499bee
parent 68 5da8188e392b
child 77 c9776eadbffd
equal deleted inserted replaced
68:5da8188e392b 72:ae47d0499bee
     1 // Copyright (c) 2001-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 // This contains CommDb Unit Test Cases 018.XX
       
    15 // 
       
    16 //
       
    17 
       
    18 // EPOC includes
       
    19 #include <e32base.h>
       
    20 #include <commdb.h>
       
    21 #include <d32comm.h>
       
    22 
       
    23 // Test system includes
       
    24 #include <networking/log.h>
       
    25 #include <networking/teststep.h>
       
    26 #include "Teststepcommdb.h"
       
    27 #include "TestSuiteCommdb.h"
       
    28 #include "Step_018_xx.h"
       
    29 
       
    30 
       
    31 
       
    32 //
       
    33 //	Test step 018.01
       
    34 //
       
    35 
       
    36 // constructor
       
    37 CCommDbTest018_01::CCommDbTest018_01()
       
    38 	{
       
    39 	// store the name of this test case
       
    40 	iTestStepName = _L("step_018_01");
       
    41 	}
       
    42 
       
    43 // destructor
       
    44 CCommDbTest018_01::~CCommDbTest018_01()
       
    45 	{
       
    46 	}
       
    47 
       
    48 
       
    49 TVerdict CCommDbTest018_01::doTestStepPreambleL()
       
    50 	{	
       
    51 	openDbAndViewL(TPtrC(DIAL_OUT_ISP));
       
    52 	return EPass;
       
    53 	}
       
    54 
       
    55 
       
    56 TInt CCommDbTest018_01::executeStepL()
       
    57 	{
       
    58 	TInt ret=KErrNone;
       
    59 
       
    60 	//Verify DeleteRecord() by deleting the records in the Dial out ISP
       
    61 	//table and then checking for their lack of existance
       
    62 
       
    63 	CDBLEAVE( iTheView->GotoFirstRecord(), KErrNone );
       
    64 	CDBLEAVE( iTheView->DeleteRecord(), KErrNone );
       
    65 
       
    66 	CDBLEAVE( iTheView->GotoNextRecord(), KErrNone );
       
    67 	CDBLEAVE( iTheView->DeleteRecord(), KErrNone );
       
    68 
       
    69 	CDBLEAVE( iTheView->GotoNextRecord(), KErrNone );
       
    70 	CDBLEAVE( iTheView->DeleteRecord(), KErrNone );
       
    71 	//The table will now be empty
       
    72 
       
    73 	delete iTheView;
       
    74 	iTheView = 0;
       
    75 	iTheView = iTheDb->OpenTableLC(TPtrC(DIAL_OUT_ISP ) );
       
    76 	CleanupStack::Pop();
       
    77 
       
    78 	CDBLEAVE( iTheView->GotoFirstRecord(), KErrNotFound );
       
    79 	
       
    80 	return ret;
       
    81 	}
       
    82 
       
    83 
       
    84 
       
    85 TVerdict CCommDbTest018_01::doTestStepL( )
       
    86 	{
       
    87 	Log(_L("Step 018.01 called "));
       
    88 
       
    89 
       
    90 	if ( executeStepL() == KErrNone )
       
    91 		iTestStepResult = EPass;
       
    92 	else
       
    93 		iTestStepResult = EFail;
       
    94 
       
    95 	return iTestStepResult;
       
    96 	}
       
    97 
       
    98 
       
    99 //
       
   100 //	Test step 018.02
       
   101 //
       
   102 
       
   103 // constructor
       
   104 CCommDbTest018_02::CCommDbTest018_02()
       
   105 	{
       
   106 	// store the name of this test case
       
   107 	iTestStepName = _L("step_018_02");
       
   108 	}
       
   109 
       
   110 // destructor
       
   111 CCommDbTest018_02::~CCommDbTest018_02()
       
   112 	{
       
   113 	}
       
   114 
       
   115 
       
   116 TVerdict CCommDbTest018_02::doTestStepPreambleL()
       
   117 	{	
       
   118 	copyTestDatabase( EDatabase_1 );
       
   119 	openDbAndViewL(TPtrC(DIAL_OUT_ISP));
       
   120 	return EPass;
       
   121 	}
       
   122 
       
   123 
       
   124 TInt CCommDbTest018_02::executeStepL()
       
   125 	{
       
   126 	TInt ret=KErrNone;
       
   127 
       
   128 	//Try to delete the last record in a view and then 
       
   129 	//verify its deletion
       
   130 
       
   131 	CDBLEAVE( iTheView->GotoFirstRecord(), KErrNone );
       
   132 	CDBLEAVE( iTheView->GotoNextRecord(), KErrNone );
       
   133 	CDBLEAVE( iTheView->GotoNextRecord(), KErrNone );
       
   134 	//The DAIL_OUT_ISP table only has 3 records, so we know
       
   135 	//we are at the end.
       
   136 
       
   137 	//Delete the last record
       
   138 	CDBLEAVE( iTheView->DeleteRecord(), KErrNone );
       
   139 
       
   140 	//The table should now only have 2 records
       
   141 	
       
   142 	delete iTheView;
       
   143 	iTheView = 0;
       
   144 	iTheView = iTheDb->OpenTableLC(TPtrC(DIAL_OUT_ISP ) );
       
   145 	CleanupStack::Pop();
       
   146 	CDBLEAVE( iTheView->GotoFirstRecord(), KErrNone );
       
   147 	CDBLEAVE( iTheView->GotoNextRecord(), KErrNone );
       
   148 	CDBLEAVE( iTheView->GotoNextRecord(), KErrNotFound ); //no more records
       
   149 	
       
   150 	return ret;
       
   151 	}
       
   152 
       
   153 
       
   154 
       
   155 TVerdict CCommDbTest018_02::doTestStepL( )
       
   156 	{
       
   157 	Log(_L("Step 018.02 called "));
       
   158 
       
   159 
       
   160 	if ( executeStepL() == KErrNone )
       
   161 		iTestStepResult = EPass;
       
   162 	else
       
   163 		iTestStepResult = EFail;
       
   164 
       
   165 	return iTestStepResult;
       
   166 	}
       
   167 
       
   168 //
       
   169 //	Test step 018.03
       
   170 //
       
   171 
       
   172 // constructor
       
   173 CCommDbTest018_03::CCommDbTest018_03()
       
   174 	{
       
   175 	// store the name of this test case
       
   176 	iTestStepName = _L("step_018_03");
       
   177 	}
       
   178 
       
   179 // destructor
       
   180 CCommDbTest018_03::~CCommDbTest018_03()
       
   181 	{
       
   182 	}
       
   183 
       
   184 
       
   185 TVerdict CCommDbTest018_03::doTestStepPreambleL()
       
   186 	{	
       
   187 	openDbAndViewL(TPtrC(IAP));
       
   188 	return EPass;
       
   189 	}
       
   190 
       
   191 
       
   192 TInt CCommDbTest018_03::executeStepL()
       
   193 	{
       
   194 	TInt ret=KErrNone;
       
   195 
       
   196 	//Delete record in empty view
       
   197 	CDBLEAVE( iTheView->DeleteRecord(), KErrNotFound );	
       
   198 
       
   199 	return ret;
       
   200 	}
       
   201 
       
   202 
       
   203 
       
   204 TVerdict CCommDbTest018_03::doTestStepL( )
       
   205 	{
       
   206 	Log(_L("Step 018.03 called "));
       
   207 
       
   208 
       
   209 	if ( executeStepL() == KErrNone )
       
   210 		iTestStepResult = EPass;
       
   211 	else
       
   212 		iTestStepResult = EFail;
       
   213 
       
   214 	return iTestStepResult;
       
   215 	}
       
   216 
       
   217 
       
   218 //
       
   219 //	Test step 018.04
       
   220 //
       
   221 
       
   222 // constructor
       
   223 CCommDbTest018_04::CCommDbTest018_04()
       
   224 	{
       
   225 	// store the name of this test case
       
   226 	iTestStepName = _L("step_018_04");
       
   227 	}
       
   228 
       
   229 // destructor
       
   230 CCommDbTest018_04::~CCommDbTest018_04()
       
   231 	{
       
   232 	}
       
   233 
       
   234 
       
   235 TVerdict CCommDbTest018_04::doTestStepPreambleL()
       
   236 	{	
       
   237 	openDbAndViewL(TPtrC(DIAL_IN_ISP));
       
   238 	return EPass;
       
   239 	}
       
   240 
       
   241 
       
   242 TInt CCommDbTest018_04::executeStepL()
       
   243 	{
       
   244 	TInt ret=KErrNone;
       
   245 
       
   246 	//Delete a read only record 
       
   247 
       
   248 	CDBLEAVE( iTheView->GotoFirstRecord(), KErrNone );
       
   249 	CDBLEAVE( iTheView->GotoNextRecord(), KErrNone );
       
   250 	CDBLEAVE( iTheView->GotoNextRecord(), KErrNone );
       
   251 	CDBLEAVE( iTheView->GotoNextRecord(), KErrNone );
       
   252 	CDBLEAVE( iTheView->GotoNextRecord(), KErrNone );
       
   253 
       
   254 	//Delete the read only record #5
       
   255 	CDBLEAVE( iTheView->DeleteRecord(), KErrNone );
       
   256 
       
   257 	//Open a new view and check that we've only 4 records left
       
   258 	delete iTheView;
       
   259 	iTheView = 0;
       
   260 	iTheView = iTheDb->OpenTableLC(TPtrC(DIAL_IN_ISP ) );
       
   261 	CleanupStack::Pop();
       
   262 	CDBLEAVE( iTheView->GotoFirstRecord(), KErrNone );
       
   263 	CDBLEAVE( iTheView->GotoNextRecord(), KErrNone );
       
   264 	CDBLEAVE( iTheView->GotoNextRecord(), KErrNone );
       
   265 	CDBLEAVE( iTheView->GotoNextRecord(), KErrNone );
       
   266 	CDBLEAVE( iTheView->GotoNextRecord(), KErrNotFound ); //no more records
       
   267 	
       
   268 
       
   269 	return ret;
       
   270 	}
       
   271 
       
   272 
       
   273 
       
   274 TVerdict CCommDbTest018_04::doTestStepL( )
       
   275 	{
       
   276 	Log(_L("Step 018.04 called "));
       
   277 
       
   278 
       
   279 	if ( executeStepL() == KErrNone )
       
   280 		iTestStepResult = EPass;
       
   281 	else
       
   282 		iTestStepResult = EFail;
       
   283 
       
   284 	return iTestStepResult;
       
   285 	}
       
   286 
       
   287 
       
   288 //
       
   289 //	Test step 018.05
       
   290 //
       
   291 
       
   292 // constructor
       
   293 CCommDbTest018_05::CCommDbTest018_05()
       
   294 	{
       
   295 	// store the name of this test case
       
   296 	iTestStepName = _L("step_018_05");
       
   297 	}
       
   298 
       
   299 // destructor
       
   300 CCommDbTest018_05::~CCommDbTest018_05()
       
   301 	{
       
   302 	}
       
   303 
       
   304 TVerdict CCommDbTest018_05::doTestStepL( )
       
   305 	{
       
   306 	Log(_L("Step 018.05 called "));
       
   307 
       
   308 	iTestStepResult = EPass;
       
   309 
       
   310 		// Heap test for 018.01
       
   311 
       
   312 	CCommDbTest018_01* step018_01 = new(ELeave) CCommDbTest018_01;
       
   313 	CleanupStack::PushL(step018_01);
       
   314 	step018_01->iSuite = iSuite;
       
   315 	if ( doTestStepWithHeapFailureL( *step018_01, KErrNone) == EFail )
       
   316 		iTestStepResult = EFail;
       
   317 	CleanupStack::PopAndDestroy(step018_01);
       
   318 
       
   319 
       
   320 	return iTestStepResult;	
       
   321 }
       
   322 
       
   323 
       
   324 //
       
   325 //	Test step 018.06
       
   326 //
       
   327 
       
   328 // constructor
       
   329 CCommDbTest018_06::CCommDbTest018_06()
       
   330 	{
       
   331 	// store the name of this test case
       
   332 	iTestStepName = _L("step_018_06");
       
   333 	}
       
   334 
       
   335 // destructor
       
   336 CCommDbTest018_06::~CCommDbTest018_06()
       
   337 	{
       
   338 	}
       
   339 
       
   340 TVerdict CCommDbTest018_06::doTestStepL( )
       
   341 	{
       
   342 	Log(_L("Step 018.06 called "));
       
   343 
       
   344 	iTestStepResult = EPass;
       
   345 	
       
   346 			// Heap test for 018.02
       
   347 
       
   348 	CCommDbTest018_02* step018_02 = new CCommDbTest018_02;
       
   349 	CleanupStack::PushL(step018_02);
       
   350 	step018_02->iSuite = iSuite;
       
   351 	if ( doTestStepWithHeapFailureL( *step018_02, KErrNone) == EFail )
       
   352 		iTestStepResult = EFail;
       
   353 	CleanupStack::PopAndDestroy(step018_02);
       
   354 	
       
   355 	return iTestStepResult;		
       
   356 	}
       
   357 	
       
   358 //
       
   359 //	Test step 018.07
       
   360 //
       
   361 
       
   362 // constructor
       
   363 CCommDbTest018_07::CCommDbTest018_07()
       
   364 	{
       
   365 	// store the name of this test case
       
   366 	iTestStepName = _L("step_018_07");
       
   367 	}
       
   368 
       
   369 // destructor
       
   370 CCommDbTest018_07::~CCommDbTest018_07()
       
   371 	{
       
   372 	}
       
   373 
       
   374 TVerdict CCommDbTest018_07::doTestStepL( )
       
   375 	{
       
   376 	Log(_L("Step 018.07 called "));
       
   377 
       
   378 	iTestStepResult = EPass;
       
   379 	
       
   380 		// Heap test for 018.03
       
   381 
       
   382 	CCommDbTest018_03* step018_03 = new CCommDbTest018_03;
       
   383 	CleanupStack::PushL(step018_03);
       
   384 	step018_03->iSuite = iSuite;
       
   385 	if ( doTestStepWithHeapFailureL( *step018_03, KErrNone) == EFail )
       
   386 		iTestStepResult = EFail;
       
   387 	CleanupStack::PopAndDestroy(step018_03);
       
   388 	
       
   389 	return iTestStepResult;		
       
   390 	}
       
   391 	
       
   392 //
       
   393 //	Test step 018.08
       
   394 //
       
   395 
       
   396 // constructor
       
   397 CCommDbTest018_08::CCommDbTest018_08()
       
   398 	{
       
   399 	// store the name of this test case
       
   400 	iTestStepName = _L("step_018_08");
       
   401 	}
       
   402 
       
   403 // destructor
       
   404 CCommDbTest018_08::~CCommDbTest018_08()
       
   405 	{
       
   406 	}
       
   407 
       
   408 TVerdict CCommDbTest018_08::doTestStepL( )
       
   409 	{
       
   410 	Log(_L("Step 018.08 called "));
       
   411 
       
   412 	iTestStepResult = EPass;
       
   413 	
       
   414 		// Heap test for 018.04
       
   415 
       
   416 	CCommDbTest018_04* step018_04 = new CCommDbTest018_04;
       
   417 	CleanupStack::PushL(step018_04);
       
   418 	step018_04->iSuite = iSuite;
       
   419 	if ( doTestStepWithHeapFailureL( *step018_04, KErrNone) == EFail )
       
   420 		iTestStepResult = EFail;
       
   421 	CleanupStack::PopAndDestroy(step018_04);
       
   422 	
       
   423 	return iTestStepResult;		
       
   424 	}
       
   425 	
       
   426 
       
   427 //EOF