contentstorage/castorage/tsrc/t_castorage/inc/castoragetest.h
changeset 117 c63ee96dbe5f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/castorage/tsrc/t_castorage/inc/castoragetest.h	Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,241 @@
+/*
+ * 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:
+ *
+ */
+#ifndef CASTORAGETEST_H
+#define CASTORAGETEST_H
+
+//  INCLUDES
+#include <e32svr.h>
+#include <e32math.h>
+#include <f32file.h>
+#include <QtTest/QtTest>
+#include <QString>
+
+#include "cainnerquery.h"
+
+class CCaStorage;
+class CCaInnerEntry;
+
+class CCAStorageTest : public QObject
+{
+    Q_OBJECT
+
+private slots:
+
+    /**
+     * Test methods are listed below.
+     */
+    
+    
+    
+    //tests for add command
+    void testAdd();
+    //tests for add command without icon
+    void testAddEmptyIcon();
+    //tests for add command with icon
+    void testAddWithIcon();
+    //tests for add command with existing icon
+    void testAddWithExistingIcon();
+    //tests for add command with existing icon where only filename specified
+    void testAddWithExistingIconOnlyFileName();
+    //tests for add command with partly matching icon
+    void testAddWithPartlyMatchingIcon();
+    //tests for add command with partly matching icon when not all icon params where set
+    void testAddWithPartlyMatchingIconNotAllParams();
+    //tests for add command with not complete icon
+    void testAddWithNotCompleteIcon();
+    //tests for add command to update icon
+    void testAddUpdateIcon();
+    //tests for add command to update icon with the same one 
+    void testAddUpdateIconOnlyFewParams();
+    //tests for add command to update icon
+    void testAddUpdateWithEmptyIcon();
+    //tests for add command to update icon
+    void testAddUpdateWithEmptyIconAdvanced();
+    //tests for add command to update icon, to an already existing icon
+    void testAddUpdateWithExistingIcon();
+    //tests for add command - add attributes
+    void testAddAttributes();
+    //tests for add command - update attributes
+    void testUpdateAttributes();
+    //tests for add command - remove attributes
+    void testDeleteAttributes();
+    //tests for remove command
+    void testRemoveOneEntryWithIcon();
+
+    void testRemoveOneEntryWhenIconIsUseByOtherEntry();
+
+    void testRemoveTwoEntriesWithSameIcon();
+
+    void testRemoveOneEntryWithoutIcon();
+
+    void testRemove5Entries();
+
+    void testRemoveEntriesWithIdOutOFBound();
+
+    void testTouch();
+
+    void testTouch2Times();
+
+    void testTouch5Entries();
+
+    void testRemoveOldFromLaunch();
+
+    void testRemoveOldWhen2DifferentLaunchTimes();
+
+    //tests getentries by id.
+    void testGetEntriesById();
+
+    //tests getentries by group id.
+    void testGetEntriesByGroupId();
+
+    //tests getentries by group id.
+    void testGetEntriesByTypeName();
+
+    //tests getentries sorted by name.
+    void testGetEntriesSortByName();
+
+    //tests getentries sorted by created timestamp.
+    void testGetEntriesSortByCreatedTimestamp();
+
+    //tests getentries sorted by most used timestamp.
+    void testGetEntriesSortByMostUsedTimestamp();
+
+    //tests getentries sorted by last used timestamp.
+    void testGetEntriesSortByLastUsedTimestamp();
+
+    //tests getentries sorted by default.
+    void testGetEntriesSortByDefault();
+
+    //tests getentries by flags.
+    void testGetEntriesByFlags();
+
+    //tests getentries by flags off.
+    void testGetEntriesByFlagsOff();
+
+    //tests getentries by flags on.
+    void testGetEntriesByFlagsOn();
+
+    //tests getentries by flags on.
+    void testGetEntriesByRole();
+
+    //tests getentries by flags.
+    void testGetEntriesByUid();
+    
+    //tests getentries by attributes.
+    void testGetEntriesByAttributes();
+    
+    //tests getentries by attributes.
+    void testGetEntriesByAttributes2();
+
+    //tests getentries by child Id.
+    void testGetEntriesByChildId();
+
+    //tests organize remove.
+    void testOrganizeRemove();
+
+    //tests organize append.
+    void testOrganizeAppend();
+
+    //tests organize prepend.
+    void testOrganizePrepend();
+
+    //tests organize insert new entry into group.
+    void testOrganizeInsertNewIntoGroup();
+
+    //tests organize get entries' ids.
+    void testGetEntriesIds();
+
+    //tests organize bad parameters case.
+    void testOrganizeBadParams();
+
+    void testGetNewEntryWithAttributes();
+
+    void testGetNewEntryWithAttributesByUid();
+
+    void testGetEntriesWhenLimitSetTo();
+
+    //tests custom sort
+    void testCustomSort();
+
+    //tests get parent ids
+    void testGetParentIds();
+
+    void testGetParentIdsInLoop();
+
+    //tests properties
+    void testPropertyGetDbVersion();
+
+    void testPropertyGetLanguage();
+
+    void testLoadDBFromROM();
+
+    //tests localization
+    void testRemoveFromLocalizationAfterNameChange();
+
+    void testGetLocalizations();
+
+    void testLocalizeEntry();
+    
+    void testAddLocalizationEntry();
+    
+    void testUpdateLocalizationEntry();
+
+    void testSaveRestoreDatabase();
+   
+    
+    //unused
+    //void testBadDBVersion();
+
+    void init(); // called before each test method
+    void cleanup(); // called after each test method
+    void initTestCase(); // called once before all test methods
+    void cleanupTestCase(); // caled once after all test methods
+    /**
+     * Utility methods are listed below.
+     */
+
+    // Test that two data arrays have opposite order.
+
+
+private:
+    TInt locEntriesCount();
+
+
+protected:
+
+
+    /**
+     * Utils methods are listed below.
+     */
+    TInt verifyOppositeOrder(RPointerArray<CCaInnerEntry>& aArray1,
+                             RPointerArray<CCaInnerEntry>& aArray2);
+
+    TInt testSortingBySortOrder(CCaInnerQuery::TSortAttribute sortAttr1,
+                                CCaInnerQuery::TSortAttribute sortAttr2);
+
+    TInt testSortingBySortOrder(CCaInnerQuery *aInnerQuery1,
+                                CCaInnerQuery *aInnerQuery2);
+    void RestoreDatabase();
+    void CopyFile(const TDesC &aSorcePath, const TDesC &aDestinationPath);
+    QString descToQString(const TDesC &descriptor);
+private:
+
+    CCaStorage *mStorage;
+
+};
+
+#endif