os/persistentdata/persistentstorage/centralrepository/pccenrep/test/common_neg.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/centralrepository/pccenrep/test/common_neg.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,526 @@
     1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#ifdef CENREP_PC_TEST
    1.20 +	#include <x86tool/centralrepository.h>
    1.21 +#else
    1.22 +	#include <centralrepository.h>
    1.23 +#endif
    1.24 +
    1.25 +#include <e32test.h>
    1.26 +#include <f32file.h>
    1.27 +
    1.28 +enum TestMode{
    1.29 +	ETxt,
    1.30 +	ECre,
    1.31 +	EAutoCre,
    1.32 +	EAutoTxt
    1.33 +};
    1.34 +
    1.35 +//DEFINED IN THE TEST MAIN CPP
    1.36 +extern void SetupEnv(const TDesC& aInFilePath,const TDesC& aOutFilePath,TUint aTestMode);
    1.37 +extern RFs TheFs;
    1.38 +extern RTest TheTest;
    1.39 +
    1.40 +using namespace NCentralRepositoryConstants;
    1.41 +
    1.42 +_LIT(KLongBuf16,"sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\
    1.43 +	ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\
    1.44 +	ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\
    1.45 +	ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\
    1.46 +	ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\
    1.47 +	ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\
    1.48 +	ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\
    1.49 +	ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\
    1.50 +	ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\
    1.51 +	ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\
    1.52 +	ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\
    1.53 +	ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss");
    1.54 +
    1.55 +
    1.56 +////////////////////////////////////////////////////////////////////////////////
    1.57 +// Test macro and function.
    1.58 +
    1.59 +LOCAL_C void Check(TInt aValue, TInt aLine)
    1.60 +	{
    1.61 +	if(!aValue)
    1.62 +		{
    1.63 +		TheTest(EFalse, aLine);
    1.64 +		}
    1.65 +	}
    1.66 +
    1.67 +LOCAL_C void Check(TInt aValue, TInt aExpected, TInt aLine)
    1.68 +	{
    1.69 +	if(aValue != aExpected)
    1.70 +		{
    1.71 +		RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
    1.72 +		TheTest(EFalse, aLine);
    1.73 +		}
    1.74 +	}
    1.75 +
    1.76 +#define TEST(arg) ::Check((arg), __LINE__)
    1.77 +#define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
    1.78 +
    1.79 +////////////////////////////////////////////////////////////////////////////////
    1.80 +
    1.81 +/**
    1.82 +NEWL Negative Testing
    1.83 +*/
    1.84 +void NewL(TUint aTestMode)
    1.85 +	{
    1.86 +	CRepository* repos=NULL;
    1.87 +	//Negative testing to do with initialising the repository
    1.88 +	
    1.89 +	//-repository file not found
    1.90 +	TUid nonexistentRepository={0x88888888};
    1.91 +	TRAPD(err,repos=CRepository::NewL(nonexistentRepository));
    1.92 +	TEST2(err, KErrNotFound);
    1.93 +	
    1.94 +	//-repository file corrupt
    1.95 +	TUid corruptRepositoryUid;
    1.96 +	if (aTestMode==EAutoCre)
    1.97 +		corruptRepositoryUid=TUid::Uid(0x88888881);
    1.98 +	else
    1.99 +		corruptRepositoryUid=TUid::Uid(0x88888880);
   1.100 +	TRAP(err,repos=CRepository::NewL(corruptRepositoryUid));
   1.101 +	TEST2(err, KErrCorrupt);
   1.102 +	
   1.103 +	delete repos;
   1.104 +	}
   1.105 +
   1.106 +
   1.107 +void GetFunction(CRepository* aRepository)
   1.108 +	{
   1.109 +	TInt error;
   1.110 +	TInt intVal;
   1.111 +	TReal realVal;
   1.112 +	TBuf<50> longStr;
   1.113 +	
   1.114 +	//GENERAL
   1.115 +	//-Setting does not exist
   1.116 +	error = aRepository->Get(100, intVal);
   1.117 +	TEST2(error, KErrNotFound);
   1.118 +	error = aRepository->Get(100, realVal);
   1.119 +	TEST2(error, KErrNotFound);
   1.120 +	error = aRepository->Get(100, longStr);
   1.121 +	TEST2(error, KErrNotFound);
   1.122 +	
   1.123 +	//-Setting exist but not requested type(mismatch)
   1.124 +	//INT
   1.125 +	error = aRepository->Get(1, realVal);
   1.126 +	TEST2(error, KErrArgument);
   1.127 +	error = aRepository->Get(1, longStr);
   1.128 +	TEST2(error, KErrArgument);
   1.129 +	
   1.130 +	//REAL
   1.131 +	error = aRepository->Get(2, intVal);
   1.132 +	TEST2(error, KErrArgument);
   1.133 +	error = aRepository->Get(2, longStr);
   1.134 +	TEST2(error, KErrArgument);
   1.135 +	
   1.136 +	//DESC8,DESC16
   1.137 +	error = aRepository->Get(0x300, intVal);
   1.138 +	TEST2(error, KErrArgument);
   1.139 +	error = aRepository->Get(0x300, realVal);
   1.140 +	TEST2(error, KErrArgument);
   1.141 +	
   1.142 +	//-The buffer allocated too small
   1.143 +	TBuf8<4> short8BitStr;
   1.144 +	error = aRepository->Get(11, short8BitStr);
   1.145 +	TEST2(error, KErrOverflow);
   1.146 +	//-The bufer allocated is ok
   1.147 +	TBuf8<12> good8BitStr;
   1.148 +	error = aRepository->Get(11, good8BitStr);
   1.149 +	TEST2(error, KErrNone);
   1.150 +	//-The buffer allocated is too big(not a problem)
   1.151 +	TBuf8<50> long8BitStr;
   1.152 +	error = aRepository->Get(11, long8BitStr);
   1.153 +	TEST2(error, KErrNone);
   1.154 +	//DESC8,DESC16(with actual length)
   1.155 +	//-The buffer allocated too small
   1.156 +	TBuf<4> shortStr;
   1.157 +	error = aRepository->Get(0x300, shortStr);
   1.158 +	TEST2(error, KErrOverflow);
   1.159 +	//-The bufer allocated is ok
   1.160 +	TBuf<11> goodStr;
   1.161 +	error = aRepository->Get(0x300, goodStr);
   1.162 +	TEST2(error, KErrNone);
   1.163 +	//-The buffer allocated is too big(not a problem)
   1.164 +	error = aRepository->Get(0x300, longStr);
   1.165 +	TEST2(error, KErrNone);
   1.166 +	}
   1.167 +	
   1.168 +void GetMeta(CRepository* aRepository)
   1.169 +	{
   1.170 +	//-Setting does not exist	
   1.171 +	TUint32 meta;
   1.172 +	TInt error;
   1.173 +	error = aRepository->GetMeta(100, meta);
   1.174 +	TEST2(error, KErrNotFound);
   1.175 +	}
   1.176 +
   1.177 +void FindFunctionL(CRepository* aRepository)
   1.178 +	{
   1.179 +	RArray<TUint32> keyList;
   1.180 +	RArray<TUint32> shortKeyList(1);
   1.181 +	CleanupClosePushL(keyList);
   1.182 +	CleanupClosePushL(shortKeyList);
   1.183 +	
   1.184 +	TInt error;
   1.185 +	
   1.186 +	//FindL
   1.187 +	//-Partial setting list requested not found(based on partialid and mask)
   1.188 +	error = aRepository->FindL(0x0000FFFF, 0x0000F000, keyList);
   1.189 +	TEST2(error, KErrNotFound);
   1.190 +	
   1.191 +	//-purposely initially allocated a array with small size(force it to grow)
   1.192 +	error = aRepository->FindL(0xFFFFFFFF, 0x0, shortKeyList);
   1.193 +	TEST2(error, KErrNone);
   1.194 +	TEST2(shortKeyList.Count(), 33);
   1.195 +	
   1.196 +	//FindEqL/FindNeqL
   1.197 +	keyList.Reset();
   1.198 +	error = aRepository->FindEqL(0xFFFFFFFF, 0, 199, keyList);
   1.199 +	TEST2(error, KErrNotFound);
   1.200 +
   1.201 +	//GENERAL
   1.202 +	//-Partial setting list requested not found(based on partialid and mask)
   1.203 +	keyList.Reset();
   1.204 +	error = aRepository->FindEqL(0x0000FFFF, 0x0000F000, 100, keyList);
   1.205 +	TEST2(error, KErrNotFound);
   1.206 +	keyList.Reset();
   1.207 +	error = aRepository->FindNeqL(0x0000FFFF, 0x0000F000, 100, keyList);
   1.208 +	TEST2(error, KErrNotFound);
   1.209 +	
   1.210 +	//-Partial setting list found but some setting not the TYPE as requested(ensure not returned)
   1.211 +	//INT
   1.212 +	keyList.Reset();
   1.213 +	error = aRepository->FindEqL(0x00100000, 0xFFFFF0FF, 88, keyList);
   1.214 +	TEST2(error, KErrNone);
   1.215 +	TEST2(keyList.Count(), 2);
   1.216 +	
   1.217 +	keyList.Reset();
   1.218 +	error = aRepository->FindNeqL(0x00100000, 0xFFFFF0FF, 88, keyList);
   1.219 +	TEST2(error, KErrNone);
   1.220 +	TEST2(keyList.Count(), 3);
   1.221 +	
   1.222 +	//REAL
   1.223 +	keyList.Reset();
   1.224 +	error = aRepository->FindEqL(0x00100000, 0xFFFFF0FF, 88.0, keyList);
   1.225 +	TEST2(error, KErrNone);
   1.226 +	TEST2(keyList.Count(), 2);
   1.227 +	
   1.228 +	keyList.Reset();
   1.229 +	error = aRepository->FindNeqL(0x00100000, 0xFFFFF0FF, 88.0, keyList);
   1.230 +	TEST2(error, KErrNone);
   1.231 +	TEST2(keyList.Count(), 3);
   1.232 +
   1.233 +	_LIT(KString16, "88");
   1.234 +	
   1.235 +	keyList.Reset();
   1.236 +	error = aRepository->FindEqL(0x00100000, 0xFFFFF0FF, KString16, keyList);
   1.237 +	TEST2(error, KErrNone);
   1.238 +	TEST2(keyList.Count(), 1);
   1.239 +	
   1.240 +	keyList.Reset();
   1.241 +	error = aRepository->FindNeqL(0x00100000, 0xFFFFF0FF, KString16, keyList);
   1.242 +	TEST2(error, KErrNone);
   1.243 +	TEST2(keyList.Count(), 4);
   1.244 +	
   1.245 +	_LIT(KString8, "88");
   1.246 +	
   1.247 +	keyList.Reset();
   1.248 +	error = aRepository->FindEqL(0x00100000, 0xFFFFF0FF, KString8, keyList);
   1.249 +	TEST2(error, KErrNone);
   1.250 +	TEST2(keyList.Count(), 1);
   1.251 +	
   1.252 +	keyList.Reset();
   1.253 +	error = aRepository->FindNeqL(0x00100000, 0xFFFFF0FF, KString8, keyList);
   1.254 +	TEST2(error, KErrNone);
   1.255 +	TEST2(keyList.Count(), 4);
   1.256 +	
   1.257 +	//-A value specified greater than the max limit allowed KMaxBinaryLength(8 bit) and KMaxUnicodeStringLength(16 bit)
   1.258 +	TBuf8<KMaxUnicodeStringLength*3> KLongBuf8;
   1.259 +	KLongBuf8.Copy(KLongBuf16);
   1.260 +	KLongBuf8.Append(KLongBuf16);
   1.261 +
   1.262 +	keyList.Reset();
   1.263 +	error = aRepository->FindEqL(0xFFFFFFFF, 0, KLongBuf8, keyList);
   1.264 +	TEST2(error, KErrNotFound);
   1.265 +	keyList.Reset();
   1.266 +	error = aRepository->FindNeqL(0xFFFFFFFF, 0, KLongBuf8, keyList);
   1.267 +	TEST2(error, KErrNone);
   1.268 +	TEST2(shortKeyList.Count(), 33);
   1.269 +	
   1.270 +	keyList.Reset();
   1.271 +	error = aRepository->FindEqL(0xFFFFFFFF, 0, KLongBuf16, keyList);
   1.272 +	TEST2(error, KErrNotFound);
   1.273 +	keyList.Reset();
   1.274 +	error = aRepository->FindNeqL(0xFFFFFFFF, 0, KLongBuf16, keyList);
   1.275 +	TEST2(error, KErrNone);
   1.276 +	TEST2(shortKeyList.Count(), 33);
   1.277 +	
   1.278 +	//-A value specified empty
   1.279 +	_LIT8(KEmptyStr8, "");
   1.280 +	keyList.Reset();
   1.281 +	error = aRepository->FindEqL(0xFFFFFFFF, 0, KEmptyStr8, keyList);
   1.282 +	TEST2(error, KErrNotFound);
   1.283 +	keyList.Reset();
   1.284 +	error = aRepository->FindNeqL(0xFFFFFFFF, 0, KEmptyStr8, keyList);
   1.285 +	TEST2(error, KErrNone);
   1.286 +	TEST2(shortKeyList.Count(), 33);
   1.287 +	
   1.288 +	_LIT16(KEmptyStr16, "");
   1.289 +	keyList.Reset();
   1.290 +	error = aRepository->FindEqL(0xFFFFFFFF, 0, KEmptyStr16, keyList);
   1.291 +	TEST2(error, KErrNotFound);
   1.292 +	keyList.Reset();
   1.293 +	error = aRepository->FindNeqL(0xFFFFFFFF, 0, KEmptyStr16, keyList);
   1.294 +	TEST2(error, KErrNone);
   1.295 +	TEST2(shortKeyList.Count(), 33);
   1.296 +	
   1.297 +	CleanupStack::PopAndDestroy(2);
   1.298 +	}
   1.299 +
   1.300 +void SetFunction(CRepository* aRepository)
   1.301 +	{
   1.302 +	//----------SET
   1.303 +	//GENERAL:
   1.304 +	//-Setting exist but not requested type(mismatch)
   1.305 +	//-If setting does not exist, it creates one(also check the expected meta)
   1.306 +	//INT
   1.307 +	//REAL
   1.308 +	//DESC8,DESC16
   1.309 +	//-Try to set a setting that is greater than KMaxBinaryLength(8 bit) and KMaxUnicodeStringLength(16 bit)
   1.310 +	//-Try to set a setting with empty string content(is this a problem)
   1.311 +		
   1.312 +	TInt intVal=0;
   1.313 +	TReal realVal=0;
   1.314 +	TUint32 metaVal=0;
   1.315 +	
   1.316 +	//INT
   1.317 +	TInt err=aRepository->Set(0x2,intVal);
   1.318 +	TEST2(err, KErrArgument);
   1.319 +	err=aRepository->Set(0x888,888);
   1.320 +	TEST2(err, KErrNone);
   1.321 +	err=aRepository->Get(0x888,intVal);
   1.322 +	TEST2(intVal, 888);
   1.323 +	//will use default one
   1.324 +	err=aRepository->GetMeta(0x888,metaVal);
   1.325 +	TEST2(metaVal, 0x10);
   1.326 +	
   1.327 +	//REAL
   1.328 +	err=aRepository->Set(0x1,realVal);
   1.329 +	TEST2(err, KErrArgument);
   1.330 +	err=aRepository->Set(0x333,333.33);
   1.331 +	TEST2(err, KErrNone);
   1.332 +	err=aRepository->Get(0x333,realVal);
   1.333 +	TEST(realVal == 333.33);
   1.334 +	//will use range one
   1.335 +	err=aRepository->GetMeta(0x333,metaVal);
   1.336 +	TEST2(metaVal, 0x20);
   1.337 +	
   1.338 +	//DESC8,DESC16
   1.339 +	_LIT8(KBuf8,"full");
   1.340 +	err=aRepository->Set(0x1,KBuf8());
   1.341 +	TEST2(err, KErrArgument);
   1.342 +	_LIT(KBuf16,"full");
   1.343 +	err=aRepository->Set(0x1,KBuf16());
   1.344 +	TEST2(err, KErrArgument);
   1.345 +	err=aRepository->Set(0x111,KBuf16());
   1.346 +	TEST2(err, KErrNone);
   1.347 +	TBuf16<255> buffer16;
   1.348 +	err=aRepository->Get(0x111,buffer16);
   1.349 +	TEST2(err, KErrNone);
   1.350 +	TEST2(buffer16.Compare(KBuf16()), 0);
   1.351 +	err=aRepository->GetMeta(0x111,metaVal);
   1.352 +	//will use range one
   1.353 +	err=aRepository->GetMeta(0x111,metaVal);
   1.354 +	TEST2(metaVal, 0x20);	
   1.355 +	
   1.356 +	//Set an existing string setting with string longer than limit(KMaxUnicodeStringLength)
   1.357 +	TBuf8<KMaxUnicodeStringLength*3> KLongBuf8;
   1.358 +	KLongBuf8.Copy(KLongBuf16());
   1.359 +	KLongBuf8.Append(KLongBuf16());
   1.360 +
   1.361 +	//try it on existing string setting
   1.362 +	err=aRepository->Set(0x222,KLongBuf16());
   1.363 +	TEST2(err, KErrArgument);
   1.364 +	err=aRepository->Set(0x222,KLongBuf8);
   1.365 +	TEST2(err, KErrArgument);
   1.366 +	
   1.367 +	//set an empty string content
   1.368 +	_LIT8(KEmptyString8,"");
   1.369 +	err=aRepository->Set(0x444,KEmptyString8());
   1.370 +	TEST2(err, KErrNone);
   1.371 +	_LIT16(KEmptyString16,"");
   1.372 +	err=aRepository->Set(0x555,KEmptyString16());
   1.373 +	TEST2(err, KErrNone);
   1.374 +	}
   1.375 +
   1.376 +void CreateFunction(CRepository* aRepository)
   1.377 +	{
   1.378 +	//----------CREATE
   1.379 +	//GENERAL:
   1.380 +	//-Setting already exist
   1.381 +	//INT
   1.382 +	//REAL
   1.383 +	//DESC8,DESC16
   1.384 +	//-Try to create a setting that is greater than KMaxBinaryLength(8 bit) and KMaxUnicodeStringLength(16 bit)
   1.385 +	//-Try to set a setting with empty string content(is this a problem)
   1.386 +	TInt intVal = 0;
   1.387 +	TReal realVal = 0.0;
   1.388 +
   1.389 +	//INT
   1.390 +	TInt err=aRepository->Create(1,intVal);
   1.391 +	TEST2(err, KErrAlreadyExists);
   1.392 +	//REAL
   1.393 +	err=aRepository->Create(2,realVal);
   1.394 +	TEST2(err, KErrAlreadyExists);
   1.395 +	//DESC8,DESC16
   1.396 +	_LIT8(KString8,"string");
   1.397 +	_LIT16(KString16,"string");	
   1.398 +	err=aRepository->Create(5,KString8);
   1.399 +	TEST2(err, KErrAlreadyExists);
   1.400 +	err=aRepository->Create(5,KString16);
   1.401 +	TEST2(err, KErrAlreadyExists);		
   1.402 +	
   1.403 +	//empty string
   1.404 +	_LIT8(KEmptyString8,"");
   1.405 +	_LIT8(KEmptyString16,"");
   1.406 +	err=aRepository->Create(0x1111,KEmptyString8());
   1.407 +	TEST2(err, KErrNone); 
   1.408 +	err=aRepository->Create(0x2222,KEmptyString16());
   1.409 +	TEST2(err, KErrNone);
   1.410 +	
   1.411 +	//Create an existing string setting with string longer than limit(KMaxUnicodeStringLength)
   1.412 +	TBuf8<KMaxUnicodeStringLength*3> KLongBuf8;
   1.413 +	KLongBuf8.Copy(KLongBuf16());
   1.414 +	KLongBuf8.Append(KLongBuf16());
   1.415 +
   1.416 +	err=aRepository->Create(0x3333,KLongBuf16());
   1.417 +	TEST2(err, KErrArgument);
   1.418 +	err=aRepository->Create(0x4444,KLongBuf8);
   1.419 +	TEST2(err, KErrArgument);
   1.420 +	}
   1.421 +
   1.422 +void DeleteFunction(CRepository* aRepository)
   1.423 +	{
   1.424 +	//----------DELETE SINGLE
   1.425 +	//-Setting does not exist
   1.426 +	//-Delete a setting and then recreate,see original meta data preserved(vary with default,range,single)
   1.427 +	//-When deleted always verify setting does not exist
   1.428 +	TInt err=aRepository->Delete(0x757);
   1.429 +	TEST2(err, KErrNotFound);
   1.430 +	
   1.431 +	//delete and existing setting with single meta, then recreate it, expect same meta before deletion
   1.432 +	TReal realVal;
   1.433 +	TUint32 metaVal;
   1.434 +	//this is the original setting meta
   1.435 +	err=aRepository->GetMeta(2,metaVal);
   1.436 +	TEST2(metaVal, 0xa);
   1.437 +	err=aRepository->Delete(2);
   1.438 +	TEST2(err, KErrNone);
   1.439 +	err=aRepository->Get(2,realVal);
   1.440 +	TEST2(err, KErrNotFound);
   1.441 +	err=aRepository->Create(2,realVal);
   1.442 +	TEST2(err, KErrNone);
   1.443 +	TUint32 newMetaVal;
   1.444 +	err=aRepository->GetMeta(2,newMetaVal);
   1.445 +	TEST2(err, KErrNone);
   1.446 +	TEST2(newMetaVal, metaVal);
   1.447 +	
   1.448 +	
   1.449 +	//----------DELETE RANGE
   1.450 +	//-Partial setting list requested not found(based on partialid and mask)
   1.451 +	//-Check the aErrorKey returned with each of the negative testing.
   1.452 +	TUint32 error;
   1.453 +	err=aRepository->Delete(0x0F010000,0xFFFFF0FF,error);
   1.454 +	TEST2(err, KErrNotFound);
   1.455 +	//if not found, the error key here will be set to the partial ID
   1.456 +	TEST2(error, 0x0F010000);
   1.457 +
   1.458 +	}
   1.459 +
   1.460 +void MoveFunction(CRepository* aRepository)
   1.461 +	{
   1.462 +	//-Partial setting list requested not found(based on partialid and mask)
   1.463 +	//-Intended target setting already exist(say 1 out of X)
   1.464 +	TUint32 errorId;	
   1.465 +	TInt err=aRepository->Move(0x0F010000,0x0E010000,0xFFFFF0FF,errorId);
   1.466 +	TEST2(err, KErrNotFound);
   1.467 +	TEST2(errorId, 0x0F010000);
   1.468 +
   1.469 +	
   1.470 +	err=aRepository->Move(0x03010000,0x02010000,0xFFFFF0FF,errorId);
   1.471 +	TEST2(err, KErrAlreadyExists);
   1.472 +	//errorId will be set to the first id of the target when error is encountered
   1.473 +	TEST2(errorId, 0x02010100);
   1.474 +	}
   1.475 +
   1.476 +/**
   1.477 +*/
   1.478 +void NegativeTestingL(TUid aUid,const TDesC& aInFile,const TDesC& aOutFile,TUint aTestMode)
   1.479 +	{
   1.480 +	SetupEnv(aInFile,aOutFile,aTestMode);
   1.481 +	
   1.482 +	__UHEAP_MARK;
   1.483 +	
   1.484 +	//repository initialising negative testing
   1.485 +	NewL(aTestMode);
   1.486 +	
   1.487 +	//ok repository but operation negative testing
   1.488 +	CRepository* repository=CRepository::NewLC(aUid);
   1.489 +
   1.490 +	//these are all negative testing specifically each of the error code
   1.491 +	GetFunction(repository);
   1.492 +	GetMeta(repository);
   1.493 +	FindFunctionL(repository);
   1.494 +	SetFunction(repository);
   1.495 +	CreateFunction(repository);
   1.496 +	DeleteFunction(repository);
   1.497 +	MoveFunction(repository);
   1.498 +
   1.499 +	CleanupStack::PopAndDestroy();	
   1.500 +	
   1.501 +	__UHEAP_MARKEND;
   1.502 +	}
   1.503 +
   1.504 +TInt CopyFile(const TDesC& aSource, const TDesC& aTarget)
   1.505 +	{
   1.506 +	RFile file;
   1.507 +	TInt ret=file.Open(TheFs,aSource,EFileRead);
   1.508 +	if (ret!=KErrNone)
   1.509 +		return ret;
   1.510 +	TInt fileSize;
   1.511 +	file.Size(fileSize);
   1.512 +	HBufC8* buf=HBufC8::New(fileSize);
   1.513 +	if (!buf)
   1.514 +		{
   1.515 +		file.Close();
   1.516 +		return KErrNoMemory;
   1.517 +		}
   1.518 +	TPtr8 mod(buf->Des());
   1.519 +	file.Read(mod);
   1.520 +	file.Close();
   1.521 +	ret=file.Replace(TheFs,aTarget,EFileWrite);
   1.522 +	if (ret==KErrNone)
   1.523 +		{
   1.524 +		file.Write(*buf);
   1.525 +		}
   1.526 +	file.Close();
   1.527 +	delete buf;
   1.528 +	return ret;
   1.529 +	}