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 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#include <gtest/gtest.h>
#include "dquickdciicon_p.h"
DQUICK_USE_NAMESPACE
class ut_DQuickDciIcon : public ::testing::Test
{
public:
virtual void SetUp()
{
target = new DQuickDciIcon;
}
virtual void TearDown()
{
delete target;
}
DQuickDciIcon *target = nullptr;
};
TEST_F(ut_DQuickDciIcon, name)
{
EXPECT_TRUE(target->isEmpty());
target->setName("test");
EXPECT_EQ(target->name(), "test");
target->resetName();
EXPECT_EQ(target->name(), "");
}
TEST_F(ut_DQuickDciIcon, width)
{
target->setWidth(20);
EXPECT_EQ(target->width(), 20);
target->resetWidth();
EXPECT_EQ(target->width(), 0);
}
TEST_F(ut_DQuickDciIcon, height)
{
target->setHeight(20);
EXPECT_EQ(target->height(), 20);
target->resetHeight();
EXPECT_EQ(target->height(), 0);
}
TEST_F(ut_DQuickDciIcon, mode)
{
target->setMode(DQMLGlobalObject::DisabledState);
EXPECT_EQ(target->mode(), DQMLGlobalObject::DisabledState);
target->resetMode();
EXPECT_EQ(target->mode(), DQMLGlobalObject::NormalState);
}
TEST_F(ut_DQuickDciIcon, theme)
{
target->setTheme(DGuiApplicationHelper::ColorType::DarkType);
EXPECT_EQ(target->theme(), DGuiApplicationHelper::ColorType::DarkType);
target->resetTheme();
EXPECT_EQ(target->theme(), DGuiApplicationHelper::ColorType::LightType);
}
TEST_F(ut_DQuickDciIcon, palette)
{
DDciIconPalette palette(Qt::red, Qt::green, Qt::red);
target->setPalette(palette);
EXPECT_EQ(target->palette(), palette);
target->resetPalette();
EXPECT_EQ(target->palette(), DDciIconPalette());
}
TEST_F(ut_DQuickDciIcon, source)
{
QUrl source("qrc:/test");
target->setSource(source);
EXPECT_EQ(target->source(), source);
target->resetSource();
EXPECT_EQ(target->source(), QUrl());
}
TEST_F(ut_DQuickDciIcon, fallbackToQIcon)
{
target->setFallbackToQIcon(false);
EXPECT_EQ(target->fallbackToQIcon(), false);
target->resetFallbackToQIcon();
EXPECT_EQ(target->fallbackToQIcon(), true);
}
TEST_F(ut_DQuickDciIcon, operatorEQ)
{
DQuickDciIcon dciIcon = *target;
EXPECT_EQ(*target, dciIcon);
}
|