applayerpluginsandutils/bookmarksupport/test/t_cbookmarkdb.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 "bkmrkdb.h"
       
    17 #include "bkmrk.h"
       
    18 #include "bkmrkfolder.h"
       
    19 #include "testutils.h"
       
    20 
       
    21 LOCAL_D CTestWrapper* gTestWrapper;
       
    22 LOCAL_D Bookmark::TAttachmentId gIconId1;
       
    23 LOCAL_D Bookmark::TAttachmentId gIconId2;
       
    24 
       
    25 _LIT(KFilename, "t_cbookmarkdb.cpp");
       
    26 
       
    27 _LIT(KTxtFolder1, "BkmrkTEST Folder 1");
       
    28 _LIT(KTxtFolder2, "BkmrkTEST Folder 2");
       
    29 _LIT(KTxtFolder3, "BkmrkTEST Folder 3");
       
    30 
       
    31 _LIT(KTxtNewFolder, "New Folder 1");
       
    32 _LIT(KTxtNewFolder2, "New Folder 2");
       
    33 _LIT(KTxtNewFolder3, "New Folder 3");
       
    34 
       
    35 _LIT(KTxtBookmark1, "BkmrkTEST Bookmark 1");
       
    36 _LIT(KTxtBookmark2, "BkmrkTEST Bookmark 2");
       
    37 _LIT(KTxtBookmark3, "BkmrkTEST Bookmark 3");
       
    38 _LIT(KTxtBookmark4, "BkmrkTEST Bookmark 4");
       
    39 
       
    40 _LIT8(KIconData, 	"123456789");
       
    41 _LIT8(KIconData2,	"999999999");
       
    42 
       
    43 _LIT(KTxtDesc, "This is the home page text");
       
    44 _LIT8(KTxtUri, "sip:user:pass@location.com:1666;transport=tcp;x=123;df=223?asd=b");
       
    45 
       
    46 const TUint32 KProxyId 	= 0x7CFFFFFF;
       
    47 const TUint32 KNapId 	= 0x6CFFF000;
       
    48 
       
    49 LOCAL_D void GeneralTestsL()
       
    50 	{
       
    51 	CBookmarkDb* db = CBookmarkDb::NewL(Bookmark::EVisibilityDefault, NULL);
       
    52 	CleanupStack::PushL(db);
       
    53 	
       
    54 	gTestWrapper->Next(_L("[CBookmarkDb tests] Icons"));
       
    55 	Bookmark::TAttachmentId id = db->CreateIconL(KIconData);
       
    56 	gTestWrapper->TEST(db->IconL(id).Compare(KIconData) == 0);
       
    57 	gTestWrapper->TEST(db->IconL(id).Compare(KIconData2) != 0);
       
    58 	
       
    59 	gTestWrapper->Next(_L("[CBookmarkDb tests] Home"));
       
    60 	CBookmark& bookmark = db->CreateBookmarkL(db->RootL());
       
    61 	gTestWrapper->TEST(!db->Home());
       
    62 	db->SetHome(&bookmark);
       
    63 	gTestWrapper->TEST(db->Home()->Id() == bookmark.Id());
       
    64 	db->SetHome(NULL);
       
    65 	gTestWrapper->TEST(!db->Home());
       
    66 	
       
    67 	gTestWrapper->Next(_L("[CBookmarkDb tests] home page text"));
       
    68 	db->SetHomePageTextL(KTxtDesc);
       
    69 	gTestWrapper->TEST(db->HomePageText().Compare(KTxtDesc) == 0);
       
    70 	
       
    71 	gTestWrapper->Next(_L("[CBookmarkDb tests] search uri"));
       
    72 	db->SetSearchUriL(KTxtUri);
       
    73 	gTestWrapper->TEST(db->SearchUri().Compare(KTxtUri) == 0);
       
    74 
       
    75 	gTestWrapper->Next(_L("[CBookmarkDb tests] default proxy and nap"));
       
    76 	gTestWrapper->TEST(db->DefaultProxy() != KProxyId);
       
    77 	db->SetDefaultProxy(KProxyId);
       
    78 	gTestWrapper->TEST(db->DefaultProxy() == KProxyId);
       
    79 	
       
    80 	gTestWrapper->TEST(db->DefaultNap() != KNapId);
       
    81 	db->SetDefaultNap(KNapId);
       
    82 	gTestWrapper->TEST(db->DefaultNap() == KNapId);
       
    83 	
       
    84 	CleanupStack::PopAndDestroy(db);
       
    85 	}
       
    86 
       
    87 LOCAL_D void TreeTestsL()
       
    88 	{
       
    89 	CBookmarkDb* db = CBookmarkDb::NewL(Bookmark::EVisibilityDefault, NULL);
       
    90 	CleanupStack::PushL(db);
       
    91 	
       
    92 	gTestWrapper->Next(_L("[CBookmarkDb tests] Construct tree and root"));
       
    93 	db->ConstructTreeL();
       
    94 	CBookmarkBase* rootPtr = db->FindItem(Bookmark::KRootItemID);
       
    95 	gTestWrapper->TEST(rootPtr != NULL);
       
    96 	gTestWrapper->TEST(db->RootL().Id() == rootPtr->Id());
       
    97 	
       
    98 	gTestWrapper->Next(_L("[CBookmarkDb tests] Create items"));
       
    99 	CBookmarkFolder& folder1 = db->CreateFolderL(KTxtFolder1, db->RootL());
       
   100 	CBookmark& bookmark1 = db->CreateBookmarkL(folder1);
       
   101 	CBookmarkFolder& folder2 = db->CreateFolderL(KTxtFolder2, folder1);
       
   102 	CBookmark& bookmark2 = db->CreateBookmarkL(folder2);
       
   103 	CBookmark& bookmark3 = db->CreateBookmarkL(folder2);
       
   104 	CBookmarkFolder& folder3 = db->CreateFolderL(KTxtFolder3, folder2);
       
   105 	CBookmark& bookmark4 = db->CreateBookmarkL(folder3);
       
   106 	
       
   107 	gTestWrapper->Next(_L("[CBookmarkDb tests] Find items"));
       
   108 	CBookmarkBase* item = db->FindItem(folder1.Id());
       
   109 	CBookmarkFolder* folder = db->FindFolder(KTxtFolder1);
       
   110 	gTestWrapper->TEST(item != NULL);
       
   111 	gTestWrapper->TEST(item == folder);
       
   112 	gTestWrapper->TEST(item->Parent()->Id() == Bookmark::KRootItemID);
       
   113 	item = db->FindItem(bookmark1.Id());
       
   114 	gTestWrapper->TEST(item != NULL);
       
   115 	gTestWrapper->TEST(item->Parent()->Id() == folder1.Id());
       
   116 	item = db->FindItem(folder2.Id());
       
   117 	folder = db->FindFolder(KTxtFolder2);
       
   118 	gTestWrapper->TEST(item != NULL);
       
   119 	gTestWrapper->TEST(item == folder);
       
   120 	gTestWrapper->TEST(item->Parent()->Id() == folder1.Id());
       
   121 	item = db->FindItem(bookmark2.Id());
       
   122 	gTestWrapper->TEST(item != NULL);
       
   123 	gTestWrapper->TEST(item->Parent()->Id() == folder2.Id());
       
   124 	item = db->FindItem(bookmark3.Id());
       
   125 	gTestWrapper->TEST(item != NULL);
       
   126 	gTestWrapper->TEST(item->Parent()->Id() == folder2.Id());
       
   127 	item = db->FindItem(folder3.Id());
       
   128 	folder = db->FindFolder(KTxtFolder3);
       
   129 	gTestWrapper->TEST(item != NULL);
       
   130 	gTestWrapper->TEST(item == folder);
       
   131 	gTestWrapper->TEST(item->Parent()->Id() == folder2.Id());
       
   132 	item = db->FindItem(bookmark4.Id());
       
   133 	gTestWrapper->TEST(item != NULL);
       
   134 	gTestWrapper->TEST(item->Parent()->Id() == folder3.Id());
       
   135 	
       
   136 	gTestWrapper->Next(_L("[CBookmarkDb tests] Delete items"));
       
   137 	CBookmarkFolder& root = db->RootL();
       
   138 	gTestWrapper->TEST(root.Count() == 1);
       
   139 	gTestWrapper->TEST(folder1.Count() == 2);
       
   140 	gTestWrapper->TEST(folder2.Count() == 3);
       
   141 	gTestWrapper->TEST(folder3.Count() == 1);
       
   142 	db->DeleteItemL(folder2.Id(), EFalse);
       
   143 	folder = db->FindFolder(KTxtFolder2);
       
   144 	gTestWrapper->TEST(!folder);
       
   145 	gTestWrapper->TEST(root.Count() == 4);
       
   146 	gTestWrapper->TEST(folder1.Count() == 1);
       
   147 	gTestWrapper->TEST(folder3.Count() == 1);
       
   148 	db->DeleteItemL(folder1.Id(), ETrue);
       
   149 	folder = db->FindFolder(KTxtFolder1);
       
   150 	gTestWrapper->TEST(!folder);
       
   151 	gTestWrapper->TEST(root.Count() == 3);
       
   152 	db->DeleteItemL(bookmark2.Id(), EFalse);
       
   153 	folder = db->FindFolder(KTxtBookmark2);
       
   154 	gTestWrapper->TEST(folder == NULL);
       
   155 	db->DeleteItemL(bookmark4.Id(), ETrue);
       
   156 	folder = db->FindFolder(KTxtBookmark4);
       
   157 	gTestWrapper->TEST(!folder);
       
   158 	gTestWrapper->TEST(root.Count() == 2);
       
   159 	gTestWrapper->TEST(folder3.Count() == 0);
       
   160 	
       
   161 	CleanupStack::PopAndDestroy(db);
       
   162 	}
       
   163 
       
   164 LOCAL_D void CreateTreeL(CBookmarkDb* aDb)
       
   165 	{
       
   166 	gTestWrapper->Next(_L("[CBookmarkDb tests] Create tree"));
       
   167 	CBookmarkFolder& folder1 = aDb->CreateFolderL(KTxtFolder1, aDb->RootL());
       
   168 	CBookmark& bookmark1 = aDb->CreateBookmarkL(folder1);
       
   169 	bookmark1.SetTitleL(KTxtBookmark1);
       
   170 	CBookmarkFolder& folder2 = aDb->CreateFolderL(KTxtFolder2, folder1);
       
   171 	CBookmark& bookmark2 = aDb->CreateBookmarkL(folder2);
       
   172 	bookmark2.SetTitleL(KTxtBookmark2);
       
   173 	CBookmark& bookmark3 = aDb->CreateBookmarkL(folder2);
       
   174 	bookmark3.SetTitleL(KTxtBookmark3);
       
   175 	CBookmarkFolder& folder3 = aDb->CreateFolderL(KTxtFolder3, folder2);
       
   176 	CBookmark& bookmark4 = aDb->CreateBookmarkL(folder3);
       
   177 	bookmark4.SetTitleL(KTxtBookmark4);
       
   178 	
       
   179 	// create a couple of icons
       
   180 	gIconId1 = aDb->CreateIconL(KIconData);
       
   181 	gIconId2 = aDb->CreateIconL(KIconData2);
       
   182 	CBkmrkExtendedProperties& properties1 = bookmark1.BkmrkExtendedPropertiesL();
       
   183 	properties1.SetIconIdL(gIconId1);
       
   184 	CBkmrkExtendedProperties& properties2 = bookmark2.BkmrkExtendedPropertiesL();
       
   185 	properties2.SetIconIdL(gIconId2);
       
   186 	
       
   187 	CBookmarkFolder& root = aDb->RootL();
       
   188 	gTestWrapper->TEST(root.Count() == 1);
       
   189 	gTestWrapper->TEST(folder1.Count() == 2);
       
   190 	gTestWrapper->TEST(folder2.Count() == 3);
       
   191 	gTestWrapper->TEST(folder3.Count() == 1);
       
   192 	}
       
   193 	
       
   194 LOCAL_D void CheckDatabaseL(CBookmarkDb& aDb)
       
   195 	{
       
   196 	CBookmarkFolder& root = aDb.RootL();
       
   197 	gTestWrapper->TEST(root.Count() == 1);
       
   198 	CBookmarkFolder* folder1 = aDb.FindFolder(KTxtFolder1);
       
   199 	gTestWrapper->TEST(folder1 != NULL);
       
   200 	gTestWrapper->TEST(folder1->Count() == 2);
       
   201 	gTestWrapper->TEST(folder1->At(0).Type() == Bookmark::ETypeBookmark);
       
   202 	CBookmark& bookmark1 = static_cast<CBookmark&>(folder1->At(0));
       
   203 	CBkmrkExtendedProperties& properties1 = bookmark1.BkmrkExtendedPropertiesL();
       
   204 	gTestWrapper->TEST(properties1.IconId() == gIconId1);
       
   205 	CBookmarkFolder* folder2 = aDb.FindFolder(KTxtFolder2);
       
   206 	gTestWrapper->TEST(folder2 != NULL);
       
   207 	gTestWrapper->TEST(folder2->Count() == 3);
       
   208 	gTestWrapper->TEST(folder2->At(0).Type() == Bookmark::ETypeBookmark);
       
   209 	CBookmark& bookmark2 = static_cast<CBookmark&>(folder2->At(0));
       
   210 	CBkmrkExtendedProperties& properties2 = bookmark2.BkmrkExtendedPropertiesL();
       
   211 	gTestWrapper->TEST(properties2.IconId() == gIconId2);
       
   212 	CBookmarkFolder* folder3 = aDb.FindFolder(KTxtFolder3);
       
   213 	gTestWrapper->TEST(folder3 != NULL);
       
   214 	gTestWrapper->TEST(folder3->Count() == 1);
       
   215 	}
       
   216 	
       
   217 LOCAL_D void CommitTestsL()
       
   218 	{
       
   219 	gTestWrapper->Next(_L("[CBookmarkDb tests] Commit"));
       
   220 	CBookmarkDb* db = CBookmarkDb::NewL(Bookmark::EVisibilityDefault, NULL);
       
   221 	CleanupStack::PushL(db);
       
   222 	CreateTreeL(db);
       
   223 	db->CommitL();
       
   224 	CleanupStack::PopAndDestroy(db);
       
   225 	
       
   226 	db = CBookmarkDb::NewL(Bookmark::EVisibilityDefault, NULL);
       
   227 	CleanupStack::PushL(db);
       
   228 	
       
   229 	CheckDatabaseL(*db);
       
   230 	
       
   231 	CBookmarkFolder* folder = db->FindFolder(KTxtFolder1);
       
   232 	db->DeleteItemL(folder->Id(), ETrue);
       
   233 	gTestWrapper->TEST(db->RootL().Count() == 0);
       
   234 	
       
   235 	CleanupStack::PopAndDestroy(db);
       
   236 	
       
   237 	// The delete has not been committed so it should reload 
       
   238 	db = CBookmarkDb::NewL(Bookmark::EVisibilityDefault, NULL);
       
   239 	CleanupStack::PushL(db);
       
   240 	
       
   241 	CheckDatabaseL(*db);
       
   242 	
       
   243 	folder = db->FindFolder(KTxtFolder1);
       
   244 	db->DeleteItemL(folder->Id(), ETrue);
       
   245 	gTestWrapper->TEST(db->RootL().Count() == 0);
       
   246 	
       
   247 	User::LeaveIfError(db->DeleteIconL(gIconId1));
       
   248 	User::LeaveIfError(db->DeleteIconL(gIconId2));
       
   249 	
       
   250 	db->CommitL();
       
   251 	
       
   252 	CleanupStack::PopAndDestroy(db);
       
   253 	
       
   254 	// The delete has been committed so it should not reload 
       
   255 	db = CBookmarkDb::NewL(Bookmark::EVisibilityDefault, NULL);
       
   256 	CleanupStack::PushL(db);
       
   257 	CBookmarkFolder& root = db->RootL();
       
   258 	gTestWrapper->TEST(root.Count() == 0);
       
   259 	CleanupStack::PopAndDestroy(db);
       
   260 	}
       
   261 
       
   262 LOCAL_D void IconDataTestsL()
       
   263 	{
       
   264 	CBookmarkDb* db = CBookmarkDb::NewL(Bookmark::EVisibilityDefault, NULL);
       
   265 	CleanupStack::PushL(db);
       
   266 	
       
   267 	gTestWrapper->Next(_L("[CBookmarkDb tests] Icon data tests"));
       
   268 	Bookmark::TAttachmentId iconId = db->CreateIconL(KIconData);
       
   269 	gTestWrapper->TEST(db->IconL(iconId).Compare(KIconData) == 0);
       
   270 	gTestWrapper->TEST(db->IconL(iconId).Compare(KIconData2) != 0);
       
   271 
       
   272 	CBookmark& bookmark = db->CreateBookmarkL(db->RootL());
       
   273 	Bookmark::TItemId bookmarkId = bookmark.Id();
       
   274 	CBkmrkExtendedProperties& properties = bookmark.BkmrkExtendedPropertiesL();
       
   275 	properties.SetIconIdL(iconId);
       
   276 	
       
   277 	db->CommitL();
       
   278 	
       
   279 	CleanupStack::PopAndDestroy(db);
       
   280 	
       
   281 	db = CBookmarkDb::NewL(Bookmark::EVisibilityDefault, NULL);
       
   282 	CleanupStack::PushL(db);
       
   283 	
       
   284 	db->ConstructTreeL();
       
   285 	
       
   286 	CBookmark* bookmarkPtr = static_cast<CBookmark*>(db->FindItem(bookmarkId));
       
   287 	if (!bookmarkPtr)
       
   288 		{
       
   289 		User::Leave(KErrNotFound);
       
   290 		}
       
   291 	CBkmrkExtendedProperties& properties2 = bookmarkPtr->BkmrkExtendedPropertiesL();
       
   292 	iconId = properties2.IconId();
       
   293 	gTestWrapper->TEST(db->IconL(iconId).Compare(KIconData) == 0);
       
   294 	gTestWrapper->TEST(db->IconL(iconId).Compare(KIconData2) != 0);
       
   295 	
       
   296 	// cleanup
       
   297 	db->DeleteItemL(bookmarkId, ETrue);
       
   298 	db->DeleteIconL(iconId);
       
   299 	db->CommitL();
       
   300 	
       
   301 	CleanupStack::PopAndDestroy(db);
       
   302 	}
       
   303 
       
   304 LOCAL_D void CreateSecurityTreeL(CBookmarkDb& aDb)
       
   305 	{
       
   306 	CBookmarkFolder& folder1 = aDb.CreateFolderL(KTxtNewFolder, aDb.RootL());
       
   307 	CBookmarkFolder& folder2 = aDb.CreateFolderL(KTxtNewFolder2, folder1);
       
   308 	CBookmarkFolder& folder3 = aDb.CreateFolderL(KTxtNewFolder3, folder2);
       
   309 	aDb.CommitL();
       
   310 	
       
   311 	folder3.SetPublicL(EFalse);
       
   312 	
       
   313 	CBookmark& bookmark1 = aDb.CreateBookmarkL(folder1);
       
   314 	CBookmark& bookmark2 = aDb.CreateBookmarkL(folder2);
       
   315 	CBookmark& bookmark3 = aDb.CreateBookmarkL(folder3);
       
   316 	aDb.CommitL();
       
   317 	
       
   318 	bookmark1.SetPublicL(ETrue); // to avoid compiler warnings
       
   319 	bookmark2.SetPublicL(EFalse);
       
   320 	bookmark3.SetPublicL(ETrue); // to avoid compiler warnings
       
   321 	aDb.CommitL();
       
   322 	}
       
   323 	
       
   324 LOCAL_D void CheckAllL(CBookmarkDb& aDb)
       
   325 	{
       
   326 	CBookmarkFolder& root = aDb.RootL();
       
   327 	gTestWrapper->TEST(root.Count() == 1);
       
   328 	
       
   329 	CBookmarkFolder* folder = aDb.FindFolder(KTxtNewFolder);
       
   330 	gTestWrapper->TEST(folder != NULL);
       
   331 	gTestWrapper->TEST(folder->Count() == 2);
       
   332 	
       
   333 	folder = aDb.FindFolder(KTxtNewFolder2);
       
   334 	gTestWrapper->TEST(folder != NULL);
       
   335 	gTestWrapper->TEST(folder->Count() == 2);
       
   336 	
       
   337 	folder = aDb.FindFolder(KTxtNewFolder3);
       
   338 	gTestWrapper->TEST(folder != NULL);
       
   339 	gTestWrapper->TEST(folder->Count() == 1);
       
   340 	}
       
   341 
       
   342 LOCAL_D void CheckAllMinusOneL(CBookmarkDb& aDb)
       
   343 	{
       
   344 	CBookmarkFolder& root = aDb.RootL();
       
   345 	gTestWrapper->TEST(root.Count() == 3);
       
   346 	
       
   347 	CBookmarkFolder* folder = aDb.FindFolder(KTxtNewFolder);
       
   348 	gTestWrapper->TEST(folder != NULL);
       
   349 	gTestWrapper->TEST(folder->Count() == 1);
       
   350 	
       
   351 	folder = aDb.FindFolder(KTxtNewFolder2);
       
   352 	gTestWrapper->TEST(!folder);
       
   353 	
       
   354 	folder = aDb.FindFolder(KTxtNewFolder3);
       
   355 	gTestWrapper->TEST(folder != NULL);
       
   356 	gTestWrapper->TEST(folder->Count() == 1);
       
   357 	}
       
   358 
       
   359 LOCAL_D void CheckPrivateL(CBookmarkDb& aDb)
       
   360 	{
       
   361 	CBookmarkFolder& root = aDb.RootL();
       
   362 	gTestWrapper->TEST(root.Count() == 1);
       
   363 	
       
   364 	CBookmarkFolder* folder = aDb.FindFolder(KTxtNewFolder);
       
   365 	gTestWrapper->TEST(folder != NULL);
       
   366 	gTestWrapper->TEST(folder->Count() == 1);
       
   367 	
       
   368 	folder = aDb.FindFolder(KTxtNewFolder2);
       
   369 	gTestWrapper->TEST(folder != NULL);
       
   370 	gTestWrapper->TEST(folder->Count() == 2);
       
   371 	
       
   372 	folder = aDb.FindFolder(KTxtNewFolder3);
       
   373 	gTestWrapper->TEST(folder != NULL);
       
   374 	gTestWrapper->TEST(folder->Count() == 0);
       
   375 	}
       
   376 
       
   377 LOCAL_D void CheckPublicL(CBookmarkDb& aDb)
       
   378 	{
       
   379 	CBookmarkFolder& root = aDb.RootL();
       
   380 	gTestWrapper->TEST(root.Count() == 2);
       
   381 	
       
   382 	CBookmarkFolder* folder = aDb.FindFolder(KTxtNewFolder);
       
   383 	gTestWrapper->TEST(folder != NULL);
       
   384 	gTestWrapper->TEST(folder->Count() == 2);
       
   385 	
       
   386 	folder = aDb.FindFolder(KTxtNewFolder2);
       
   387 	gTestWrapper->TEST(folder != NULL);
       
   388 	gTestWrapper->TEST(folder->Count() == 0);
       
   389 	
       
   390 	folder = aDb.FindFolder(KTxtNewFolder3);
       
   391 	gTestWrapper->TEST(!folder);
       
   392 	}
       
   393 
       
   394 LOCAL_D void SecurityTestsL()
       
   395 	{
       
   396 	gTestWrapper->Next(_L("[CBookmarkDb tests] Security"));
       
   397 	CBookmarkDb* db = CBookmarkDb::NewL(Bookmark::EVisibilityManager, NULL);
       
   398 	CleanupStack::PushL(db);
       
   399 	CreateSecurityTreeL(*db);
       
   400 	CheckAllL(*db);
       
   401 	CleanupStack::PopAndDestroy(db);
       
   402 	
       
   403 	db = CBookmarkDb::NewL(Bookmark::EVisibilityDefault, NULL);
       
   404 	CleanupStack::PushL(db);
       
   405 	db->ConstructTreeL();
       
   406 	CheckAllL(*db);
       
   407 	CleanupStack::PopAndDestroy(db);
       
   408 	
       
   409 	db = CBookmarkDb::NewL(Bookmark::EVisibilityPublic, NULL);
       
   410 	CleanupStack::PushL(db);
       
   411 	db->ConstructTreeL();
       
   412 	CheckPublicL(*db);
       
   413 	CleanupStack::PopAndDestroy(db);
       
   414 	
       
   415 	db = CBookmarkDb::NewL(Bookmark::EVisibilityPrivate, NULL);
       
   416 	CleanupStack::PushL(db);
       
   417 	db->ConstructTreeL();
       
   418 	CheckPrivateL(*db);
       
   419 	CleanupStack::PopAndDestroy(db);
       
   420 	
       
   421 	db = CBookmarkDb::NewL(Bookmark::EVisibilityManager, NULL);
       
   422 	CleanupStack::PushL(db);
       
   423 	db->ConstructTreeL();
       
   424 	CBookmarkFolder* publicFolder = db->FindFolder(KTxtNewFolder2);
       
   425 	publicFolder->SetOwnerL(0x00001234); 
       
   426 	db->CommitL();
       
   427 	CleanupStack::PopAndDestroy(db);
       
   428 	
       
   429 	db = CBookmarkDb::NewL(Bookmark::EVisibilityAll, NULL);
       
   430 	CleanupStack::PushL(db);
       
   431 	db->ConstructTreeL();
       
   432 	CheckAllMinusOneL(*db);
       
   433 	CleanupStack::PopAndDestroy(db);
       
   434 	
       
   435 	db = CBookmarkDb::NewL(Bookmark::EVisibilityManager, NULL);
       
   436 	CleanupStack::PushL(db);
       
   437 	db->ConstructTreeL();
       
   438 	CheckAllL(*db);
       
   439 	CleanupStack::PopAndDestroy(db);
       
   440 	
       
   441 	db = CBookmarkDb::NewL(Bookmark::EVisibilityDefault, NULL);
       
   442 	CleanupStack::PushL(db);
       
   443 	db->ConstructTreeL();
       
   444 	CBookmarkFolder* folder = db->FindFolder(KTxtNewFolder);
       
   445 	gTestWrapper->TEST(folder != NULL);
       
   446 	db->DeleteItemL(folder->Id(), ETrue);
       
   447 	db->CommitL();
       
   448 	CleanupStack::PopAndDestroy(db);
       
   449 	}
       
   450 	
       
   451 void DoCBookmarkDbUnitL(CTestWrapper* aTest)
       
   452 	{
       
   453 	gTestWrapper = aTest;
       
   454 	gTestWrapper->SetFile(KFilename);
       
   455 	gTestWrapper->Next(_L("*** CBookmarkDb tests ***"));
       
   456 	
       
   457 	GeneralTestsL();
       
   458 	TreeTestsL();
       
   459 	CommitTestsL();
       
   460 	IconDataTestsL();
       
   461 	SecurityTestsL();
       
   462 	}