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