telutils/dialpad/tsrc/unit/ut_dialpadbluetootheventfilter/ut_dialpadbluetootheventfilter.cpp
changeset 51 12bc758d6a02
parent 31 a2467631ae02
child 53 25b8d29b7c59
equal deleted inserted replaced
48:78df25012fda 51:12bc758d6a02
    23 #include <hbaction.h>
    23 #include <hbaction.h>
    24 #include <hbtoolbar.h>
    24 #include <hbtoolbar.h>
    25 #include <hbview.h>
    25 #include <hbview.h>
    26 #include <hblineedit.h>
    26 #include <hblineedit.h>
    27 #include <hbinstance.h>
    27 #include <hbinstance.h>
       
    28 #include <btxqserviceapi.h>
    28 
    29 
    29 #ifdef Q_OS_SYMBIAN
    30 #ifdef Q_OS_SYMBIAN
    30 #include "xqservicerequest.h"
    31 #include "xqappmgr.h"
    31 #endif
    32 #endif
    32 
    33 
    33 #include "dialpadtest.h"
    34 #include "dialpadtest.h"
    34 #include "dialpadtestutil.h"
    35 #include "dialpadtestutil.h"
    35 #include "dialpadbluetootheventfilter.h"
    36 #include "dialpadbluetootheventfilter.h"
    36 #include "dialpad.h"
    37 #include "dialpad.h"
    37 
    38 
    38 const int WAIT_TIME = 300;
    39 const int WAIT_TIME = 300;
    39 QString mService;
    40 QString mService;
    40 QString mMessage;
    41 QString mInterface;
    41 bool mXQServiceConstructed;
    42 QString mOperation;
       
    43 bool mEmbedded;
    42 bool mSendCalled;
    44 bool mSendCalled;
    43 
    45 
    44 #ifdef Q_OS_SYMBIAN
    46 #ifdef Q_OS_SYMBIAN
    45 XQServiceRequest::XQServiceRequest(const QString& service, const QString& message, const bool& synchronous) { mService=service; mMessage=message; mXQServiceConstructed=true; }
    47 XQAiwRequest* XQApplicationManager::create(const QString& service, const QString& interface, const QString& operation, bool embedded)
    46 XQServiceRequest::~XQServiceRequest() {}
    48 {
    47 bool XQServiceRequest::send(QVariant& retValue) { mSendCalled=true; return true; }
    49     mService = service;
    48 void XQServiceRequest::addArg(const QVariant& v) {}
    50     mInterface = interface;
       
    51     mOperation = operation;
       
    52     mEmbedded = embedded;
       
    53     return new XQAiwRequest(); 
       
    54 }
       
    55 void XQAiwRequest::send() { mSendCalled = true; }
    49 #endif
    56 #endif
    50 
    57 
    51 // helper class
    58 // helper class
    52 class KeyEventCatcher : public QObject
    59 class KeyEventCatcher : public QObject
    53 {
    60 {
   120 }
   127 }
   121 
   128 
   122 void ut_DialpadBluetoothEventFilter::init()
   129 void ut_DialpadBluetoothEventFilter::init()
   123 {
   130 {
   124     mService = QString("");
   131     mService = QString("");
   125     mMessage = QString("");
   132     mInterface = QString("");
   126     mXQServiceConstructed = false;
   133     mOperation = QString("");
       
   134     mEmbedded = false;
   127     mSendCalled = false;
   135     mSendCalled = false;
   128 }
   136 }
   129 
   137 
   130 void ut_DialpadBluetoothEventFilter::cleanupTestCase()
   138 void ut_DialpadBluetoothEventFilter::cleanupTestCase()
   131 {
   139 {
   154     mUtil->mouseClickDialpad(Qt::Key_Asterisk, DialpadTestUtil::Release);
   162     mUtil->mouseClickDialpad(Qt::Key_Asterisk, DialpadTestUtil::Release);
   155     QTest::qWait(1000);
   163     QTest::qWait(1000);
   156     QCOMPARE(mDialpad->editor().text(), QString(""));
   164     QCOMPARE(mDialpad->editor().text(), QString(""));
   157     mDialpad->closeDialpad();
   165     mDialpad->closeDialpad();
   158     
   166     
   159     QVERIFY(mXQServiceConstructed == true);
   167     QCOMPARE(mService, BluetoothServiceName);
   160     QCOMPARE(mService, QString("com.nokia.services.btservices.ToggleBluetooth"));
   168     QCOMPARE(mInterface, BluetoothInterfaceTogglePower);
   161     QCOMPARE(mMessage, QString("toggleBluetooth()"));
   169     QCOMPARE(mOperation, BluetoothTogglePower);
       
   170     QVERIFY(mEmbedded == false);
   162     QVERIFY(mSendCalled == true);
   171     QVERIFY(mSendCalled == true);
   163 }
   172 }
   164 
   173 
   165 void ut_DialpadBluetoothEventFilter::testShortAndLongPressAsteriskKey()
   174 void ut_DialpadBluetoothEventFilter::testShortAndLongPressAsteriskKey()
   166 {
   175 {