зеркало из https://github.com/nextcloud/desktop.git
Add simple test for basic. default date properties of DateFieldBackend
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Родитель
797663eb17
Коммит
a4767a108b
|
@ -17,6 +17,8 @@
|
|||
#include <QDate>
|
||||
#include <QObject>
|
||||
|
||||
class TestDateFieldBackend;
|
||||
|
||||
namespace OCC
|
||||
{
|
||||
namespace Quick
|
||||
|
@ -78,6 +80,8 @@ signals:
|
|||
void validDateChanged();
|
||||
|
||||
private:
|
||||
friend class ::TestDateFieldBackend;
|
||||
|
||||
QDate _date = QDate::currentDate();
|
||||
QDate _minimumDate;
|
||||
QDate _maximumDate;
|
||||
|
@ -87,4 +91,4 @@ private:
|
|||
};
|
||||
|
||||
} // namespace Quick
|
||||
} // namespace OCC
|
||||
} // namespace OCC
|
||||
|
|
|
@ -22,4 +22,24 @@ using namespace OCC;
|
|||
class TestDateFieldBackend : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
}
|
||||
|
||||
private slots:
|
||||
void testDefaultBehaviour()
|
||||
{
|
||||
constexpr auto dateStringFormat = "dd/MM/yyyy";
|
||||
|
||||
Quick::DateFieldBackend backend;
|
||||
backend._dateFormat = dateStringFormat;
|
||||
|
||||
const auto currentDate = QDate::currentDate();
|
||||
const auto currentDateMSecs = currentDate.startOfDay(Qt::UTC).toMSecsSinceEpoch();
|
||||
const auto currentDateString = currentDate.toString(dateStringFormat);
|
||||
|
||||
QCOMPARE(backend.date(), currentDate);
|
||||
QCOMPARE(backend.dateMsecs(), currentDateMSecs);
|
||||
QCOMPARE(backend.dateString(), currentDateString);
|
||||
}
|
||||
};
|
||||
|
||||
QTEST_MAIN(TestDateFieldBackend)
|
||||
#include "testdatefieldbackend.moc"
|
||||
|
|
Загрузка…
Ссылка в новой задаче