persistentstorage/dbms/tdbms/t_dbenvdestroy.cpp
changeset 0 08ec8eefde2f
child 55 44f437012c90
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     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 - cleanup operations
       
    15 // Please, ensure that t_postdbsc test is executed after t_dbsc<N> tests!
       
    16 // 
       
    17 //
       
    18 
       
    19 #include <d32dbms.h>
       
    20 #include <e32test.h>
       
    21 
       
    22 static RTest TheTest(_L("t_dbenvdestroy: DBMS platform security tetsing - cleanup"));
       
    23 static RDbs TheDbs;
       
    24 const TUid KSecureDbUid = {0x11335578};
       
    25 const TUid KSecureDbUid2 = {0x11335579};
       
    26 const TUid KSecureDbUid3 = {0x1133557A};
       
    27 _LIT(KProtDb1CName, "c:A.DB");
       
    28 _LIT(KProtDb2CName, "c:b.DB");
       
    29 _LIT(KProtDb3CName, "c:C.DB");
       
    30 _LIT(KProtDb4CName, "c:z.DB");
       
    31 _LIT(KProtDb5CName, "C:TEstdB.dB");
       
    32 _LIT(KProtDb6CName, "C:AbcD.db");
       
    33 _LIT(KProtDb7CName, "c:A0123456789B0123456789C0123456789D0123456789E0123456789F0123.Db");
       
    34 _LIT(KProtDb8CName, "c:ZADFS.Db");
       
    35 
       
    36 ///////////////////////////////////////////////////////////////////////////////////////
       
    37 ///////////////////////////////////////////////////////////////////////////////////////
       
    38 //Test macros and functions
       
    39 static void Check(TInt aValue, TInt aExpected, TInt aLine)
       
    40 	{
       
    41 	if(aValue != aExpected)
       
    42 		{
       
    43 		RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
       
    44 		TheTest(EFalse, aLine);
       
    45 		}
       
    46 	}
       
    47 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
       
    48 
       
    49 ///////////////////////////////////////////////////////////////////////////////////////
       
    50 
       
    51 static void DeleteTestDatabase(TUid aUid, const TDesC& aDbName)
       
    52 	{
       
    53 	RDebug::Print(_L("Deleting %X \"%S\" database.\n"), aUid, &aDbName);
       
    54 	TInt err = TheDbs.DeleteDatabase(aDbName, aUid);
       
    55 	if(err != KErrNone && err != KErrNotFound)
       
    56 		{
       
    57 		RDebug::Print(_L("Error %d deleting \"%S\" database.\n"), err, &aDbName);
       
    58 		}
       
    59 	}
       
    60 
       
    61 /**
       
    62 @SYMTestCaseID SYSLIB-DBMS-CT-0024
       
    63 @SYMTestCaseDesc This test app must be executed after all t_dbsc<N> tests.
       
    64                  It ensures that the test data removd from drive C:.
       
    65 @SYMTestPriority High
       
    66 @SYMTestActions  Remove used test databases from drive C:.
       
    67 @SYMTestExpectedResults The test must not fail.
       
    68 @SYMREQ REQ2429
       
    69                  DBMS shall provide an API to apply security policies to database tables.
       
    70 */
       
    71 static void DoRun()
       
    72 	{
       
    73 	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0024 Delete protected databases from C: "));
       
    74 	::DeleteTestDatabase(KSecureDbUid2, KProtDb5CName);
       
    75 	::DeleteTestDatabase(KSecureDbUid, KProtDb4CName);
       
    76 	::DeleteTestDatabase(KSecureDbUid, KProtDb3CName);
       
    77 	::DeleteTestDatabase(KSecureDbUid, KProtDb2CName);
       
    78 	::DeleteTestDatabase(KSecureDbUid, KProtDb1CName);
       
    79 	::DeleteTestDatabase(KSecureDbUid3, KProtDb6CName);
       
    80 	::DeleteTestDatabase(KSecureDbUid3, KProtDb7CName);
       
    81 	::DeleteTestDatabase(KSecureDbUid3, KProtDb8CName);
       
    82 	}
       
    83 
       
    84 TInt E32Main()
       
    85     {
       
    86 	TInt err = TheDbs.Connect();
       
    87 	TEST2(err, KErrNone);
       
    88 
       
    89 	::DoRun();
       
    90 
       
    91 	TheDbs.Close();
       
    92 
       
    93 	TheTest.End();
       
    94 	TheTest.Close();
       
    95 
       
    96 	return KErrNone;
       
    97     }