File indexing completed on 2024-04-28 11:33:57
0001 /* 0002 This file is part of the kcalcore library. 0003 0004 SPDX-FileCopyrightText: 2003 Cornelius Schumacher <schumacher@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #include "filestorage.h" 0010 #include "memorycalendar.h" 0011 0012 #include <QCommandLineParser> 0013 #include <QCoreApplication> 0014 #include <QDebug> 0015 #include <QTimeZone> 0016 0017 using namespace KCalendarCore; 0018 0019 int main(int argc, char **argv) 0020 { 0021 QCommandLineParser parser; 0022 parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("verbose"), QStringLiteral("Verbose output"))); 0023 0024 QCoreApplication app(argc, argv); 0025 QCoreApplication::setApplicationName(QStringLiteral("testincidence")); 0026 QCoreApplication::setApplicationVersion(QStringLiteral("0.1")); 0027 parser.process(app); 0028 0029 MemoryCalendar::Ptr cal(new MemoryCalendar(QTimeZone::utc())); 0030 FileStorage store(cal, QStringLiteral("cal")); 0031 if (!store.load()) { 0032 qWarning() << "Error storing into memory calendar"; 0033 return 1; 0034 } 0035 0036 Todo::List todoList; 0037 0038 // Build dictionary to look up Task object from Todo uid. Each task is a 0039 // QListViewItem, and is initially added with the view as the parent. 0040 todoList = cal->rawTodos(); 0041 0042 if (todoList.isEmpty()) { 0043 qWarning() << "Error loading calendar"; 0044 return 1; 0045 } 0046 0047 qDebug() << (*todoList.begin())->uid(); 0048 QString result = (*todoList.begin())->customProperty(QByteArray("karm"), QByteArray("totalTaskTime")); 0049 qDebug() << result; 0050 if (result != QLatin1String("a,b")) { 0051 qDebug() << "The string a,b was expected, but given was" << result; 0052 return 1; 0053 } else { 0054 qDebug() << "Test passed"; 0055 } 0056 }