persistentstorage/sql/TEST/t_sqlenvcreate.cpp
branchRCL_3
changeset 12 6b6fd149daa2
parent 0 08ec8eefde2f
child 15 fcc16690f446
equal deleted inserted replaced
11:211563e4b919 12:6b6fd149daa2
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    10 //
    10 //
    11 // Contributors:
    11 // Contributors:
    12 //
    12 //
    13 // Description:
    13 // Description:
    14 // SQL security - copying secure test databases to C:
    14 // SQL security - copying secure test databases to C:
    15 // Please, ensure that t_sqlenvcreate test is executed before the other sql security tests
    15 // Please, ensure that t_sqlenvcreate test is executed before the other sql tests
    16 // 
    16 // 
    17 //
    17 //
    18 
    18 
    19 #include <e32test.h>
    19 #include <e32test.h>
    20 #include <bautils.h>
    20 #include <bautils.h>
    57 _LIT(KDb7, "c:\\private\\10281e17\\[98765432]t_invobject.db");
    57 _LIT(KDb7, "c:\\private\\10281e17\\[98765432]t_invobject.db");
    58 
    58 
    59 _LIT(KDb8org, "z:\\private\\10281e17\\[98765432]t_2defaultpolicies.db");
    59 _LIT(KDb8org, "z:\\private\\10281e17\\[98765432]t_2defaultpolicies.db");
    60 _LIT(KDb8, "c:\\private\\10281e17\\[98765432]t_2defaultpolicies.db");
    60 _LIT(KDb8, "c:\\private\\10281e17\\[98765432]t_2defaultpolicies.db");
    61 
    61 
       
    62 _LIT(KPrivateSubDir, "c:\\private\\10281e17\\TestDir.db");
       
    63 
    62 ///////////////////////////////////////////////////////////////////////////////////////
    64 ///////////////////////////////////////////////////////////////////////////////////////
    63 ///////////////////////////////////////////////////////////////////////////////////////
    65 ///////////////////////////////////////////////////////////////////////////////////////
    64 //Test macros and functions
    66 //Test macros and functions
       
    67 static void Check(TInt aValue, TInt aLine)
       
    68 	{
       
    69 	if(!aValue)
       
    70 		{
       
    71 		RDebug::Print(_L("*** Line %d\r\n"), aLine);
       
    72 		TheTest(EFalse, aLine);
       
    73 		}
       
    74 	}
    65 static void Check(TInt aValue, TInt aExpected, TInt aLine)
    75 static void Check(TInt aValue, TInt aExpected, TInt aLine)
    66 	{
    76 	{
    67 	if(aValue != aExpected)
    77 	if(aValue != aExpected)
    68 		{
    78 		{
    69 		RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
    79 		RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
    70 		TheTest(EFalse, aLine);
    80 		TheTest(EFalse, aLine);
    71 		}
    81 		}
    72 	}
    82 	}
       
    83 #define TEST(arg) ::Check((arg), __LINE__)
    73 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
    84 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
    74 
    85 
    75 ///////////////////////////////////////////////////////////////////////////////////////
    86 ///////////////////////////////////////////////////////////////////////////////////////
    76 
    87 
    77 void DoRun()
    88 void DoRun()
    80 	TInt err = fs.Connect();
    91 	TInt err = fs.Connect();
    81 	TEST2(err, KErrNone);
    92 	TEST2(err, KErrNone);
    82 
    93 
    83 	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-SQL-LEGACY-T_SQLENVCREATE-0001 Copy secure databases from Z: to C: "));
    94 	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-SQL-LEGACY-T_SQLENVCREATE-0001 Copy secure databases from Z: to C: "));
    84 
    95 
       
    96 	//Create a subdir in the private datacage. The SQL production code should properly detects
       
    97 	//KPrivateSubDir is a directory not a database file
       
    98 	err = fs.MkDir(KPrivateSubDir);
       
    99 	TEST(err == KErrNone || err == KErrAlreadyExists);
       
   100 	
    85 	err = BaflUtils::CopyFile(fs, KDbZFileName1, KDbCFileName1);
   101 	err = BaflUtils::CopyFile(fs, KDbZFileName1, KDbCFileName1);
    86 	TEST2(err, KErrNone);
   102 	TEST2(err, KErrNone);
    87 	err = fs.SetAtt(KDbCFileName1, 0, KEntryAttReadOnly);
   103 	err = fs.SetAtt(KDbCFileName1, 0, KEntryAttReadOnly);
    88 	TEST2(err, KErrNone);
   104 	TEST2(err, KErrNone);
    89 
   105