|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * ?description_line |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 |
|
22 #include "FT_CPosTp4.h" |
|
23 #include <EPos_CPosLandmarkDatabase.h> |
|
24 #include <EPos_CPosLMItemIterator.h> |
|
25 #include <EPos_CPosLmDatabaseManager.h> |
|
26 #include "FT_LandmarkConstants.h" |
|
27 |
|
28 // ================= MEMBER FUNCTIONS ======================= |
|
29 |
|
30 |
|
31 // --------------------------------------------------------- |
|
32 // CPosTp4::StartL |
|
33 // |
|
34 // (other items were commented in a header). |
|
35 // --------------------------------------------------------- |
|
36 // |
|
37 void CPosTp4::StartL() |
|
38 { |
|
39 TestCompactL(ESynchronous); |
|
40 |
|
41 TestCompactL(EAsynchronous); |
|
42 |
|
43 TestCompactL(EWaitForRequest); |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------- |
|
47 // CPosTp4::TestCompactL |
|
48 // |
|
49 // (other items were commented in a header). |
|
50 // --------------------------------------------------------- |
|
51 // |
|
52 void CPosTp4::TestCompactL(TExecutionMode aExecutionMode) |
|
53 { |
|
54 _LIT(KFileSizeErr, "Returned file size is incorrect"); |
|
55 _LIT(KUsageErr, "Returned usage is incorrect"); |
|
56 _LIT(KFileSizeAfterCompactErr, "The file size after compact is not less than the file size before compact"); |
|
57 _LIT(KUsageAfterCompactErr, "The usage is equal or less than before compact"); |
|
58 |
|
59 RemoveDefaultDbL(); |
|
60 RemoveAllLmDatabasesL(); |
|
61 |
|
62 CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); |
|
63 CleanupStack::PushL(manager); |
|
64 |
|
65 // Create new test db |
|
66 HPosLmDatabaseInfo* dbInfoDefault = HPosLmDatabaseInfo::NewLC(KTp4TestDb); |
|
67 manager->CreateDatabaseL(*dbInfoDefault); |
|
68 CleanupStack::PopAndDestroy(dbInfoDefault); |
|
69 // This db must exist |
|
70 manager->SetDefaultDatabaseUriL(KTp4TestDb); |
|
71 CleanupStack::PopAndDestroy(manager); |
|
72 |
|
73 CPosLandmarkDatabase* tmp = CPosLandmarkDatabase::OpenL(); // Make sure default database is created |
|
74 CleanupStack::PushL(tmp); |
|
75 if (tmp->IsInitializingNeeded()) |
|
76 { |
|
77 ExecuteAndDeleteLD(tmp->InitializeL()); |
|
78 } |
|
79 CleanupStack::PopAndDestroy(tmp); |
|
80 |
|
81 RFile file; |
|
82 User::LeaveIfError(file.Open(iFileSession, KLmTp4DefaultDbPath, EFileRead)); |
|
83 TInt fileSize=0; |
|
84 file.Size(fileSize); |
|
85 file.Close(); |
|
86 |
|
87 CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); |
|
88 CleanupStack::PushL(lmd); |
|
89 |
|
90 CPosLandmarkDatabase::TSize size = lmd->SizeL(); |
|
91 |
|
92 AssertTrueSecL(size.iFileSize == fileSize, KFileSizeErr); |
|
93 AssertTrueSecL(size.iUsage >= 0.0 && size.iUsage <= 1.0, KUsageErr); // For now, when compact is supported should usage be 100% |
|
94 |
|
95 CPosLmOperation* op = lmd->CompactL(); |
|
96 switch (aExecutionMode) |
|
97 { |
|
98 case ESynchronous: |
|
99 ExecuteAndDeleteLD(op); |
|
100 break; |
|
101 case EAsynchronous: |
|
102 RunAsyncOperationLD(op); //*** async |
|
103 break; |
|
104 case EWaitForRequest: |
|
105 CleanupStack::PushL(op); |
|
106 RunAsyncOperationByWaitForReqL(op); |
|
107 CleanupStack::PopAndDestroy(op); |
|
108 break; |
|
109 default: |
|
110 |
|
111 break; |
|
112 } |
|
113 |
|
114 CPosLandmarkDatabase::TSize sizeAfterCompact = lmd->SizeL(); |
|
115 |
|
116 AssertTrueSecL(sizeAfterCompact.iFileSize < size.iFileSize, KFileSizeAfterCompactErr); |
|
117 |
|
118 AssertTrueSecL(sizeAfterCompact.iUsage >= size.iUsage, KUsageAfterCompactErr); |
|
119 |
|
120 CleanupStack::PopAndDestroy(lmd); |
|
121 } |
|
122 |
|
123 // End of File |