summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKranthi Kuntala <kranthi.kumar-kuntala@nokia.com>2012-02-22 11:17:36 +0200
committerKranthi Kuntala <kranthi.kumar-kuntala@nokia.com>2012-02-27 10:37:49 +0100
commit9be8d51e49adfc01c64cf594a0408bd8c9a30525 (patch)
tree44a57eb5ca68fbf14926f48432bfd37fb7e2377a
parentd7738e7ab35eb50802936afcbe5e6eeefdb26b60 (diff)
AlignedTimer addon module
Change-Id: I28d4cdc2b0a24294940e2fc12361927e03d30e72 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
-rw-r--r--alignedtimer.pro17
-rw-r--r--modules/qt_alignedtimer.pri15
-rw-r--r--src/alignedtimer/alignedtimer.pro36
-rw-r--r--src/alignedtimer/qalignedtimer.cpp271
-rw-r--r--src/alignedtimer/qalignedtimer.h104
-rw-r--r--src/alignedtimer/qalignedtimer_stub.cpp122
-rw-r--r--src/alignedtimer/qalignedtimer_stub_p.h87
-rw-r--r--src/alignedtimer/qalignedtimer_systemhb.cpp231
-rw-r--r--src/alignedtimer/qalignedtimer_systemhb_p.h105
-rw-r--r--src/alignedtimer/qalignedtimerglobal.h63
-rw-r--r--src/src.pro3
-rw-r--r--sync.profile24
-rw-r--r--tests/auto/alignedtimer/alignedtimer.pro5
-rw-r--r--tests/auto/alignedtimer/tst_qalignedtimer.cpp283
-rw-r--r--tests/auto/auto.pri5
-rw-r--r--tests/auto/auto.pro4
-rw-r--r--tests/tests.pro2
17 files changed, 1377 insertions, 0 deletions
diff --git a/alignedtimer.pro b/alignedtimer.pro
new file mode 100644
index 0000000..0cfd3aa
--- /dev/null
+++ b/alignedtimer.pro
@@ -0,0 +1,17 @@
+ TEMPLATE = subdirs
+ CONFIG += ordered
+
+
+ module_alignedtimer_src.subdir = src
+ module_alignedtimer_src.target = module-alignedtimer-src
+
+ module_alignedtimer_tests.subdir = tests
+ module_alignedtimer_tests.target = module-alignedtimer-tests
+ module_alignedtimer_tests.depends = module_alignedtimer_src
+ module_alignedtimer_tests.CONFIG = no_default_install
+ !contains(QT_BUILD_PARTS,tests) {
+ module_alignedtimer_tests.CONFIG += no_default_target
+ }
+
+ SUBDIRS += module_alignedtimer_src \
+ module_alignedtimer_tests \
diff --git a/modules/qt_alignedtimer.pri b/modules/qt_alignedtimer.pri
new file mode 100644
index 0000000..6d674df
--- /dev/null
+++ b/modules/qt_alignedtimer.pri
@@ -0,0 +1,15 @@
+QT.alignedtimer.VERSION = 5.0.0
+QT.alignedtimer.MAJOR_VERSION = 5
+QT.alignedtimer.MINOR_VERSION = 0
+QT.alignedtimer.PATCH_VERSION = 0
+
+QT.alignedtimer.name = QtAlignedTimer
+QT.alignedtimer.bins = $$QT_MODULE_BIN_BASE
+QT.alignedtimer.includes = $$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/QtAlignedTimer
+QT.alignedtimer.private_includes = $$QT_MODULE_INCLUDE_BASE/QtAlignedTimer/$$QT.alignedtimer.VERSION
+QT.alignedtimer.sources = $$QT_MODULE_BASE/src/alignedtimer
+QT.alignedtimer.libs = $$QT_MODULE_LIB_BASE
+QT.alignedtimer.depends = core
+QT.alignedtimer.DEFINES = QT_ALIGNEDTIMER_LIB
+
+QT_CONFIG += alignedtimer
diff --git a/src/alignedtimer/alignedtimer.pro b/src/alignedtimer/alignedtimer.pro
new file mode 100644
index 0000000..70c5bba
--- /dev/null
+++ b/src/alignedtimer/alignedtimer.pro
@@ -0,0 +1,36 @@
+load(qt_module)
+
+TARGET = QtAlignedTimer
+QPRO_PWD = $PWD
+CONFIG += module
+MODULE_PRI = ../../modules/qt_alignedtimer.pri
+
+QT = core
+
+DEFINES += QT_BUILD_ALIGNEDTIMER_LIB QT_MAKEDLL
+
+load(qt_module_config)
+VERSION = $$QT.alignedtimer.VERSION
+
+
+PUBLIC_HEADERS += \
+ qalignedtimer.h \
+ qalignedtimerglobal.h
+
+
+SOURCES += \
+ qalignedtimer.cpp
+
+ # alignedtimer for systemhb
+ contains(systemhb_enabled, yes): {
+ SOURCES += qalignedtimer_systemhb.cpp
+ HEADERS += qalignedtimer_systemhb_p.h
+ PKGCONFIG += libsystemhb
+ DEFINES += ALIGNEDTIMER_SYSTEMHB
+ LIBS += -lsystemhb
+ } else {
+ SOURCES += qalignedtimer_stub.cpp
+ HEADERS += qalignedtimer_stub_p.h
+ }
+
+HEADERS += qtalignedtimerversion.h $$PUBLIC_HEADERS $$PRIVATE_HEADERS
diff --git a/src/alignedtimer/qalignedtimer.cpp b/src/alignedtimer/qalignedtimer.cpp
new file mode 100644
index 0000000..e329e86
--- /dev/null
+++ b/src/alignedtimer/qalignedtimer.cpp
@@ -0,0 +1,271 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the alignedtimer module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qalignedtimer.h"
+#include <QDebug>
+#if defined(ALIGNEDTIMER_SYSTEMHB)
+#include "qalignedtimer_systemhb_p.h"
+#else
+#include "qalignedtimer_stub_p.h"
+#endif
+QT_BEGIN_NAMESPACE
+
+Q_GLOBAL_STATIC(QAlignedTimerPrivate, alignedTimerPrivate)
+
+/*!
+ \class QAlignedTimer
+ \ingroup events
+ \brief The QAlignedTimer class provides a service for applications to synchronize their activity.
+
+ QAlignedTimer is a fuzzy timer that allows applications that must do periodic activity like
+ after being in sleep mode a certain period, to synchronize their activities in the same window of time.
+
+ For example send network "alive" messages at the same time (i.e. turn the wireless radio on at the same time).
+
+ The service is not only for network-aware applications, it is for use by any applications
+ that need to periodic wake-ups.
+
+ The recommended use case is when app uses single-shot timer only: set mintime 0 for the first call
+ 'to jump to the train' and mintime > 0 after 1st wakeup.
+ \sa QBasicTimer, QTimer, QTimerEvent, QObject::timerEvent(), Timers,
+*/
+
+/*!
+ \fn void QAlignedTimer::timeout()
+
+ This signal is emitted when the timer times out.
+*/
+
+/*!
+ \enum QAlignedTimer::AlignedTimerError
+ This enum describes the last known AlignedTimerError
+
+ \value NoError No error.
+ \value AlignedTimerNotSupported The aligned timer is not support on this platform
+ \value InvalidArgument Interval arguments are invalid.
+ \value TimerFailed General timer failure.
+ \value InternalError Internal error.
+*/
+
+/*!
+ Constructs a QAlignedTimer object with the given \a parent.
+*/
+QAlignedTimer::QAlignedTimer(QObject *parent)
+ : QObject(parent)
+{
+ d = new QAlignedTimerPrivate(this);
+ connect(d, SIGNAL(timeout()), this, SIGNAL(timeout()));
+ connect(d, SIGNAL(error(QAlignedTimer::AlignedTimerError)), this, SIGNAL(error(QAlignedTimer::AlignedTimerError)));
+}
+
+/*!
+ Destructs the QAlignedTimer
+*/
+QAlignedTimer::~QAlignedTimer()
+{
+}
+
+/*!
+ Starts the timer with the minimal interval of \a minimumTime, and maximum interval \a maximumTime in seconds.
+
+ This is not a guaranteed interval, and the timeout signal may be fired at any time,
+ depending on other clients attached to this timer.
+
+ In the case of minimalInterval of 0, it means 'wake me up when someone else is woken up'.
+
+*/
+void QAlignedTimer::start(int minimumTime, int maximumTime)
+{
+ if (minimumTime > maximumTime || maximumTime <= 0) {
+ d->m_lastError = QAlignedTimer::InvalidArgument;
+ qWarning()<<Q_FUNC_INFO <<"invalid arguments minimumTime and maximumTime";
+ return;
+ }
+ d->start(minimumTime, maximumTime);
+}
+
+/*!
+ Starts the alignedtimer if the minimumtime is greater than zero
+ and maximumtime is greater than the minimumtime
+*/
+void QAlignedTimer::start()
+{
+ int minimumTime = minimumInterval();
+ int maximumTime = maximumInterval();
+ if ((minimumTime > maximumTime) || (maximumTime <= 0)) {
+ d->m_lastError = QAlignedTimer::InvalidArgument;
+ qWarning() <<Q_FUNC_INFO <<"invalid arguments minimumTime and maximumTime";
+ return;
+ }
+ d->start();
+}
+
+/*!
+ This should be called when the application wakes up via other means than QAlignedTimer timeout.
+
+ Other applications that are in their wakeup window *may* be woken up. Single-shot timer is canceled,
+ and reoccuring timer interval will restart.
+
+*/
+void QAlignedTimer::wokeUp()
+{
+ d->wokeUp();
+}
+
+/*!
+ Stops this timer request.
+*/
+void QAlignedTimer::stop()
+{
+ d->stop();
+}
+
+/*!
+ Set the timeout minimum interval to \a seconds in seconds that must be waited before timeout
+ signal is emitted.
+
+ Time in seconds that MUST be waited before timeout.
+ Value 0 means 'wake me up when someboy else is woken'.
+
+ mintime value 0 should be used with special care, as it may cause too frequent wakeups.
+ It is recommended that the first wait (if possible) uses minimum value of 0 to
+ "jump to the train" and minimum value > 0 after 1st wakeup
+*/
+void QAlignedTimer::setMinimumInterval(int seconds)
+{
+ d->setMinimumInterval(seconds);
+}
+
+/*!
+ \property QAlignedTimer::minimumInterval
+ \brief The timers's minimumInterval.
+
+ Returns this current timer minimum interval.
+*/
+int QAlignedTimer::minimumInterval() const
+{
+ return d->minimumInterval();
+}
+
+/*!
+ Set the timeout maximum interval to \a seconds the wait must end.
+
+ Time in seconds when the wait MUST end. It is wise to have maxtime-mintime
+ quite big so all users of this service get synced.
+ For example if you preferred wait is 120 seconds, use minval 110 and maxval 130.
+
+ max interval must be greater than min interval.
+*/
+void QAlignedTimer::setMaximumInterval(int seconds)
+{
+ d->setMaximumInterval(seconds);
+}
+
+/*!
+ \property QAlignedTimer::maximumInterval
+ \brief The timer's maximumInterval.
+
+ Returns this current timer maximum interval.
+*/
+int QAlignedTimer::maximumInterval() const
+{
+ return d->maximumInterval();
+}
+
+/*!
+ Sets this timer to be a single shot \a singleShot is true, otherwise false.
+*/
+void QAlignedTimer::setSingleShot(bool singleShot)
+{
+ d->setSingleShot(singleShot);
+}
+
+/*!
+ This static function starts a timer to call a slot after a \a minimumTime
+ interval has elapsed, and ensures that it will be called before the
+ \a maximumTime has elapsed.
+
+ These values are specified in seconds.
+
+ The receiver is the \a receiver object and the \a member is the slot.
+*/
+void QAlignedTimer::singleShot(int minimumTime, int maximumTime, QObject *receiver, const char *member)
+{
+ if (minimumTime > maximumTime || maximumTime <= 0)
+ return;
+ QAlignedTimerPrivate::singleShot(minimumTime, maximumTime, receiver, member);
+}
+
+/*!
+ \property QAlignedTimer::singleShot
+ Whether the timer is single shot.
+*/
+
+/*!
+ Returns true if this timer is a single shot, otherwise false.
+*/
+bool QAlignedTimer::isSingleShot() const
+{
+ return d->isSingleShot();
+}
+
+/*!
+ Returns the last AlignedTimerError.
+*/
+QAlignedTimer::AlignedTimerError QAlignedTimer::lastError() const
+{
+ return d->lastError();
+}
+
+/*!
+ \property QAlignedTimer::active
+ Returns true if the timer is running; otherwise false.
+*/
+
+/*!
+ Returns true if the timer is running; otherwise false.
+*/
+bool QAlignedTimer::isActive () const
+{
+ return d->isActive();
+}
+
+QT_END_NAMESPACE
diff --git a/src/alignedtimer/qalignedtimer.h b/src/alignedtimer/qalignedtimer.h
new file mode 100644
index 0000000..1c94e08
--- /dev/null
+++ b/src/alignedtimer/qalignedtimer.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the alignedtimer module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QALIGNEDTIMER_H
+#define QALIGNEDTIMER_H
+
+#include <QObject>
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QAlignedTimerPrivate;
+
+class Q_CORE_EXPORT QAlignedTimer : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int minimumInterval READ minimumInterval WRITE setMinimumInterval)
+ Q_PROPERTY(int maximumInterval READ maximumInterval WRITE setMaximumInterval)
+ Q_PROPERTY(bool singleShot READ isSingleShot WRITE setSingleShot)
+ Q_PROPERTY(bool active READ isActive)
+
+public:
+ explicit QAlignedTimer(QObject *parent = 0);
+ ~QAlignedTimer();
+
+ enum AlignedTimerError {
+ NoError = 0,
+ AlignedTimerNotSupported,
+ InvalidArgument,
+ TimerFailed,
+ InternalError
+ };
+
+ Q_INVOKABLE void wokeUp();
+
+ int minimumInterval() const;
+ void setMinimumInterval(int seconds);
+
+ int maximumInterval() const;
+ void setMaximumInterval(int seconds);
+
+ void setSingleShot(bool single);
+ bool isSingleShot() const;
+
+ Q_INVOKABLE static void singleShot(int minimumTime, int maximumTime, QObject *receiver, const char *member);
+
+ AlignedTimerError lastError() const;
+ bool isActive () const;
+
+public Q_SLOTS:
+ void start(int minimumTime, int maximumTime);
+ void start();
+ void stop();
+
+Q_SIGNALS:
+ void timeout();
+
+private:
+ QAlignedTimerPrivate *d;
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif // QALIGNEDTIMER_H
diff --git a/src/alignedtimer/qalignedtimer_stub.cpp b/src/alignedtimer/qalignedtimer_stub.cpp
new file mode 100644
index 0000000..46ef949
--- /dev/null
+++ b/src/alignedtimer/qalignedtimer_stub.cpp
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the alignedtimer module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qalignedtimer.h"
+#include "qalignedtimer_stub_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QAlignedTimerPrivate::QAlignedTimerPrivate(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QAlignedTimerPrivate::~QAlignedTimerPrivate()
+{
+}
+
+void QAlignedTimerPrivate::wokeUp()
+{
+}
+
+int QAlignedTimerPrivate::minimumInterval() const
+{
+ return -1;
+}
+
+void QAlignedTimerPrivate::setMinimumInterval(int seconds)
+{
+ Q_UNUSED(seconds);
+}
+
+int QAlignedTimerPrivate::maximumInterval() const
+{
+ return -1;
+}
+
+void QAlignedTimerPrivate::setMaximumInterval(int seconds)
+{
+ Q_UNUSED(seconds);
+}
+
+void QAlignedTimerPrivate::setSingleShot(bool singleShot)
+{
+ Q_UNUSED(singleShot);
+}
+
+bool QAlignedTimerPrivate::isSingleShot() const
+{
+ return false;
+}
+
+void QAlignedTimerPrivate::singleShot(int minimumTime, int maximumTime, QObject *receiver, const char *member)
+{
+ Q_UNUSED(minimumTime);
+ Q_UNUSED(maximumTime);
+ Q_UNUSED(receiver);
+ Q_UNUSED(member);
+}
+
+QAlignedTimer::AlignedTimerError QAlignedTimerPrivate::lastError() const
+{
+ return QAlignedTimer::AlignedTimerNotSupported;
+}
+
+void QAlignedTimerPrivate::start(int minimumTime, int maximumTime)
+{
+ Q_UNUSED(minimumTime);
+ Q_UNUSED(maximumTime);
+}
+
+void QAlignedTimerPrivate::start()
+{
+}
+
+void QAlignedTimerPrivate::stop()
+{
+}
+
+bool QAlignedTimerPrivate::isActive () const
+{
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/alignedtimer/qalignedtimer_stub_p.h b/src/alignedtimer/qalignedtimer_stub_p.h
new file mode 100644
index 0000000..dc62c05
--- /dev/null
+++ b/src/alignedtimer/qalignedtimer_stub_p.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the alignedtimer module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QALIGNEDTIMER_STUB_P_H
+#define QALIGNEDTIMER_STUB_P_H
+
+#include "qalignedtimer.h"
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QAlignedTimerPrivate : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit QAlignedTimerPrivate(QObject *parent = 0);
+ ~QAlignedTimerPrivate();
+
+public:
+ void wokeUp();
+
+ int minimumInterval() const;
+ void setMinimumInterval(int seconds);
+
+ int maximumInterval() const;
+ void setMaximumInterval(int seconds);
+
+ bool isSingleShot() const;
+ void setSingleShot(bool singleShot);
+
+ static void singleShot(int minimumTime, int maximumTime, QObject *receiver, const char *member);
+ QAlignedTimer::AlignedTimerError lastError() const;
+ bool isActive() const;
+ QAlignedTimer::AlignedTimerError m_lastError;
+
+Q_SIGNALS:
+ void timeout();
+
+public Q_SLOTS:
+ void start(int minimumTime, int maximumTime);
+ void start();
+ void stop();
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif // QALIGNEDTIMER_STUB_P_H
diff --git a/src/alignedtimer/qalignedtimer_systemhb.cpp b/src/alignedtimer/qalignedtimer_systemhb.cpp
new file mode 100644
index 0000000..001a77d
--- /dev/null
+++ b/src/alignedtimer/qalignedtimer_systemhb.cpp
@@ -0,0 +1,231 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the alignedtimer module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qalignedtimer.h"
+#include "qalignedtimer_systemhb_p.h"
+#include <QDebug>
+
+#include <errno.h>
+#include <stdio.h>
+
+QT_BEGIN_NAMESPACE
+
+QAlignedTimerPrivate::QAlignedTimerPrivate(QObject *parent)
+ : QObject(parent)
+ , m_lastError(QAlignedTimer::NoError)
+ , m_minimumInterval(0)
+ , m_maximumInterval(0)
+ , m_running(false)
+ , m_singleShot(false)
+ , m_systemhbdHandler(0)
+ , m_notifier(0)
+{
+ m_systemhbdHandler = systemhb_open(0);
+
+ if (!m_systemhbdHandler) {
+ m_lastError = QAlignedTimer::InternalError;
+ qWarning() <<Q_FUNC_INFO <<"systemhb_open error" << m_systemhbdHandler<< errno <<strerror(errno);
+ return;
+ }
+
+ int sockfd = systemhb_get_fd(m_systemhbdHandler);
+ if (!(sockfd > -1)) {
+ m_lastError = QAlignedTimer::InternalError;
+ qWarning() <<Q_FUNC_INFO <<"socket failure"<<strerror(errno);
+ return;
+ }
+
+ m_notifier = new QSocketNotifier(sockfd, QSocketNotifier::Read);
+ if (!QObject::connect(m_notifier, SIGNAL(activated(int)), this, SLOT(heartbeatReceived(int)))) {
+ delete m_notifier, m_notifier = 0;
+ m_lastError = QAlignedTimer::TimerFailed;
+ qWarning()<<Q_FUNC_INFO <<"timer failed";
+ return;
+ }
+ m_notifier->setEnabled(false);
+}
+
+QAlignedTimerPrivate::~QAlignedTimerPrivate()
+{
+ if (m_systemhbdHandler)
+ (void)systemhb_close(m_systemhbdHandler);
+
+ if (m_notifier)
+ delete m_notifier;
+}
+
+void QAlignedTimerPrivate::wokeUp()
+{
+ if (!m_running)
+ return;
+
+ if (!(m_systemhbdHandler && m_notifier)) {
+ m_lastError = QAlignedTimer::InternalError;
+ qWarning()<<Q_FUNC_INFO <<"internal error occured";
+ return;
+ }
+
+ m_notifier->setEnabled(false);
+
+ (void)systemhb_I_woke_up(m_systemhbdHandler);
+
+ m_running = false;
+ m_lastError = QAlignedTimer::NoError;
+
+ if (!m_singleShot)
+ start();
+}
+
+int QAlignedTimerPrivate::minimumInterval() const
+{
+ return m_minimumInterval;
+}
+
+void QAlignedTimerPrivate::setMinimumInterval(int seconds)
+{
+ m_minimumInterval = seconds;
+}
+
+int QAlignedTimerPrivate::maximumInterval() const
+{
+ return m_maximumInterval;
+}
+
+void QAlignedTimerPrivate::setMaximumInterval(int seconds)
+{
+ m_maximumInterval = seconds;
+}
+
+void QAlignedTimerPrivate::setSingleShot(bool singleShot)
+{
+ m_singleShot = singleShot;
+}
+
+bool QAlignedTimerPrivate::isSingleShot() const
+{
+ return m_singleShot;
+}
+
+void QAlignedTimerPrivate::singleShot(int minimumTime, int maximumTime, QObject *receiver, const char *member)
+{
+ if (receiver && member) {
+ QAlignedTimerPrivate *alignedTimer = new QAlignedTimerPrivate(receiver);
+
+ alignedTimer->m_singleShot = true;
+
+ connect(alignedTimer, SIGNAL(timeout()), receiver, member);
+ alignedTimer->start(minimumTime, maximumTime);
+ }
+}
+
+QAlignedTimer::AlignedTimerError QAlignedTimerPrivate::lastError() const
+{
+ return m_lastError;
+}
+
+void QAlignedTimerPrivate::start(int minimumTime, int maximumTime)
+{
+ m_minimumInterval = minimumTime;
+ m_maximumInterval = maximumTime;
+
+ start();
+}
+
+void QAlignedTimerPrivate::start()
+{
+ if (m_running)
+ return;
+
+ if (!(m_systemhbdHandler && m_notifier)) {
+ m_lastError = QAlignedTimer::InternalError;
+ qWarning()<<Q_FUNC_INFO <<"internal error occured";
+ return;
+ }
+
+ int mustWait = 0;
+ time_t unixTime = systemhb_wait(m_systemhbdHandler, m_minimumInterval, m_maximumInterval, mustWait);
+
+ if (unixTime == (time_t)-1) {
+ m_lastError = QAlignedTimer::TimerFailed;
+ qWarning()<<Q_FUNC_INFO <<"Timer failed";
+ return;
+ }
+
+ m_notifier->setEnabled(true);
+ m_running = true;
+ m_lastError = QAlignedTimer::NoError;
+}
+
+void QAlignedTimerPrivate::stop()
+{
+ if (!m_running)
+ return;
+
+ if (!(m_systemhbdHandler && m_notifier)) {
+ m_lastError = QAlignedTimer::InternalError;
+ qWarning() <<Q_FUNC_INFO<< "systemhb_internal error";
+ return;
+ }
+
+ m_notifier->setEnabled(false);
+
+ (void)systemhb_discard_wakeups(m_systemhbdHandler);
+
+ m_running = false;
+ m_lastError = QAlignedTimer::NoError;
+}
+
+void QAlignedTimerPrivate::heartbeatReceived(int sock) {
+ Q_UNUSED(sock);
+
+ stop();
+ emit timeout();
+
+ if (!m_singleShot)
+ start();
+}
+
+bool QAlignedTimerPrivate::isActive() const
+{
+ return m_running;
+}
+
+QT_END_NAMESPACE
diff --git a/src/alignedtimer/qalignedtimer_systemhb_p.h b/src/alignedtimer/qalignedtimer_systemhb_p.h
new file mode 100644
index 0000000..f5f83e1
--- /dev/null
+++ b/src/alignedtimer/qalignedtimer_systemhb_p.h
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the alignedtimer module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QALIGNEDTIMER_SYSTEMHB_P_H
+#define QALIGNEDTIMER_SYSTEMHB_P_H
+
+#include "qalignedtimer.h"
+
+#include <QSocketNotifier>
+
+extern "C" {
+#include <systemhb/libsystemhb.h>
+}
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QAlignedTimerPrivate : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit QAlignedTimerPrivate(QObject *parent = 0);
+ ~QAlignedTimerPrivate();
+
+public:
+ void wokeUp();
+
+ int minimumInterval() const;
+ void setMinimumInterval(int seconds);
+
+ int maximumInterval() const;
+ void setMaximumInterval(int seconds);
+
+ bool isSingleShot() const;
+ void setSingleShot(bool singleShot);
+
+ static void singleShot(int minimumTime, int maximumTime, QObject *receiver, const char *member);
+ QAlignedTimer::AlignedTimerError lastError() const;
+
+ bool isActive() const;
+ QAlignedTimer::AlignedTimerError m_lastError;
+
+Q_SIGNALS:
+ void timeout();
+
+private:
+ int m_minimumInterval;
+ int m_maximumInterval;
+ bool m_running;
+ bool m_singleShot;
+ systemhb_t m_systemhbdHandler;
+ QSocketNotifier *m_notifier;
+
+public Q_SLOTS:
+ void start(int minimumTime, int maximumTime);
+ void start();
+ void stop();
+
+private Q_SLOTS:
+ void heartbeatReceived(int sock);
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif // QALIGNEDTIMER_SYSTEMHB_P_H
diff --git a/src/alignedtimer/qalignedtimerglobal.h b/src/alignedtimer/qalignedtimerglobal.h
new file mode 100644
index 0000000..22dbb0c
--- /dev/null
+++ b/src/alignedtimer/qalignedtimerglobal.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the alignedtimer module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTALIGNEDTIMERGLOBAL_H
+#define QTALIGNEDTIMERGLOBAL_H
+
+#include <QtCore/qglobal.h>
+
+#if defined(QT_NAMESPACE)
+# define QTALIGNEDTIMER_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::QtAlignedTimer::name
+# define QTALIGNEDTIMER_BEGIN_NAMESPACE namespace QT_NAMESPACE { namespace QtAlignedTimer {
+# define QTALIGNEDTIMER_END_NAMESPACE } }
+# define QTALIGNEDTIMER_USE_NAMESPACE using namespace QT_NAMESPACE; using namespace QtAlignedTimer;
+#else
+# define QTALIGNEDTIMER_PREPEND_NAMESPACE(name) ::QtAlignedTimer::name
+# define QTALIGNEDTIMER_BEGIN_NAMESPACE namespace QtAlignedTimer {
+# define QTALIGNEDTIMER_END_NAMESPACE }
+# define QTALIGNEDTIMER_USE_NAMESPACE using namespace QtAlignedTimer;
+#endif
+
+#define QTALIGNEDTIMER_VERSION_NAME "org.qt-project.Qt.alignedtimer.api.version"
+#define QTALIGNEDTIMER_IMPLEMENTATION_VERSION_NAME "org.qt-project.Qt.alignedtimer.implementation.version"
+#define QTALIGNEDTIMER_VERSION 1
+
+#endif
diff --git a/src/src.pro b/src/src.pro
new file mode 100644
index 0000000..2c0adbb
--- /dev/null
+++ b/src/src.pro
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+CONFIG += ordered
+SUBDIRS = alignedtimer
diff --git a/sync.profile b/sync.profile
new file mode 100644
index 0000000..c27af74
--- /dev/null
+++ b/sync.profile
@@ -0,0 +1,24 @@
+%modules = ( # path to module name map
+ "QtAlignedTimer" => "$basedir/src/alignedtimer",
+);
+%moduleheaders = ( # restrict the module headers to those found in relative path
+);
+%classnames = (
+ "qtalignedtimerversion.h" => "QtAlignedTimerVersion",
+);
+%mastercontent = (
+ "alignedtimer" => "#include <QtAlignedTimer/QtAlignedTimer>\n",
+);
+%modulepris = (
+ "QtAlignedTimer" => "$basedir/modules/qt_alignedtimer.pri",
+);
+# Module dependencies.
+# Every module that is required to build this module should have one entry.
+# Each of the module version specifiers can take one of the following values:
+# - A specific Git revision.
+# - any git symbolic ref resolvable from the module's repository (e.g. "refs/heads/master" to track master branch)
+#
+%dependencies = (
+ "qtbase" => "refs/heads/master",
+);
+
diff --git a/tests/auto/alignedtimer/alignedtimer.pro b/tests/auto/alignedtimer/alignedtimer.pro
new file mode 100644
index 0000000..7cb543e
--- /dev/null
+++ b/tests/auto/alignedtimer/alignedtimer.pro
@@ -0,0 +1,5 @@
+include(../auto.pri)
+
+QT += alignedtimer
+
+SOURCES += tst_qalignedtimer.cpp
diff --git a/tests/auto/alignedtimer/tst_qalignedtimer.cpp b/tests/auto/alignedtimer/tst_qalignedtimer.cpp
new file mode 100644
index 0000000..be15647
--- /dev/null
+++ b/tests/auto/alignedtimer/tst_qalignedtimer.cpp
@@ -0,0 +1,283 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <qalignedtimer.h>
+
+Q_DECLARE_METATYPE(QAlignedTimer::AlignedTimerError);
+
+static bool waitForSignal(QObject *obj, const char *signal, int timeout = 0)
+{
+ QEventLoop loop;
+ QObject::connect(obj, signal, &loop, SLOT(quit()));
+ QTimer timer;
+ QSignalSpy timeoutSpy(&timer, SIGNAL(timeout()));
+ if (timeout > 0) {
+ QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+ timer.setSingleShot(true);
+ timer.start(timeout);
+ }
+ loop.exec();
+ return timeoutSpy.isEmpty();
+}
+
+class tst_QAlignedTimer : public QObject
+{
+
+ Q_OBJECT
+
+public:
+ tst_QAlignedTimer();
+ virtual ~tst_QAlignedTimer();
+
+private slots:
+ void initTestCase();
+
+ void tst_wokeUp();
+
+ void tst_minimumInterval();
+ void tst_maximumInterval();
+
+ void tst_setSingleShot();
+ void tst_isSingleShot() ;
+
+ void tst_singleShot();
+
+ void tst_lastError();
+
+ void tst_start();
+ void tst_stop();
+
+public Q_SLOTS:
+ void timeout();
+
+private:
+ QAlignedTimer alignedtime2r;
+
+};
+
+tst_QAlignedTimer::tst_QAlignedTimer()
+{
+}
+
+tst_QAlignedTimer::~tst_QAlignedTimer()
+{
+}
+
+void tst_QAlignedTimer::initTestCase()
+{
+ qRegisterMetaType<QAlignedTimer::AlignedTimerError>("QAlignedTimer::AlignedTimerError");
+}
+
+void tst_QAlignedTimer::tst_wokeUp()
+{
+ QAlignedTimer alignedtimer;
+ if (alignedtimer.lastError() == QAlignedTimer::AlignedTimerNotSupported) {
+ QSKIP("This test not supported on this platform");
+ }
+ alignedtimer.setSingleShot(true);
+ alignedtimer.start(8,10);
+
+ QVERIFY(alignedtimer.isActive());
+
+ alignedtimer.wokeUp();
+ QVERIFY(!alignedtimer.isActive());
+}
+
+void tst_QAlignedTimer::tst_minimumInterval()
+{
+ QAlignedTimer alignedtimer;
+ if (alignedtimer.lastError() == QAlignedTimer::AlignedTimerNotSupported) {
+ QSKIP("This test not supported on this platform");
+ }
+ alignedtimer.setMinimumInterval(0);
+ QVERIFY(alignedtimer.minimumInterval() == 0);
+ alignedtimer.setMinimumInterval(10);
+ QVERIFY(alignedtimer.minimumInterval() == 10);
+
+ alignedtimer.setMinimumInterval(-1);
+ alignedtimer.start();
+ QVERIFY(alignedtimer.lastError() == QAlignedTimer::InvalidArgument);
+}
+
+void tst_QAlignedTimer::tst_maximumInterval()
+{
+
+ QAlignedTimer alignedtimer;
+ if (alignedtimer.lastError() == QAlignedTimer::AlignedTimerNotSupported) {
+ QSKIP("This test not supported on this platform");
+ }
+
+ alignedtimer.setMinimumInterval(0);
+ alignedtimer.setMaximumInterval(0);
+ QVERIFY(alignedtimer.maximumInterval() == 0);
+
+ alignedtimer.setMaximumInterval(11);
+ QVERIFY(alignedtimer.maximumInterval() == 11);
+
+ alignedtimer.setMaximumInterval(-1);
+ alignedtimer.start();
+ QVERIFY(alignedtimer.lastError() == QAlignedTimer::InvalidArgument);
+}
+
+void tst_QAlignedTimer::tst_setSingleShot()
+{
+ QAlignedTimer alignedtimer;
+ if (alignedtimer.lastError() == QAlignedTimer::AlignedTimerNotSupported) {
+ QSKIP("This test not supported on this platform");
+ }
+ alignedtimer.setSingleShot(true);
+ QVERIFY(alignedtimer.isSingleShot());
+ alignedtimer.setSingleShot(false);
+ QVERIFY(!alignedtimer.isSingleShot());
+}
+
+void tst_QAlignedTimer::tst_isSingleShot()
+{
+ QAlignedTimer alignedtimer;
+ if (alignedtimer.lastError() == QAlignedTimer::AlignedTimerNotSupported) {
+ QSKIP("This test not supported on this platform");
+ }
+ alignedtimer.setSingleShot(true);
+ QVERIFY(alignedtimer.isSingleShot());
+ alignedtimer.setSingleShot(false);
+ QVERIFY(!alignedtimer.isSingleShot());
+}
+
+void tst_QAlignedTimer::tst_singleShot()
+{
+ QAlignedTimer alignedtimer;
+ if (alignedtimer.lastError() == QAlignedTimer::AlignedTimerNotSupported) {
+ QSKIP("This test not supported on this platform");
+ }
+
+ alignedtimer.setSingleShot(true);
+ alignedtimer.start(2,3);
+ QVERIFY(alignedtimer.isActive());
+ QVERIFY(::waitForSignal(&alignedtimer, SIGNAL(timeout()), 4 * 1000));
+ QVERIFY(!alignedtimer.isActive());
+
+ alignedtimer.setSingleShot(false);
+ alignedtimer.start(2,3);
+ QVERIFY(alignedtimer.isActive());
+ QVERIFY(::waitForSignal(&alignedtimer, SIGNAL(timeout()), 4 * 1000));
+ QVERIFY(alignedtimer.isActive());
+}
+
+void tst_QAlignedTimer::tst_lastError()
+{
+ QAlignedTimer alignedtimer;
+ if (alignedtimer.lastError() == QAlignedTimer::AlignedTimerNotSupported) {
+ QSKIP("This test not supported on this platform");
+ }
+}
+
+void tst_QAlignedTimer::tst_start()
+{
+ QAlignedTimer alignedtimer;
+ if (alignedtimer.lastError() == QAlignedTimer::AlignedTimerNotSupported) {
+ QSKIP("This test not supported on this platform");
+ }
+
+
+ alignedtimer.start(8,10);
+ QVERIFY(alignedtimer.isActive());
+ alignedtimer.stop();
+ alignedtimer.setMinimumInterval(8);
+ alignedtimer.setMaximumInterval(10);
+ alignedtimer.start();
+ QVERIFY(alignedtimer.isActive());
+
+ alignedtime2r.start(2,3);
+ QVERIFY(alignedtime2r.isActive());
+ QVERIFY(::waitForSignal(&alignedtime2r, SIGNAL(timeout()), 5 * 1000));
+ QVERIFY(alignedtime2r.isActive());
+
+ QAlignedTimer alignedtimer2;
+ alignedtimer2.setMinimumInterval(11);
+ alignedtimer2.setMaximumInterval(10);
+ alignedtimer2.start();
+ QVERIFY(alignedtimer2.lastError() == QAlignedTimer::InvalidArgument);
+ QVERIFY(!alignedtimer2.isActive());
+
+ QAlignedTimer alignedtimer3;
+ alignedtimer3.start(11,10);
+ QVERIFY(alignedtimer3.lastError() == QAlignedTimer::InvalidArgument);
+ QVERIFY(!alignedtimer3.isActive());
+
+ QAlignedTimer alignedtimer4;
+ alignedtimer4.start(10,0);
+ QVERIFY(alignedtimer4.lastError() == QAlignedTimer::InvalidArgument);
+ QVERIFY(!alignedtimer4.isActive());
+
+}
+
+void tst_QAlignedTimer::tst_stop()
+{
+ QAlignedTimer alignedtimer;
+ if (alignedtimer.lastError() == QAlignedTimer::AlignedTimerNotSupported) {
+ QSKIP("This test not supported on this platform");
+ }
+ alignedtimer.start(8,10);
+ alignedtimer.stop();
+ QVERIFY(!alignedtimer.isActive());
+
+ alignedtimer.start();
+ alignedtimer.stop();
+ QVERIFY(!alignedtimer.isActive());
+
+ alignedtimer.setSingleShot(true);
+ alignedtimer.start();
+ alignedtimer.stop();
+ QVERIFY(!alignedtimer.isActive());
+
+ alignedtimer.start();
+ alignedtimer.stop();
+ QVERIFY(!alignedtimer.isActive());
+}
+
+void tst_QAlignedTimer::timeout()
+{
+ QVERIFY(!alignedtime2r.isActive());
+}
+
+QTEST_MAIN(tst_QAlignedTimer)
+#include "tst_qalignedtimer.moc"
diff --git a/tests/auto/auto.pri b/tests/auto/auto.pri
new file mode 100644
index 0000000..4ca3b5a
--- /dev/null
+++ b/tests/auto/auto.pri
@@ -0,0 +1,5 @@
+TEMPLATE = app
+CONFIG += qt warn_on console depend_includepath testcase
+
+qtAddLibrary(QtTest)
+
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
new file mode 100644
index 0000000..8192a1c
--- /dev/null
+++ b/tests/auto/auto.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+ alignedtimer
diff --git a/tests/tests.pro b/tests/tests.pro
new file mode 100644
index 0000000..157ef34
--- /dev/null
+++ b/tests/tests.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += auto