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