commsconfig/commsdatabaseshim/TE_commdb/src/Step_037_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 037.XX
       
    19 
       
    20 // EPOC includes
       
    21 #include <e32base.h>
       
    22 #include <commdb.h>
       
    23 #include <d32comm.h>
       
    24 #include <cdbtemp.h>
       
    25 
       
    26 // Test system includes
       
    27 #include "Teststepcommdb.h"
       
    28 #include "Step_037_xx.h"
       
    29 
       
    30 
       
    31 CCommDbTest037_01::CCommDbTest037_01()
       
    32 	{
       
    33 	// store the name of this test case
       
    34 	SetTestStepName(_L("step_037_01"));
       
    35 	}
       
    36 
       
    37 CCommDbTest037_01::~CCommDbTest037_01()
       
    38 	{}
       
    39 
       
    40 TVerdict CCommDbTest037_01::doTestStepL( void )
       
    41 	{
       
    42 	if(executeStepL()!=KErrNone)
       
    43          SetTestStepResult(EFail);        SetTestStepResult(EPass);	return TestStepResult();
       
    44 	}
       
    45 
       
    46 TVerdict CCommDbTest037_01::doTestStepPreambleL()
       
    47 	{
       
    48 	iTheDb=CCommsDatabase::NewL();
       
    49 
       
    50         SetTestStepResult(EPass);	return TestStepResult();
       
    51 	}
       
    52 
       
    53 TInt CCommDbTest037_01::executeStepL()
       
    54 	{
       
    55 	//alter something in the template
       
    56 	CCommsDbTemplateRecord* templateRecord = CCommsDbTemplateRecord::NewL(iTheDb, TPtrC(MODEM_BEARER));
       
    57 	CleanupStack::PushL(templateRecord);
       
    58 	
       
    59 	User::LeaveIfError(templateRecord->Modify());
       
    60 	templateRecord->WriteTextL(TPtrC(COMMDB_NAME), _L("DummyName"));
       
    61 	TBufC8<KCommsDbSvrMaxFieldLength> firstInputString = _L8("first string");
       
    62 
       
    63 	templateRecord->WriteTextL(TPtrC(MODEM_FAX_INIT_STRING), firstInputString);
       
    64 	User::LeaveIfError(templateRecord->StoreModifications());
       
    65 	//Now start to overwrite initial change, but don't commit, cancel instead.
       
    66 	User::LeaveIfError(templateRecord->Modify());
       
    67 
       
    68 	TBufC8<KCommsDbSvrMaxFieldLength> secondInputString = _L8("second string");
       
    69 	templateRecord->WriteTextL(TPtrC(MODEM_FAX_INIT_STRING), secondInputString);
       
    70 	templateRecord->CancelModifications();
       
    71 
       
    72 	TBuf8<KCommsDbSvrMaxFieldLength> retrievedString;
       
    73 	templateRecord->ReadTextL(TPtrC(MODEM_FAX_INIT_STRING), retrievedString);
       
    74 	CleanupStack::PopAndDestroy(templateRecord);
       
    75 
       
    76 	if(retrievedString!=firstInputString)
       
    77 		return KErrGeneral;
       
    78 	
       
    79 	return KErrNone;
       
    80 	}
       
    81 	
       
    82 TVerdict CCommDbTest037_01::doTestStepPostambleL()
       
    83 	{
       
    84 	delete iTheDb;
       
    85 	iTheDb=NULL;
       
    86         SetTestStepResult(EPass);	return TestStepResult();
       
    87 	}
       
    88 
       
    89 /////////////////////////////////////////////////////////////////////////
       
    90 
       
    91 CCommDbTest037_02::CCommDbTest037_02()
       
    92 	{
       
    93 	// store the name of this test case
       
    94 	SetTestStepName(_L("step_037_02"));
       
    95 	}
       
    96 
       
    97 CCommDbTest037_02::~CCommDbTest037_02()
       
    98 	{}
       
    99 
       
   100 TVerdict CCommDbTest037_02::doTestStepL( void )
       
   101 	{
       
   102 	executeStepL();
       
   103         SetTestStepResult(EPass);	return TestStepResult();	//If we get here we've passed
       
   104 	}
       
   105 
       
   106 TVerdict CCommDbTest037_02::doTestStepPreambleL()
       
   107 	{
       
   108 	iTheDb=CCommsDatabase::NewL();
       
   109 
       
   110         SetTestStepResult(EPass);	return TestStepResult();
       
   111 	}
       
   112 
       
   113 TInt CCommDbTest037_02::executeStepL()
       
   114 	{
       
   115 	//alter something in the template
       
   116 	CCommsDbTemplateRecord* templateRecord = CCommsDbTemplateRecord::NewL(iTheDb, TPtrC(MODEM_BEARER));
       
   117 	CleanupStack::PushL(templateRecord);
       
   118 
       
   119 	templateRecord->CancelModifications();
       
   120 	
       
   121 	CleanupStack::PopAndDestroy(templateRecord);
       
   122 
       
   123 	return KErrNone;
       
   124 	}
       
   125 	
       
   126 TVerdict CCommDbTest037_02::doTestStepPostambleL()
       
   127 	{
       
   128 	delete iTheDb;
       
   129 	iTheDb=NULL;
       
   130         SetTestStepResult(EPass);	return TestStepResult();
       
   131 	}
       
   132 
       
   133 //////////////////////////////////////////////////////////////////////////
       
   134 
       
   135 CCommDbTest037_03::CCommDbTest037_03()
       
   136 	{
       
   137 	// store the name of this test case
       
   138 	SetTestStepName(_L("step_037_03"));
       
   139 	}
       
   140 
       
   141 CCommDbTest037_03::~CCommDbTest037_03()
       
   142 	{}
       
   143 
       
   144 TVerdict CCommDbTest037_03::doTestStepL( void )
       
   145 	{
       
   146 	INFO_PRINTF1(_L("Step 037.03 called "));
       
   147 
       
   148 	SetTestStepResult(EPass);
       
   149 	CCommDbTest037_01* step037_01 = new(ELeave) CCommDbTest037_01;
       
   150 	CleanupStack::PushL(step037_01);
       
   151 	doTestStepWithHeapFailureL( *step037_01, KErrNone);
       
   152 	CleanupStack::PopAndDestroy(step037_01);
       
   153 
       
   154 	CCommDbTest037_02* step037_02 = new(ELeave) CCommDbTest037_02;
       
   155 	CleanupStack::PushL(step037_02);
       
   156 	doTestStepWithHeapFailureL( *step037_02, KErrNone);
       
   157 	CleanupStack::PopAndDestroy(step037_02);
       
   158 
       
   159 	return TestStepResult();
       
   160 	}