|
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 // Contains implementation of CTestDeleteItemsInFolderStep class |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalTechnology |
|
21 */ |
|
22 |
|
23 // System Include |
|
24 #include <bookmarkdatabase.h> |
|
25 |
|
26 // User Include |
|
27 #include "TestDeleteItemsInFolderStep.h" |
|
28 |
|
29 /** |
|
30 Constructor. Sets the test step name |
|
31 @internalTechnology |
|
32 @test |
|
33 */ |
|
34 CTestDeleteItemsInFolderStep::CTestDeleteItemsInFolderStep(CTestBookmarksServer& aTestServer) : CTestBookmarksBaseStep(aTestServer) |
|
35 { |
|
36 //Call base class method to set human readable name for test step |
|
37 SetTestStepName(KTestDeleteItemsInFolderStep); |
|
38 } |
|
39 |
|
40 |
|
41 /** |
|
42 Base class pure virtual. |
|
43 @internalTechnology |
|
44 @test |
|
45 @param None |
|
46 @return EPass or EFail indicating the result of the test step. |
|
47 */ |
|
48 TVerdict CTestDeleteItemsInFolderStep::doTestStepL() |
|
49 { |
|
50 TPtrC title; |
|
51 if(!GetStringFromConfig(ConfigSection(), KIniTitle, title)) |
|
52 { |
|
53 ERR_PRINTF2(_L("Problem in reading values from ini. \ |
|
54 \nExpected fields are: \n%S\n" |
|
55 ), &KIniTitle |
|
56 ); |
|
57 SetTestStepResult(EFail); |
|
58 } |
|
59 else |
|
60 { |
|
61 TRAPD(error, DoTestL(title)); |
|
62 if(error != KErrNone) |
|
63 { |
|
64 ERR_PRINTF2(_L("Error occured in CTestDeleteItemsInFolderStep::DoTestL: %D"), error); |
|
65 SetTestStepError(error); |
|
66 } |
|
67 } |
|
68 return TestStepResult(); |
|
69 } // doTestStepL |
|
70 |
|
71 /** |
|
72 Deletes the children of a folder |
|
73 @internalTechnology |
|
74 @test |
|
75 @param Title of the folder whose children are to be deleted |
|
76 @return None |
|
77 */ |
|
78 void CTestDeleteItemsInFolderStep::DoTestL(const TPtrC& aTitle) |
|
79 { |
|
80 _LIT(KPrintType, "The type of item is %S"); |
|
81 RBkFolder bkFolder; |
|
82 if(aTitle == KRoot) |
|
83 {// Root folder |
|
84 bkFolder = iBkDb.OpenRootL(); |
|
85 } |
|
86 else |
|
87 { |
|
88 bkFolder = iBkDb.OpenFolderL(aTitle); |
|
89 } |
|
90 CleanupClosePushL(bkFolder); |
|
91 RBkNode bkItem; |
|
92 for(TInt index = 0; index < bkFolder.Count(); ++index) |
|
93 { |
|
94 // Open the item to get the id |
|
95 bkItem = bkFolder.OpenItemL(index); |
|
96 CleanupClosePushL(bkItem); |
|
97 |
|
98 // Print |
|
99 INFO_PRINTF4(_L("The title of child %D is %S and Id is %U"), index + 1 , &(bkItem.Title()), bkItem.Id()); |
|
100 if(bkItem.Type() == Bookmark::ETypeFolder) |
|
101 { |
|
102 INFO_PRINTF2(KPrintType, &(KFolder())); |
|
103 } |
|
104 else |
|
105 { |
|
106 INFO_PRINTF2(KPrintType, &(KBookmark())); |
|
107 } |
|
108 |
|
109 // Delete |
|
110 iBkDb.DeleteItemL(bkItem.Id(), ETrue); |
|
111 CleanupStack::PopAndDestroy(&bkItem); |
|
112 } |
|
113 // Commit |
|
114 CommitDb(); |
|
115 CleanupStack::PopAndDestroy(&bkFolder); |
|
116 } // DoTestL |