/*
* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd.
*
* Author:     leilong  <leilong@uniontech.com>
*
* Maintainer: leilong  <leilong@uniontech.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#include "test_cpushbutton.h"

test_cpushbutton::test_cpushbutton(QObject *parent) : QObject(parent)
{

}

TEST_F(test_cpushbutton, setHighlight_001)
{
    mWidget->setHighlight(true);
    EXPECT_TRUE(mWidget->m_Highlighted);
}

TEST_F(test_cpushbutton, setHighlight_002)
{
    mWidget->setHighlight(false);
    EXPECT_FALSE(mWidget->m_Highlighted);
}

TEST_F(test_cpushbutton, isHighlight_001)
{
    mWidget->setHighlight(true);
    EXPECT_TRUE(mWidget->isHighlight());
}

TEST_F(test_cpushbutton, isHighlight_002)
{
    mWidget->setHighlight(false);
    EXPECT_FALSE(mWidget->isHighlight());
}

TEST_F(test_cpushbutton, mousePressEvent_001)
{
    QMouseEvent *e = new QMouseEvent(QEvent::MouseMove, QPointF(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
    mWidget->mousePressEvent(e);
    EXPECT_TRUE(mWidget->m_pressed);
    delete e;
}

TEST_F(test_cpushbutton, mouseReleaseEvent_001)
{
    QMouseEvent *e = new QMouseEvent(QEvent::MouseMove, QPointF(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
    mWidget->mouseReleaseEvent(e);
    EXPECT_FALSE(mWidget->m_pressed);
    delete e;
}

TEST_F(test_cpushbutton, paintEvent_001)
{
    QPaintEvent *e = new QPaintEvent(QRect());
    mWidget->setHighlight(true);
    mWidget->paintEvent(e);
    delete e;
}

TEST_F(test_cpushbutton, paintEvent_002)
{
    QPaintEvent *e = new QPaintEvent(QRect());
    mWidget->setHighlight(false);
    mWidget->paintEvent(e);
    delete e;
}
