/*
* Copyright (C) 2019 ~ 2026 Deepin Technology Co., Ltd.
*
* Author:     xiepengfei <xiepengfei@uniontech.com>
* Maintainer: xiepengfei <xiepengfei@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.
*/

#include "indexdotswidget.h"

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

class ut_indexdotswidget_test : public ::testing::Test
{
protected:
    void SetUp() override;
    void TearDown() override;

    IndexDotsWidget *m_widget = nullptr;
};

void ut_indexdotswidget_test::SetUp()
{
    m_widget = new IndexDotsWidget(5);
}

void ut_indexdotswidget_test::TearDown()
{
    if (m_widget) {
        delete m_widget;
        m_widget = nullptr;
    }
}

TEST_F(ut_indexdotswidget_test, constructor)
{
    ASSERT_TRUE(m_widget != nullptr);
}

TEST_F(ut_indexdotswidget_test, setCurrentIndex)
{
    m_widget->setCurrentIndex(2);
    EXPECT_EQ(m_widget->m_index, 2);
    m_widget->setCurrentIndex(0);
    EXPECT_EQ(m_widget->m_index, 0);
}

TEST_F(ut_indexdotswidget_test, paintEvent)
{
    { QPaintEvent e(m_widget->rect()); m_widget->paintEvent(&e); }
}

TEST_F(ut_indexdotswidget_test, paintEventSelectedMiddle)
{
    m_widget->setCurrentIndex(3);
    { QPaintEvent e(m_widget->rect()); m_widget->paintEvent(&e); }
}
