commsconfig/commsdatabaseshim/ts_commdb/Step_029_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 029.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_029_xx.h"
       
    29 
       
    30 
       
    31 CCommDbTest029_01::CCommDbTest029_01()
       
    32 	{
       
    33 	// store the name of this test case
       
    34 	iTestStepName = _L("step_029_01");
       
    35 	}
       
    36 
       
    37 CCommDbTest029_01::~CCommDbTest029_01()
       
    38 	{}
       
    39 
       
    40 TVerdict CCommDbTest029_01::doTestStepL( void )
       
    41 	{
       
    42 	if(executeStepL()!=KErrNotFound)
       
    43 		return EFail;
       
    44 	return EPass;
       
    45 	}
       
    46 
       
    47 TVerdict CCommDbTest029_01::doTestStepPreambleL()
       
    48 	{
       
    49 	iTheDb=CCommsDatabase::NewL();
       
    50 
       
    51 	iPrefView = iTheDb->OpenConnectionPrefTableLC();
       
    52 	CleanupStack::Pop();
       
    53 
       
    54 	return EPass;
       
    55 	}
       
    56 
       
    57 TInt CCommDbTest029_01::executeStepL()
       
    58 	{
       
    59 	CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref1;
       
    60 	pref1.iRanking = 1;
       
    61 	pref1.iDirection = ECommDbConnectionDirectionOutgoing;
       
    62 	pref1.iDialogPref = ECommDbDialogPrefPrompt;
       
    63 	pref1.iBearer.iBearerSet = KCommDbBearerCSD;
       
    64 	pref1.iBearer.iIapId = 1;
       
    65 
       
    66 	iPrefView->InsertConnectionPreferenceL(pref1, EFalse);
       
    67 
       
    68 	User::LeaveIfError(iPrefView->GotoFirstRecord());
       
    69 
       
    70 	iPrefView->DeleteConnectionPreferenceL();
       
    71 
       
    72 	return iPrefView->GotoFirstRecord();	//There should now be no records in the connection pref table, so this should be KErrNotFound
       
    73 	}
       
    74 
       
    75 TVerdict CCommDbTest029_01::doTestStepPostambleL()
       
    76 	{
       
    77 	delete iPrefView;
       
    78 	iPrefView = NULL;
       
    79 	delete iTheDb;
       
    80 	iTheDb=NULL;
       
    81 	return EPass;
       
    82 	}
       
    83 
       
    84 //
       
    85 
       
    86 CCommDbTest029_02::CCommDbTest029_02()
       
    87 	{
       
    88 	// store the name of this test case
       
    89 	iTestStepName = _L("step_029_02");
       
    90 	}
       
    91 
       
    92 CCommDbTest029_02::~CCommDbTest029_02()
       
    93 	{}
       
    94 
       
    95 TVerdict CCommDbTest029_02::doTestStepL( void )
       
    96 	{
       
    97 	if(executeStepL()!=KErrAccessDenied)
       
    98 		return EFail;
       
    99 	return EPass;
       
   100 	}
       
   101 
       
   102 TVerdict CCommDbTest029_02::doTestStepPreambleL()
       
   103 	{
       
   104 	iTheDb=CCommsDatabase::NewL();
       
   105 
       
   106 	iPrefView = iTheDb->OpenConnectionPrefTableLC();
       
   107 	CleanupStack::Pop();
       
   108 
       
   109 	return EPass;
       
   110 	}
       
   111 
       
   112 TInt CCommDbTest029_02::executeStepL()
       
   113 	{
       
   114 	CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref1;
       
   115 	pref1.iRanking = 1;
       
   116 	pref1.iDirection = ECommDbConnectionDirectionOutgoing;
       
   117 	pref1.iDialogPref = ECommDbDialogPrefPrompt;
       
   118 	pref1.iBearer.iBearerSet = KCommDbBearerCSD;
       
   119 	pref1.iBearer.iIapId = 1;
       
   120 
       
   121 	iPrefView->InsertConnectionPreferenceL(pref1, ETrue);
       
   122 
       
   123 	CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref2;
       
   124 	pref2.iRanking = 2;
       
   125 	pref2.iDirection = ECommDbConnectionDirectionOutgoing;
       
   126 	pref2.iDialogPref = ECommDbDialogPrefPrompt;
       
   127 	pref2.iBearer.iBearerSet = KCommDbBearerCSD;
       
   128 	pref2.iBearer.iIapId = 2;
       
   129 
       
   130 	iPrefView->InsertConnectionPreferenceL(pref2, ETrue);
       
   131 
       
   132 	User::LeaveIfError(iPrefView->GotoFirstRecord());
       
   133 
       
   134 	TRAPD(err, iPrefView->UpdateDialogPrefL(ECommDbDialogPrefDoNotPrompt));	//Trying to edit a read only entry
       
   135 
       
   136 	return err;
       
   137 	}
       
   138 
       
   139 TVerdict CCommDbTest029_02::doTestStepPostambleL()
       
   140 	{
       
   141 	delete iPrefView;
       
   142 	iPrefView = NULL;
       
   143 	delete iTheDb;
       
   144 	iTheDb=NULL;
       
   145 	return EPass;
       
   146 	}
       
   147 
       
   148 //
       
   149 
       
   150 CCommDbTest029_03::CCommDbTest029_03()
       
   151 	{
       
   152 	// store the name of this test case
       
   153 	iTestStepName = _L("step_029_03");
       
   154 	}
       
   155 
       
   156 CCommDbTest029_03::~CCommDbTest029_03()
       
   157 	{}
       
   158 
       
   159 TVerdict CCommDbTest029_03::doTestStepL( void )
       
   160 	{
       
   161 	if (executeStepL() != KErrNotFound)
       
   162 		{
       
   163 		iTestStepResult = EFail;
       
   164 		}
       
   165 
       
   166 	return iTestStepResult;
       
   167 	}
       
   168 
       
   169 TVerdict CCommDbTest029_03::doTestStepPreambleL()
       
   170 	{
       
   171 	iTheDb=CCommsDatabase::NewL();
       
   172 
       
   173 	iPrefView = iTheDb->OpenConnectionPrefTableLC();
       
   174 	CleanupStack::Pop();
       
   175 
       
   176 	return EPass;
       
   177 	}
       
   178 
       
   179 TInt CCommDbTest029_03::executeStepL()
       
   180 	{
       
   181 	TRAPD(err, iPrefView->DeleteConnectionPreferenceL());	//This should leave with KErrNotFound
       
   182 
       
   183 	return err;
       
   184 	}
       
   185 
       
   186 TVerdict CCommDbTest029_03::doTestStepPostambleL()
       
   187 	{
       
   188 	delete iPrefView;
       
   189 	iPrefView = NULL;
       
   190 	delete iTheDb;
       
   191 	iTheDb=NULL;
       
   192 	return EPass;
       
   193 	}
       
   194 
       
   195 //
       
   196 
       
   197 CCommDbTest029_04::CCommDbTest029_04()
       
   198 	{
       
   199 	// store the name of this test case
       
   200 	iTestStepName = _L("step_029_04");
       
   201 	}
       
   202 
       
   203 CCommDbTest029_04::~CCommDbTest029_04()
       
   204 	{}
       
   205 
       
   206 TVerdict CCommDbTest029_04::doTestStepL( void )
       
   207 	{
       
   208 	Log(_L("Step 029.04 called "));
       
   209 
       
   210 	iTestStepResult = EPass;
       
   211 
       
   212 	CCommDbTest029_01* step029_01 = new(ELeave) CCommDbTest029_01;
       
   213 	CleanupStack::PushL(step029_01);
       
   214 	step029_01->iSuite = iSuite;
       
   215 	doTestStepWithHeapFailureL( *step029_01, KErrNotFound);
       
   216 	CleanupStack::PopAndDestroy(step029_01);
       
   217 
       
   218 	CCommDbTest029_02* step029_02 = new(ELeave) CCommDbTest029_02;
       
   219 	CleanupStack::PushL(step029_02);
       
   220 	step029_02->iSuite = iSuite;
       
   221 	doTestStepWithHeapFailureL( *step029_02, KErrAccessDenied);
       
   222 	CleanupStack::PopAndDestroy(step029_02);
       
   223 
       
   224 	//Don't bother with step 3, since it's a panic test.
       
   225 
       
   226 	return iTestStepResult;
       
   227 	}