commsconfig/commsdatabaseshim/ts_commdb/step_004_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 004.01 - 004.04
       
    15 // 
       
    16 //
       
    17 
       
    18 // EPOC includes
       
    19 #include <e32base.h>
       
    20 #include <commdb.h>
       
    21 
       
    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_004_xx.h"
       
    29 
       
    30 
       
    31 
       
    32 
       
    33 //
       
    34 //	Test step 004.001
       
    35 //
       
    36 
       
    37 // constructor
       
    38 CCommDbTest004_01::CCommDbTest004_01()
       
    39 	{
       
    40 	// store the name of this test case
       
    41 	iTestStepName = _L("step_004_01");
       
    42 	}
       
    43 
       
    44 // destructor
       
    45 CCommDbTest004_01::~CCommDbTest004_01()
       
    46 	{
       
    47 	}
       
    48 
       
    49 TVerdict CCommDbTest004_01::doTestStepPreambleL()
       
    50 	{	
       
    51 	openDbAndViewL(TPtrC(DIAL_OUT_ISP));
       
    52 	return EPass;
       
    53 	}
       
    54 
       
    55 TInt CCommDbTest004_01::executeStepL()
       
    56 	{
       
    57 	TInt ret = KErrGeneral;
       
    58 
       
    59 	TBuf<KCommsDbSvrMaxColumnNameLength> tableName;
       
    60 
       
    61 	// Get the table name and check it matches with the known value
       
    62 	iTheView->GetTableName( tableName );
       
    63 	if ( tableName.Compare( TPtrC(DIAL_OUT_ISP)) == 0 )
       
    64 		ret = KErrNone;
       
    65 
       
    66 	return ret;
       
    67 	}
       
    68 
       
    69 TVerdict CCommDbTest004_01::doTestStepL( )
       
    70 	{
       
    71 	Log(_L("Step 004.01 called "));
       
    72 
       
    73 
       
    74 	if ( executeStep()== KErrNone )
       
    75 		{
       
    76 		iTestStepResult = EPass;	
       
    77 		}
       
    78 	else
       
    79 		{
       
    80 		iTestStepResult = EFail;
       
    81 		}
       
    82 
       
    83 
       
    84 	return iTestStepResult;
       
    85 	}
       
    86 
       
    87 
       
    88 //
       
    89 //	Test step 004.002
       
    90 //
       
    91 
       
    92 // constructor
       
    93 CCommDbTest004_02::CCommDbTest004_02()
       
    94 	{
       
    95 	// store the name of this test case
       
    96 	iTestStepName = _L("step_004_02");
       
    97 	}
       
    98 
       
    99 // destructor
       
   100 CCommDbTest004_02::~CCommDbTest004_02( )
       
   101 	{
       
   102 	}
       
   103 
       
   104 TVerdict CCommDbTest004_02::doTestStepPreambleL()
       
   105 	{	
       
   106 	openDbAndViewL(TPtrC(DIAL_OUT_ISP));
       
   107 	return EPass;
       
   108 	}
       
   109 
       
   110 
       
   111 #define BUFFER_TOO_SMALL	5	//Must be smaller than the length of the DAIL_OUT_ISP table name
       
   112 
       
   113 TBool CCommDbTest004_02::executeStepL()
       
   114 	{
       
   115 	TBuf<BUFFER_TOO_SMALL> tableName;
       
   116 
       
   117 	//NB. This should cause a Panic!
       
   118 
       
   119 	iTheView->GetTableName( tableName );
       
   120 
       
   121 	if ( tableName.Compare( TPtrC(DIAL_OUT_ISP)) == 0 )
       
   122 		{
       
   123 		iTestStepResult = EPass;	
       
   124 		}
       
   125 	else
       
   126 		{
       
   127 		iTestStepResult = EFail;
       
   128 		}
       
   129 
       
   130 	return EFail;
       
   131 	}
       
   132 
       
   133 
       
   134 TVerdict CCommDbTest004_02::doTestStepL( )
       
   135 	{
       
   136 	if  ( executeStep() )
       
   137 		iTestStepResult = EPass;
       
   138 	else
       
   139 		iTestStepResult = EFail;
       
   140 
       
   141 		
       
   142 	return iTestStepResult;
       
   143 	}
       
   144 
       
   145 
       
   146 //
       
   147 //	Test step 004.003
       
   148 //
       
   149 
       
   150 // constructor
       
   151 CCommDbTest004_03::CCommDbTest004_03()
       
   152 	{
       
   153 	// store the name of this test case
       
   154 	iTestStepName = _L("step_004_03");
       
   155 	}
       
   156 
       
   157 // destructor
       
   158 CCommDbTest004_03::~CCommDbTest004_03()
       
   159 	{
       
   160 	}
       
   161 
       
   162 TVerdict CCommDbTest004_03::doTestStepPreambleL()
       
   163 	{	
       
   164 	copyTestDatabase( EDatabase_1 );
       
   165 	openDbAndViewL(TPtrC(DIAL_OUT_ISP));
       
   166 	return EPass;
       
   167 	}
       
   168 
       
   169 //NB. If a zero size buffer is used this will cause an ARM compiler error
       
   170 #define BUFFER_VERYSMALL	1
       
   171 
       
   172 TBool CCommDbTest004_03::executeStepL()
       
   173 	{
       
   174 	
       
   175 	TBuf<BUFFER_VERYSMALL> tableName;
       
   176 
       
   177 	//NB. This should cause a Panic
       
   178 	
       
   179 	iTheView->GetTableName( tableName );
       
   180 
       
   181 	if ( tableName.Compare( TPtrC(DIAL_OUT_ISP)) == 0 )
       
   182 		{
       
   183 		iTestStepResult = EPass;	
       
   184 		}
       
   185 	else
       
   186 		{
       
   187 		iTestStepResult = EFail;
       
   188 		}
       
   189 
       
   190 	return EFail;
       
   191 	}
       
   192 
       
   193 TVerdict CCommDbTest004_03::doTestStepL( )
       
   194 	{
       
   195 	
       
   196 	if ( executeStep() )
       
   197 		{
       
   198 		iTestStepResult = EPass;	
       
   199 		}
       
   200 	else
       
   201 		{
       
   202 		iTestStepResult = EFail;
       
   203 		}
       
   204 
       
   205 	
       
   206 	return iTestStepResult;
       
   207 	}
       
   208 
       
   209 
       
   210 
       
   211 //
       
   212 //	Test step 004.004
       
   213 //
       
   214 
       
   215 // constructor
       
   216 CCommDbTest004_04::CCommDbTest004_04()
       
   217 	{
       
   218 	// store the name of this test case
       
   219 	iTestStepName = _L("step_004_04");
       
   220 	}
       
   221 
       
   222 // destructor
       
   223 CCommDbTest004_04::~CCommDbTest004_04()
       
   224 	{
       
   225 	}
       
   226 
       
   227 
       
   228 TVerdict CCommDbTest004_04::doTestStepL( )
       
   229 	{
       
   230 	Log(_L("Step 004.04 called "));
       
   231 	
       
   232 	iTestStepResult = EPass;
       
   233 
       
   234 	//Heap test for 004.01
       
   235 
       
   236 	CCommDbTest004_01* step004_01 = new CCommDbTest004_01;
       
   237 	CleanupStack::PushL(step004_01);
       
   238 	step004_01->iSuite = iSuite;				
       
   239 	doTestStepWithHeapFailureL( *step004_01, KErrNone);
       
   240 	if( step004_01->iTestStepResult == EFail )
       
   241 		iTestStepResult = EFail;
       
   242 	CleanupStack::PopAndDestroy(step004_01);
       
   243 	
       
   244 	return iTestStepResult;
       
   245 	}
       
   246 	
       
   247 //
       
   248 //	Test step 004.005
       
   249 //
       
   250 
       
   251 // constructor
       
   252 CCommDbTest004_05::CCommDbTest004_05()
       
   253 	{
       
   254 	// store the name of this test case
       
   255 	iTestStepName = _L("step_004_05");
       
   256 	}
       
   257 
       
   258 // destructor
       
   259 CCommDbTest004_05::~CCommDbTest004_05()
       
   260 	{
       
   261 	}
       
   262 
       
   263 
       
   264 TVerdict CCommDbTest004_05::doTestStepL( )
       
   265 	{
       
   266 	
       
   267 	iTestStepResult = EPass;	
       
   268 	
       
   269 	//Heap test for 004.02
       
   270 //	    a panic is expected
       
   271 	CCommDbTest004_02* step004_02 = new CCommDbTest004_02;
       
   272 	CleanupStack::PushL(step004_02);
       
   273 	step004_02->iSuite = iSuite;				
       
   274 	doTestStepWithHeapFailureL( *step004_02, KErrNone);
       
   275 	if( step004_02->iTestStepResult == EFail )
       
   276 		iTestStepResult = EFail;
       
   277 	CleanupStack::PopAndDestroy(step004_02);
       
   278 
       
   279 	return iTestStepResult;
       
   280 	}
       
   281 
       
   282 	
       
   283 //
       
   284 //	Test step 004.006
       
   285 //
       
   286 
       
   287 // constructor
       
   288 CCommDbTest004_06::CCommDbTest004_06()
       
   289 	{
       
   290 	// store the name of this test case
       
   291 	iTestStepName = _L("step_004_06");
       
   292 	}
       
   293 
       
   294 // destructor
       
   295 CCommDbTest004_06::~CCommDbTest004_06()
       
   296 	{
       
   297 	}
       
   298 
       
   299 
       
   300 TVerdict CCommDbTest004_06::doTestStepL( )
       
   301 	{
       
   302 	
       
   303 	iTestStepResult = EPass;	
       
   304 	//Heap test for 004.03
       
   305 
       
   306 	// a panic is expected
       
   307 	CCommDbTest004_03* step004_03 = new CCommDbTest004_03;
       
   308 	CleanupStack::PushL(step004_03);
       
   309 	step004_03->iSuite = iSuite;				
       
   310 	doTestStepWithHeapFailureL( *step004_03, KErrNone);
       
   311 	if( step004_03->iTestStepResult == EFail )
       
   312 		iTestStepResult = EFail;
       
   313 	CleanupStack::PopAndDestroy(step004_03);
       
   314 
       
   315 	return iTestStepResult;
       
   316 	}