phoneapp/phoneuiqtviewadapter/tsrc/ut_telephonyservice/unit_tests.cpp
changeset 21 92ab7f8d0eab
child 46 bc5a64e5bc3c
equal deleted inserted replaced
4:c84cf270c54f 21:92ab7f8d0eab
       
     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:  Unit tests for telephonyservice.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QtTest/QtTest>
       
    19 #include <QtGui>
       
    20 #include <hbapplication.h>
       
    21 #include <QSignalSpy>
       
    22 #include <xqservicerequest.h>
       
    23 #include <hbmenu.h>
       
    24 
       
    25 #include "telephonyservice.h"
       
    26 #include "phoneuiqtviewif.h"
       
    27 #include "phoneuiqtviewadapter.h"
       
    28 
       
    29 extern bool phoneAppStart;
       
    30 extern bool inCallDialerStart;
       
    31 
       
    32 #define PHONE_QT_NOTE_CONTROLLER_TEST_MAIN(TestObject) \
       
    33 int main(int argc, char *argv[]) \
       
    34 { \
       
    35     HbApplication app(argc, argv); \
       
    36     TestObject tc; \
       
    37     QResource::registerResource("../hbcore.rcc"); \
       
    38     int ret = QTest::qExec(&tc, argc, argv); \
       
    39     /* Core dump if HbIconLoader instance is not destroyed before the application instance. */ \
       
    40     /* HbIconLoader uses QCoreApplication::aboutToQuit() signal to destroy itself. */ \
       
    41     /* app.exec() where the signal is normally emitted is not called here. */ \
       
    42     /* So, invoking the signal explicitly. */ \
       
    43     QMetaObject::invokeMethod(&app, "aboutToQuit", Qt::DirectConnection); \
       
    44     return ret; \
       
    45 }
       
    46 
       
    47 class TestTelephonyService : public QObject,  public PhoneUIQtViewIF
       
    48 {
       
    49     Q_OBJECT
       
    50 public:
       
    51     TestTelephonyService();
       
    52     virtual ~TestTelephonyService();
       
    53     
       
    54 public: // PhoneUIQtViewIF
       
    55     
       
    56         BubbleManagerIF& bubbleManager (){};
       
    57         void addBubbleCommand ( 
       
    58                 int bubbleId,
       
    59                 const PhoneAction& action ){};
       
    60         void clearBubbleCommands (int bubbleId){};
       
    61         void addParticipantListAction(
       
    62                 int commandId,  
       
    63                 const QString &text, 
       
    64                 const HbIcon &icon){};
       
    65         void clearParticipantListActions(){};
       
    66         void hideToolbar () {};
       
    67         void showToolbar () {};
       
    68         void setToolbarActions (const QList<PhoneAction*>& actions){};
       
    69         int volumeSliderValue () {};
       
    70         void removeVolumeSlider () {};
       
    71         void setVolumeSliderValue (
       
    72                 int value, 
       
    73                 int commandId, 
       
    74                 int maxVolumeValue, 
       
    75                 int minVolumeValue ) { };
       
    76 
       
    77         void setExpandAction(int bubbleId, int commandId) {};
       
    78         void removeExpandAction(int bubbleId) {};
       
    79         void showDialpad() {};
       
    80         void hideDialpad() {};
       
    81         bool isDialpadVisible() {};
       
    82         QString dialpadText() {return QString("1234567");};
       
    83         void clearAndHideDialpad(){};
       
    84         void bringToForeground() {;};
       
    85         void setMenuActions(const QList<PhoneAction*>& actions){;};
       
    86         void shutdownPhoneApp() {;};
       
    87         void setBackButtonVisible(bool visible) {;};        
       
    88         HbMenu &menuReference() { return mMenu; };
       
    89         
       
    90 public slots:
       
    91     void initTestCase ();
       
    92     void cleanupTestCase ();
       
    93     void init ();
       
    94     void cleanup (); 
       
    95     
       
    96 private slots:
       
    97     void testConstructionDestruction ();
       
    98     void startPhoneApp ();
       
    99     void startInCallDialer ();
       
   100     
       
   101 private:
       
   102     TelephonyService *m_service; // class under test
       
   103     PhoneUIQtViewAdapter *m_viewstub; // stub test
       
   104     HbMenu mMenu;
       
   105 };
       
   106 
       
   107 TestTelephonyService::TestTelephonyService ()
       
   108 {
       
   109 }
       
   110 
       
   111 TestTelephonyService::~TestTelephonyService ()
       
   112 {
       
   113 }
       
   114 
       
   115 void TestTelephonyService::initTestCase ()
       
   116 {
       
   117     m_viewstub = new PhoneUIQtViewAdapter (*this);
       
   118     m_service = new TelephonyService(m_viewstub, this);
       
   119 }
       
   120 
       
   121 void TestTelephonyService::cleanupTestCase ()
       
   122 {
       
   123     if (m_viewstub) {
       
   124     delete m_viewstub;
       
   125     }
       
   126     
       
   127     if (m_service) {
       
   128     delete m_service;
       
   129     }
       
   130 }
       
   131 
       
   132 void TestTelephonyService::init ()
       
   133 {
       
   134 }
       
   135 
       
   136 void TestTelephonyService::cleanup ()
       
   137 {
       
   138 }
       
   139 
       
   140 void TestTelephonyService::testConstructionDestruction ()
       
   141 {
       
   142 // empty
       
   143 }
       
   144 
       
   145 void TestTelephonyService::startPhoneApp ()
       
   146 {
       
   147     phoneAppStart = false;
       
   148     inCallDialerStart = false;
       
   149     int phoneApp(0);
       
   150     m_service->start(phoneApp);
       
   151     QVERIFY (phoneAppStart == true);
       
   152     QVERIFY (inCallDialerStart == false);
       
   153 }
       
   154 
       
   155 void TestTelephonyService::startInCallDialer ()
       
   156 {
       
   157     phoneAppStart = false;
       
   158     inCallDialerStart = false;
       
   159     int dialer(1);
       
   160     m_service->start(dialer);
       
   161     QVERIFY (phoneAppStart == true);
       
   162     QVERIFY (inCallDialerStart == true);
       
   163 }
       
   164 
       
   165 PHONE_QT_NOTE_CONTROLLER_TEST_MAIN(TestTelephonyService)
       
   166 #include "unit_tests.moc"