contentstorage/castorage/tsrc/t_castorage/src/castoragetestbackup.cpp
author Jaakko Haukipuro (Nokia-MS/Oulu) <Jaakko.Haukipuro@nokia.com>
Thu, 16 Sep 2010 12:11:40 +0100
changeset 117 c63ee96dbe5f
permissions -rw-r--r--
Missing activityfw and taskswitcher components - fix for Bug 3670

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
/*
 * castoragetestgetparentids.cpp
 *
 *  Created on: 2009-09-14
 *      Author: michal.czerwiec
 */

#include "castoragetest.h"
#include "castoragefactory.h"
#include "castorage.h"
#include "cainnerentry.h"
#include "casqlquery.h"
#include "casqlitestorage.h"
#include "castoragetestsqlcommands.h"
#include "casqlcommands.h"



void CCAStorageTest::testSaveRestoreDatabase()
{
    
    TBool result = EFalse; 
    TRAPD(err,
    	    RFs fs;
    	    User::LeaveIfError(fs.Connect());
    	    
    	    CCaSqLiteStorage *storage = dynamic_cast<CCaSqLiteStorage *>(mStorage);
    		if( BaflUtils::FileExists( fs, storage->iPrivatePathCDriveDbBackup) )
    			{
    		    BaflUtils::DeleteFile(fs, storage->iPrivatePathCDriveDbBackup);    		    
    			}
    		
    		mStorage->SaveDatabaseL();
    		
    		mStorage->RestoreDatabaseL();
    		

    		if( BaflUtils::FileExists( fs, storage->iPrivatePathCDriveDbBackup) )
    			{
    		    result = ETrue;
    		    BaflUtils::DeleteFile(fs, storage->iPrivatePathCDriveDbBackup);    		    
    			}
            fs.Close();
     );

    QCOMPARE(err, KErrNone);
    QVERIFY(result);
}