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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QtGui> |
|
19 #include <QtTest/QtTest> |
|
20 |
|
21 #include <hbapplication.h> |
|
22 #include <hbmainwindow.h> |
|
23 #include <hblineedit.h> |
|
24 |
|
25 #include "dialpadmultitaphandler.h" |
|
26 #include "dialpadtest.h" |
|
27 |
|
28 |
|
29 class ut_DialpadMultitapHandler : public QObject |
|
30 { |
|
31 Q_OBJECT |
|
32 |
|
33 private slots: |
|
34 void initTestCase(); |
|
35 void cleanupTestCase(); |
|
36 void cleanup(); |
|
37 |
|
38 void testWatchedNotEditor(); |
|
39 void testNumericKeyPress(); |
|
40 void testNonNumericKeyPress(); |
|
41 void testAsterisk(); |
|
42 void testAsteriskMultitap(); |
|
43 |
|
44 private: |
|
45 QObject* mHandler; |
|
46 HbLineEdit* mEditor; |
|
47 }; |
|
48 |
|
49 void ut_DialpadMultitapHandler::initTestCase() |
|
50 { |
|
51 mEditor = new HbLineEdit; |
|
52 mHandler = new DialpadMultitapHandler(*mEditor); |
|
53 } |
|
54 |
|
55 void ut_DialpadMultitapHandler::cleanupTestCase() |
|
56 { |
|
57 delete mHandler; |
|
58 delete mEditor; |
|
59 } |
|
60 |
|
61 void ut_DialpadMultitapHandler::cleanup() |
|
62 { |
|
63 mEditor->setText(QString()); |
|
64 } |
|
65 |
|
66 void ut_DialpadMultitapHandler::testWatchedNotEditor() |
|
67 { |
|
68 QKeyEvent asteriskPress(QEvent::KeyPress, Qt::Key_Asterisk, Qt::NoModifier); |
|
69 QKeyEvent asteriskRelease(QEvent::KeyRelease, Qt::Key_Asterisk, Qt::NoModifier); |
|
70 HbLineEdit edit2; |
|
71 |
|
72 QVERIFY(mHandler->eventFilter(&edit2,&asteriskPress)==false); |
|
73 QVERIFY(mHandler->eventFilter(&edit2,&asteriskRelease)==false); |
|
74 } |
|
75 |
|
76 void ut_DialpadMultitapHandler::testNumericKeyPress() |
|
77 { |
|
78 QKeyEvent key1Press(QEvent::KeyPress, Qt::Key_1, Qt::NoModifier); |
|
79 QKeyEvent key1Char(QEvent::KeyPress, Qt::Key_1, Qt::NoModifier, "1"); |
|
80 QKeyEvent key1Release(QEvent::KeyRelease, Qt::Key_1, Qt::NoModifier); |
|
81 |
|
82 QVERIFY(mHandler->eventFilter(mEditor,&key1Press)==true); |
|
83 QVERIFY(mHandler->eventFilter(mEditor,&key1Char)==false); |
|
84 QVERIFY(mHandler->eventFilter(mEditor,&key1Release)==false); |
|
85 } |
|
86 |
|
87 void ut_DialpadMultitapHandler::testNonNumericKeyPress() |
|
88 { |
|
89 QKeyEvent keyYesPress(QEvent::KeyPress, Qt::Key_Yes, Qt::NoModifier); |
|
90 QKeyEvent keyYesRelease(QEvent::KeyRelease, Qt::Key_Yes, Qt::NoModifier); |
|
91 |
|
92 QVERIFY(mHandler->eventFilter(mEditor,&keyYesPress)==false); |
|
93 QVERIFY(mHandler->eventFilter(mEditor,&keyYesRelease)==false); |
|
94 |
|
95 QKeyEvent keyBackspacePress(QEvent::KeyPress, Qt::Key_Backspace, Qt::NoModifier); |
|
96 QKeyEvent keyBackspaceRelease(QEvent::KeyRelease, Qt::Key_Backspace, Qt::NoModifier); |
|
97 |
|
98 QVERIFY(mHandler->eventFilter(mEditor,&keyBackspacePress)==false); |
|
99 QVERIFY(mHandler->eventFilter(mEditor,&keyBackspaceRelease)==false); |
|
100 } |
|
101 |
|
102 void ut_DialpadMultitapHandler::testAsterisk() |
|
103 { |
|
104 QKeyEvent asteriskPress(QEvent::KeyPress, Qt::Key_Asterisk, Qt::NoModifier); |
|
105 QKeyEvent asteriskChar(QEvent::KeyPress, Qt::Key_Asterisk, Qt::NoModifier, "*"); |
|
106 QKeyEvent asteriskRelease(QEvent::KeyRelease, Qt::Key_Asterisk, Qt::NoModifier); |
|
107 |
|
108 QVERIFY(mHandler->eventFilter(mEditor,&asteriskPress)==true); |
|
109 QVERIFY(mHandler->eventFilter(mEditor,&asteriskChar)==false); |
|
110 QTest::qWait( 1000 ); |
|
111 QVERIFY(mHandler->eventFilter(mEditor,&asteriskRelease)==false); |
|
112 } |
|
113 |
|
114 void ut_DialpadMultitapHandler::testAsteriskMultitap() |
|
115 { |
|
116 QKeyEvent asteriskPress(QEvent::KeyPress, Qt::Key_Asterisk, Qt::NoModifier); |
|
117 QKeyEvent asteriskChar(QEvent::KeyPress, Qt::Key_Asterisk, Qt::NoModifier, "*"); |
|
118 QKeyEvent asteriskRelease(QEvent::KeyRelease, Qt::Key_Asterisk, Qt::NoModifier); |
|
119 |
|
120 QVERIFY(mHandler->eventFilter(mEditor,&asteriskPress)==true); |
|
121 QVERIFY(mHandler->eventFilter(mEditor,&asteriskChar)==false); |
|
122 QTest::qWait( 100 ); |
|
123 QVERIFY(mHandler->eventFilter(mEditor,&asteriskChar)==true); // + |
|
124 QTest::qWait( 100 ); |
|
125 QVERIFY(mHandler->eventFilter(mEditor,&asteriskChar)==true); // p |
|
126 QTest::qWait( 100 ); |
|
127 QVERIFY(mHandler->eventFilter(mEditor,&asteriskChar)==true); // w |
|
128 QTest::qWait( 100 ); |
|
129 QVERIFY(mHandler->eventFilter(mEditor,&asteriskChar)==true); // * |
|
130 QVERIFY(mHandler->eventFilter(mEditor,&asteriskRelease)==false); |
|
131 } |
|
132 |
|
133 DIALPAD_TEST_MAIN(ut_DialpadMultitapHandler) |
|
134 #include "ut_dialpadmultitaphandler.moc" |
|
135 |
|