phoneengine/phoneservices/tsrc/ut_phoneservices/unit_tests.cpp
changeset 30 ebdbd102c78a
parent 21 92ab7f8d0eab
child 51 f39ed5e045e0
equal deleted inserted replaced
27:2f8f8080a020 30:ebdbd102c78a
    19 
    19 
    20 //#include <hbglobal_p.h>
    20 //#include <hbglobal_p.h>
    21 #include "phoneservices.h"
    21 #include "phoneservices.h"
    22 #include "dialservice.h"
    22 #include "dialservice.h"
    23 #include "dtmfservice.h"
    23 #include "dtmfservice.h"
       
    24 #include "keysequencerecognitionservice.h"
       
    25 #include "mpekeysequencerecognitionif.h"
    24 
    26 
    25 bool m_dialServiceConstructed;
    27 bool m_dialServiceConstructed;
    26 bool m_dtmfServiceConstructed;
    28 bool m_dtmfServiceConstructed;
       
    29 bool g_keySequenceServiceConstructed;
    27 MPECallControlIF* m_dialServiceCallPointer;
    30 MPECallControlIF* m_dialServiceCallPointer;
    28 MPECallSettersIF* m_dialServiceParameterPointer;
    31 MPECallSettersIF* m_dialServiceParameterPointer;
       
    32 MPEKeySequenceRecognitionIF* g_keySequenceRecognizerParameterPointer;
    29 MPECallControlIF* m_dtmfServiceCallPointer;
    33 MPECallControlIF* m_dtmfServiceCallPointer;
    30 MPECallSettersIF* m_dtmfServiceParameterPointer;
    34 MPECallSettersIF* m_dtmfServiceParameterPointer;
    31 
    35 
    32 class TestPhoneServices : public QObject, public MPECallControlIF, public MPECallSettersIF
    36 class TestPhoneServices 
       
    37     : 
       
    38     public QObject,
       
    39     public MPECallControlIF,
       
    40     public MPECallSettersIF,
       
    41     public MPEKeySequenceRecognitionIF
    33 {
    42 {
    34     Q_OBJECT
    43     Q_OBJECT
    35 public:
    44 public:
    36     TestPhoneServices();
    45     TestPhoneServices();
    37     virtual ~TestPhoneServices();    
    46     virtual ~TestPhoneServices();    
    38 
    47 
       
    48 public:
       
    49     TBool ExecuteKeySequenceL(const TDesC16& aSequence);
       
    50     
    39 public slots:
    51 public slots:
    40     void initTestCase ();
    52     void initTestCase ();
    41     void cleanupTestCase ();
    53     void cleanupTestCase ();
    42     void init ();
    54     void init ();
    43     void cleanup ();
    55     void cleanup ();
    70     bool m_setKeyCodeCalled;
    82     bool m_setKeyCodeCalled;
    71     ushort keyValue;
    83     ushort keyValue;
    72 };
    84 };
    73 
    85 
    74 DialService::DialService(MPECallControlIF &call, MPECallSettersIF &parameters, QObject* parent) : 
    86 DialService::DialService(MPECallControlIF &call, MPECallSettersIF &parameters, QObject* parent) : 
    75     XQServiceProvider(QLatin1String("com.nokia.services.telephony"), parent), m_call (call), m_parameters (parameters)
    87     XQServiceProvider(QLatin1String("com.nokia.symbian.ICallDial"), parent), m_call (call), m_parameters (parameters)
    76 {
    88 {
    77     m_dialServiceConstructed = true;
    89     m_dialServiceConstructed = true;
    78     m_dialServiceCallPointer = &call;
    90     m_dialServiceCallPointer = &call;
    79     m_dialServiceParameterPointer = &parameters;
    91     m_dialServiceParameterPointer = &parameters;
    80 }
    92 }
   131 Q_UNUSED(serviceId);
   143 Q_UNUSED(serviceId);
   132 Q_UNUSED(contactId);
   144 Q_UNUSED(contactId);
   133 }
   145 }
   134 
   146 
   135 DTMFService::DTMFService(MPECallControlIF &call, MPECallSettersIF &parameters, QObject* parent) : 
   147 DTMFService::DTMFService(MPECallControlIF &call, MPECallSettersIF &parameters, QObject* parent) : 
   136     XQServiceProvider(QLatin1String("com.nokia.services.telephony.dtmf"), parent), m_call (call), m_parameters (parameters)
   148     XQServiceProvider(QLatin1String("com.nokia.symbian.IDtmfPlay"), parent), m_call (call), m_parameters (parameters)
   137 {
   149 {
   138     m_dtmfServiceConstructed = true;
   150     m_dtmfServiceConstructed = true;
   139     m_dtmfServiceCallPointer = &call;
   151     m_dtmfServiceCallPointer = &call;
   140     m_dtmfServiceParameterPointer = &parameters;
   152     m_dtmfServiceParameterPointer = &parameters;
   141 }
   153 }
   142 
   154 
   143 DTMFService::~DTMFService()
   155 DTMFService::~DTMFService()
   144 {
   156 {
   145 }
   157 }
   146 
   158 
   147 void DTMFService::executeKeySequence(const QString& keySequence)
   159 void DTMFService::playDTMFTone(const QChar& keyToPlay)
       
   160 {
       
   161     Q_UNUSED(keyToPlay);
       
   162 }
       
   163 
       
   164 void DTMFService::stopDTMFPlay()
       
   165 {
       
   166 }
       
   167 
       
   168 KeySequenceRecognitionService::KeySequenceRecognitionService(
       
   169     MPEKeySequenceRecognitionIF &keySequenceRecognizer,
       
   170     QObject* parent) 
       
   171     : 
       
   172     XQServiceProvider(
       
   173         QLatin1String("com.nokia.symbian.IDtmfPlay"), parent),
       
   174         m_keySequenceRecognizer(keySequenceRecognizer)
       
   175 {
       
   176     g_keySequenceServiceConstructed = true;
       
   177     g_keySequenceRecognizerParameterPointer = &keySequenceRecognizer;
       
   178 }
       
   179 
       
   180 bool KeySequenceRecognitionService::executeKeySequence(
       
   181     const QString &keySequence)
   148 {
   182 {
   149     Q_UNUSED(keySequence);
   183     Q_UNUSED(keySequence);
   150 }
   184     return true;
   151 
   185 }
   152 void DTMFService::playDTMFTone(const QChar& keyToPlay)
   186 
   153 {
   187 KeySequenceRecognitionService::~KeySequenceRecognitionService()
   154     Q_UNUSED(keyToPlay);
       
   155 }
       
   156 
       
   157 void DTMFService::stopDTMFPlay()
       
   158 {
   188 {
   159 }
   189 }
   160 
   190 
   161 TestPhoneServices::TestPhoneServices ()
   191 TestPhoneServices::TestPhoneServices ()
   162 {
   192 {
   186     m_handlePlayDTMFLCalled = false;
   216     m_handlePlayDTMFLCalled = false;
   187     m_setKeyCodeCalled = false;
   217     m_setKeyCodeCalled = false;
   188     keyValue = -1;
   218     keyValue = -1;
   189     m_dialServiceConstructed = false;
   219     m_dialServiceConstructed = false;
   190     m_dtmfServiceConstructed = false;
   220     m_dtmfServiceConstructed = false;
   191     
   221     g_keySequenceServiceConstructed = false;
   192     m_phoneServices = new PhoneServices (*this, *this, this);
   222     
       
   223     m_phoneServices = new PhoneServices (*this, *this, *this, this);
   193 
   224 
   194     QVERIFY(m_dialServiceConstructed == true);
   225     QVERIFY(m_dialServiceConstructed == true);
   195     QVERIFY(m_dialServiceCallPointer == this);
   226     QVERIFY(m_dialServiceCallPointer == this);
   196     QVERIFY(m_dialServiceParameterPointer == this);
   227     QVERIFY(m_dialServiceParameterPointer == this);
   197     
   228     
   198     QVERIFY(m_dtmfServiceConstructed == true);
   229     QVERIFY(m_dtmfServiceConstructed == true);
   199     QVERIFY(m_dtmfServiceCallPointer == this);
   230     QVERIFY(m_dtmfServiceCallPointer == this);
   200     QVERIFY(m_dtmfServiceParameterPointer == this);
   231     QVERIFY(m_dtmfServiceParameterPointer == this);
       
   232     
       
   233     QVERIFY(g_keySequenceServiceConstructed == true);
       
   234     QVERIFY(g_keySequenceRecognizerParameterPointer == this);
   201 }
   235 }
   202 
   236 
   203 void TestPhoneServices::cleanup ()
   237 void TestPhoneServices::cleanup ()
   204 {
   238 {
   205     delete m_phoneServices;
   239     delete m_phoneServices;
       
   240 }
       
   241 
       
   242 TBool TestPhoneServices::ExecuteKeySequenceL(const TDesC16& aSequence)
       
   243 {
       
   244     Q_UNUSED(aSequence)
       
   245     return ETrue;
   206 }
   246 }
   207 
   247 
   208 void TestPhoneServices::SetKeyCode( const TChar& aKeyCode )
   248 void TestPhoneServices::SetKeyCode( const TChar& aKeyCode )
   209 {
   249 {
   210     m_setKeyCodeCalled = true;
   250     m_setKeyCodeCalled = true;
   240     m_contactId = aContactId;	
   280     m_contactId = aContactId;	
   241 }
   281 }
   242 
   282 
   243 void TestPhoneServices::SetServiceIdCommand( TUint32 aServiceId )
   283 void TestPhoneServices::SetServiceIdCommand( TUint32 aServiceId )
   244 {
   284 {
   245 	
   285     Q_UNUSED(aServiceId)
   246 }
   286 }
   247 
   287 
   248 TInt TestPhoneServices::HandleDialServiceCall( const TBool aClientCall )
   288 TInt TestPhoneServices::HandleDialServiceCall( const TBool aClientCall )
   249 {
   289 {
   250     m_handleDialCallCalled = true;
   290     m_handleDialCallCalled = true;