#include <gtest/gtest.h>
#include <gtest/gtest-death-test.h>
#include <QDBusReply>
#include "../../registeredSession/plugins/about/aboutinterface.h"
#include "stubext.h"

using namespace stub_ext;

class AboutInterfaceTest : public testing::Test
{
protected:
    static void SetUpTestSuite()
    {
        m_pAboutInterface = new AboutInterface();
	m_pAboutDbus = new QDBusInterface("org.ukui.ukcc.session",
			"/About",
			"org.ukui.ukcc.session.About",
                        QDBusConnection::sessionBus());
    }

    static void TearDownTestSuite()
    {
	if (m_pAboutInterface) {
            delete m_pAboutInterface;
            m_pAboutInterface = nullptr;
	}
	if (m_pAboutInterface) {
	    delete m_pAboutInterface;
	    m_pAboutInterface = nullptr;
	}
    }

    static AboutInterface *m_pAboutInterface;
    static QDBusInterface* m_pAboutDbus;
};

AboutInterface *AboutInterfaceTest::m_pAboutInterface = nullptr;
QDBusInterface *AboutInterfaceTest::m_pAboutDbus =  nullptr;

TEST_F(AboutInterfaceTest, openActivation)
{
    if (!m_pAboutDbus || !m_pAboutDbus->isValid()) {
       return;
    }
    QDBusReply<bool> ret = m_pAboutDbus->call("openActivation");
    if (ret.isValid()) {
    	ASSERT_EQ(ret.value(), true);
    }
}
