commsconfig/commsdatabaseshim/TE_commdb/src/Step_010_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 010.XX
       
    19 
       
    20 // EPOC includes
       
    21 #include <e32base.h>
       
    22 #include <commdb.h>
       
    23 
       
    24 
       
    25 // Test system includes
       
    26 #include "Teststepcommdb.h"
       
    27 #include "Step_010_xx.h"
       
    28 
       
    29 
       
    30 
       
    31 /////////////////////
       
    32 //	Test step 010.001
       
    33 /////////////////////
       
    34 
       
    35 // constructor
       
    36 CCommDbTest010_01::CCommDbTest010_01()
       
    37 	{
       
    38 	// store the name of this test case
       
    39 	SetTestStepName(_L("step_010_01"));
       
    40 	}
       
    41 
       
    42 // destructor
       
    43 CCommDbTest010_01::~CCommDbTest010_01()
       
    44 	{
       
    45 	}
       
    46 
       
    47 TVerdict CCommDbTest010_01::doTestStepPreambleL()
       
    48 	{	
       
    49 	openDbAndViewL(TPtrC(DIAL_OUT_ISP));
       
    50         SetTestStepResult(EPass);	return TestStepResult();
       
    51 	}
       
    52 
       
    53 
       
    54 TInt CCommDbTest010_01::executeStepL()
       
    55 	{
       
    56 	TInt ret=KErrGeneral;
       
    57 
       
    58 
       
    59 	//This test must be executed on a populated table
       
    60 	CDBLEAVE( ret = iTheView->GotoFirstRecord(), KErrNone );
       
    61 
       
    62 
       
    63 	//Move through the records in the table until the last record is reached
       
    64 	while( ret == KErrNone )
       
    65 		{
       
    66 		TRAPD(r, ret = iTheView->GotoNextRecord() );
       
    67 		if ( r!= KErrNone )
       
    68 			User::Leave(r);
       
    69 		}
       
    70 
       
    71 
       
    72 	
       
    73 	return ret;
       
    74 	}
       
    75 
       
    76 
       
    77 TVerdict CCommDbTest010_01::doTestStepL( )
       
    78 	{
       
    79 	INFO_PRINTF1(_L("Step 010.01 called "));
       
    80 
       
    81 
       
    82 	if ( executeStepL() == KErrNotFound )
       
    83 		SetTestStepResult(EPass);	else
       
    84 		SetTestStepResult(EFail);
       
    85 
       
    86 	return TestStepResult();
       
    87 	}
       
    88 
       
    89 
       
    90 
       
    91 
       
    92 /////////////////////
       
    93 //	Test step 010.02
       
    94 /////////////////////
       
    95 
       
    96 // constructor
       
    97 CCommDbTest010_02::CCommDbTest010_02()
       
    98 	{
       
    99 	// store the name of this test case
       
   100 	SetTestStepName(_L("step_010_02"));
       
   101 	}
       
   102 
       
   103 // destructor
       
   104 CCommDbTest010_02::~CCommDbTest010_02()
       
   105 	{
       
   106 	}
       
   107 
       
   108 TVerdict CCommDbTest010_02::doTestStepPreambleL()
       
   109 	{	
       
   110 	openDbAndViewL(TPtrC(DIAL_OUT_ISP));
       
   111         SetTestStepResult(EPass);	return TestStepResult();
       
   112 	}
       
   113 
       
   114 TInt CCommDbTest010_02::executeStepL()
       
   115 	{
       
   116 	TInt ret=KErrGeneral;
       
   117 
       
   118 	//Move through the records in the table from the last to the first
       
   119 
       
   120 	CDBLEAVE ( ret = iTheView->GotoFirstRecord(), KErrNone);
       
   121 
       
   122 	while( ret == KErrNone )
       
   123 		{
       
   124 		TRAPD(r, ret = iTheView->GotoNextRecord() );
       
   125 		if ( r!= KErrNone )
       
   126 			User::Leave(r);
       
   127 		}
       
   128 	//We should be at the end of the records in this table,
       
   129 	//and ret == KErrNotFound
       
   130 
       
   131 	CDBLEAVE( ret, KErrNotFound  );
       
   132 
       
   133 	//Now move back to the first record 
       
   134 	CDBLEAVE ( ret = iTheView->GotoPreviousRecord(), KErrNone);
       
   135 
       
   136 	while( ret == KErrNone )
       
   137 		{
       
   138 		TRAPD(r, ret = iTheView->GotoPreviousRecord() );
       
   139 		if ( r!=KErrNone )
       
   140 			User::Leave(r);
       
   141 		}
       
   142 
       
   143 
       
   144 	return ret;
       
   145 	}
       
   146 
       
   147 
       
   148 TVerdict CCommDbTest010_02::doTestStepL( )
       
   149 	{
       
   150 	INFO_PRINTF1(_L("Step 010.02 called "));
       
   151 
       
   152 	
       
   153 	if ( executeStepL() == KErrNotFound )
       
   154 		SetTestStepResult(EPass);	else
       
   155 		SetTestStepResult(EFail);
       
   156 
       
   157 	return TestStepResult();
       
   158 	}
       
   159 
       
   160 
       
   161 /////////////////////
       
   162 //	Test step 010.03
       
   163 /////////////////////
       
   164 
       
   165 // constructor
       
   166 CCommDbTest010_03::CCommDbTest010_03()
       
   167 	{
       
   168 	// store the name of this test case
       
   169 	SetTestStepName(_L("step_010_03"));
       
   170 	}
       
   171 
       
   172 // destructor
       
   173 CCommDbTest010_03::~CCommDbTest010_03()
       
   174 	{
       
   175 	}
       
   176 
       
   177 TVerdict CCommDbTest010_03::doTestStepPreambleL()
       
   178 	{	
       
   179 	openDbAndViewL(TPtrC(DIAL_OUT_ISP));
       
   180         SetTestStepResult(EPass);	return TestStepResult();
       
   181 	}
       
   182 
       
   183 
       
   184 TInt CCommDbTest010_03::executeStepL()
       
   185 	{
       
   186 	TInt ret=KErrGeneral;
       
   187 
       
   188 	//The view must contain zero records
       
   189 
       
   190 	TRAPD(r, ret = iTheView->GotoFirstRecord() );
       
   191 	if( r!=KErrNone )
       
   192 		ret =r;
       
   193 
       
   194 	return ret;
       
   195 	}
       
   196 
       
   197 
       
   198 TVerdict CCommDbTest010_03::doTestStepL( )
       
   199 	{
       
   200 	INFO_PRINTF1(_L("Step 010.03 called "));
       
   201 
       
   202 	
       
   203 	if ( executeStepL() == KErrNotFound )
       
   204 		SetTestStepResult(EPass);	else
       
   205 		SetTestStepResult(EFail);
       
   206 
       
   207 	return TestStepResult();
       
   208 	}
       
   209 
       
   210 
       
   211 
       
   212 /////////////////////
       
   213 //	Test step 010.04
       
   214 /////////////////////
       
   215 
       
   216 // constructor
       
   217 CCommDbTest010_04::CCommDbTest010_04()
       
   218 	{
       
   219 	// store the name of this test case
       
   220 	SetTestStepName(_L("step_010_04"));
       
   221 	}
       
   222 
       
   223 // destructor
       
   224 CCommDbTest010_04::~CCommDbTest010_04()
       
   225 	{
       
   226 	}
       
   227 
       
   228 
       
   229 TVerdict CCommDbTest010_04::doTestStepPreambleL()
       
   230 	{	
       
   231 	openDbAndViewL(TPtrC(DIAL_OUT_ISP));
       
   232         SetTestStepResult(EPass);	return TestStepResult();
       
   233 	}
       
   234 
       
   235 TInt CCommDbTest010_04::executeStepL()
       
   236 	{
       
   237 	TInt ret=KErrGeneral;
       
   238 
       
   239 	//The view must contain zero records
       
   240 
       
   241 	TRAPD( r, ret = iTheView->GotoNextRecord() );
       
   242 
       
   243 	if ( r!= KErrNone )
       
   244 		ret = r;
       
   245 
       
   246 
       
   247 	return ret;
       
   248 	}
       
   249 
       
   250 
       
   251 TVerdict CCommDbTest010_04::doTestStepL( )
       
   252 	{
       
   253 	INFO_PRINTF1(_L("Step 010.04 called "));
       
   254 
       
   255 	
       
   256 	if ( executeStepL() == KErrNotFound )
       
   257 		SetTestStepResult(EPass);	else
       
   258 		SetTestStepResult(EFail);
       
   259 
       
   260 	return TestStepResult();
       
   261 	}
       
   262 
       
   263 
       
   264 
       
   265 /////////////////////
       
   266 //	Test step 010.05
       
   267 /////////////////////
       
   268 
       
   269 // constructor
       
   270 CCommDbTest010_05::CCommDbTest010_05()
       
   271 	{
       
   272 	// store the name of this test case
       
   273 	SetTestStepName(_L("step_010_05"));
       
   274 	}
       
   275 
       
   276 // destructor
       
   277 CCommDbTest010_05::~CCommDbTest010_05()
       
   278 	{
       
   279 	}
       
   280 
       
   281 
       
   282 TVerdict CCommDbTest010_05::doTestStepL( )
       
   283 	{
       
   284 	INFO_PRINTF1(_L("Step 010.05 called "));
       
   285 
       
   286 	SetTestStepResult(EPass);
       
   287 	// Heap test for 010.01
       
   288 
       
   289 	CCommDbTest010_01* step010_01 = new CCommDbTest010_01;
       
   290 	CleanupStack::PushL(step010_01);
       
   291 	if ( doTestStepWithHeapFailureL( *step010_01, KErrNotFound) == EFail )
       
   292 		SetTestStepResult(EFail);	CleanupStack::PopAndDestroy(step010_01);
       
   293 
       
   294 	//Heap test for 010.02
       
   295 
       
   296 	CCommDbTest010_02* step010_02 = new CCommDbTest010_02;
       
   297 	CleanupStack::PushL(step010_02);
       
   298 	if ( doTestStepWithHeapFailureL( *step010_02, KErrNotFound) == EFail )
       
   299 		SetTestStepResult(EFail);	CleanupStack::PopAndDestroy(step010_02);
       
   300 
       
   301 	//Heap test for 010.03
       
   302 
       
   303 	CCommDbTest010_03* step010_03 = new CCommDbTest010_03;
       
   304 	CleanupStack::PushL(step010_03);
       
   305 	if ( doTestStepWithHeapFailureL( *step010_03, KErrNotFound) == EFail )
       
   306 		SetTestStepResult(EFail);	CleanupStack::PopAndDestroy(step010_03);
       
   307 
       
   308 	//Heap test for 010.04
       
   309 
       
   310 	CCommDbTest010_04* step010_04 = new CCommDbTest010_04;
       
   311 	CleanupStack::PushL(step010_04);
       
   312 	if ( doTestStepWithHeapFailureL( *step010_04, KErrNotFound) == EFail )
       
   313 		SetTestStepResult(EFail);	CleanupStack::PopAndDestroy(step010_04);
       
   314 
       
   315 
       
   316 
       
   317 	return TestStepResult();	
       
   318 }