|
1 // Copyright (c) 2004-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 // DBMS security policy - testing new APIs - utility functions |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef T_DBPLATSECUTL_H |
|
19 #define T_DBPLATSECUTL_H |
|
20 |
|
21 #include <d32dbms.h> |
|
22 #include "t_dbsecuritypolicy.h" |
|
23 |
|
24 //Forward declarations |
|
25 class RTest; |
|
26 |
|
27 //Table column definition structure. |
|
28 struct TColDef |
|
29 { |
|
30 const TText* iName; |
|
31 TDbColType iType; |
|
32 TInt iAttributes; |
|
33 }; |
|
34 |
|
35 typedef void (*TCleanupFunc)(); |
|
36 |
|
37 //Test utility class. Define TheDbscUtils instance somewhere in your test code. |
|
38 class TDBSCUtils |
|
39 { |
|
40 public: |
|
41 TDBSCUtils(RTest& aTest, TCleanupFunc aFunc); |
|
42 |
|
43 static CDbColSet* CreateColSetLC(const TColDef* aColDef); |
|
44 static CDbKey* CreateKeyLC(const TDesC& aColName); |
|
45 static void CreateTableL(RDbNamedDatabase& aDb, const TDesC& aTblName, const TColDef* aColDef); |
|
46 |
|
47 static RDbNamedDatabase CreateDatabase(RDbs& aDbs, TUid aPolicyUid, const TDesC& aDbName); |
|
48 static TInt DeleteDatabase(RDbs& aDbs, TUid aPolicyUid, const TDesC& aDbName); |
|
49 |
|
50 static TBool IsDatabaseThereL(RDbs& aDbs, TUid aPolicyUid, TDriveNumber aDriveNumber, const TDesC& aDatabaseName); |
|
51 static TBool HasCapability(const TCompiledSecurityPolicy& aPolicy, TCapability aCapability); |
|
52 |
|
53 static void Check(TInt aValue, TInt aLine); |
|
54 static void Check(TInt aValue, TInt aExpected, TInt aLine); |
|
55 |
|
56 private: |
|
57 RTest& iTest; |
|
58 TCleanupFunc iFunc; |
|
59 }; |
|
60 |
|
61 #define TEST(arg) TDBSCUtils::Check((arg), __LINE__) |
|
62 #define TEST2(aValue, aExpected) TDBSCUtils::Check(aValue, aExpected, __LINE__) |
|
63 |
|
64 extern TDBSCUtils TheDbscUtils; |
|
65 |
|
66 #endif//T_DBPLATSECUTL_H |