File indexing completed on 2024-04-14 03:50:34
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 #include <stdlib.h> 0018 0019 using namespace KCalendarCore; 0020 0021 int main(int argc, char **argv) 0022 { 0023 QCommandLineParser parser; 0024 parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("verbose"), QStringLiteral("Verbose output"))); 0025 0026 QCoreApplication app(argc, argv); 0027 QCoreApplication::setApplicationName(QStringLiteral("testincidence")); 0028 QCoreApplication::setApplicationVersion(QStringLiteral("0.1")); 0029 parser.process(app); 0030 0031 MemoryCalendar::Ptr cal(new MemoryCalendar(QTimeZone::utc())); 0032 FileStorage store(cal, QStringLiteral("cal")); 0033 if (!store.load()) { 0034 qWarning() << "Error storing into memory calendar"; 0035 return EXIT_FAILURE; 0036 } 0037 0038 Todo::List todoList; 0039 0040 // Build dictionary to look up Task object from Todo uid. Each task is a 0041 // QListViewItem, and is initially added with the view as the parent. 0042 todoList = cal->rawTodos(); 0043 0044 if (todoList.isEmpty()) { 0045 qWarning() << "Error loading calendar"; 0046 return EXIT_FAILURE; 0047 } 0048 0049 qDebug() << (*todoList.begin())->uid(); 0050 QString result = (*todoList.begin())->customProperty(QByteArray("karm"), QByteArray("totalTaskTime")); 0051 qDebug() << result; 0052 if (result != QLatin1String("a,b")) { 0053 qDebug() << "The string a,b was expected, but given was" << result; 0054 return EXIT_FAILURE; 0055 } else { 0056 qDebug() << "Test passed"; 0057 } 0058 return EXIT_SUCCESS; 0059 }