persistentstorage/sql/TEST/t_sqlapi.cpp
branchRCL_3
changeset 16 b6ab70c1385f
parent 15 fcc16690f446
equal deleted inserted replaced
15:fcc16690f446 16:b6ab70c1385f
   297 
   297 
   298 	if(filesysname.CompareF(_L("HVFS")) == 0)
   298 	if(filesysname.CompareF(_L("HVFS")) == 0)
   299 	    {
   299 	    {
   300         maxFileName = KMaxFileName -150;//The test will panic in PlatSim when the file name is too long. This line should be removed when platsim team fixes the file system defect.
   300         maxFileName = KMaxFileName -150;//The test will panic in PlatSim when the file name is too long. This line should be removed when platsim team fixes the file system defect.
   301 	    }
   301 	    }
   302 	HBufC* dbPath = HBufC::NewLC(maxFileName);
   302 	HBufC* dbPath = HBufC::New(maxFileName);
       
   303 	TEST(dbPath != NULL);
       
   304 	TPtr dbPathPtr = dbPath->Des();
   303 	_LIT(KExt, ".DB");
   305 	_LIT(KExt, ".DB");
   304 	dbPath->Des().Copy(_L("C:"));
   306 	dbPathPtr.Copy(_L("C:"));
   305 	dbPath->Des().Append(KSecureUid.Name());
   307 	dbPathPtr.Append(KSecureUid.Name());
   306 	TInt len = maxFileName + 1 - (dbPath->Length() + KExt().Length() + privatePath.Length());
   308 	TInt len = maxFileName + 1 - (dbPathPtr.Length() + KExt().Length() + privatePath.Length());
   307 	
   309 	
   308 	while(--len)
   310 	while(--len)
   309 		{
   311 		{
   310         dbPath->Des().Append(TChar('A'));	
   312         dbPathPtr.Append(TChar('A'));	
   311 		}
   313 		}
   312 	dbPath->Des().Append(KExt);	
   314 	dbPathPtr.Append(KExt);	
   313 	TEST(dbPath->Length() == (maxFileName - privatePath.Length()));	
   315 	TEST(dbPathPtr.Length() == (maxFileName - privatePath.Length()));	
   314 	rc = db.Create(dbPath->Des(), securityPolicy);
   316 	rc = db.Create(dbPathPtr, securityPolicy);
   315 	TEST2(rc, KErrNone);
   317 	TEST2(rc, KErrNone);
   316 	db.Close();
   318 	db.Close();
   317 	rc2 = RSqlDatabase::Delete(dbPath->Des());
   319 	rc2 = RSqlDatabase::Delete(dbPathPtr);
   318 	TEST2(rc2, KErrNone);
   320 	TEST2(rc2, KErrNone);
   319 	
   321 	
   320 	// Private database with config
   322 	// Private database with config
   321 	TBuf<KMaxFileName> cfgPath;
   323 	TBuf<KMaxFileName> cfgPath;
   322 	cfgPath.Copy(_L("C:"));
   324 	cfgPath.Copy(_L("C:"));
   328 	TEST2(rc, KErrNone);
   330 	TEST2(rc, KErrNone);
   329 	TEST2(rc2, KErrNone);
   331 	TEST2(rc2, KErrNone);
   330 	
   332 	
   331 	//Public shared database file on an existing drive (C:). 
   333 	//Public shared database file on an existing drive (C:). 
   332 	//Very long database file name.
   334 	//Very long database file name.
   333 	dbPath->Des().Copy(_L("C:\\TEST\\D"));
   335 	dbPathPtr.Copy(_L("C:\\TEST\\D"));
   334 	len = maxFileName + 1 - (dbPath->Length() + KExt().Length());
   336 	len = maxFileName + 1 - (dbPathPtr.Length() + KExt().Length());
   335 	while(--len)
   337 	while(--len)
   336 		{
   338 		{
   337         dbPath->Des().Append(TChar('A'));	
   339         dbPathPtr.Append(TChar('A'));	
   338 		}
   340 		}
   339 	dbPath->Des().Append(KExt);	
   341 	dbPathPtr.Append(KExt);	
   340 	TEST(dbPath->Length() == maxFileName);
   342 	TEST(dbPathPtr.Length() == maxFileName);
   341 	rc = db.Create(dbPath->Des());
   343 	rc = db.Create(dbPathPtr);
   342 	db.Close();
   344 	db.Close();
   343 	rc2 = RSqlDatabase::Delete(dbPath->Des());
   345 	rc2 = RSqlDatabase::Delete(dbPathPtr);
   344 	
   346 	
   345 	CleanupStack::PopAndDestroy(dbPath);
   347 	delete dbPath;
       
   348 
   346 	TEST2(rc, KErrNone);
   349 	TEST2(rc, KErrNone);
   347 	TEST2(rc2, KErrNone);
   350 	TEST2(rc2, KErrNone);
   348 
   351 
   349 	//Create/Close/Open/Close secure shared database test
   352 	//Create/Close/Open/Close secure shared database test
   350 	rc = db.Create(KTestDbName6, securityPolicy);
   353 	rc = db.Create(KTestDbName6, securityPolicy);