Merge lp:~mardy/signon-ui/lp1135038 into lp:signon-ui

Proposed by Alberto Mardegan
Status: Merged
Approved by: Alberto Mardegan
Approved revision: 79
Merged at revision: 78
Proposed branch: lp:~mardy/signon-ui/lp1135038
Merge into: lp:signon-ui
Diff against target: 672 lines (+367/-51)
12 files modified
.bzrignore (+2/-0)
src/inactivity-timer.cpp (+68/-0)
src/inactivity-timer.h (+58/-0)
src/indicator-service.cpp (+18/-0)
src/indicator-service.h (+5/-0)
src/main.cpp (+12/-7)
src/service.cpp (+15/-42)
src/service.h (+3/-2)
src/src.pro (+2/-0)
tests/unit/tst_inactivity_timer.cpp (+143/-0)
tests/unit/tst_inactivity_timer.pro (+37/-0)
tests/unit/unit.pro (+4/-0)
To merge this branch: bzr merge lp:~mardy/signon-ui/lp1135038
Reviewer Review Type Date Requested Status
David King (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+153356@code.launchpad.net

Commit message

Do not quit if some accounts are failing

The inactivity timer should not trigger if there are some account failures (we
even had a comment warning about that!), because signon-ui is also the host for
the com.canonical.indicators.webcredentials service.

Create a new InactivityTimer to monitor both the Service and IndicatorService
objects.

Description of the change

Do not quit if some accounts are failing

The inactivity timer should not trigger if there are some account failures (we
even had a comment warning about that!), because signon-ui is also the host for
the com.canonical.indicators.webcredentials service.

Create a new InactivityTimer to monitor both the Service and IndicatorService
objects.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~mardy/signon-ui/lp1135038 updated
79. By Alberto Mardegan

Use xvfb-run

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
David King (amigadave) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2012-11-15 08:10:18 +0000
+++ .bzrignore 2013-03-14 13:21:22 +0000
@@ -13,6 +13,7 @@
13core13core
14debian/14debian/
15Makefile15Makefile
16Makefile.*
16moc_*17moc_*
17qrc_*.cpp18qrc_*.cpp
18signon-ui-test19signon-ui-test
@@ -20,6 +21,7 @@
20src/signon_ui_adaptor.*21src/signon_ui_adaptor.*
21src/webcredentials_adaptor.*22src/webcredentials_adaptor.*
22tests/unit/signon-ui-unittest23tests/unit/signon-ui-unittest
24tests/unit/tst_inactivity_timer
23tests/.config/Trolltech.conf25tests/.config/Trolltech.conf
24tests/functional/.cache/26tests/functional/.cache/
25tests/functional/.config/27tests/functional/.config/
2628
=== added file 'src/inactivity-timer.cpp'
--- src/inactivity-timer.cpp 1970-01-01 00:00:00 +0000
+++ src/inactivity-timer.cpp 2013-03-14 13:21:22 +0000
@@ -0,0 +1,68 @@
1/*
2 * This file is part of signon-ui
3 *
4 * Copyright (C) 2013 Canonical Ltd.
5 *
6 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include "inactivity-timer.h"
22
23#include "debug.h"
24
25using namespace SignOnUi;
26
27InactivityTimer::InactivityTimer(int interval, QObject *parent):
28 QObject(parent),
29 m_interval(interval)
30{
31 m_timer.setSingleShot(true);
32 QObject::connect(&m_timer, SIGNAL(timeout()),
33 this, SLOT(onTimeout()));
34}
35
36void InactivityTimer::watchObject(QObject *object)
37{
38 connect(object, SIGNAL(isIdleChanged()), SLOT(onIdleChanged()));
39 m_watchedObjects.append(object);
40
41 /* Force an initial check */
42 onIdleChanged();
43}
44
45void InactivityTimer::onIdleChanged()
46{
47 if (allObjectsAreIdle()) {
48 m_timer.start(m_interval);
49 }
50}
51
52void InactivityTimer::onTimeout()
53{
54 TRACE();
55 if (allObjectsAreIdle()) {
56 Q_EMIT timeout();
57 }
58}
59
60bool InactivityTimer::allObjectsAreIdle() const
61{
62 foreach (const QObject *object, m_watchedObjects) {
63 if (!object->property("isIdle").toBool()) {
64 return false;
65 }
66 }
67 return true;
68}
069
=== added file 'src/inactivity-timer.h'
--- src/inactivity-timer.h 1970-01-01 00:00:00 +0000
+++ src/inactivity-timer.h 2013-03-14 13:21:22 +0000
@@ -0,0 +1,58 @@
1/*
2 * This file is part of signon-ui
3 *
4 * Copyright (C) 2013 Canonical Ltd.
5 *
6 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef SIGNON_UI_INACTIVITY_TIMER_H
22#define SIGNON_UI_INACTIVITY_TIMER_H
23
24#include <QList>
25#include <QObject>
26#include <QTimer>
27
28namespace SignOnUi {
29
30class InactivityTimer: public QObject
31{
32 Q_OBJECT
33
34public:
35 InactivityTimer(int interval, QObject *parent = 0);
36 ~InactivityTimer() {}
37
38 void watchObject(QObject *object);
39
40Q_SIGNALS:
41 void timeout();
42
43private Q_SLOTS:
44 void onIdleChanged();
45 void onTimeout();
46
47private:
48 bool allObjectsAreIdle() const;
49
50private:
51 QList<QObject*> m_watchedObjects;
52 QTimer m_timer;
53 int m_interval;
54};
55
56} // namespace
57
58#endif // SIGNON_UI_INACTIVITY_TIMER_H
059
=== modified file 'src/indicator-service.cpp'
--- src/indicator-service.cpp 2013-01-23 07:48:35 +0000
+++ src/indicator-service.cpp 2013-03-14 13:21:22 +0000
@@ -121,14 +121,23 @@
121121
122void IndicatorServicePrivate::RemoveFailures(const QSet<uint> &accountIds)122void IndicatorServicePrivate::RemoveFailures(const QSet<uint> &accountIds)
123{123{
124 Q_Q(IndicatorService);
124 m_failures.subtract(accountIds);125 m_failures.subtract(accountIds);
125 notifyPropertyChanged("Failures");126 notifyPropertyChanged("Failures");
127 if (q->isIdle()) {
128 Q_EMIT q->isIdleChanged();
129 }
126}130}
127131
128void IndicatorServicePrivate::ReportFailure(uint accountId,132void IndicatorServicePrivate::ReportFailure(uint accountId,
129 const QVariantMap &notification)133 const QVariantMap &notification)
130{134{
135 Q_Q(IndicatorService);
136 bool wasIdle = q->isIdle();
131 m_failures.insert(accountId);137 m_failures.insert(accountId);
138 if (wasIdle) {
139 Q_EMIT q->isIdleChanged();
140 }
132141
133 /* If the original client data is provided, we remember it: it can142 /* If the original client data is provided, we remember it: it can
134 * be used to replay the authentication later.143 * be used to replay the authentication later.
@@ -249,6 +258,8 @@
249258
250void IndicatorServicePrivate::onReauthenticatorFinished(bool success)259void IndicatorServicePrivate::onReauthenticatorFinished(bool success)
251{260{
261 Q_Q(IndicatorService);
262
252 Reauthenticator *reauthenticator =263 Reauthenticator *reauthenticator =
253 qobject_cast<Reauthenticator*>(sender());264 qobject_cast<Reauthenticator*>(sender());
254265
@@ -277,6 +288,7 @@
277288
278 if (m_failures.isEmpty()) {289 if (m_failures.isEmpty()) {
279 ClearErrorStatus();290 ClearErrorStatus();
291 Q_EMIT q->isIdleChanged();
280 }292 }
281 }293 }
282294
@@ -342,4 +354,10 @@
342 return d->m_errorStatus;354 return d->m_errorStatus;
343}355}
344356
357bool IndicatorService::isIdle() const
358{
359 Q_D(const IndicatorService);
360 return d->m_failures.isEmpty();
361}
362
345#include "indicator-service.moc"363#include "indicator-service.moc"
346364
=== modified file 'src/indicator-service.h'
--- src/indicator-service.h 2012-03-06 13:54:30 +0000
+++ src/indicator-service.h 2013-03-14 13:21:22 +0000
@@ -36,6 +36,7 @@
36class IndicatorService: public QObject36class IndicatorService: public QObject
37{37{
38 Q_OBJECT38 Q_OBJECT
39 Q_PROPERTY(bool isIdle READ isIdle NOTIFY isIdleChanged)
3940
40public:41public:
4142
@@ -52,6 +53,10 @@
5253
53 QSet<uint> failures() const;54 QSet<uint> failures() const;
54 bool errorStatus() const;55 bool errorStatus() const;
56 bool isIdle() const;
57
58Q_SIGNALS:
59 void isIdleChanged();
5560
56private:61private:
57 IndicatorServicePrivate *d_ptr;62 IndicatorServicePrivate *d_ptr;
5863
=== modified file 'src/main.cpp'
--- src/main.cpp 2013-02-01 17:11:24 +0000
+++ src/main.cpp 2013-03-14 13:21:22 +0000
@@ -20,6 +20,7 @@
2020
21#include "debug.h"21#include "debug.h"
22#include "i18n.h"22#include "i18n.h"
23#include "inactivity-timer.h"
23#include "indicator-service.h"24#include "indicator-service.h"
24#include "my-network-proxy-factory.h"25#include "my-network-proxy-factory.h"
25#include "service.h"26#include "service.h"
@@ -75,24 +76,26 @@
75 QNetworkProxyFactory::setApplicationProxyFactory(proxyFactory);76 QNetworkProxyFactory::setApplicationProxyFactory(proxyFactory);
7677
77 Service *service = new Service();78 Service *service = new Service();
78 if (daemonTimeout > 0)
79 service->setTimeout(daemonTimeout);
80 QDBusConnection connection = QDBusConnection::sessionBus();79 QDBusConnection connection = QDBusConnection::sessionBus();
81 connection.registerService(QLatin1String(serviceName));80 connection.registerService(QLatin1String(serviceName));
82 connection.registerObject(QLatin1String(objectPath),81 connection.registerObject(QLatin1String(objectPath),
83 service,82 service,
84 QDBusConnection::ExportAllContents);83 QDBusConnection::ExportAllContents);
85 /* FIXME: before quitting we should check if the IndicatorService is idle
86 * too. However, since this feature is used for unit tests only, for the
87 * time being this is fine.
88 */
89 QObject::connect(service, SIGNAL(idleTimeout()), &app, SLOT(quit()));
9084
91 IndicatorService *indicatorService = new IndicatorService();85 IndicatorService *indicatorService = new IndicatorService();
92 connection.registerService(QLatin1String(WEBCREDENTIALS_BUS_NAME));86 connection.registerService(QLatin1String(WEBCREDENTIALS_BUS_NAME));
93 connection.registerObject(QLatin1String(WEBCREDENTIALS_OBJECT_PATH),87 connection.registerObject(QLatin1String(WEBCREDENTIALS_OBJECT_PATH),
94 indicatorService->serviceObject());88 indicatorService->serviceObject());
9589
90 InactivityTimer *inactivityTimer = 0;
91 if (daemonTimeout > 0) {
92 inactivityTimer = new InactivityTimer(daemonTimeout * 1000);
93 inactivityTimer->watchObject(service);
94 inactivityTimer->watchObject(indicatorService);
95 QObject::connect(inactivityTimer, SIGNAL(timeout()),
96 &app, SLOT(quit()));
97 }
98
96 int ret = app.exec();99 int ret = app.exec();
97100
98 connection.unregisterService(QLatin1String(WEBCREDENTIALS_BUS_NAME));101 connection.unregisterService(QLatin1String(WEBCREDENTIALS_BUS_NAME));
@@ -103,6 +106,8 @@
103 connection.unregisterObject(QLatin1String(objectPath));106 connection.unregisterObject(QLatin1String(objectPath));
104 delete service;107 delete service;
105108
109 delete inactivityTimer;
110
106 return ret;111 return ret;
107}112}
108113
109114
=== modified file 'src/service.cpp'
--- src/service.cpp 2012-04-03 11:46:12 +0000
+++ src/service.cpp 2013-03-14 13:21:22 +0000
@@ -23,7 +23,6 @@
23#include "debug.h"23#include "debug.h"
24#include "request.h"24#include "request.h"
2525
26#include <QTimer>
27#include <QQueue>26#include <QQueue>
2827
29using namespace SignOnUi;28using namespace SignOnUi;
@@ -41,24 +40,16 @@
41 ServicePrivate(Service *service);40 ServicePrivate(Service *service);
42 ~ServicePrivate();41 ~ServicePrivate();
4342
44 void setTimeout(int timeout);
45
46 RequestQueue &queueForWindowId(WId windowId);43 RequestQueue &queueForWindowId(WId windowId);
47 void enqueue(Request *request);44 void enqueue(Request *request);
48 void runQueue(RequestQueue &queue);45 void runQueue(RequestQueue &queue);
49 void cancelUiRequest(const QString &requestId);46 void cancelUiRequest(const QString &requestId);
5047
51private:
52 void resetTimer();
53
54private Q_SLOTS:48private Q_SLOTS:
55 void onRequestCompleted();49 void onRequestCompleted();
56 void onTimeout();
5750
58private:51private:
59 mutable Service *q_ptr;52 mutable Service *q_ptr;
60 QTimer m_timer;
61 int m_timeout;
62 /* each window Id has a different queue */53 /* each window Id has a different queue */
63 QMap<WId,RequestQueue> m_requests;54 QMap<WId,RequestQueue> m_requests;
64};55};
@@ -67,41 +58,14 @@
6758
68ServicePrivate::ServicePrivate(Service *service):59ServicePrivate::ServicePrivate(Service *service):
69 QObject(service),60 QObject(service),
70 q_ptr(service),61 q_ptr(service)
71 m_timeout(0)
72{62{
73 m_timer.setSingleShot(true);
74 QObject::connect(&m_timer, SIGNAL(timeout()),
75 this, SLOT(onTimeout()));
76}63}
7764
78ServicePrivate::~ServicePrivate()65ServicePrivate::~ServicePrivate()
79{66{
80}67}
8168
82void ServicePrivate::setTimeout(int timeout)
83{
84 m_timeout = timeout * 1000;
85 resetTimer();
86}
87
88void ServicePrivate::resetTimer()
89{
90 m_timer.stop();
91 if (m_timeout > 0) {
92 m_timer.start(m_timeout);
93 }
94}
95
96void ServicePrivate::onTimeout()
97{
98 Q_Q(Service);
99
100 if (m_requests.isEmpty()) {
101 Q_EMIT q->idleTimeout();
102 }
103}
104
105RequestQueue &ServicePrivate::queueForWindowId(WId windowId)69RequestQueue &ServicePrivate::queueForWindowId(WId windowId)
106{70{
107 if (!m_requests.contains(windowId)) {71 if (!m_requests.contains(windowId)) {
@@ -113,13 +77,18 @@
11377
114void ServicePrivate::enqueue(Request *request)78void ServicePrivate::enqueue(Request *request)
115{79{
116 resetTimer();80 Q_Q(Service);
81 bool wasIdle = q->isIdle();
11782
118 WId windowId = request->windowId();83 WId windowId = request->windowId();
11984
120 RequestQueue &queue = queueForWindowId(windowId);85 RequestQueue &queue = queueForWindowId(windowId);
121 queue.enqueue(request);86 queue.enqueue(request);
12287
88 if (wasIdle) {
89 Q_EMIT q->isIdleChanged();
90 }
91
123 runQueue(queue);92 runQueue(queue);
124}93}
12594
@@ -140,7 +109,7 @@
140109
141void ServicePrivate::onRequestCompleted()110void ServicePrivate::onRequestCompleted()
142{111{
143 resetTimer();112 Q_Q(Service);
144113
145 Request *request = qobject_cast<Request*>(sender());114 Request *request = qobject_cast<Request*>(sender());
146 WId windowId = request->windowId();115 WId windowId = request->windowId();
@@ -160,6 +129,10 @@
160 /* start the next request */129 /* start the next request */
161 runQueue(queue);130 runQueue(queue);
162 }131 }
132
133 if (q->isIdle()) {
134 Q_EMIT q->isIdleChanged();
135 }
163}136}
164137
165void ServicePrivate::cancelUiRequest(const QString &requestId)138void ServicePrivate::cancelUiRequest(const QString &requestId)
@@ -193,10 +166,10 @@
193{166{
194}167}
195168
196void Service::setTimeout(int timeout)169bool Service::isIdle() const
197{170{
198 Q_D(Service);171 Q_D(const Service);
199 d->setTimeout(timeout);172 return d->m_requests.isEmpty();
200}173}
201174
202QVariantMap Service::queryDialog(const QVariantMap &parameters)175QVariantMap Service::queryDialog(const QVariantMap &parameters)
203176
=== modified file 'src/service.h'
--- src/service.h 2012-04-03 11:46:12 +0000
+++ src/service.h 2013-03-14 13:21:22 +0000
@@ -32,13 +32,14 @@
32class Service: public QObject, protected QDBusContext32class Service: public QObject, protected QDBusContext
33{33{
34 Q_OBJECT34 Q_OBJECT
35 Q_PROPERTY(bool isIdle READ isIdle NOTIFY isIdleChanged)
35 Q_CLASSINFO("D-Bus Interface", "com.nokia.singlesignonui")36 Q_CLASSINFO("D-Bus Interface", "com.nokia.singlesignonui")
3637
37public:38public:
38 explicit Service(QObject *parent = 0);39 explicit Service(QObject *parent = 0);
39 ~Service();40 ~Service();
4041
41 void setTimeout(int timeout);42 bool isIdle() const;
4243
43public Q_SLOTS:44public Q_SLOTS:
44 QVariantMap queryDialog(const QVariantMap &parameters);45 QVariantMap queryDialog(const QVariantMap &parameters);
@@ -46,7 +47,7 @@
46 Q_NOREPLY void cancelUiRequest(const QString &requestId);47 Q_NOREPLY void cancelUiRequest(const QString &requestId);
4748
48Q_SIGNALS:49Q_SIGNALS:
49 void idleTimeout();50 void isIdleChanged();
5051
51private:52private:
52 ServicePrivate *d_ptr;53 ServicePrivate *d_ptr;
5354
=== modified file 'src/src.pro'
--- src/src.pro 2013-01-23 07:48:35 +0000
+++ src/src.pro 2013-03-14 13:21:22 +0000
@@ -34,6 +34,7 @@
34 dialog.h \34 dialog.h \
35 errors.h \35 errors.h \
36 i18n.h \36 i18n.h \
37 inactivity-timer.h \
37 indicator-service.h \38 indicator-service.h \
38 network-access-manager.h \39 network-access-manager.h \
39 reauthenticator.h \40 reauthenticator.h \
@@ -49,6 +50,7 @@
49 dialog-request.cpp \50 dialog-request.cpp \
50 dialog.cpp \51 dialog.cpp \
51 i18n.cpp \52 i18n.cpp \
53 inactivity-timer.cpp \
52 indicator-service.cpp \54 indicator-service.cpp \
53 main.cpp \55 main.cpp \
54 my-network-proxy-factory.cpp \56 my-network-proxy-factory.cpp \
5557
=== added file 'tests/unit/tst_inactivity_timer.cpp'
--- tests/unit/tst_inactivity_timer.cpp 1970-01-01 00:00:00 +0000
+++ tests/unit/tst_inactivity_timer.cpp 2013-03-14 13:21:22 +0000
@@ -0,0 +1,143 @@
1/*
2 * This file is part of signon-ui
3 *
4 * Copyright (C) 2013 Canonical Ltd.
5 *
6 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include "debug.h"
22#include "inactivity-timer.h"
23
24#include <QDebug>
25#include <QObject>
26#include <QSignalSpy>
27#include <QTest>
28
29using namespace SignOnUi;
30
31class InactivityTest: public QObject
32{
33 Q_OBJECT
34
35public:
36 InactivityTest() {};
37
38private Q_SLOTS:
39 void testAlwaysIdle();
40 void testIdleThenBusy();
41 void testStartBusy();
42};
43
44class TestObject: public QObject
45{
46 Q_OBJECT
47 Q_PROPERTY(bool isIdle READ isIdle NOTIFY isIdleChanged)
48
49public:
50 TestObject(): QObject(0), m_isIdle(false) {}
51 ~TestObject() {}
52
53 bool isIdle() const { return m_isIdle; }
54 void setIdle(bool idle) {
55 if (idle == m_isIdle) return;
56 m_isIdle = idle;
57 Q_EMIT isIdleChanged();
58 }
59
60Q_SIGNALS:
61 void isIdleChanged();
62
63private:
64 bool m_isIdle;
65};
66
67void InactivityTest::testAlwaysIdle()
68{
69 InactivityTimer inactivityTimer(100);
70 QSignalSpy timeout(&inactivityTimer, SIGNAL(timeout()));
71
72 TestObject object1;
73 object1.setIdle(true);
74 inactivityTimer.watchObject(&object1);
75
76 TestObject object2;
77 object2.setIdle(true);
78 inactivityTimer.watchObject(&object2);
79
80 QCOMPARE(timeout.count(), 0);
81 QTest::qWait(150);
82 QCOMPARE(timeout.count(), 1);
83}
84
85void InactivityTest::testIdleThenBusy()
86{
87 InactivityTimer inactivityTimer(100);
88 QSignalSpy timeout(&inactivityTimer, SIGNAL(timeout()));
89
90 TestObject object1;
91 object1.setIdle(true);
92 inactivityTimer.watchObject(&object1);
93
94 TestObject object2;
95 object2.setIdle(true);
96 inactivityTimer.watchObject(&object2);
97
98 QCOMPARE(timeout.count(), 0);
99
100 QTest::qWait(30);
101 QCOMPARE(timeout.count(), 0);
102 object2.setIdle(false);
103
104 QTest::qWait(100);
105 QCOMPARE(timeout.count(), 0);
106 object2.setIdle(true);
107 QTest::qWait(30);
108 QCOMPARE(timeout.count(), 0);
109
110 QTest::qWait(100);
111 QCOMPARE(timeout.count(), 1);
112}
113
114void InactivityTest::testStartBusy()
115{
116 InactivityTimer inactivityTimer(100);
117 QSignalSpy timeout(&inactivityTimer, SIGNAL(timeout()));
118
119 TestObject object1;
120 inactivityTimer.watchObject(&object1);
121
122 TestObject object2;
123 inactivityTimer.watchObject(&object2);
124
125 QCOMPARE(timeout.count(), 0);
126
127 QTest::qWait(130);
128 QCOMPARE(timeout.count(), 0);
129 object2.setIdle(true);
130
131 QTest::qWait(130);
132 QCOMPARE(timeout.count(), 0);
133 object1.setIdle(true);
134
135 QTest::qWait(30);
136 QCOMPARE(timeout.count(), 0);
137
138 QTest::qWait(100);
139 QCOMPARE(timeout.count(), 1);
140}
141
142QTEST_MAIN(InactivityTest);
143#include "tst_inactivity_timer.moc"
0144
=== added file 'tests/unit/tst_inactivity_timer.pro'
--- tests/unit/tst_inactivity_timer.pro 1970-01-01 00:00:00 +0000
+++ tests/unit/tst_inactivity_timer.pro 2013-03-14 13:21:22 +0000
@@ -0,0 +1,37 @@
1include(../../common-project-config.pri)
2include($${TOP_SRC_DIR}/common-vars.pri)
3include($${TOP_SRC_DIR}/common-installs-config.pri)
4
5TARGET = tst_inactivity_timer
6
7CONFIG += \
8 build_all \
9 debug \
10 qtestlib
11
12QT += \
13 core
14
15SOURCES += \
16 tst_inactivity_timer.cpp \
17 $$TOP_SRC_DIR/src/debug.cpp \
18 $$TOP_SRC_DIR/src/inactivity-timer.cpp
19HEADERS += \
20 $$TOP_SRC_DIR/src/debug.h \
21 $$TOP_SRC_DIR/src/inactivity-timer.h
22
23INCLUDEPATH += \
24 . \
25 $$TOP_SRC_DIR/src
26
27QMAKE_CXXFLAGS += \
28 -fno-exceptions \
29 -fno-rtti
30
31DEFINES += \
32 DEBUG_ENABLED \
33 UNIT_TESTS
34
35check.commands = "xvfb-run -a ./$$TARGET"
36check.depends = $$TARGET
37QMAKE_EXTRA_TARGETS += check
038
=== renamed file 'tests/unit/unit.pro' => 'tests/unit/tst_signon_ui.pro'
=== added file 'tests/unit/unit.pro'
--- tests/unit/unit.pro 1970-01-01 00:00:00 +0000
+++ tests/unit/unit.pro 2013-03-14 13:21:22 +0000
@@ -0,0 +1,4 @@
1TEMPLATE = subdirs
2SUBDIRS = \
3 tst_inactivity_timer.pro \
4 tst_signon_ui.pro

Subscribers

People subscribed via source and target branches

to all changes: