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 #include <QtGui> |
|
19 #include <QtTest/QtTest> |
|
20 #include <HbMainWindow> |
|
21 #ifdef Q_OS_SYMBIAN |
|
22 #include <featmgr.h> |
|
23 #endif // Q_OS_SYMBIAN |
|
24 |
|
25 #include <smcmockclassincludes.h> |
|
26 #include "ut_dialpadkeyhandler.h" |
|
27 #include "dialpad.h" |
|
28 #include "dialpadkeyhandler.h" |
|
29 #include "dialpadtest.h" |
|
30 |
|
31 HbMainWindow *HbWidget::mainWindow() const |
|
32 { |
|
33 return 0; |
|
34 } |
|
35 |
|
36 |
|
37 void QObject::installEventFilter(QObject *obj) |
|
38 { |
|
39 SMC_MOCK_METHOD1( void, QObject *, obj ) |
|
40 } |
|
41 |
|
42 void QObject::removeEventFilter(QObject *obj) |
|
43 { |
|
44 SMC_MOCK_METHOD1( void, QObject *, obj ) |
|
45 } |
|
46 |
|
47 UT_DialpadKeyHandler::UT_DialpadKeyHandler() |
|
48 : |
|
49 m_dialPad(0), |
|
50 m_keyHandler(0) |
|
51 { |
|
52 |
|
53 } |
|
54 |
|
55 |
|
56 UT_DialpadKeyHandler::~UT_DialpadKeyHandler() |
|
57 { |
|
58 delete m_dialPad; |
|
59 delete m_keyHandler; |
|
60 } |
|
61 |
|
62 |
|
63 void UT_DialpadKeyHandler::init() |
|
64 { |
|
65 initialize(); |
|
66 |
|
67 HbMainWindow *dummyWindow = 0; |
|
68 m_dialPad = new Dialpad(*dummyWindow); |
|
69 } |
|
70 |
|
71 |
|
72 void UT_DialpadKeyHandler::cleanup() |
|
73 { |
|
74 reset(); |
|
75 |
|
76 delete m_dialPad; |
|
77 m_dialPad = NULL; |
|
78 delete m_keyHandler; |
|
79 m_keyHandler = NULL; |
|
80 } |
|
81 |
|
82 |
|
83 void UT_DialpadKeyHandler::t_constructionWithAllFilters() |
|
84 { |
|
85 EXPECT(QObject, installEventFilter).times(5); |
|
86 EXPECT(QObject, removeEventFilter).times(5); |
|
87 |
|
88 DialpadKeyHandler::DialpadKeyEventFilters filters( |
|
89 DialpadKeyHandler::VoiceMailbox | |
|
90 DialpadKeyHandler::VideoMailBox | |
|
91 DialpadKeyHandler::Bluetooth | |
|
92 DialpadKeyHandler::KeySequence | |
|
93 DialpadKeyHandler::EmergencyCall | |
|
94 DialpadKeyHandler::Hash ); |
|
95 |
|
96 m_keyHandler = new DialpadKeyHandler(m_dialPad, filters, this); |
|
97 delete m_keyHandler; |
|
98 m_keyHandler = 0; |
|
99 |
|
100 QVERIFY(verify()); |
|
101 } |
|
102 |
|
103 |
|
104 void UT_DialpadKeyHandler::t_constructionWithNoFilters() |
|
105 { |
|
106 EXPECT(QObject, installEventFilter).times(0); |
|
107 |
|
108 DialpadKeyHandler::DialpadKeyEventFilters filters; |
|
109 m_keyHandler = new DialpadKeyHandler(m_dialPad, filters, this); |
|
110 |
|
111 QVERIFY(verify()); |
|
112 } |
|
113 |
|
114 |
|
115 void UT_DialpadKeyHandler::t_deprecatedConstructionWithVideoMailbox() |
|
116 { |
|
117 #ifdef Q_OS_SYMBIAN |
|
118 EXPECT(FeatureManager, FeatureSupported).returns(true); |
|
119 EXPECT(QObject, installEventFilter).times(4); |
|
120 |
|
121 HbMainWindow *dummyWindow = 0; |
|
122 m_keyHandler = new DialpadKeyHandler(m_dialPad, *dummyWindow, this); |
|
123 |
|
124 QVERIFY(verify()); |
|
125 #endif // Q_OS_SYMBIAN |
|
126 } |
|
127 |
|
128 |
|
129 void UT_DialpadKeyHandler::t_deprecatedConstructionWithoutVideoMailbox() |
|
130 { |
|
131 EXPECT(FeatureManager, FeatureSupported).returns(false); |
|
132 EXPECT(QObject, installEventFilter).times(3); |
|
133 |
|
134 HbMainWindow *dummyWindow = 0; |
|
135 m_keyHandler = new DialpadKeyHandler(m_dialPad, *dummyWindow, this); |
|
136 |
|
137 QVERIFY(verify()); |
|
138 } |
|
139 |
|
140 |
|
141 int main(int argc, char *argv[]) |
|
142 { |
|
143 QCoreApplication app(argc, argv); |
|
144 UT_DialpadKeyHandler tc; |
|
145 return QTest::qExec(&tc, argc, argv); |
|
146 } |
|