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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
// SPDX-FileCopyrightText: 2021 - 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#include <gtest/gtest.h>
#include "dbuttonbox.h"
DWIDGET_USE_NAMESPACE
class ut_DButtonBox : public testing::Test
{
protected:
void SetUp() override
{
target = new DButtonBox();
}
void TearDown() override
{
if (target) {
delete target;
target = nullptr;
}
}
DButtonBox *target = nullptr;
};
TEST_F(ut_DButtonBox, setButtonList)
{
QList<DButtonBoxButton*> buttons;
buttons.push_back(new DButtonBoxButton("DButtonBoxButton"));
target->setButtonList(buttons, true);
ASSERT_EQ(target->buttonList().size(), buttons.size());
qDeleteAll(buttons);
};
TEST_F(ut_DButtonBox, setId)
{
auto btn = new DButtonBoxButton("DButtonBoxButton");
target->setId(btn, 1);
ASSERT_EQ(target->id(btn), 1);
ASSERT_EQ(target->button(1), btn);
btn->deleteLater();
};
TEST_F(ut_DButtonBox, setOrientation)
{
target->setOrientation(Qt::Horizontal);
ASSERT_EQ(target->orientation(), Qt::Horizontal);
};
class ut_DButtonBoxButton : public testing::Test
{
protected:
void SetUp() override
{
target = new DButtonBoxButton("DButtonBoxButton");
}
void TearDown() override
{
if (target) {
delete target;
target = nullptr;
}
}
DButtonBoxButton *target = nullptr;
};
TEST_F(ut_DButtonBoxButton, iconSize)
{
target->setIconSize(QSize(10, 10));
ASSERT_EQ(target->iconSize(), QSize(10, 10));
};
TEST_F(ut_DButtonBoxButton, minimumSizeHint)
{
target->minimumSizeHint();
};
TEST_F(ut_DButtonBoxButton, setIcon)
{
target->setIcon(QIcon::fromTheme("preferences-system"));
ASSERT_EQ(target->icon().name(), QIcon::fromTheme("preferences-system").name());
};
|