File: ut_ddbusinterface.cpp

package info (click to toggle)
dtkcore 5.7.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,728 kB
  • sloc: cpp: 22,021; ansic: 183; python: 68; xml: 58; makefile: 27; sh: 15
file content (52 lines) | stat: -rw-r--r-- 1,624 bytes parent folder | download
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
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include <gtest/gtest.h>
#include <ddbusinterface.h>

#include "fakedbus/fakedbusservice.h"
#include <QTest>
#include <QSignalSpy>

using Dtk::Core::DDBusInterface;

class ut_DDBusInterface : public testing::Test
{
public:
    void SetUp() override
    {
        m_testservice = new FakeDBusService();
        m_testDBusInterfaceParent = new FakeDBusServiceParent();
        // if parent is nullptr
        m_testInterface = new DDBusInterface(FakeDBusService::get_service(),
                                             FakeDBusService::get_path(),
                                             FakeDBusService::get_interface(),
                                             QDBusConnection::sessionBus());
    }
    void TearDown() override
    {
        delete m_testDBusInterfaceParent;
        delete m_testInterface;
        delete m_testservice;
    }
    DDBusInterface *m_testInterface;
    FakeDBusService *m_testservice;
    FakeDBusServiceParent *m_testDBusInterfaceParent;
};

TEST_F(ut_DDBusInterface, TestProperty)
{
    auto objectpaths = m_testservice->objectpaths();
    EXPECT_EQ(m_testDBusInterfaceParent->objectpaths().length(), objectpaths.length());

    auto strproperty = qvariant_cast<QString>(m_testInterface->property("strProperty"));
    EXPECT_EQ(strproperty, m_testservice->strproperty());
}

TEST_F(ut_DDBusInterface, suffix)
{
    EXPECT_EQ(m_testInterface->suffix(), "");
    m_testInterface->setSuffix("-suffix");
    EXPECT_EQ(m_testInterface->suffix(), "-suffix");
}