File: drivetestutils.cpp

package info (click to toggle)
libkgapi 25.08.3-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 (64 lines) | stat: -rw-r--r-- 1,538 bytes parent folder | download | duplicates (3)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 * 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 "about.h"
#include "change.h"
#include "drives.h"
#include "file.h"
#include "teamdrive.h"
#include "testutils.h"

#include <QFile>

KGAPI2::Drive::AboutPtr aboutFromFile(const QString &path)
{
    QFile f(path);
    VERIFY_RET(f.open(QIODevice::ReadOnly), {});

    auto about = KGAPI2::Drive::About::fromJSON(f.readAll());
    VERIFY_RET(about, {});
    return about;
}

KGAPI2::Drive::ChangePtr changeFromFile(const QString &path)
{
    QFile f(path);
    VERIFY_RET(f.open(QIODevice::ReadOnly), {});

    auto change = KGAPI2::Drive::Change::fromJSON(f.readAll());
    VERIFY_RET(change, {});
    return change;
}

KGAPI2::Drive::FilePtr fileFromFile(const QString &path)
{
    QFile f(path);
    VERIFY_RET(f.open(QIODevice::ReadOnly), {});

    auto file = KGAPI2::Drive::File::fromJSON(f.readAll());
    VERIFY_RET(file, {});
    return file;
}

KGAPI2::Drive::DrivesPtr drivesFromFile(const QString &path)
{
    QFile f(path);
    VERIFY_RET(f.open(QIODevice::ReadOnly), {});

    auto drives = KGAPI2::Drive::Drives::fromJSON(f.readAll());
    VERIFY_RET(drives, {});
    return drives;
}

KGAPI2::Drive::TeamdrivePtr teamdriveFromFile(const QString &path)
{
    QFile f(path);
    VERIFY_RET(f.open(QIODevice::ReadOnly), {});

    auto teamdrive = KGAPI2::Drive::Teamdrive::fromJSON(f.readAll());
    VERIFY_RET(teamdrive, {});
    return teamdrive;
}