85 |
91 |
86 void UT_LogsMainWindow::testEventFilter() |
92 void UT_LogsMainWindow::testEventFilter() |
87 { |
93 { |
88 QSignalSpy spy( mMainWindow, SIGNAL(localeChanged()) ); |
94 QSignalSpy spy( mMainWindow, SIGNAL(localeChanged()) ); |
89 QSignalSpy foregroundSpy( mMainWindow, SIGNAL(appGainedForeground()) ); |
95 QSignalSpy foregroundSpy( mMainWindow, SIGNAL(appGainedForeground()) ); |
|
96 QVERIFY( !mMainWindow->mKeyCapture->mKeys.contains(Qt::Key_Yes) ); |
90 |
97 |
91 //Event we are not interested in |
98 //Event we are not interested in |
92 QEvent event(QEvent::Show); |
99 QEvent event(QEvent::Show); |
93 QVERIFY( !mMainWindow->eventFilter(this, &event) ); |
100 QVERIFY( !mMainWindow->eventFilter(this, &event) ); |
94 QVERIFY( !mMainWindow->isForeground() ); |
101 QVERIFY( !mMainWindow->isForeground() ); |
95 QVERIFY( !mMainWindow->mLocaleChanged ); |
102 QVERIFY( !mMainWindow->mLocaleChanged ); |
96 QCOMPARE( foregroundSpy.count(), 0 ); |
103 QCOMPARE( foregroundSpy.count(), 0 ); |
|
104 QVERIFY( !mMainWindow->mKeyCapture->mKeys.contains(Qt::Key_Yes) ); |
97 |
105 |
98 //Coming foreground, locale not changed |
106 //Coming foreground, locale not changed |
99 QEvent eventFg(QEvent::ApplicationActivate); |
107 QEvent eventFg(QEvent::ApplicationActivate); |
100 QVERIFY( !mMainWindow->eventFilter(this, &eventFg) ); |
108 QVERIFY( !mMainWindow->eventFilter(this, &eventFg) ); |
101 QVERIFY( mMainWindow->isForeground() ); |
109 QVERIFY( mMainWindow->isForeground() ); |
102 QVERIFY( !mMainWindow->mLocaleChanged ); |
110 QVERIFY( !mMainWindow->mLocaleChanged ); |
103 QCOMPARE( foregroundSpy.count(), 1 ); |
111 QCOMPARE( foregroundSpy.count(), 1 ); |
|
112 QVERIFY( mMainWindow->mKeyCapture->mKeys.contains(Qt::Key_Yes) ); |
104 foregroundSpy.clear(); |
113 foregroundSpy.clear(); |
105 |
114 |
106 //LocaleChange event on FG |
115 //LocaleChange event on FG |
107 QEvent eventLocale(QEvent::LocaleChange); |
116 QEvent eventLocale(QEvent::LocaleChange); |
108 QVERIFY( !mMainWindow->eventFilter(this, &eventLocale) ); |
117 QVERIFY( !mMainWindow->eventFilter(this, &eventLocale) ); |
109 QVERIFY( mMainWindow->isForeground() ); |
118 QVERIFY( mMainWindow->isForeground() ); |
110 QVERIFY( !mMainWindow->mLocaleChanged ); |
119 QVERIFY( !mMainWindow->mLocaleChanged ); |
111 QVERIFY( spy.count() == 1 ); |
120 QVERIFY( spy.count() == 1 ); |
|
121 QVERIFY( mMainWindow->mKeyCapture->mKeys.contains(Qt::Key_Yes) ); |
112 QCOMPARE( foregroundSpy.count(), 0 ); |
122 QCOMPARE( foregroundSpy.count(), 0 ); |
113 spy.clear(); |
123 spy.clear(); |
114 |
124 |
115 //Going background |
125 //Going background partially, surface check is not reliable at the moment so |
|
126 // don't care about that, just handle as full foreground loosing |
|
127 HbStubHelper::createWindowSurface(); |
116 QEvent eventBg(QEvent::ApplicationDeactivate); |
128 QEvent eventBg(QEvent::ApplicationDeactivate); |
117 QVERIFY( !mMainWindow->eventFilter(this, &eventBg) ); |
129 QVERIFY( !mMainWindow->eventFilter(this, &eventBg) ); |
118 QVERIFY( !mMainWindow->isForeground() ); |
130 QVERIFY( !mMainWindow->isForeground() ); |
119 QVERIFY( !mMainWindow->mLocaleChanged ); |
131 QVERIFY( !mMainWindow->mLocaleChanged ); |
|
132 QVERIFY( !mMainWindow->mKeyCapture->mKeys.contains(Qt::Key_Yes) ); |
120 QCOMPARE( foregroundSpy.count(), 0 ); |
133 QCOMPARE( foregroundSpy.count(), 0 ); |
121 |
134 |
|
135 //Going background fully |
|
136 HbStubHelper::reset(); |
|
137 QVERIFY( !mMainWindow->eventFilter(this, &eventBg) ); |
|
138 QVERIFY( !mMainWindow->isForeground() ); |
|
139 QVERIFY( !mMainWindow->mLocaleChanged ); |
|
140 QVERIFY( !mMainWindow->mKeyCapture->mKeys.contains(Qt::Key_Yes) ); |
|
141 QCOMPARE( foregroundSpy.count(), 0 ); |
|
142 |
122 //LocaleChange event on BG |
143 //LocaleChange event on BG |
123 QVERIFY( !mMainWindow->eventFilter(this, &eventLocale) ); |
144 QVERIFY( !mMainWindow->eventFilter(this, &eventLocale) ); |
124 QVERIFY( !mMainWindow->isForeground() ); |
145 QVERIFY( !mMainWindow->isForeground() ); |
125 QVERIFY( mMainWindow->mLocaleChanged ); |
146 QVERIFY( mMainWindow->mLocaleChanged ); |
|
147 QVERIFY( !mMainWindow->mKeyCapture->mKeys.contains(Qt::Key_Yes) ); |
126 QVERIFY( spy.count() == 0 ); |
148 QVERIFY( spy.count() == 0 ); |
127 |
149 |
128 //Coming foreground after locale cange event |
150 //Coming foreground after locale cange event |
129 QVERIFY( !mMainWindow->eventFilter(this, &eventFg) ); |
151 QVERIFY( !mMainWindow->eventFilter(this, &eventFg) ); |
130 QVERIFY( mMainWindow->isForeground() ); |
152 QVERIFY( mMainWindow->isForeground() ); |
131 QVERIFY( !mMainWindow->mLocaleChanged ); |
153 QVERIFY( !mMainWindow->mLocaleChanged ); |
|
154 QVERIFY( mMainWindow->mKeyCapture->mKeys.contains(Qt::Key_Yes) ); |
132 QVERIFY( spy.count() == 1 ); |
155 QVERIFY( spy.count() == 1 ); |
133 } |
156 } |