installationservices/swcomponentregistry/test/tscrdatalayer/source/datalayersteps.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 19 Mar 2010 09:33:35 +0200
changeset 24 84a16765cd86
permissions -rw-r--r--
Revision: 201007 Kit: 201011
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description: 
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
* Implements the unit test steps for the SCR Data Layer.
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
*/
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include "datalayersteps.h"
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
CScrTestDataLayer::CScrTestDataLayer(CScrDataLayerTestServer&)
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
// Constructor.
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
	:	COomTestStep()
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
	{
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
	SetTestStepName(KScrDataLayerStep);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
	}
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
CScrTestDataLayer::~CScrTestDataLayer()
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
// Destructor.
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
	{
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
	}
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
void CScrTestDataLayer::ImplTestStepPreambleL()
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
	{
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
	}
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
void CScrTestDataLayer::ImplTestStepPostambleL()
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
	{
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
	}
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
static const TUint MAX_SCR_ERROR_MESSAGE_LENGTH = 512;
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
void CScrTestDataLayer::PrintErrorL(const TDesC& aMsg, TInt aErrNum,...)
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
	{
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
	VA_LIST list;
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
	VA_START(list, aErrNum);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
	RBuf msgBuf;
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
	msgBuf.CreateL(MAX_SCR_ERROR_MESSAGE_LENGTH);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
	msgBuf.CleanupClosePushL();
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
	msgBuf.AppendFormatList(aMsg, list);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
	ERR_PRINTF1(msgBuf);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
	SetTestStepResult(EFail);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
	CleanupStack::PopAndDestroy(&msgBuf);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
	User::Leave(aErrNum);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
	}
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
void CScrTestDataLayer::ImplTestStepL()
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
	{
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
	INFO_PRINTF1(_L("SCR Data Layer Unit Tests"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
	INFO_PRINTF1(_L(" SEC_SCR_DataLayer_0001: Open database file"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
	_LIT(KDbFilePath, "c:\\private\\1028634C\\scr.db");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
	_LIT(KJournalFilePath, "c:\\private\\1028634C\\scr.db-journal");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
	RFs fs;
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
	User::LeaveIfError(fs.Connect());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
	CleanupClosePushL(fs);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
	RFile databaseFile;
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
	User::LeaveIfError(databaseFile.Open(fs, KDbFilePath, EFileShareAny|EFileWrite));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
	CleanupClosePushL(databaseFile);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
	RFile journalFile;
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
	User::LeaveIfError(journalFile.Replace(fs, KJournalFilePath, EFileShareAny|EFileWrite));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
	CleanupClosePushL(journalFile);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
	CDatabase *db = CDatabase::NewL(databaseFile, journalFile);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
	CleanupStack::PushL(db);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
	INFO_PRINTF1(_L(" SEC_SCR_DataLayer_0001.1: Negative test in LastInsertedIdL"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
	TRAPD(err, db->LastInsertedIdL());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
	if (err != KErrNotFound)
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
		PrintErrorL(_L("Unexpected error for LastInsertedIdL when nothing was inserted"), err);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
	INFO_PRINTF1(_L(" SEC_SCR_DataLayer_0002: Insert records"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
	_LIT(KScrTestInsert, "INSERT INTO Components(SoftwareTypeId,InstalledDrivesRefCount,Version,InstallTime) VALUES(?,?,?,?);");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
	CStatement* stmt = db->PrepareStatementLC(KScrTestInsert());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
	// Insert first record
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
	const TInt KSoftTypeIdRow1 = 1;
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
	_LIT(KInstalledDrivesRow1, "123");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
	_LIT(KVersionRow1, "1.1.1");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
	InsertRecordL(*stmt, KSoftTypeIdRow1, KInstalledDrivesRow1(), KVersionRow1());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
	// Insert second record
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
	const TInt KSoftTypeIdRow2 = 2;
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
	_LIT(KInstalledDrivesRow2, "456");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
	_LIT(KVersionRow2, "1.1.2");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
	InsertRecordL(*stmt, KSoftTypeIdRow2, KInstalledDrivesRow2(), KVersionRow2());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
	CleanupStack::PopAndDestroy(stmt);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
	INFO_PRINTF1(_L(" SEC_SCR_DataLayer_0003: Verify inserted records"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
	_LIT(KScrTestSelect, "SELECT SoftwareTypeId,InstalledDrivesRefCount,Version FROM Components;");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
	stmt = db->PrepareStatementLC(KScrTestSelect());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
	if(!stmt->ProcessNextRowL())
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
		PrintErrorL(_L("Result row set contains unexpected number of records (0)!"), KErrGeneral);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
	VerifyRecordL(*stmt, KSoftTypeIdRow1, KInstalledDrivesRow1, KVersionRow1);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
	if(!stmt->ProcessNextRowL())
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
		PrintErrorL(_L("Result row set contains unexpected number of records (1)!"), KErrGeneral);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
	VerifyRecordL(*stmt, KSoftTypeIdRow2, KInstalledDrivesRow2(), KVersionRow2());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
	if(stmt->ProcessNextRowL())
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
		PrintErrorL(_L("Result row set contains more records than expected ones (2)!"), KErrGeneral);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
	CleanupStack::PopAndDestroy(stmt);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
	INFO_PRINTF1(_L(" SEC_SCR_DataLayer_0004: Update a record"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
	_LIT(KScrTestUpdate, "UPDATE Components SET Version=? WHERE InstalledDrivesRefCount=?;");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
	stmt = db->PrepareStatementLC(KScrTestUpdate());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
	_LIT(KNewVersionRow2, "6.7.9");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
	stmt->BindStrL(1, KNewVersionRow2());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
	stmt->BindStrL(2, KInstalledDrivesRow2());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
	stmt->ExecuteStatementL();
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
	CleanupStack::PopAndDestroy(stmt);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
	INFO_PRINTF1(_L(" SEC_SCR_DataLayer_0005: Verify updated record"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
	_LIT(KScrTestSelectCond, "SELECT SoftwareTypeId,InstalledDrivesRefCount,Version FROM Components WHERE InstalledDrivesRefCount=?;");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
	stmt = db->PrepareStatementLC(KScrTestSelectCond());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
	stmt->BindStrL(1, KInstalledDrivesRow2());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
	if(!stmt->ProcessNextRowL())
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
		PrintErrorL(_L("Updated record could not be found!"), KErrGeneral);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
	VerifyRecordL(*stmt, KSoftTypeIdRow2, KInstalledDrivesRow2(), KNewVersionRow2());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
	CleanupStack::PopAndDestroy(stmt);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
		
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
	INFO_PRINTF1(_L(" SEC_SCR_DataLayer_0006: Delete a record"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
	_LIT(KScrTestDelete, "DELETE FROM Components WHERE InstalledDrivesRefCount=?;");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
	stmt = db->PrepareStatementLC(KScrTestDelete());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
	stmt->BindStrL(1, KInstalledDrivesRow1());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
	stmt->ExecuteStatementL();
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
	CleanupStack::PopAndDestroy(stmt);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
	INFO_PRINTF1(_L("SEC_SCR_DataLayer_0007: Verify deleted record"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
	_LIT(KScrTestSelectVerify, "SELECT * FROM Components WHERE InstalledDrivesRefCount=?;");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
	stmt = db->PrepareStatementLC(KScrTestSelectVerify());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
	stmt->BindStrL(1, KInstalledDrivesRow1());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
	if(stmt->ProcessNextRowL())
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
		PrintErrorL(_L("Deleted record has been retrieved!"), KErrGeneral);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
	CleanupStack::PopAndDestroy(stmt);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
	INFO_PRINTF1(_L("SEC_SCR_DataLayer_0008: Begin a transaction"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
	_LIT(KScrTestBegin, "BEGIN TRANSACTION SCRUnitTest;");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
	stmt = db->PrepareStatementLC(KScrTestBegin());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
	stmt->ExecuteStatementL();
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
	CleanupStack::PopAndDestroy(stmt);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
	INFO_PRINTF1(_L("SEC_SCR_DataLayer_0009: Insert a record"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
	stmt = db->PrepareStatementLC(KScrTestInsert());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
	const TInt KSoftTypeIdRow3 = 1;
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
	_LIT(KInstalledDrivesRow3, "789");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
	_LIT(KVersionRow3, "1.1.3");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
	InsertRecordL(*stmt, KSoftTypeIdRow3, KInstalledDrivesRow3(), KVersionRow3());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
	CleanupStack::PopAndDestroy(stmt);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
	INFO_PRINTF1(_L("SEC_SCR_DataLayer_0010: Insert second record"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
	stmt = db->PrepareStatementLC(KScrTestInsert());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
	const TInt KSoftTypeIdRow4 = 3;
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
	_LIT(KInstalledDrivesRow4, "001");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
	_LIT(KVersionRow4, "0.0.7");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
	InsertRecordL(*stmt, KSoftTypeIdRow4, KInstalledDrivesRow4(), KVersionRow4());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
	CleanupStack::PopAndDestroy(stmt);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
	INFO_PRINTF1(_L("SEC_SCR_DataLayer_0011: Rollback the transaction"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
	_LIT(KScrTestRollback, "ROLLBACK TRANSACTION SCRUnitTest;");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
	stmt = db->PrepareStatementLC(KScrTestRollback());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
	stmt->ExecuteStatementL();
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
	CleanupStack::PopAndDestroy(stmt);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
	INFO_PRINTF1(_L("SEC_SCR_DataLayer_0012: Verify rollback"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
	stmt = db->PrepareStatementLC(KScrTestSelectVerify());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
	stmt->BindStrL(1, KInstalledDrivesRow3());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
	if(stmt->ProcessNextRowL())
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
		PrintErrorL(_L("First record inserted  has been retrieved! It should have been rolled back!"), KErrGeneral);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
	stmt->ResetL();
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
	stmt->BindStrL(1, KInstalledDrivesRow4());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
	if(stmt->ProcessNextRowL())
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
		PrintErrorL(_L("Second record inserted  has been retrieved! It should have been rolled back!"), KErrGeneral);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
	CleanupStack::PopAndDestroy(stmt);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
	ExecuteBadStatementL(*db, 13, _L("INSERT INTO Components;"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
	ExecuteBadStatementL(*db, 14, _L(";"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
	ExecuteBadStatementL(*db, 15, _L("SELECT * FROM Components;SELECT * FROM Files;"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
		
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
	INFO_PRINTF1(_L("SEC_SCR_DataLayer_0016: Bind to a column which does not exist"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
	stmt = db->PrepareStatementLC(KScrTestInsert());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
	TRAP(err, stmt->BindIntL(5, 1)); // There is no 5th column
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
	if(err != KErrArgument)
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
		PrintErrorL(_L("Unexpected error returned with binding to a non-existing column!"), err);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
	CleanupStack::PopAndDestroy(stmt);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
	INFO_PRINTF1(_L("SEC_SCR_DataLayer_0017: Retrieve the value of a column which does not exist"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
	stmt = db->PrepareStatementLC(KScrTestSelect());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
	if(!stmt->ProcessNextRowL())
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
			PrintErrorL(_L("The database is empty!"), KErrGeneral);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
	TRAP(err,TPtrC ptrColX(stmt->StrColumnL(5))); // There is no 5th column
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
	if(err != KErrArgument)
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
		PrintErrorL(_L("Unexpected error returned with retrieving a non-existing column!"), err);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
	TRAP(err,TPtrC ptrColX(stmt->StrColumnL(-1))); // Check negative value
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
	if(err != KErrArgument)
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
		PrintErrorL(_L("Unexpected error returned with retrieving a negative column!"), err);	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
	INFO_PRINTF1(_L("SEC_SCR_DataLayer_0018: Retrieve the value of a column whose type doesn't match"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
	TRAP(err,TPtrC ptrCol0(stmt->StrColumnL(0))); // Column0 is integer
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
	if(err != KErrArgument)
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
		PrintErrorL(_L("Unexpected error returned with retrieving the type mismatched column!"), err);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
	CleanupStack::PopAndDestroy(stmt);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
	INFO_PRINTF1(_L("SEC_SCR_DataLayer_0019: Insert a record - attempt injecting raw SQL in parameters"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
	stmt = db->PrepareStatementLC(KScrTestInsert());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
	const TInt KSoftTypeIdRowInject1 = 1;
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
	_LIT(KRowInject1, "a?b");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
	_LIT(KVersionRowInject1, "???");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
	InsertRecordL(*stmt, KSoftTypeIdRowInject1, KRowInject1(), KVersionRowInject1());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
	_LIT(KRowInject2, "';<>!?\\/.,~#:");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
	_LIT(KRowInject3, "\n\r\t\b");	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
	InsertRecordL(*stmt, KSoftTypeIdRowInject1, KRowInject2(), KRowInject3());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
	CleanupStack::PopAndDestroy(stmt);	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
	INFO_PRINTF1(_L("SEC_SCR_DataLayer_0020: Query - attempt injecting raw SQL"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
	_LIT(KScrInjectTestQuery, "SELECT * FROM Components WHERE ComponentId=?;");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
	stmt = db->PrepareStatementLC(KScrInjectTestQuery());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
	stmt->BindStrL(1, KRowInject1());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
	stmt->ProcessNextRowL();
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
	CleanupStack::PopAndDestroy(stmt);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
	stmt = db->PrepareStatementLC(KScrInjectTestQuery());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
	stmt->BindStrL(1, KRowInject2());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
	stmt->ProcessNextRowL();
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
	CleanupStack::PopAndDestroy(stmt);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
	stmt = db->PrepareStatementLC(KScrInjectTestQuery());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
	stmt->BindStrL(1, KRowInject3());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
	stmt->ProcessNextRowL();		
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   245
	CleanupStack::PopAndDestroy(stmt);	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
	_LIT8(K8BitInstalledDrives, "testInstalledDrives");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
	_LIT8(K8BitVersion, "testVersion");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
	INFO_PRINTF1(_L("SEC_SCR_DataLayer_0021: Test 8-bit field support"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
	stmt = db->PrepareStatementLC(KScrTestInsert());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
	stmt->BindIntL(1, 1);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
	stmt->BindBinaryL(2, K8BitInstalledDrives());	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
	stmt->BindBinaryL(3, K8BitVersion());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
	stmt->BindIntL(4, 0); // install time
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
	stmt->ExecuteStatementL();
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
	CleanupStack::PopAndDestroy(stmt);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
	// Try and do a select by 8-bit values, followed by their retrieval
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   259
	_LIT(KScr8BitTestQuery, "SELECT InstalledDrivesRefCount, ComponentId FROM Components WHERE Version=?;");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
	stmt = db->PrepareStatementLC(KScr8BitTestQuery());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
	stmt->BindBinaryL(1, K8BitVersion());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
	if(!stmt->ProcessNextRowL())
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
		PrintErrorL(_L("8-bit value SELECT did not match!"), KErrGeneral);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
	TPtrC8 ptrCol(stmt->BinaryColumnL(0));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
	if (ptrCol != K8BitInstalledDrives)
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
		PrintErrorL(_L("8-bit values did not match!"), KErrGeneral);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
	TRAP(err, stmt->BinaryColumnL(1));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
	if (err != KErrArgument)
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
		PrintErrorL(_L("Expected error on non-binary columnb did not match!"), KErrGeneral);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
	CleanupStack::PopAndDestroy(stmt);			
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
	INFO_PRINTF1(_L("SEC_SCR_DataLayer_0022: Try binding huge parameters"));	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
	stmt = db->PrepareStatementLC(KScrInjectTestQuery());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
  	static TUint charsCount = 1024;
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
  	_LIT(KTestPrefix, "TestValuePrefix");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
  	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
  	// Test large localizable property with negative values
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   279
  	RBuf propertyValue;
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
  	propertyValue.CreateL(charsCount * 2 + KTestPrefix().Length());
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   281
  	CleanupClosePushL(propertyValue);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   282
  	propertyValue.Copy(KTestPrefix);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
  	const TChar testChar(0xFFFD);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
  	propertyValue.AppendFill(testChar, charsCount);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
	TRAP(err, stmt->BindStrL(2, propertyValue));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
	if (err != KErrArgument)
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
		PrintErrorL(_L("Expected error wasn't returned on large parameter!"), KErrGeneral);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
	CleanupStack::PopAndDestroy(&propertyValue);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
		
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
	CleanupStack::PopAndDestroy(4, &databaseFile); // databaseFile, journalFile, db, stmt
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
	INFO_PRINTF1(_L("SEC_SCR_DataLayer_0023: Open and work on a non-database file"));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
	CDatabase* nondb(0); 
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
	_LIT(KScrTestNonDbFile, "c:\\private\\1028634C\\nonscr.db");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
	_LIT(KScrTestNonDbFileJournal, "c:\\private\\1028634C\\nonscr.db-journal");
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
	User::LeaveIfError(databaseFile.Open(fs, KScrTestNonDbFile, EFileShareAny|EFileRead));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
	CleanupClosePushL(databaseFile);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
	User::LeaveIfError(journalFile.Replace(fs, KScrTestNonDbFileJournal, EFileShareAny|EFileWrite));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
	CleanupClosePushL(journalFile);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
	nondb = CDatabase::NewL(databaseFile, journalFile);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
	CleanupStack::PushL(nondb);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
  	stmt = NULL;
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
  	TRAP(err, stmt = nondb->PrepareStatementLC(KScrTestSelect()));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
  	if (stmt) 
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
  		CleanupStack::PopAndDestroy(stmt);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
   	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
  	if(err == KErrNoMemory)
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
  		User::Leave(err);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
  	else if(err != KErrNotFound)
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
  		PrintErrorL(_L("Unexpected error returned with non-database file!"), err);			
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
	CleanupStack::PopAndDestroy(4, &fs); // fs, databaseFile, journalFile, nondb
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
	}
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
void CScrTestDataLayer::InsertRecordL(CStatement& aStmt, TInt aCol1, const TDesC& aCol2, const TDesC& aCol3)
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
	{
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
	aStmt.BindIntL(1, aCol1);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
	aStmt.BindStrL(2, aCol2);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
	aStmt.BindStrL(3, aCol3);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
	aStmt.BindIntL(4, aCol1); // install time
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
	aStmt.ExecuteStatementL();
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
	aStmt.ResetL();
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
	}
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
void CScrTestDataLayer::VerifyRecordL(CStatement& aStmt, TInt aCol1, const TDesC& aCol2, const TDesC& aCol3)
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
	{
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
	TInt intCol1 = aStmt.IntColumnL(0);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
	TInt64 int64Col1 = aStmt.Int64ColumnL(0); // Due to coverage concerns
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
	if((intCol1 != aCol1) || (int64Col1 != aCol1))
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
		{
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
		ERR_PRINTF1(_L("The integer column does not match with the returned one."));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
		SetTestStepResult(EFail);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
		User::Leave(KErrGeneral);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
		}
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
	TPtrC ptrCol2(aStmt.StrColumnL(1));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
	TPtrC ptrCol3(aStmt.StrColumnL(2));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
	if(ptrCol2.Compare(aCol2) || ptrCol3.Compare(aCol3))
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
		{
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
		ERR_PRINTF1(_L("The string column does not match with the returned one."));
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
		SetTestStepResult(EFail);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
		User::Leave(KErrGeneral);	
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
		}
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
	}
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   345
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   346
void CScrTestDataLayer::ExecuteBadStatementL(CDatabase &aDb, TInt aTestNum, const TDesC& aStatement)
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
	{
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
	INFO_PRINTF3(_L("SEC_SCR_DataLayer_00%d: Run a badly constructed statement (%S)"), aTestNum, &aStatement);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
	CStatement	*stmt = NULL;
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   350
	TRAPD(err, stmt = aDb.PrepareStatementLC(aStatement); 
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
		  if(stmt) 
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   352
			  CleanupStack::PopAndDestroy(stmt););// end of TRAPD
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   353
	if(err != KErrArgument)
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
			PrintErrorL(_L("The badly constructed statement did not cause the expected err"), err);
84a16765cd86 Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
	}