diff --git a/doc/images/state-based-rule.odg b/doc/images/state-based-rule.odg new file mode 100644 index 00000000..386c3cff Binary files /dev/null and b/doc/images/state-based-rule.odg differ diff --git a/plugins/guh-generateplugininfo b/plugins/guh-generateplugininfo index ac17ddc7..e4a2b001 100755 --- a/plugins/guh-generateplugininfo +++ b/plugins/guh-generateplugininfo @@ -4,16 +4,16 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# Copyright (C) 2015 Simon Stuerz # +# Copyright (C) 2015-2016 Simon Stuerz # # Copyright (C) 2014 Michael Zanetti # # # -# This file is part of guh-cli. # +# This file is part of guh. # # # -# guh-cli is free software: you can redistribute it and/or modify # +# guh is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation, version 2 of the License. # # # -# guh-cli is distributed in the hope that it will be useful, # +# guh is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # diff --git a/server/time/calendaritem.cpp b/server/time/calendaritem.cpp index 13254021..df5cb27c 100644 --- a/server/time/calendaritem.cpp +++ b/server/time/calendaritem.cpp @@ -198,7 +198,6 @@ bool CalendarItem::evaluateWeekly(const QDateTime &dateTime) const // and end of this calendar item from the previouse week return true; - } else if (dateTime >= startDateTime && dateTime < endDateTime) { // Return true if the current time is between start // and end of this calendar item diff --git a/server/time/timemanager.cpp b/server/time/timemanager.cpp index ce42516c..479cf28f 100644 --- a/server/time/timemanager.cpp +++ b/server/time/timemanager.cpp @@ -24,7 +24,6 @@ \ingroup rules \inmodule core - */ /*! \fn void guhserver::TimeManager::tick() @@ -70,12 +69,12 @@ QByteArray TimeManager::timeZone() const return m_timeZone.id(); } -/*! Sets the \a timeZone of this \l{TimeManager}. */ +/*! Sets the \a timeZone of this \l{TimeManager}. Allowed values according to the \l{http://www.iana.org/time-zones}{IANA database}. */ void TimeManager::setTimeZone(const QByteArray &timeZone) { if (!QTimeZone(timeZone).isValid()) { qCWarning(dcTimeManager()) << "Invalid time zone" << timeZone; - qCWarning(dcTimeManager()) << "Using default system timezone" << QTimeZone::systemTimeZoneId(); + qCWarning(dcTimeManager()) << "Using system time zone" << QTimeZone::systemTimeZoneId(); m_timeZone = QTimeZone(QTimeZone::systemTimeZoneId()); } else { qCDebug(dcTimeManager()) << "Set time zone" << timeZone; @@ -107,7 +106,6 @@ void TimeManager::guhTimeout() emit tick(); QDateTime currentDateTime = QDateTime::currentDateTimeUtc(); - //qCDebug(dcTimeManager) << "Time changed" << currentDateTime.toTimeZone(m_timeZone).time().toString("hh:mm:ss"); // Minute based guh time if (m_dateTime.time().minute() != currentDateTime.toTimeZone(m_timeZone).time().minute()) { diff --git a/server/time/timemanager.h b/server/time/timemanager.h index 26322857..3f730efe 100644 --- a/server/time/timemanager.h +++ b/server/time/timemanager.h @@ -51,7 +51,6 @@ signals: void dateChanged(const QDate ¤tDate); void timeChanged(const QTime ¤tTime); - private slots: void guhTimeout(); diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 523016d7..e6e59d47 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -17,5 +17,5 @@ SUBDIRS = versioning \ websocketserver \ logging \ restlogging \ - coap \ + timemanager \ diff --git a/tests/auto/timemanager/testtimemanager.cpp b/tests/auto/timemanager/testtimemanager.cpp new file mode 100644 index 00000000..7f9feb26 --- /dev/null +++ b/tests/auto/timemanager/testtimemanager.cpp @@ -0,0 +1,86 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * + * Copyright (C) 2015 Simon Stuerz * + * Copyright (C) 2014 Michael Zanetti * + * * + * This file is part of guh. * + * * + * Guh is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, version 2 of the License. * + * * + * Guh is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with guh. If not, see . * + * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include "guhtestbase.h" +#include "guhcore.h" +#include "time/timemanager.h" +#include "devicemanager.h" +#include "mocktcpserver.h" + +#include +#include +#include +#include + +using namespace guhserver; + +class TestTimeManager: public GuhTestBase +{ + Q_OBJECT + +private slots: + void changeTimeZone_data(); + void changeTimeZone(); + +}; + + + + +void TestTimeManager::changeTimeZone_data() +{ + QTest::addColumn("timeZoneId"); + QTest::addColumn("valid"); + + QTest::newRow("valid timezone: Asia/Tokyo") << QByteArray("Asia/Tokyo") << true; + QTest::newRow("valid timezone: America/Lima") << QByteArray("America/Lima") << true; + QTest::newRow("valid timezone: Africa/Harare") << QByteArray("Africa/Harare") << true; + QTest::newRow("invalid timezone: Mars/Diacria") << QByteArray("Mars/Diacria") << false; + QTest::newRow("invalid timezone: Moon/Kepler") << QByteArray("Moon/Kepler") << false; +} + +void TestTimeManager::changeTimeZone() +{ + QFETCH(QByteArray, timeZoneId); + QFETCH(bool, valid); + + QTimeZone currentTimeZone(GuhCore::instance()->timeManager()->timeZone()); + QTimeZone newTimeZone(timeZoneId); + + + QDateTime currentDateTime = GuhCore::instance()->timeManager()->currentDateTime(); + qDebug() << currentDateTime.toString(); + + GuhCore::instance()->timeManager()->setTimeZone(timeZoneId); + + QDateTime newDateTime = GuhCore::instance()->timeManager()->currentDateTime(); + qDebug() << newDateTime.toString(); + + int offsetOriginal = currentTimeZone.offsetFromUtc(currentDateTime); + int offsetNew = newTimeZone.offsetFromUtc(newDateTime); + + if (valid) + QVERIFY(offsetOriginal != offsetNew); + +} + +#include "testtimemanager.moc" +QTEST_MAIN(TestTimeManager) diff --git a/tests/auto/timemanager/timemanager.pro b/tests/auto/timemanager/timemanager.pro new file mode 100644 index 00000000..d8d26188 --- /dev/null +++ b/tests/auto/timemanager/timemanager.pro @@ -0,0 +1,6 @@ +TARGET = testtimemanager + +include(../../../guh.pri) +include(../autotests.pri) + +SOURCES += testtimemanager.cpp