telutils/dialpad/tsrc/unit/ut_dialpadhasheventfilter/ut_dialpadhasheventfilter.h
branchRCL_3
changeset 20 987c9837762f
parent 19 7d48bed6ce0c
child 21 0a6dd2dc9970
equal deleted inserted replaced
19:7d48bed6ce0c 20:987c9837762f
     1 /*
       
     2 * Copyright (c) 2010 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:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef UT_DIALPADHASHEVENTFILTER_H
       
    19 #define UT_DIALPADHASHEVENTFILTER_H
       
    20 
       
    21 #include <QtTest/QtTest>
       
    22 #include <mockservice.h>
       
    23 
       
    24 class Dialpad;
       
    25 class DialpadHashEventFilter;
       
    26 class HbLineEdit;
       
    27 class QTimer;
       
    28 
       
    29 // helper class
       
    30 class KeyEventCatcher : public QObject
       
    31 {
       
    32 public:
       
    33     bool eventFilter(QObject* watched, QEvent * event)
       
    34     {
       
    35         Q_UNUSED(watched);
       
    36 
       
    37         if (event->type() == QEvent::KeyPress) {
       
    38             QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
       
    39             mKeyPresses.append(keyEvent->key());
       
    40             return false;
       
    41         } else if (event->type() == QEvent::KeyRelease) {
       
    42             QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
       
    43             mKeyReleases.append(keyEvent->key());
       
    44             return false;
       
    45         }
       
    46         return false;
       
    47     }
       
    48 
       
    49 public:
       
    50     QList<int> mKeyPresses;
       
    51     QList<int> mKeyReleases;
       
    52 };
       
    53 
       
    54 class UT_DialpadHashEventFilter : public QObject, public MockService
       
    55 {
       
    56     Q_OBJECT
       
    57 
       
    58 public:    
       
    59     
       
    60     UT_DialpadHashEventFilter();
       
    61     ~UT_DialpadHashEventFilter();
       
    62     
       
    63 private slots:
       
    64 
       
    65     void init();
       
    66     void cleanup();
       
    67     // void callEventFilter();
       
    68     
       
    69 #ifdef Q_OS_SYMBIAN
       
    70     // These are actual hash event filter unit tests
       
    71     void testeventFilter();
       
    72     void testhandleLongKeyPress();
       
    73     void testhandleCallButtonPress();
       
    74     void testhandleMailboxOperation();
       
    75 #endif
       
    76     
       
    77 private:
       
    78     Dialpad *m_dialPad;
       
    79     DialpadHashEventFilter *m_eventFilter;
       
    80     HbLineEdit *m_lineEditMock;
       
    81     QTimer *mLongPressTimer;
       
    82 };
       
    83 
       
    84 #endif  // UT_DIALPADHASHEVENTFILTER_H