contentstorage/castorage/tsrc/t_castorage/src/castoragetestbackup.cpp
changeset 117 c63ee96dbe5f
equal deleted inserted replaced
115:3ab5c078b490 117:c63ee96dbe5f
       
     1 /*
       
     2 * Copyright (c) 2009 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 *
       
    16 */
       
    17 /*
       
    18  * castoragetestgetparentids.cpp
       
    19  *
       
    20  *  Created on: 2009-09-14
       
    21  *      Author: michal.czerwiec
       
    22  */
       
    23 
       
    24 #include "castoragetest.h"
       
    25 #include "castoragefactory.h"
       
    26 #include "castorage.h"
       
    27 #include "cainnerentry.h"
       
    28 #include "casqlquery.h"
       
    29 #include "casqlitestorage.h"
       
    30 #include "castoragetestsqlcommands.h"
       
    31 #include "casqlcommands.h"
       
    32 
       
    33 
       
    34 
       
    35 void CCAStorageTest::testSaveRestoreDatabase()
       
    36 {
       
    37     
       
    38     TBool result = EFalse; 
       
    39     TRAPD(err,
       
    40     	    RFs fs;
       
    41     	    User::LeaveIfError(fs.Connect());
       
    42     	    
       
    43     	    CCaSqLiteStorage *storage = dynamic_cast<CCaSqLiteStorage *>(mStorage);
       
    44     		if( BaflUtils::FileExists( fs, storage->iPrivatePathCDriveDbBackup) )
       
    45     			{
       
    46     		    BaflUtils::DeleteFile(fs, storage->iPrivatePathCDriveDbBackup);    		    
       
    47     			}
       
    48     		
       
    49     		mStorage->SaveDatabaseL();
       
    50     		
       
    51     		mStorage->RestoreDatabaseL();
       
    52     		
       
    53 
       
    54     		if( BaflUtils::FileExists( fs, storage->iPrivatePathCDriveDbBackup) )
       
    55     			{
       
    56     		    result = ETrue;
       
    57     		    BaflUtils::DeleteFile(fs, storage->iPrivatePathCDriveDbBackup);    		    
       
    58     			}
       
    59             fs.Close();
       
    60      );
       
    61 
       
    62     QCOMPARE(err, KErrNone);
       
    63     QVERIFY(result);
       
    64 }
       
    65 
       
    66