phonebookengines/cntsimutility/tsrc/ut_cntsimutility/ut_cntsimutility.h
changeset 81 640d30f4fb64
equal deleted inserted replaced
77:c18f9fa7f42e 81:640d30f4fb64
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef _UT_SIM_UTILITY_H_
       
    43 #define _UT_SIM_UTILITY_H_
       
    44 #include <QtTest/QtTest>
       
    45 #include <QObject>
       
    46 
       
    47 #include <qtcontacts.h>
       
    48 
       
    49 #ifdef SYMBIANSIM_BACKEND_USE_ETEL_TESTSERVER
       
    50 #include <etelmm_etel_test_server.h>
       
    51 #else
       
    52 #include <etelmm.h>
       
    53 #endif
       
    54 #include <mmtsy_names.h>
       
    55 #include "cntsimutility.h"
       
    56 QTM_USE_NAMESPACE
       
    57 
       
    58 
       
    59 #ifndef QTRY_COMPARE
       
    60 #define QTRY_COMPARE(__expr, __expected) \
       
    61     do { \
       
    62         const int __step = 50; \
       
    63         const int __timeout = 5000; \
       
    64         if ((__expr) != (__expected)) { \
       
    65             QTest::qWait(0); \
       
    66         } \
       
    67         for (int __i = 0; __i < __timeout && ((__expr) != (__expected)); __i+=__step) { \
       
    68             QTest::qWait(__step); \
       
    69         } \
       
    70         QCOMPARE(__expr, __expected); \
       
    71     } while(0)
       
    72 #endif
       
    73 
       
    74 //TESTED_CLASS=
       
    75 //TESTED_FILES=
       
    76 
       
    77 /*!
       
    78 */
       
    79 class TestCntSimUtility : public QObject
       
    80 {
       
    81 Q_OBJECT
       
    82 
       
    83 public:
       
    84     TestCntSimUtility();
       
    85     virtual ~TestCntSimUtility();
       
    86 public:
       
    87    static bool returnErrorInStub_1;
       
    88    static bool returnErrorInStub_2;
       
    89 public slots:
       
    90     void adnCacheStatusReady(CntSimUtility::CacheStatus& cacheStatus, int error);
       
    91     void simInfoReady(CntSimUtility::SimInfo& simInfo, int error);
       
    92     void availableStoresReady(CntSimUtility::AvailableStores& availableStores, int error);
       
    93 
       
    94 
       
    95 private slots:
       
    96    void initTestCase();
       
    97    void cleanupTestCase();
       
    98    void TestStoreCreation();
       
    99    void TestGetSimInfo();
       
   100    void TestGetAvailableStores();
       
   101    void TestVerifyPin2Code();
       
   102    void TestIsFdnActive();
       
   103    void TestSetFdnStatus();
       
   104    void TestGetLastImportTime();
       
   105    void TestSetLastImportTime();
       
   106    //Async
       
   107    //async request
       
   108    void TestStartGetSimInfo();
       
   109    void TestStartGetAvailableStores();
       
   110    void TestNotifyAdnCacheStatus();
       
   111 private:
       
   112    void initManager(QString simStore);
       
   113    void outputSimInfo(CntSimUtility::SimInfo &results);
       
   114 private:
       
   115     CntSimUtility* m_SimStore;
       
   116 
       
   117     bool mAdnStorePresent;
       
   118     bool mSdnStorePresent;
       
   119     bool mSimPresent;
       
   120     int mAdnStoreEntries;
       
   121     int mSdnStoreEntries;
       
   122     bool mSimError;
       
   123     bool mWaitingForAdnCache;
       
   124     bool mImportInProgress;
       
   125     bool mAdnEntriesPresent;
       
   126 
       
   127 
       
   128 
       
   129 };
       
   130 
       
   131 #endif //_UT_SIM_UTILITY_H_