commsconfig/commsdatabaseshim/TE_commdb/src/Step_038_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 038.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_038_xx.h"
       
    29 
       
    30 
       
    31 
       
    32 CCommDbTest038_01::CCommDbTest038_01()
       
    33 	{
       
    34 	// store the name of this test case
       
    35 	SetTestStepName(_L("step_038_01"));
       
    36 	}
       
    37 
       
    38 CCommDbTest038_01::~CCommDbTest038_01()
       
    39 	{}
       
    40 
       
    41 TVerdict CCommDbTest038_01::doTestStepL( void )
       
    42 	{
       
    43 	if(executeStepL()!=KErrNone)
       
    44          SetTestStepResult(EFail);        SetTestStepResult(EPass);	return TestStepResult();
       
    45 	}
       
    46 
       
    47 TVerdict CCommDbTest038_01::doTestStepPreambleL()
       
    48 	{
       
    49 	iTheDb=CCommsDatabase::NewL();
       
    50 
       
    51         SetTestStepResult(EPass);	return TestStepResult();
       
    52 	}
       
    53 
       
    54 TInt CCommDbTest038_01::executeStepL()
       
    55 	{
       
    56 	CCommsDbTemplateRecord* templateRecord = CCommsDbTemplateRecord::NewL(iTheDb, TPtrC(MODEM_BEARER));
       
    57 	CleanupStack::PushL(templateRecord);
       
    58 	User::LeaveIfError(	templateRecord->Modify());
       
    59 	templateRecord->WriteTextL(TPtrC(COMMDB_NAME), _L("DummyName"));
       
    60 	User::LeaveIfError(templateRecord->StoreModifications());
       
    61 
       
    62 	//delete the template
       
    63 	User::LeaveIfError(templateRecord->Delete());
       
    64 
       
    65 	TInt ret(KErrNone);
       
    66 
       
    67 	if(templateRecord->TemplateRecordExists())
       
    68 		ret = KErrGeneral;
       
    69 
       
    70 	CleanupStack::PopAndDestroy(templateRecord);
       
    71 
       
    72 	return ret;
       
    73 	}
       
    74 	
       
    75 TVerdict CCommDbTest038_01::doTestStepPostambleL()
       
    76 	{
       
    77 	delete iTheDb;
       
    78 	iTheDb=NULL;
       
    79         SetTestStepResult(EPass);	return TestStepResult();
       
    80 	}
       
    81 
       
    82 ///////////////////////////////////////////////////////////////////////
       
    83 
       
    84 CCommDbTest038_02::CCommDbTest038_02()
       
    85 	{
       
    86 	// store the name of this test case
       
    87 	SetTestStepName(_L("step_038_02"));
       
    88 	}
       
    89 
       
    90 CCommDbTest038_02::~CCommDbTest038_02()
       
    91 	{}
       
    92 
       
    93 TVerdict CCommDbTest038_02::doTestStepL( void )
       
    94 	{
       
    95 	if(executeStepL()!=KErrNotFound)
       
    96          SetTestStepResult(EFail);        SetTestStepResult(EPass);	return TestStepResult();
       
    97 	}
       
    98 
       
    99 TVerdict CCommDbTest038_02::doTestStepPreambleL()
       
   100 	{
       
   101 	iTheDb=CCommsDatabase::NewL();
       
   102 
       
   103         SetTestStepResult(EPass);	return TestStepResult();
       
   104 	}
       
   105 
       
   106 TInt CCommDbTest038_02::executeStepL()
       
   107 	{
       
   108 	CCommsDbTemplateRecord* templateRecord = CCommsDbTemplateRecord::NewL(iTheDb, TPtrC(MODEM_BEARER));
       
   109 	CleanupStack::PushL(templateRecord);
       
   110 
       
   111 	User::LeaveIfError(	templateRecord->Modify());
       
   112 	templateRecord->WriteTextL(TPtrC(COMMDB_NAME), _L("DummyName"));
       
   113 	User::LeaveIfError(templateRecord->StoreModifications());
       
   114 
       
   115 	//delete the template
       
   116 	User::LeaveIfError(templateRecord->Delete());
       
   117 	
       
   118 	TInt ret = templateRecord->Delete();
       
   119 
       
   120 	CleanupStack::PopAndDestroy(templateRecord);
       
   121 
       
   122 	return ret;
       
   123 	}
       
   124 	
       
   125 TVerdict CCommDbTest038_02::doTestStepPostambleL()
       
   126 	{
       
   127 	delete iTheDb;
       
   128 	iTheDb=NULL;
       
   129         SetTestStepResult(EPass);	return TestStepResult();
       
   130 	}
       
   131 
       
   132 //////////////////////////////////////////////////////////////////////////
       
   133 
       
   134 CCommDbTest038_03::CCommDbTest038_03()
       
   135 	{
       
   136 	// store the name of this test case
       
   137 	SetTestStepName(_L("step_038_03"));
       
   138 	}
       
   139 
       
   140 CCommDbTest038_03::~CCommDbTest038_03()
       
   141 	{}
       
   142 
       
   143 TVerdict CCommDbTest038_03::doTestStepL( void )
       
   144 	{
       
   145 	INFO_PRINTF1(_L("Step 038.03 called "));
       
   146 
       
   147 	SetTestStepResult(EPass);
       
   148 	CCommDbTest038_01* step038_01 = new(ELeave) CCommDbTest038_01;
       
   149 	CleanupStack::PushL(step038_01);
       
   150 	doTestStepWithHeapFailureL( *step038_01, KErrNone);
       
   151 	CleanupStack::PopAndDestroy(step038_01);
       
   152 
       
   153 	CCommDbTest038_02* step038_02 = new(ELeave) CCommDbTest038_02;
       
   154 	CleanupStack::PushL(step038_02);
       
   155 	doTestStepWithHeapFailureL( *step038_02, KErrNotFound);
       
   156 	CleanupStack::PopAndDestroy(step038_02);
       
   157 
       
   158 	return TestStepResult();
       
   159 	}