File: calendartestutils.cpp

package info (click to toggle)
libkgapi 25.12.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,408 kB
  • sloc: cpp: 37,386; ansic: 977; python: 671; xml: 58; makefile: 16; sh: 1
file content (31 lines) | stat: -rw-r--r-- 764 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 * SPDX-FileCopyrightText: 2018 Daniel Vrátil <dvratil@kde.org>
 *
 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
 */

#include "calendartestutils.h"
#include "calendarservice.h"
#include "testutils.h"

#include <QFile>

KGAPI2::CalendarPtr calendarFromFile(const QString &path)
{
    QFile f(path);
    VERIFY_RET(f.open(QIODevice::ReadOnly), {});

    auto calendar = KGAPI2::CalendarService::JSONToCalendar(f.readAll());
    VERIFY_RET(calendar, {});
    return calendar;
}

KGAPI2::EventPtr eventFromFile(const QString &path)
{
    QFile f(path);
    VERIFY_RET(f.open(QIODevice::ReadOnly), {});

    auto event = KGAPI2::CalendarService::JSONToEvent(f.readAll());
    VERIFY_RET(event, {});
    return event;
}