66 void UT_LogsMainWindow::testSendAppToBackground() |
66 void UT_LogsMainWindow::testSendAppToBackground() |
67 { |
67 { |
68 QtHighwayStubHelper::reset(); |
68 QtHighwayStubHelper::reset(); |
69 mMainWindow->sendAppToBackground(); |
69 mMainWindow->sendAppToBackground(); |
70 QVERIFY( QtHighwayStubHelper::utilToBackground() ); |
70 QVERIFY( QtHighwayStubHelper::utilToBackground() ); |
71 QVERIFY( !mMainWindow->isForeground() ); |
|
72 } |
71 } |
73 |
72 |
74 void UT_LogsMainWindow::testBringAppToForeground() |
73 void UT_LogsMainWindow::testBringAppToForeground() |
75 { |
74 { |
76 QtHighwayStubHelper::reset(); |
75 QtHighwayStubHelper::reset(); |
77 HbStubHelper::reset(); |
76 HbStubHelper::reset(); |
78 mMainWindow->bringAppToForeground(); |
77 mMainWindow->bringAppToForeground(); |
79 QVERIFY( HbStubHelper::isWidgetRaised() ); |
78 QVERIFY( HbStubHelper::isWidgetRaised() ); |
80 QVERIFY( mMainWindow->isForeground() ); |
|
81 |
79 |
82 // Subsequent call raise tries to raise regardless of current state |
80 // Subsequent call raise tries to raise regardless of current state |
83 HbStubHelper::reset(); |
81 HbStubHelper::reset(); |
84 mMainWindow->bringAppToForeground(); |
82 mMainWindow->bringAppToForeground(); |
85 QVERIFY( HbStubHelper::isWidgetRaised() ); |
83 QVERIFY( HbStubHelper::isWidgetRaised() ); |
86 QVERIFY( mMainWindow->isForeground() ); |
|
87 } |
84 } |
88 |
85 |
|
86 void UT_LogsMainWindow::testEventFilter() |
|
87 { |
|
88 QSignalSpy spy( mMainWindow, SIGNAL(localeChanged()) ); |
|
89 QSignalSpy foregroundSpy( mMainWindow, SIGNAL(appGainedForeground()) ); |
|
90 |
|
91 //Event we are not interested in |
|
92 QEvent event(QEvent::Show); |
|
93 QVERIFY( !mMainWindow->eventFilter(this, &event) ); |
|
94 QVERIFY( !mMainWindow->isForeground() ); |
|
95 QVERIFY( !mMainWindow->mLocaleChanged ); |
|
96 QCOMPARE( foregroundSpy.count(), 0 ); |
|
97 |
|
98 //Coming foreground, locale not changed |
|
99 QEvent eventFg(QEvent::ApplicationActivate); |
|
100 QVERIFY( !mMainWindow->eventFilter(this, &eventFg) ); |
|
101 QVERIFY( mMainWindow->isForeground() ); |
|
102 QVERIFY( !mMainWindow->mLocaleChanged ); |
|
103 QCOMPARE( foregroundSpy.count(), 1 ); |
|
104 foregroundSpy.clear(); |
|
105 |
|
106 //LocaleChange event on FG |
|
107 QEvent eventLocale(QEvent::LocaleChange); |
|
108 QVERIFY( !mMainWindow->eventFilter(this, &eventLocale) ); |
|
109 QVERIFY( mMainWindow->isForeground() ); |
|
110 QVERIFY( !mMainWindow->mLocaleChanged ); |
|
111 QVERIFY( spy.count() == 1 ); |
|
112 QCOMPARE( foregroundSpy.count(), 0 ); |
|
113 spy.clear(); |
|
114 |
|
115 //Going background |
|
116 QEvent eventBg(QEvent::ApplicationDeactivate); |
|
117 QVERIFY( !mMainWindow->eventFilter(this, &eventBg) ); |
|
118 QVERIFY( !mMainWindow->isForeground() ); |
|
119 QVERIFY( !mMainWindow->mLocaleChanged ); |
|
120 QCOMPARE( foregroundSpy.count(), 0 ); |
|
121 |
|
122 //LocaleChange event on BG |
|
123 QVERIFY( !mMainWindow->eventFilter(this, &eventLocale) ); |
|
124 QVERIFY( !mMainWindow->isForeground() ); |
|
125 QVERIFY( mMainWindow->mLocaleChanged ); |
|
126 QVERIFY( spy.count() == 0 ); |
|
127 |
|
128 //Coming foreground after locale cange event |
|
129 QVERIFY( !mMainWindow->eventFilter(this, &eventFg) ); |
|
130 QVERIFY( mMainWindow->isForeground() ); |
|
131 QVERIFY( !mMainWindow->mLocaleChanged ); |
|
132 QVERIFY( spy.count() == 1 ); |
|
133 } |