applayerpluginsandutils/bookmarksupport/test/tdirtytests.cpp
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <bookmarkdatabase.h>
       
    17 #include "testutils.h"
       
    18 
       
    19 _LIT(KFilename, "tdirtytests.cpp");
       
    20 
       
    21 LOCAL_D CTestWrapper* gTestWrapper;
       
    22 
       
    23 _LIT(KTxtTester1, 		"DirtyTEST Tester 1");
       
    24 
       
    25 _LIT(KTxtFolder1, 		"DirtyTEST Folder 1");
       
    26 
       
    27 _LIT(KTxtBookmark1,		"DirtyTEST Bookmark 1");
       
    28 _LIT(KTxtBookmarkMod,	"DirtyTEST Bookmark Modified");
       
    29 
       
    30 _LIT(KTxtDes1,			"This is DirtyTEST Bookmark 1");
       
    31 _LIT(KTxtDesMod,		"This is a modified description");
       
    32 
       
    33 _LIT8(KIconData1,		"****4644372131**7*&879");
       
    34 
       
    35 _LIT(KTxtDesc, "This is the home page text");
       
    36 _LIT8(KTxtUri, "sip:user:pass@location.com:1666;transport=tcp;x=123;df=223?asd=b");
       
    37 _LIT8(KTxtUser, "user");
       
    38 _LIT8(KTxtPassword, "pass");
       
    39 _LIT8(KTxtNewUser, "user2");
       
    40 _LIT8(KTxtNewPassword, "password");
       
    41 
       
    42 const TUint32 KProxyId 	= 0x7CFFFFFF;
       
    43 const TUint32 KNapId 	= 0x6CFFF000;
       
    44 
       
    45 const TInt KMaxTestLength = 50;
       
    46 _LIT8(KData8Bit1, "8BitData");
       
    47 _LIT(KData16Bit1, "16BitData");
       
    48 const TInt KInt1 = 999;
       
    49 const TReal KReal1 = 42.999;
       
    50 
       
    51 const TUid KUid1 = {0x111};
       
    52 const TUid KUid2 = {0x222};
       
    53 const TUid KUid3 = {0x333};
       
    54 const TUid KUid4 = {0x444};
       
    55 const TUid KUid5 = {0x555};
       
    56 const TUid KUid6 = {0x666};
       
    57 const TUid KUid7 = {0x777};
       
    58 const TUid KUid8 = {0x888};
       
    59 const TUid KUid9 = {0x999};
       
    60 const TUid KUid10 = {0xAAA};
       
    61 const TUid KUid11 = {0xBBB};
       
    62 const TUid KUid12 = {0xCCC};
       
    63 
       
    64 class CDirtyTester: public CBase
       
    65 	{
       
    66 public:
       
    67 	static CDirtyTester* NewL(const TDesC& aTitle);
       
    68 	~CDirtyTester();
       
    69 
       
    70 	void SetupL();
       
    71 	void ShutdownL();
       
    72 	void DeleteBookmarksL();
       
    73 
       
    74 	void OpenAllL(Bookmark::TVisibility aVisibility = Bookmark::EVisibilityDefault);
       
    75 	void CloseAll();
       
    76 
       
    77 	void CheckTitleL();
       
    78 	void CheckDescriptionL();
       
    79 	void CheckTimeL();
       
    80 	void CheckIconL();
       
    81 	void CheckPublicWritableL();
       
    82 	void CheckConfigL();
       
    83 	void CheckCustomPropertiesL();
       
    84 	void CheckAuthenticationL();
       
    85 
       
    86 private:
       
    87 	CDirtyTester();
       
    88 	void ConstructL(const TDesC& aTitle);
       
    89 
       
    90 private:
       
    91 	HBufC*			  	iTitle;
       
    92 	RBkDatabase	iDatabase;
       
    93 	RBkFolder		iRoot;
       
    94 	RBkBookmark			iBookmark;
       
    95 	RBkFolder		iFolder;
       
    96 	};
       
    97 
       
    98 CDirtyTester* CDirtyTester::NewL(const TDesC& aTitle)
       
    99 	{
       
   100 	CDirtyTester* self = new (ELeave) CDirtyTester();
       
   101 	CleanupStack::PushL(self);
       
   102 	self->ConstructL(aTitle);
       
   103 	CleanupStack::Pop(self);
       
   104 	return self;
       
   105 	}
       
   106 
       
   107 CDirtyTester::CDirtyTester()
       
   108 	{
       
   109 	}
       
   110 
       
   111 CDirtyTester::~CDirtyTester()
       
   112 	{
       
   113 	delete iTitle;
       
   114 	}
       
   115 
       
   116 
       
   117 void CDirtyTester::ConstructL(const TDesC& aTitle)
       
   118 	{
       
   119 	iTitle = aTitle.AllocL();
       
   120 	}
       
   121 
       
   122 void CDirtyTester::OpenAllL(Bookmark::TVisibility aVisibility)
       
   123 	{
       
   124 	iDatabase.OpenL(aVisibility);
       
   125 	iRoot = iDatabase.OpenRootL();
       
   126 
       
   127 	RBkNode item = iRoot.OpenItemL(0);
       
   128 	CleanupClosePushL(item);
       
   129 	gTestWrapper->TEST(item.Type() == Bookmark::ETypeBookmark);
       
   130 	iBookmark = item.OpenBookmarkL();
       
   131 	CleanupStack::PopAndDestroy(&item);
       
   132 
       
   133 	if (iRoot.Count() > 1)
       
   134 		{
       
   135 		item = iRoot.OpenItemL(1);
       
   136 		CleanupClosePushL(item);
       
   137 		gTestWrapper->TEST(item.Type() == Bookmark::ETypeFolder);
       
   138 		iFolder = item.OpenFolderL();
       
   139 		CleanupStack::PopAndDestroy(&item);
       
   140 		}
       
   141 	}
       
   142 
       
   143 void CDirtyTester::CloseAll()
       
   144 	{
       
   145 	iBookmark.Close();
       
   146 	if (iRoot.Count() > 1)
       
   147 		{
       
   148 		iFolder.Close();
       
   149 		}
       
   150 	iRoot.Close();
       
   151 	iDatabase.Close();
       
   152 	}
       
   153 
       
   154 void CDirtyTester::SetupL()
       
   155 	{
       
   156 	iDatabase.OpenL(Bookmark::EVisibilityDefault);
       
   157 	iRoot = iDatabase.OpenRootL();
       
   158 	iBookmark = iDatabase.CreateBookmarkL();
       
   159 	iFolder = iDatabase.CreateFolderL(KTxtFolder1);
       
   160 	}
       
   161 
       
   162 void CDirtyTester::ShutdownL()
       
   163 	{
       
   164 	iBookmark.Close();
       
   165 	iFolder.Close();
       
   166 	DeleteBookmarksL();
       
   167 	iRoot.Close();
       
   168 	iDatabase.Close();
       
   169 	}
       
   170 
       
   171 void CDirtyTester::CheckTitleL()
       
   172 	{
       
   173 	gTestWrapper->Next(_L("[Dirty tests] Check Title"));
       
   174 
       
   175 	SetupL();
       
   176 	iBookmark.SetTitleL(KTxtBookmark1);
       
   177 	iDatabase.CommitL();
       
   178 	CloseAll();
       
   179 	OpenAllL();
       
   180 	gTestWrapper->TEST(iBookmark.Title().Compare(KTxtBookmark1) == 0);
       
   181 	iBookmark.SetTitleL(KTxtBookmarkMod);
       
   182 	iDatabase.CommitL();
       
   183 	CloseAll();
       
   184 	OpenAllL();
       
   185 	gTestWrapper->TEST(iBookmark.Title().Compare(KTxtBookmarkMod) == 0);
       
   186 	ShutdownL();
       
   187 	}
       
   188 
       
   189 void CDirtyTester::CheckDescriptionL()
       
   190 	{
       
   191 	gTestWrapper->Next(_L("[Dirty tests] Check Description"));
       
   192 
       
   193 	SetupL();
       
   194 	iBookmark.SetDescriptionL(KTxtDes1);
       
   195 	iDatabase.CommitL();
       
   196 	CloseAll();
       
   197 	OpenAllL();
       
   198 	gTestWrapper->TEST(iBookmark.DescriptionL().Compare(KTxtDes1) == 0);
       
   199 	iBookmark.SetDescriptionL(KTxtDesMod);
       
   200 	iDatabase.CommitL();
       
   201 	CloseAll();
       
   202 	OpenAllL();
       
   203 	gTestWrapper->TEST(iBookmark.DescriptionL().Compare(KTxtDesMod) == 0);
       
   204 	ShutdownL();
       
   205 	}
       
   206 
       
   207 void CDirtyTester::CheckTimeL()
       
   208 	{
       
   209 	gTestWrapper->Next(_L("[Dirty tests] Check Time"));
       
   210 
       
   211 	SetupL();
       
   212 	iBookmark.UpdateVisited();
       
   213 	TTime firstUpdate = iBookmark.LastVisited();
       
   214 	iDatabase.CommitL();
       
   215 	CloseAll();
       
   216 	OpenAllL();
       
   217 	gTestWrapper->TEST(iBookmark.LastVisited() == firstUpdate);
       
   218 	iBookmark.UpdateVisited();
       
   219 	TTime nextUpdate = iBookmark.LastVisited();
       
   220 	iDatabase.CommitL();
       
   221 	CloseAll();
       
   222 	OpenAllL();
       
   223 	gTestWrapper->TEST(iBookmark.LastVisited() == nextUpdate);
       
   224 	TRAPD(err, iBookmark.SetLastVisitedL(firstUpdate));
       
   225 	gTestWrapper->TESTE(err == KErrPermissionDenied, err);
       
   226 	iDatabase.CommitL();
       
   227 	ShutdownL();
       
   228 	}
       
   229 
       
   230 void CDirtyTester::CheckIconL()
       
   231 	{
       
   232 	gTestWrapper->Next(_L("[Dirty tests] Check Icon"));
       
   233 
       
   234 	SetupL();
       
   235 	Bookmark::TAttachmentId iconId = iDatabase.CreateIconL(KIconData1);
       
   236 	iDatabase.CommitL();
       
   237 	CloseAll();
       
   238 	OpenAllL();
       
   239 	TRAPD(err, iDatabase.GetIconL(iconId));
       
   240 	gTestWrapper->TESTE(err == KErrNone, err);
       
   241 	iBookmark.SetIconIdL(iconId);
       
   242 	iDatabase.CommitL();
       
   243 	CloseAll();
       
   244 	OpenAllL();
       
   245 	gTestWrapper->TEST(iBookmark.IconIdL() == iconId);
       
   246 	User::LeaveIfError(iDatabase.DeleteIconL(iconId));
       
   247 	iDatabase.CommitL();
       
   248 	CloseAll();
       
   249 	OpenAllL();
       
   250 	TRAP(err, iDatabase.GetIconL(iconId));
       
   251 	gTestWrapper->TESTE(err == KErrNotFound, err);
       
   252 	ShutdownL();
       
   253 	}
       
   254 
       
   255 void CDirtyTester::CheckPublicWritableL()
       
   256 	{
       
   257 	gTestWrapper->Next(_L("[Dirty tests] Check Public & Writable"));
       
   258 
       
   259 	SetupL();
       
   260 	iDatabase.CommitL();
       
   261 	CloseAll();
       
   262 	OpenAllL();
       
   263 	iBookmark.SetPublicL(EFalse);
       
   264 	iDatabase.CommitL();
       
   265 	CloseAll();
       
   266 	OpenAllL();
       
   267 	gTestWrapper->TEST(!iBookmark.IsPublic());
       
   268 	RThread thread;
       
   269 	TSecurityInfo secInfo(thread);
       
   270 	TRAPD(err, iBookmark.OwnerL());
       
   271 	gTestWrapper->TESTE(err == KErrPermissionDenied, err);
       
   272 	TRAP(err, iBookmark.SetOwnerL(0x00112233));
       
   273 	gTestWrapper->TESTE(err == KErrPermissionDenied, err);
       
   274 	TRAP(err, iBookmark.SetWritableL(EFalse));
       
   275 	gTestWrapper->TESTE(err == KErrNone, err);
       
   276 	ShutdownL();
       
   277 	}
       
   278 
       
   279 void CDirtyTester::CheckConfigL()
       
   280 	{
       
   281 	gTestWrapper->Next(_L("[Dirty tests] Check Database Config Properties"));
       
   282 
       
   283 	SetupL();
       
   284 	RBkBookmark homepage;
       
   285 	TRAPD(err, homepage = iDatabase.OpenHomeL());
       
   286 	gTestWrapper->TESTE(err == KErrNotFound, err);
       
   287 	gTestWrapper->TEST(iDatabase.HomePageText().Compare(KTxtDesc) != 0);
       
   288 	gTestWrapper->TEST(iDatabase.SearchUri().Compare(KTxtUri) != 0);
       
   289 	gTestWrapper->TEST(iDatabase.DefaultProxy() != KProxyId);
       
   290 	gTestWrapper->TEST(iDatabase.DefaultNap() != KNapId);
       
   291 	iDatabase.SetHomePageTextL(KTxtDesc);
       
   292 	iDatabase.SetHome(iBookmark);
       
   293 	iDatabase.SetSearchUriL(KTxtUri);
       
   294 	iDatabase.SetDefaultProxy(KProxyId);
       
   295 	iDatabase.SetDefaultNap(KNapId);
       
   296 	gTestWrapper->TEST(iDatabase.HomePageText().Compare(KTxtDesc) == 0);
       
   297 	TRAP(err, homepage = iDatabase.OpenHomeL());
       
   298 	gTestWrapper->TESTE(err == KErrNone, err);
       
   299 	homepage.Close();
       
   300 	gTestWrapper->TEST(iBookmark.IsHomePage());
       
   301 	gTestWrapper->TEST(iDatabase.SearchUri().Compare(KTxtUri) == 0);
       
   302 	gTestWrapper->TEST(iDatabase.DefaultProxy() == KProxyId);
       
   303 	gTestWrapper->TEST(iDatabase.DefaultNap() == KNapId);
       
   304 	iDatabase.CommitL();
       
   305 	CloseAll();
       
   306 	OpenAllL();
       
   307 	gTestWrapper->TEST(iDatabase.HomePageText().Compare(KTxtDesc) == 0);
       
   308 	TRAP(err, homepage = iDatabase.OpenHomeL());
       
   309 	gTestWrapper->TESTE(err == KErrNone, err);
       
   310 	homepage.Close();
       
   311 	gTestWrapper->TEST(iBookmark.IsHomePage());
       
   312 	gTestWrapper->TEST(iDatabase.SearchUri().Compare(KTxtUri) == 0);
       
   313 	gTestWrapper->TEST(iDatabase.DefaultProxy() == KProxyId);
       
   314 	gTestWrapper->TEST(iDatabase.DefaultNap() == KNapId);
       
   315 	CloseAll();
       
   316 	OpenAllL(Bookmark::EVisibilityPrivate);
       
   317 	iDatabase.SetHomePageTextL(KNullDesC);
       
   318 	iDatabase.SetSearchUriL(KNullDesC8);
       
   319 	iDatabase.SetDefaultProxy(0);
       
   320 	iDatabase.SetDefaultNap(0);
       
   321 	iDatabase.CommitL();
       
   322 	CloseAll();
       
   323 	OpenAllL();
       
   324 	gTestWrapper->TEST(iDatabase.HomePageText().Compare(KTxtDesc) != 0);
       
   325 	gTestWrapper->TEST(iDatabase.SearchUri().Compare(KTxtUri) != 0);
       
   326 	gTestWrapper->TEST(iDatabase.DefaultProxy() != KProxyId);
       
   327 	gTestWrapper->TEST(iDatabase.DefaultNap() != KNapId);
       
   328 	ShutdownL();
       
   329 	}
       
   330 
       
   331 void CDirtyTester::CheckCustomPropertiesL()
       
   332 	{
       
   333 	TInt retInt = 0;
       
   334 	TReal retReal = 0.0;
       
   335 	HBufC* retDesC16 = HBufC::NewLC(KMaxTestLength);
       
   336 	TPtr retPtr16 = retDesC16->Des();
       
   337 	HBufC8* retDesC8 = HBufC8::NewLC(KMaxTestLength * 2);
       
   338 	TPtr8 retPtr8 = retDesC8->Des();
       
   339 
       
   340 	gTestWrapper->Next(_L("[Dirty tests] Custom Properties"));
       
   341 
       
   342 	SetupL();
       
   343 
       
   344 	TRAPD(err, iDatabase.RegisterDatabasePropertyL(KUid1, Bookmark::EDataTypeInt));
       
   345 	gTestWrapper->TESTE(err == KErrNone, err);
       
   346 	TRAP(err, iDatabase.RegisterDatabasePropertyL(KUid2, Bookmark::EDataTypeReal));
       
   347 	gTestWrapper->TESTE(err == KErrNone, err);
       
   348 	TRAP(err, iDatabase.RegisterDatabasePropertyL(KUid3, Bookmark::EDataTypeDes8));
       
   349 	gTestWrapper->TESTE(err == KErrNone, err);
       
   350 	TRAP(err, iDatabase.RegisterDatabasePropertyL(KUid4, Bookmark::EDataTypeDes16));
       
   351 	gTestWrapper->TESTE(err == KErrNone, err);
       
   352 
       
   353 	TRAP(err, iDatabase.RegisterBookmarkPropertyL(KUid5, Bookmark::EDataTypeInt));
       
   354 	gTestWrapper->TESTE(err == KErrNone, err);
       
   355 	TRAP(err, iDatabase.RegisterBookmarkPropertyL(KUid6, Bookmark::EDataTypeReal));
       
   356 	gTestWrapper->TESTE(err == KErrNone, err);
       
   357 	TRAP(err, iDatabase.RegisterBookmarkPropertyL(KUid7, Bookmark::EDataTypeDes8));
       
   358 	gTestWrapper->TESTE(err == KErrNone, err);
       
   359 	TRAP(err, iDatabase.RegisterBookmarkPropertyL(KUid8, Bookmark::EDataTypeDes16));
       
   360 	gTestWrapper->TESTE(err == KErrNone, err);
       
   361 
       
   362 	TRAP(err, iDatabase.RegisterFolderPropertyL(KUid9, Bookmark::EDataTypeInt));
       
   363 	gTestWrapper->TESTE(err == KErrNone, err);
       
   364 	TRAP(err, iDatabase.RegisterFolderPropertyL(KUid10, Bookmark::EDataTypeReal));
       
   365 	gTestWrapper->TESTE(err == KErrNone, err);
       
   366 	TRAP(err, iDatabase.RegisterFolderPropertyL(KUid11, Bookmark::EDataTypeDes8));
       
   367 	gTestWrapper->TESTE(err == KErrNone, err);
       
   368 	TRAP(err, iDatabase.RegisterFolderPropertyL(KUid12, Bookmark::EDataTypeDes16));
       
   369 	gTestWrapper->TESTE(err == KErrNone, err);
       
   370 
       
   371 	iDatabase.CommitL();
       
   372 	CloseAll();
       
   373 	OpenAllL();
       
   374 
       
   375 	TRAP(err, iDatabase.RegisterDatabasePropertyL(KUid1, Bookmark::EDataTypeInt));
       
   376 	gTestWrapper->TESTE(err == Bookmark::KErrUidAlreadyUsed, err);
       
   377 	TRAP(err, iDatabase.RegisterDatabasePropertyL(KUid2, Bookmark::EDataTypeReal));
       
   378 	gTestWrapper->TESTE(err == Bookmark::KErrUidAlreadyUsed, err);
       
   379 	TRAP(err, iDatabase.RegisterDatabasePropertyL(KUid3, Bookmark::EDataTypeDes8));
       
   380 	gTestWrapper->TESTE(err == Bookmark::KErrUidAlreadyUsed, err);
       
   381 	TRAP(err, iDatabase.RegisterDatabasePropertyL(KUid4, Bookmark::EDataTypeDes16));
       
   382 	gTestWrapper->TESTE(err == Bookmark::KErrUidAlreadyUsed, err);
       
   383 
       
   384 	TRAP(err, iDatabase.RegisterBookmarkPropertyL(KUid5, Bookmark::EDataTypeInt));
       
   385 	gTestWrapper->TESTE(err == Bookmark::KErrUidAlreadyUsed, err);
       
   386 	TRAP(err, iDatabase.RegisterBookmarkPropertyL(KUid6, Bookmark::EDataTypeReal));
       
   387 	gTestWrapper->TESTE(err == Bookmark::KErrUidAlreadyUsed, err);
       
   388 	TRAP(err, iDatabase.RegisterBookmarkPropertyL(KUid7, Bookmark::EDataTypeDes8));
       
   389 	gTestWrapper->TESTE(err == Bookmark::KErrUidAlreadyUsed, err);
       
   390 	TRAP(err, iDatabase.RegisterBookmarkPropertyL(KUid8, Bookmark::EDataTypeDes16));
       
   391 	gTestWrapper->TESTE(err == Bookmark::KErrUidAlreadyUsed, err);
       
   392 
       
   393 	TRAP(err, iDatabase.RegisterFolderPropertyL(KUid9, Bookmark::EDataTypeInt));
       
   394 	gTestWrapper->TESTE(err == Bookmark::KErrUidAlreadyUsed, err);
       
   395 	TRAP(err, iDatabase.RegisterFolderPropertyL(KUid10, Bookmark::EDataTypeReal));
       
   396 	gTestWrapper->TESTE(err == Bookmark::KErrUidAlreadyUsed, err);
       
   397 	TRAP(err, iDatabase.RegisterFolderPropertyL(KUid11, Bookmark::EDataTypeDes8));
       
   398 	gTestWrapper->TESTE(err == Bookmark::KErrUidAlreadyUsed, err);
       
   399 	TRAP(err, iDatabase.RegisterFolderPropertyL(KUid12, Bookmark::EDataTypeDes16));
       
   400 	gTestWrapper->TESTE(err == Bookmark::KErrUidAlreadyUsed, err);
       
   401 
       
   402 	TRAP(err, iDatabase.DeregisterDatabasePropertyL(KUid1));
       
   403 	gTestWrapper->TESTE(err == KErrNone, err);
       
   404 	TRAP(err, iDatabase.DeregisterDatabasePropertyL(KUid2));
       
   405 	gTestWrapper->TESTE(err == KErrNone, err);
       
   406 	TRAP(err, iDatabase.DeregisterDatabasePropertyL(KUid3));
       
   407 	gTestWrapper->TESTE(err == KErrNone, err);
       
   408 	TRAP(err, iDatabase.DeregisterDatabasePropertyL(KUid4));
       
   409 	gTestWrapper->TESTE(err == KErrNone, err);
       
   410 
       
   411 	TRAP(err, iDatabase.DeregisterBookmarkPropertyL(KUid5));
       
   412 	gTestWrapper->TESTE(err == KErrNone, err);
       
   413 	TRAP(err, iDatabase.DeregisterBookmarkPropertyL(KUid6));
       
   414 	gTestWrapper->TESTE(err == KErrNone, err);
       
   415 	TRAP(err, iDatabase.DeregisterBookmarkPropertyL(KUid7));
       
   416 	gTestWrapper->TESTE(err == KErrNone, err);
       
   417 	TRAP(err, iDatabase.DeregisterBookmarkPropertyL(KUid8));
       
   418 	gTestWrapper->TESTE(err == KErrNone, err);
       
   419 
       
   420 	TRAP(err, iDatabase.DeregisterFolderPropertyL(KUid9));
       
   421 	gTestWrapper->TESTE(err == KErrNone, err);
       
   422 	TRAP(err, iDatabase.DeregisterFolderPropertyL(KUid10));
       
   423 	gTestWrapper->TESTE(err == KErrNone, err);
       
   424 	TRAP(err, iDatabase.DeregisterFolderPropertyL(KUid11));
       
   425 	gTestWrapper->TESTE(err == KErrNone, err);
       
   426 	TRAP(err, iDatabase.DeregisterFolderPropertyL(KUid12));
       
   427 	gTestWrapper->TESTE(err == KErrNone, err);
       
   428 
       
   429 	iDatabase.CommitL();
       
   430 	CloseAll();
       
   431 	OpenAllL();
       
   432 
       
   433 	TRAP(err, iDatabase.RegisterDatabasePropertyL(KUid1, Bookmark::EDataTypeInt));
       
   434 	gTestWrapper->TESTE(err == KErrNone, err);
       
   435 	TRAP(err, iDatabase.RegisterDatabasePropertyL(KUid2, Bookmark::EDataTypeReal));
       
   436 	gTestWrapper->TESTE(err == KErrNone, err);
       
   437 	TRAP(err, iDatabase.RegisterDatabasePropertyL(KUid3, Bookmark::EDataTypeDes8));
       
   438 	gTestWrapper->TESTE(err == KErrNone, err);
       
   439 	TRAP(err, iDatabase.RegisterDatabasePropertyL(KUid4, Bookmark::EDataTypeDes16));
       
   440 	gTestWrapper->TESTE(err == KErrNone, err);
       
   441 
       
   442 	TRAP(err, iDatabase.RegisterBookmarkPropertyL(KUid5, Bookmark::EDataTypeInt));
       
   443 	gTestWrapper->TESTE(err == KErrNone, err);
       
   444 	TRAP(err, iDatabase.RegisterBookmarkPropertyL(KUid6, Bookmark::EDataTypeReal));
       
   445 	gTestWrapper->TESTE(err == KErrNone, err);
       
   446 	TRAP(err, iDatabase.RegisterBookmarkPropertyL(KUid7, Bookmark::EDataTypeDes8));
       
   447 	gTestWrapper->TESTE(err == KErrNone, err);
       
   448 	TRAP(err, iDatabase.RegisterBookmarkPropertyL(KUid8, Bookmark::EDataTypeDes16));
       
   449 	gTestWrapper->TESTE(err == KErrNone, err);
       
   450 
       
   451 	TRAP(err, iDatabase.RegisterFolderPropertyL(KUid9, Bookmark::EDataTypeInt));
       
   452 	gTestWrapper->TESTE(err == KErrNone, err);
       
   453 	TRAP(err, iDatabase.RegisterFolderPropertyL(KUid10, Bookmark::EDataTypeReal));
       
   454 	gTestWrapper->TESTE(err == KErrNone, err);
       
   455 	TRAP(err, iDatabase.RegisterFolderPropertyL(KUid11, Bookmark::EDataTypeDes8));
       
   456 	gTestWrapper->TESTE(err == KErrNone, err);
       
   457 	TRAP(err, iDatabase.RegisterFolderPropertyL(KUid12, Bookmark::EDataTypeDes16));
       
   458 	gTestWrapper->TESTE(err == KErrNone, err);
       
   459 
       
   460 	TRAP(err, iDatabase.SetCustomPropertyL(KUid1, KInt1));
       
   461 	gTestWrapper->TESTE(err == KErrNone, err);
       
   462 	TRAP(err, iDatabase.SetCustomPropertyL(KUid2, KReal1));
       
   463 	gTestWrapper->TESTE(err == KErrNone, err);
       
   464 	TRAP(err, iDatabase.SetCustomPropertyL(KUid3, KData8Bit1));
       
   465 	gTestWrapper->TESTE(err == KErrNone, err);
       
   466 	TRAP(err, iDatabase.SetCustomPropertyL(KUid4, KData16Bit1));
       
   467 	gTestWrapper->TESTE(err == KErrNone, err);
       
   468 
       
   469 	TRAP(err, iBookmark.SetCustomPropertyL(KUid5, KInt1));
       
   470 	gTestWrapper->TESTE(err == KErrNone, err);
       
   471 	TRAP(err, iBookmark.SetCustomPropertyL(KUid6, KReal1));
       
   472 	gTestWrapper->TESTE(err == KErrNone, err);
       
   473 	TRAP(err, iBookmark.SetCustomPropertyL(KUid7, KData8Bit1));
       
   474 	gTestWrapper->TESTE(err == KErrNone, err);
       
   475 	TRAP(err, iBookmark.SetCustomPropertyL(KUid8, KData16Bit1));
       
   476 	gTestWrapper->TESTE(err == KErrNone, err);
       
   477 
       
   478 	TRAP(err, iFolder.SetCustomPropertyL(KUid9, KInt1));
       
   479 	gTestWrapper->TESTE(err == KErrNone, err);
       
   480 	TRAP(err, iFolder.SetCustomPropertyL(KUid10, KReal1));
       
   481 	gTestWrapper->TESTE(err == KErrNone, err);
       
   482 	TRAP(err, iFolder.SetCustomPropertyL(KUid11, KData8Bit1));
       
   483 	gTestWrapper->TESTE(err == KErrNone, err);
       
   484 	TRAP(err, iFolder.SetCustomPropertyL(KUid12, KData16Bit1));
       
   485 	gTestWrapper->TESTE(err == KErrNone, err);
       
   486 
       
   487 	iDatabase.CommitL();
       
   488 	CloseAll();
       
   489 	OpenAllL();
       
   490 
       
   491 	TRAP(err, iDatabase.GetCustomPropertyL(KUid1, retInt));
       
   492 	gTestWrapper->TESTE(err == KErrNone, err);
       
   493 	gTestWrapper->TEST(retInt == KInt1);
       
   494 	TRAP(err, iDatabase.GetCustomPropertyL(KUid2, retReal));
       
   495 	gTestWrapper->TESTE(err == KErrNone, err);
       
   496 	gTestWrapper->TEST(retReal == KReal1);
       
   497 	TRAP(err, iDatabase.GetCustomPropertyL(KUid3, retPtr8));
       
   498 	gTestWrapper->TESTE(err == KErrNone, err);
       
   499 	gTestWrapper->TEST(retPtr8.Compare(KData8Bit1) == 0);
       
   500 	TRAP(err, iDatabase.GetCustomPropertyL(KUid4, retPtr16));
       
   501 	gTestWrapper->TESTE(err == KErrNone, err);
       
   502 	gTestWrapper->TEST(retPtr16.Compare(KData16Bit1) == 0);
       
   503 
       
   504 	TRAP(err, iBookmark.GetCustomPropertyL(KUid5, retInt));
       
   505 	gTestWrapper->TESTE(err == KErrNone, err);
       
   506 	gTestWrapper->TEST(retInt == KInt1);
       
   507 	TRAP(err, iBookmark.GetCustomPropertyL(KUid6, retReal));
       
   508 	gTestWrapper->TESTE(err == KErrNone, err);
       
   509 	gTestWrapper->TEST(retReal == KReal1);
       
   510 	TRAP(err, iBookmark.GetCustomPropertyL(KUid7, retPtr8));
       
   511 	gTestWrapper->TESTE(err == KErrNone, err);
       
   512 	gTestWrapper->TEST(retPtr8.Compare(KData8Bit1) == 0);
       
   513 	TRAP(err, iBookmark.GetCustomPropertyL(KUid8, retPtr16));
       
   514 	gTestWrapper->TESTE(err == KErrNone, err);
       
   515 	gTestWrapper->TEST(retPtr16.Compare(KData16Bit1) == 0);
       
   516 
       
   517 	TRAP(err, iFolder.GetCustomPropertyL(KUid9, retInt));
       
   518 	gTestWrapper->TESTE(err == KErrNone, err);
       
   519 	gTestWrapper->TEST(retInt == KInt1);
       
   520 	TRAP(err, iFolder.GetCustomPropertyL(KUid10, retReal));
       
   521 	gTestWrapper->TESTE(err == KErrNone, err);
       
   522 	gTestWrapper->TEST(retReal == KReal1);
       
   523 	TRAP(err, iFolder.GetCustomPropertyL(KUid11, retPtr8));
       
   524 	gTestWrapper->TESTE(err == KErrNone, err);
       
   525 	gTestWrapper->TEST(retPtr8.Compare(KData8Bit1) == 0);
       
   526 	TRAP(err, iFolder.GetCustomPropertyL(KUid12, retPtr16));
       
   527 	gTestWrapper->TESTE(err == KErrNone, err);
       
   528 	gTestWrapper->TEST(retPtr16.Compare(KData16Bit1) == 0);
       
   529 
       
   530 	TRAP(err, iDatabase.DeregisterDatabasePropertyL(KUid1));
       
   531 	gTestWrapper->TESTE(err == KErrNone, err);
       
   532 	TRAP(err, iDatabase.DeregisterDatabasePropertyL(KUid2));
       
   533 	gTestWrapper->TESTE(err == KErrNone, err);
       
   534 	TRAP(err, iDatabase.DeregisterDatabasePropertyL(KUid3));
       
   535 	gTestWrapper->TESTE(err == KErrNone, err);
       
   536 	TRAP(err, iDatabase.DeregisterDatabasePropertyL(KUid4));
       
   537 	gTestWrapper->TESTE(err == KErrNone, err);
       
   538 
       
   539 	TRAP(err, iDatabase.DeregisterBookmarkPropertyL(KUid5));
       
   540 	gTestWrapper->TESTE(err == KErrNone, err);
       
   541 	TRAP(err, iDatabase.DeregisterBookmarkPropertyL(KUid6));
       
   542 	gTestWrapper->TESTE(err == KErrNone, err);
       
   543 	TRAP(err, iDatabase.DeregisterBookmarkPropertyL(KUid7));
       
   544 	gTestWrapper->TESTE(err == KErrNone, err);
       
   545 	TRAP(err, iDatabase.DeregisterBookmarkPropertyL(KUid8));
       
   546 	gTestWrapper->TESTE(err == KErrNone, err);
       
   547 
       
   548 	TRAP(err, iDatabase.DeregisterFolderPropertyL(KUid9));
       
   549 	gTestWrapper->TESTE(err == KErrNone, err);
       
   550 	TRAP(err, iDatabase.DeregisterFolderPropertyL(KUid10));
       
   551 	gTestWrapper->TESTE(err == KErrNone, err);
       
   552 	TRAP(err, iDatabase.DeregisterFolderPropertyL(KUid11));
       
   553 	gTestWrapper->TESTE(err == KErrNone, err);
       
   554 	TRAP(err, iDatabase.DeregisterFolderPropertyL(KUid12));
       
   555 	gTestWrapper->TESTE(err == KErrNone, err);
       
   556 
       
   557 	iDatabase.CommitL();
       
   558 	CloseAll();
       
   559 	OpenAllL();
       
   560 
       
   561 	TRAP(err, iDatabase.GetCustomPropertyL(KUid1, retInt));
       
   562 	gTestWrapper->TESTE(err == KErrNotFound, err);
       
   563 	TRAP(err, iDatabase.GetCustomPropertyL(KUid2, retReal));
       
   564 	gTestWrapper->TESTE(err == KErrNotFound, err);
       
   565 	TRAP(err, iDatabase.GetCustomPropertyL(KUid3, retPtr8));
       
   566 	gTestWrapper->TESTE(err == KErrNotFound, err);
       
   567 	TRAP(err, iDatabase.GetCustomPropertyL(KUid4, retPtr16));
       
   568 	gTestWrapper->TESTE(err == KErrNotFound, err);
       
   569 
       
   570 	TRAP(err, iBookmark.GetCustomPropertyL(KUid5, retInt));
       
   571 	gTestWrapper->TESTE(err == KErrNotFound, err);
       
   572 	TRAP(err, iBookmark.GetCustomPropertyL(KUid6, retReal));
       
   573 	gTestWrapper->TESTE(err == KErrNotFound, err);
       
   574 	TRAP(err, iBookmark.GetCustomPropertyL(KUid7, retPtr8));
       
   575 	gTestWrapper->TESTE(err == KErrNotFound, err);
       
   576 	TRAP(err, iBookmark.GetCustomPropertyL(KUid8, retPtr16));
       
   577 	gTestWrapper->TESTE(err == KErrNotFound, err);
       
   578 
       
   579 	TRAP(err, iFolder.GetCustomPropertyL(KUid9, retInt));
       
   580 	gTestWrapper->TESTE(err == KErrNotFound, err);
       
   581 	TRAP(err, iFolder.GetCustomPropertyL(KUid10, retReal));
       
   582 	gTestWrapper->TESTE(err == KErrNotFound, err);
       
   583 	TRAP(err, iFolder.GetCustomPropertyL(KUid11, retPtr8));
       
   584 	gTestWrapper->TESTE(err == KErrNotFound, err);
       
   585 	TRAP(err, iFolder.GetCustomPropertyL(KUid12, retPtr16));
       
   586 	gTestWrapper->TESTE(err == KErrNotFound, err);
       
   587 
       
   588 	ShutdownL();
       
   589 
       
   590 	CleanupStack::PopAndDestroy(retDesC8);
       
   591 	CleanupStack::PopAndDestroy(retDesC16);
       
   592 	}
       
   593 
       
   594 void CDirtyTester::CheckAuthenticationL()
       
   595 	{
       
   596 	gTestWrapper->Next(_L("[Dirty tests] Check Authenication"));
       
   597 
       
   598 	SetupL();
       
   599 	iBookmark.SetUriL(KTxtUri);
       
   600 	gTestWrapper->TEST(iBookmark.AuthenticationL().Name().Compare(KTxtUser) == 0);
       
   601 	gTestWrapper->TEST(iBookmark.AuthenticationL().Password().Compare(KTxtPassword) == 0);
       
   602 	iDatabase.CommitL();
       
   603 	CloseAll();
       
   604 	OpenAllL();
       
   605 	gTestWrapper->TEST(iBookmark.AuthenticationL().Name().Compare(KTxtUser) == 0);
       
   606 	gTestWrapper->TEST(iBookmark.AuthenticationL().Password().Compare(KTxtPassword) == 0);
       
   607 	CAuthentication* newAuth = CAuthentication::NewL(KTxtNewUser(), KTxtNewPassword());
       
   608 	CleanupStack::PushL(newAuth);
       
   609 	iBookmark.SetAuthenticationL(*newAuth);
       
   610 	CleanupStack::PopAndDestroy(newAuth);
       
   611 	gTestWrapper->TEST(iBookmark.AuthenticationL().Name().Compare(KTxtNewUser) == 0);
       
   612 	gTestWrapper->TEST(iBookmark.AuthenticationL().Password().Compare(KTxtNewPassword) == 0);
       
   613 	iDatabase.CommitL();
       
   614 	CloseAll();
       
   615 	OpenAllL();
       
   616 	gTestWrapper->TEST(iBookmark.AuthenticationL().Name().Compare(KTxtNewUser) == 0);
       
   617 	gTestWrapper->TEST(iBookmark.AuthenticationL().Password().Compare(KTxtNewPassword) == 0);
       
   618 	ShutdownL();
       
   619 	}
       
   620 
       
   621 void SmallDatabaseTestL()
       
   622 	{
       
   623 	gTestWrapper->Next(_L("[Dirty tests] Small custom database property test"));
       
   624 
       
   625 	RBkDatabase db;
       
   626 	db.OpenL();
       
   627 	CleanupClosePushL(db);
       
   628 
       
   629 	TUid myuid = TUid::Uid(0x1234a);
       
   630 	TRAPD(error, db.RegisterDatabasePropertyL(myuid, Bookmark::EDataTypeInt));
       
   631 	gTestWrapper->TESTE(error == KErrNone, error);
       
   632 	db.CommitL();
       
   633 	db.Close();
       
   634 
       
   635 	TRAP(error, db.OpenL());
       
   636 	gTestWrapper->TESTE(error == KErrNone, error);
       
   637 	TUid myuid2  = TUid::Uid(0x1234b);
       
   638 	TRAP(error, db.RegisterDatabasePropertyL(myuid2, Bookmark::EDataTypeReal));
       
   639 	gTestWrapper->TESTE(error == KErrNone, error);
       
   640 	db.CommitL();
       
   641 	db.Close();
       
   642 
       
   643 	TRAP(error, db.OpenL());
       
   644 	gTestWrapper->TESTE(error == KErrNone, error);
       
   645 	TRAP(error, db.SetCustomPropertyL(myuid, 10));
       
   646 	gTestWrapper->TESTE(error == KErrNone, error);
       
   647 	db.CommitL();
       
   648 	db.Close();
       
   649 
       
   650 	TRAP(error, db.OpenL());
       
   651 	gTestWrapper->TESTE(error == KErrNone, error);
       
   652 	TReal real = 234.1234;
       
   653 	TRAP(error, db.SetCustomPropertyL(myuid2, real));
       
   654 	gTestWrapper->TESTE(error == KErrNone, error);
       
   655 	db.CommitL();
       
   656 	db.Close();
       
   657 
       
   658 	TRAP(error, db.OpenL());
       
   659 	gTestWrapper->TESTE(error == KErrNone, error);
       
   660 	TInt var = 0;
       
   661 	TRAP(error, db.GetCustomPropertyL(myuid, var));
       
   662 	gTestWrapper->TESTE(error == KErrNone, error);
       
   663 	gTestWrapper->TEST(var == 10);
       
   664 	db.CommitL();
       
   665 	db.Close();
       
   666 
       
   667 	TRAP(error, db.OpenL());
       
   668 	gTestWrapper->TESTE(error == KErrNone, error);
       
   669 	TReal realvar = 0;
       
   670 	TRAP(error, db.GetCustomPropertyL(myuid2, realvar));
       
   671 	gTestWrapper->TESTE(error == KErrNone, error);
       
   672 	gTestWrapper->TEST(var == 10);
       
   673 	db.CommitL();
       
   674 	db.Close();
       
   675 
       
   676 	TRAP(error, db.OpenL());
       
   677 	gTestWrapper->TESTE(error == KErrNone, error);
       
   678 	TRAP(error, db.DeregisterDatabasePropertyL(myuid));
       
   679 	gTestWrapper->TESTE(error == KErrNone, error);
       
   680 	db.CommitL();
       
   681 	db.Close();
       
   682 
       
   683 	TRAP(error, db.OpenL());
       
   684 	gTestWrapper->TESTE(error == KErrNone, error);
       
   685 	TRAP(error, db.DeregisterDatabasePropertyL(myuid2));
       
   686 	gTestWrapper->TESTE(error == KErrNone, error);
       
   687 	db.CommitL();
       
   688 
       
   689 	CleanupStack::PopAndDestroy(&db);
       
   690 	}
       
   691 
       
   692 void DeleteHomePageTestL()
       
   693 	{
       
   694 	gTestWrapper->Next(_L("[Dirty tests] Fix: DEF057872 Bookmarks home page is not updated when the home page bookmark is deleted"));
       
   695 	
       
   696 	RBkDatabase db;
       
   697 	db.OpenL();
       
   698 	CleanupClosePushL(db);
       
   699 	
       
   700 	RBkBookmark homepage;
       
   701 	TRAPD(err, homepage = db.OpenHomeL());
       
   702 	gTestWrapper->TESTE(err == KErrNotFound, err);
       
   703 	homepage = db.CreateBookmarkL();
       
   704 	db.SetHome(homepage);
       
   705 	homepage.Close();
       
   706 	TRAP(err, homepage = db.OpenHomeL());
       
   707 	gTestWrapper->TESTE(err == KErrNone, err);
       
   708 	homepage.Close();
       
   709 	db.CommitL();
       
   710 	db.Close();
       
   711 	
       
   712 	TRAP(err, db.OpenL());
       
   713 	gTestWrapper->TESTE(err == KErrNone, err);
       
   714 	TRAP(err, homepage = db.OpenHomeL());
       
   715 	gTestWrapper->TESTE(err == KErrNone, err);
       
   716 	Bookmark::TItemId homeId = homepage.Id();
       
   717 	homepage.Close();
       
   718 	TRAP(err, db.DeleteItemL(homeId));
       
   719 	gTestWrapper->TESTE(err == KErrNone, err);
       
   720 	TRAP(err, homepage = db.OpenHomeL());
       
   721 	gTestWrapper->TESTE(err == KErrNotFound, err);
       
   722 	db.CommitL();
       
   723 	db.Close();
       
   724 	
       
   725 	TRAP(err, db.OpenL());
       
   726 	gTestWrapper->TESTE(err == KErrNone, err);
       
   727 	TRAP(err, homepage = db.OpenHomeL());
       
   728 	gTestWrapper->TESTE(err == KErrNotFound, err);
       
   729 	
       
   730 	CleanupStack::PopAndDestroy(&db);
       
   731 	}
       
   732 	
       
   733 void CDirtyTester::DeleteBookmarksL()
       
   734 	{
       
   735 	RBkNode item;
       
   736 	TInt index = iRoot.Count() -1;
       
   737 	for (; index >= 0; --index)
       
   738 		{
       
   739 		item = iRoot.OpenItemL(index);
       
   740 		CleanupClosePushL(item);
       
   741 		iDatabase.DeleteItemL(item.Id(), ETrue);
       
   742 		CleanupStack::PopAndDestroy(&item);
       
   743 		}
       
   744 	iDatabase.CommitL();
       
   745 	}
       
   746 
       
   747 void DoDirtyTestsL(CTestWrapper* aTest)
       
   748 	{
       
   749 	gTestWrapper = aTest;
       
   750 	gTestWrapper->SetFile(KFilename);
       
   751 	gTestWrapper->Next(_L("*** Dirty tests ***"));
       
   752 
       
   753 	CDirtyTester* tester = CDirtyTester::NewL(KTxtTester1);
       
   754 	gTestWrapper->TEST(tester != NULL);
       
   755 	CleanupStack::PushL(tester);
       
   756 
       
   757 	tester->CheckTitleL();
       
   758 	tester->CheckDescriptionL();
       
   759 	tester->CheckTimeL();
       
   760 	tester->CheckAuthenticationL();
       
   761 	tester->CheckIconL();
       
   762 	tester->CheckPublicWritableL();
       
   763 	tester->CheckCustomPropertiesL();
       
   764 	tester->CheckConfigL();
       
   765 
       
   766 	CleanupStack::PopAndDestroy(tester);
       
   767 
       
   768 	SmallDatabaseTestL();
       
   769 	DeleteHomePageTestL();
       
   770 	}
       
   771 
       
   772