phoneengine/phoneservices/tsrc/ut_phoneservices/unit_tests.cpp
changeset 46 bc5a64e5bc3c
parent 45 6b911d05207e
child 51 f39ed5e045e0
child 60 1eef62f5c541
equal deleted inserted replaced
45:6b911d05207e 46:bc5a64e5bc3c
    14 * Description:  Unit tests for Phone Services.
    14 * Description:  Unit tests for Phone Services.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include <QtTest/QtTest>
    18 #include <QtTest/QtTest>
    19 
       
    20 //#include <hbglobal_p.h>
       
    21 #include "phoneservices.h"
    19 #include "phoneservices.h"
    22 #include "dialservice.h"
    20 #include "dialservice.h"
    23 #include "dtmfservice.h"
    21 #include "dtmfservice.h"
    24 
    22 #include "urischemehandlerservice.h"
    25 bool m_dialServiceConstructed;
    23 
    26 bool m_dtmfServiceConstructed;
    24 bool g_dialServiceConstructed;
    27 MPECallControlIF* m_dialServiceCallPointer;
    25 MPECallControlIF* g_dialServiceCallPointer;
    28 MPECallSettersIF* m_dialServiceParameterPointer;
    26 MPECallSettersIF* g_dialServiceParameterPointer;
    29 MPECallControlIF* m_dtmfServiceCallPointer;
    27 
    30 MPECallSettersIF* m_dtmfServiceParameterPointer;
    28 bool g_dtmfServiceConstructed;
       
    29 MPECallControlIF* g_dtmfServiceCallPointer;
       
    30 MPECallSettersIF* g_dtmfServiceParameterPointer;
       
    31 
       
    32 bool g_uriSchemeHandlerServiceConstructed;
       
    33 MPECallControlIF* g_uriSchemeServiceCallPointer;
       
    34 MPECallSettersIF* g_uriSchemeServiceParameterPointer;
    31 
    35 
    32 class TestPhoneServices 
    36 class TestPhoneServices 
    33     : 
    37     : 
    34     public QObject,
    38     public QObject,
    35     public MPECallControlIF,
    39     public MPECallControlIF,
    76 };
    80 };
    77 
    81 
    78 DialService::DialService(MPECallControlIF &call, MPECallSettersIF &parameters, QObject* parent) : 
    82 DialService::DialService(MPECallControlIF &call, MPECallSettersIF &parameters, QObject* parent) : 
    79     XQServiceProvider(QLatin1String("com.nokia.symbian.ICallDial"), parent), m_call (call), m_parameters (parameters)
    83     XQServiceProvider(QLatin1String("com.nokia.symbian.ICallDial"), parent), m_call (call), m_parameters (parameters)
    80 {
    84 {
    81     m_dialServiceConstructed = true;
    85     g_dialServiceConstructed = true;
    82     m_dialServiceCallPointer = &call;
    86     g_dialServiceCallPointer = &call;
    83     m_dialServiceParameterPointer = &parameters;
    87     g_dialServiceParameterPointer = &parameters;
    84 }
    88 }
    85 
    89 
    86 DialService::~DialService()
    90 DialService::~DialService()
    87 {
    91 {
    88 }
    92 }
    89 
    93 
    90 int DialService::dial(const QString& number)
    94 int DialService::dial(const QString& number)
    91 {
    95 {
    92     Q_UNUSED(number);
    96     Q_UNUSED(number)
    93     return 0;
    97     return 0;
    94 }
    98 }
    95 
    99 
    96 int DialService::dial(const QString& number, int contactId)
   100 int DialService::dial(const QString& number, int contactId)
    97 {
   101 {
    98     Q_UNUSED(number);
   102     Q_UNUSED(number)
    99     Q_UNUSED (contactId);
   103     Q_UNUSED (contactId)
   100     return 0;
   104     return 0;
   101 }
   105 }
   102 
   106 
   103 void DialService::dialVideo(const QString& number)
   107 void DialService::dialVideo(const QString& number)
   104 {
   108 {
   105     Q_UNUSED(number);
   109     Q_UNUSED(number)
   106 }
   110 }
   107 
   111 
   108 void DialService::dialVideo(const QString& number, int contactId)
   112 void DialService::dialVideo(const QString& number, int contactId)
   109 {
   113 {
   110     Q_UNUSED(number);
   114     Q_UNUSED(number)
   111     Q_UNUSED(contactId);
   115     Q_UNUSED(contactId)
   112 }
   116 }
   113 
   117 
   114 void DialService::dialVoip(const QString& address)
   118 void DialService::dialVoip(const QString& address)
   115 {
   119 {
   116 Q_UNUSED(address);
   120     Q_UNUSED(address)
   117 }
   121 }
   118 
   122 
   119 void DialService::dialVoip(const QString& address, int contactId)
   123 void DialService::dialVoip(const QString& address, int contactId)
   120 {
   124 {
   121 Q_UNUSED(address);
   125     Q_UNUSED(address)
   122 Q_UNUSED(contactId);
   126     Q_UNUSED(contactId)
   123 }
   127 }
   124 
   128 
   125 void DialService::dialVoipService(const QString& address, int serviceId)
   129 void DialService::dialVoipService(const QString& address, int serviceId)
   126 {
   130 {
   127 Q_UNUSED(address);
   131     Q_UNUSED(address)
   128 Q_UNUSED(serviceId);
   132     Q_UNUSED(serviceId)
   129 }
   133 }
   130 
   134 
   131 void DialService::dialVoipService(
   135 void DialService::dialVoipService(
   132         const QString& address, int serviceId, int contactId)
   136         const QString& address, int serviceId, int contactId)
   133 {
   137 {
   134 Q_UNUSED(address);
   138     Q_UNUSED(address)
   135 Q_UNUSED(serviceId);
   139     Q_UNUSED(serviceId)
   136 Q_UNUSED(contactId);
   140     Q_UNUSED(contactId)
   137 }
   141 }
   138 
   142 
   139 DTMFService::DTMFService(MPECallControlIF &call, MPECallSettersIF &parameters, QObject* parent) : 
   143 DTMFService::DTMFService(MPECallControlIF &call, MPECallSettersIF &parameters, QObject* parent) : 
   140     XQServiceProvider(QLatin1String("com.nokia.symbian.IDtmfPlay"), parent), m_call (call), m_parameters (parameters)
   144     XQServiceProvider(QLatin1String("com.nokia.symbian.IDtmfPlay"), parent), m_call (call), m_parameters (parameters)
   141 {
   145 {
   142     m_dtmfServiceConstructed = true;
   146     g_dtmfServiceConstructed = true;
   143     m_dtmfServiceCallPointer = &call;
   147     g_dtmfServiceCallPointer = &call;
   144     m_dtmfServiceParameterPointer = &parameters;
   148     g_dtmfServiceParameterPointer = &parameters;
   145 }
   149 }
   146 
   150 
   147 DTMFService::~DTMFService()
   151 DTMFService::~DTMFService()
   148 {
   152 {
   149 }
   153 }
   150 
   154 
   151 void DTMFService::playDTMFTone(const QChar& keyToPlay)
   155 void DTMFService::playDTMFTone(const QChar& keyToPlay)
   152 {
   156 {
   153     Q_UNUSED(keyToPlay);
   157     Q_UNUSED(keyToPlay)
   154 }
   158 }
   155 
   159 
   156 void DTMFService::stopDTMFPlay()
   160 void DTMFService::stopDTMFPlay()
   157 {
   161 {
       
   162 }
       
   163 
       
   164 UriSchemeHandlerService::UriSchemeHandlerService(
       
   165     MPECallControlIF &call, MPECallSettersIF &parameters, QObject* parent)
       
   166     : 
       
   167     XQServiceProvider(
       
   168         QLatin1String("phoneui.com.nokia.symbian.IUriView"), parent),
       
   169     m_callControlIf(call),
       
   170     m_callParameters(parameters)
       
   171 {
       
   172     g_uriSchemeHandlerServiceConstructed = true;
       
   173     g_uriSchemeServiceCallPointer = &call;
       
   174     g_uriSchemeServiceParameterPointer = &parameters;
       
   175 }
       
   176 
       
   177 UriSchemeHandlerService::~UriSchemeHandlerService()
       
   178 {
       
   179     
       
   180 }
       
   181 
       
   182 bool UriSchemeHandlerService::view(const QString &uri)
       
   183 {
       
   184     Q_UNUSED(uri)
       
   185     return true;
   158 }
   186 }
   159 
   187 
   160 TestPhoneServices::TestPhoneServices ()
   188 TestPhoneServices::TestPhoneServices ()
   161 {
   189 {
   162 }
   190 }
   183     m_contactId = -1;
   211     m_contactId = -1;
   184     m_handleEndDTMFCalled = false;
   212     m_handleEndDTMFCalled = false;
   185     m_handlePlayDTMFLCalled = false;
   213     m_handlePlayDTMFLCalled = false;
   186     m_setKeyCodeCalled = false;
   214     m_setKeyCodeCalled = false;
   187     keyValue = -1;
   215     keyValue = -1;
   188     m_dialServiceConstructed = false;
   216     g_dialServiceConstructed = false;
   189     m_dtmfServiceConstructed = false;
   217     g_dtmfServiceConstructed = false;
       
   218     
       
   219     g_uriSchemeHandlerServiceConstructed = false;
       
   220     g_uriSchemeServiceCallPointer = NULL;
       
   221     g_uriSchemeServiceParameterPointer = NULL;
   190     
   222     
   191     m_phoneServices = new PhoneServices(*this, *this, this);
   223     m_phoneServices = new PhoneServices(*this, *this, this);
   192 
   224 
   193     QVERIFY(m_dialServiceConstructed == true);
   225     QVERIFY(g_dialServiceConstructed == true);
   194     QVERIFY(m_dialServiceCallPointer == this);
   226     QVERIFY(g_dialServiceCallPointer == this);
   195     QVERIFY(m_dialServiceParameterPointer == this);
   227     QVERIFY(g_dialServiceParameterPointer == this);
   196     
   228     
   197     QVERIFY(m_dtmfServiceConstructed == true);
   229     QVERIFY(g_dtmfServiceConstructed == true);
   198     QVERIFY(m_dtmfServiceCallPointer == this);
   230     QVERIFY(g_dtmfServiceCallPointer == this);
   199     QVERIFY(m_dtmfServiceParameterPointer == this);
   231     QVERIFY(g_dtmfServiceParameterPointer == this);
       
   232     
       
   233     QVERIFY(g_uriSchemeHandlerServiceConstructed == true);
       
   234     QVERIFY(g_uriSchemeServiceCallPointer == this);
       
   235     QVERIFY(g_uriSchemeServiceParameterPointer == this);
   200 }
   236 }
   201 
   237 
   202 void TestPhoneServices::cleanup ()
   238 void TestPhoneServices::cleanup ()
   203 {
   239 {
   204     delete m_phoneServices;
   240     delete m_phoneServices;