commsconfig/commsdatabaseshim/ts_commdb/step_005_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 005.01 - 005.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_005_xx.h"
       
    29 
       
    30 
       
    31 
       
    32 
       
    33 //
       
    34 //	Test step 005.001
       
    35 //
       
    36 
       
    37 // constructor
       
    38 CCommDbTest005_01::CCommDbTest005_01()
       
    39 	{
       
    40 	// store the name of this test case
       
    41 	iTestStepName = _L("step_005_01");
       
    42 	}
       
    43 
       
    44 // destructor
       
    45 CCommDbTest005_01::~CCommDbTest005_01()
       
    46 	{
       
    47 	}
       
    48 
       
    49 
       
    50 TVerdict CCommDbTest005_01::doTestStepPreambleL()
       
    51 	{	
       
    52 	openDbAndViewL(TPtrC(DIAL_IN_ISP));
       
    53 	return EPass;
       
    54 	}
       
    55 
       
    56 
       
    57 TBool CCommDbTest005_01::executeStepL()
       
    58 	{
       
    59 	TDbColType colType;
       
    60 	TUint32 attrib;
       
    61 	TBool ret=EFail;
       
    62 
       
    63 	//NB this step is design NOT to leave. 
       
    64 
       
    65 	//Read column type attibutes and check against the known true values
       
    66 	iTheView->ReadTypeAttribL( TPtrC(ISP_DESCRIPTION), colType, attrib );
       
    67 	if ( colType == EDbColText && attrib == 0 )
       
    68 		ret = EPass;
       
    69 
       
    70 	if ( ret == EPass )
       
    71 		{
       
    72 			iTheView->ReadTypeAttribL( TPtrC(ISP_LOGIN_SCRIPT), colType, attrib );
       
    73 			if ( !(colType == EDbColLongText && attrib == 0) )
       
    74 				ret = EFail;
       
    75 		}
       
    76 
       
    77 	if ( ret == EPass )
       
    78 		{
       
    79 			iTheView->ReadTypeAttribL( TPtrC(ISP_TYPE), colType, attrib );
       
    80 			if ( !(colType == EDbColUint32 && attrib == 0) )
       
    81 				ret = EFail;
       
    82 		}
       
    83 
       
    84 	if ( ret == EPass )
       
    85 		{
       
    86 			iTheView->ReadTypeAttribL( TPtrC(ISP_USE_LOGIN_SCRIPT), colType, attrib );
       
    87 			if ( !(colType == EDbColBit && attrib == 0) )
       
    88 				ret = EFail;
       
    89 		}
       
    90 
       
    91 	return ret;
       
    92 	}
       
    93 
       
    94 TVerdict CCommDbTest005_01::doTestStepL( )
       
    95 	{
       
    96 	Log(_L("Step 005.01 called "));
       
    97 	
       
    98 	if ( executeStep() )
       
    99 		{
       
   100 		iTestStepResult = EFail;
       
   101 		}
       
   102 	else
       
   103 		{
       
   104 		iTestStepResult = EPass;
       
   105 		}
       
   106 		
       
   107 	return iTestStepResult;
       
   108 	}
       
   109 
       
   110 
       
   111 //
       
   112 //	Test step 005.002
       
   113 //
       
   114 
       
   115 // constructor
       
   116 CCommDbTest005_02::CCommDbTest005_02()
       
   117 	{
       
   118 	// store the name of this test case
       
   119 	iTestStepName = _L("step_005_02");
       
   120 	}
       
   121 
       
   122 // destructor
       
   123 CCommDbTest005_02::~CCommDbTest005_02()
       
   124 	{
       
   125 	}
       
   126 
       
   127 TVerdict CCommDbTest005_02::doTestStepPreambleL()
       
   128 	{	
       
   129 	openDbAndViewL(TPtrC(DIAL_OUT_ISP));
       
   130 	return EPass;
       
   131 	}
       
   132 
       
   133 
       
   134 TBool CCommDbTest005_02::executeStepL()
       
   135 	{
       
   136 	TDbColType colType;
       
   137 	TUint32 attrib;
       
   138 	TBool ret=EFail;
       
   139 
       
   140 
       
   141 	//NB. This step is designed not to leave
       
   142 
       
   143 	//Read attributes for columns, and check against known correct values
       
   144 	iTheView->ReadTypeAttribL( TPtrC(COMMDB_ID), colType, attrib );
       
   145 
       
   146 	if ( colType == EDbColUint32 && attrib == (TDbCol::EAutoIncrement|TDbCol::ENotNull) )
       
   147 		ret = EPass;
       
   148 
       
   149 	if ( ret == EPass )
       
   150 		{
       
   151 			iTheView->ReadTypeAttribL( TPtrC(COMMDB_NAME), colType, attrib );
       
   152 			if ( !(colType == EDbColText && attrib == TDbCol::ENotNull) )
       
   153 				ret = EFail;
       
   154 		}
       
   155 
       
   156 	return ret;
       
   157 		
       
   158 	}
       
   159 
       
   160 TVerdict CCommDbTest005_02::doTestStepL( )
       
   161 	{
       
   162 	Log(_L("Step 005.02 called "));
       
   163 
       
   164 	if ( executeStep() )
       
   165 		{
       
   166 		iTestStepResult = EFail;
       
   167 		}
       
   168 	else
       
   169 		{
       
   170 		iTestStepResult = EPass;
       
   171 		}
       
   172 
       
   173 	
       
   174 	return iTestStepResult;
       
   175 	}
       
   176 
       
   177 
       
   178 //
       
   179 //	Test step 005.003
       
   180 //
       
   181 
       
   182 // constructor
       
   183 CCommDbTest005_03::CCommDbTest005_03()
       
   184 	{
       
   185 	// store the name of this test case
       
   186 	iTestStepName = _L("step_005_03");
       
   187 }
       
   188 
       
   189 // destructor
       
   190 CCommDbTest005_03::~CCommDbTest005_03()
       
   191 	{
       
   192 	}
       
   193 
       
   194 TVerdict CCommDbTest005_03::doTestStepPreambleL()
       
   195 	{	
       
   196 	openDbAndViewL(TPtrC(DIAL_OUT_ISP));
       
   197 	return EPass;
       
   198 	}
       
   199 
       
   200 
       
   201 TInt CCommDbTest005_03::executeStepL()
       
   202 	{
       
   203 	TDbColType colType;
       
   204 	TUint32 attrib;
       
   205 
       
   206 	//NB. This test should leave
       
   207 	TRAPD(ret, iTheView->ReadTypeAttribL( KInvalidColumnName, colType, attrib ) );
       
   208 
       
   209 	return ret;
       
   210 	}
       
   211 
       
   212 TVerdict CCommDbTest005_03::doTestStepL( )
       
   213 	{
       
   214 	Log(_L("Step 005.03 called "));
       
   215 
       
   216 	iTestStepResult = EFail;
       
   217 	
       
   218 	if ( executeStep() == KErrNotFound )
       
   219 		iTestStepResult = EPass;
       
   220 
       
   221 	return iTestStepResult;
       
   222 	}
       
   223 
       
   224 
       
   225 
       
   226 //
       
   227 //	Test step 005.004
       
   228 //
       
   229 
       
   230 // constructor
       
   231 CCommDbTest005_04::CCommDbTest005_04()
       
   232 	{
       
   233 	// store the name of this test case
       
   234 	iTestStepName = _L("step_005_04");
       
   235 	}
       
   236 
       
   237 // destructor
       
   238 CCommDbTest005_04::~CCommDbTest005_04()
       
   239 	{
       
   240 	}
       
   241 
       
   242 
       
   243 
       
   244 TVerdict CCommDbTest005_04::doTestStepL( )
       
   245 	{
       
   246 	Log(_L("Step 005.04 called "));
       
   247 	
       
   248 	iTestStepResult = EPass;
       
   249 
       
   250 	//Heap test for 005.01
       
   251 
       
   252 	CCommDbTest005_01* step005_01 = new CCommDbTest005_01;
       
   253 	CleanupStack::PushL(step005_01);
       
   254 	step005_01->iSuite = iSuite;				
       
   255 	doTestStepWithHeapFailureL( *step005_01, KErrNone);
       
   256 	if( step005_01->iTestStepResult == EFail )
       
   257 		iTestStepResult = EFail;
       
   258 	CleanupStack::PopAndDestroy(step005_01);
       
   259 		
       
   260 	//Heap test for 005.02
       
   261 	
       
   262 	CCommDbTest005_02* step005_02 = new CCommDbTest005_02;
       
   263 	CleanupStack::PushL(step005_02);
       
   264 	step005_02->iSuite = iSuite;				
       
   265 	doTestStepWithHeapFailureL( *step005_02, KErrNone);
       
   266 	if( step005_02->iTestStepResult == EFail )
       
   267 		iTestStepResult = EFail;
       
   268 	CleanupStack::PopAndDestroy(step005_02);
       
   269 
       
   270 
       
   271 	
       
   272 	//Heap test for 005.03
       
   273 
       
   274 	
       
   275 	CCommDbTest005_03* step005_03 = new CCommDbTest005_03;
       
   276 	CleanupStack::PushL(step005_03);
       
   277 	step005_03->iSuite = iSuite;				
       
   278 	doTestStepWithHeapFailureL( *step005_03, KErrNotFound);
       
   279 	if( step005_03->iTestStepResult == EFail )
       
   280 		iTestStepResult = EFail;
       
   281 	CleanupStack::PopAndDestroy(step005_03);
       
   282 
       
   283 	return iTestStepResult;
       
   284 	}