File: ut_dtitlebar.cpp

package info (click to toggle)
dtkwidget 5.7.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 36,540 kB
  • sloc: cpp: 63,257; ansic: 132; python: 88; sh: 42; makefile: 13
file content (126 lines) | stat: -rw-r--r-- 2,879 bytes parent folder | download
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// SPDX-FileCopyrightText: 2021 - 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include <gtest/gtest.h>
#include <QTest>
#include <QDebug>

#include "DTitlebar"

DWIDGET_USE_NAMESPACE

class ut_DTitlebar : public testing::Test
{
protected:
    void SetUp() override;
    void TearDown() override;
    QWidget *widget = nullptr;
    DTitlebar *titleBar = nullptr;
};

void ut_DTitlebar::SetUp()
{
    widget = new QWidget;
    titleBar = new DTitlebar(widget);
    widget->resize(300, 200);
}

void ut_DTitlebar::TearDown()
{
    widget->deleteLater();
}

TEST_F(ut_DTitlebar, testDTitlebarMenu)
{
    QIcon icon(QIcon::fromTheme("preferences-system"));
    titleBar->setIcon(icon);

    QMenu menu;
    QString action("testDTitlebarMenu");
    menu.addAction(action);
    titleBar->setMenu(&menu);
    ASSERT_EQ(titleBar->menu()->actions()[0]->text(), action);
}

TEST_F(ut_DTitlebar, testDTitlebarCustomWidget)
{
    QWidget w;
    titleBar->setCustomWidget(&w);
    ASSERT_EQ(titleBar->customWidget(), &w);
}

TEST_F(ut_DTitlebar, testDTitlebarAddRemoveWidget)
{
    return;
    QWidget w1, w2, w3;
    titleBar->addWidget(&w1);
    titleBar->addWidget(&w2);
    titleBar->addWidget(&w3);
    titleBar->removeWidget(&w1);
    titleBar->removeWidget(&w2);
    titleBar->removeWidget(&w3);
    // TODO
}

TEST_F(ut_DTitlebar, testDTitlebarSetFixedHeight)
{
    int fixedHeight = 40;
    titleBar->setFixedHeight(fixedHeight);
    ASSERT_EQ(titleBar->height(), fixedHeight);
}

TEST_F(ut_DTitlebar, testDTitlebarBackgroundTransparent)
{
    return;
    bool bgTransparent = false;
    titleBar->setBackgroundTransparent(bgTransparent);
    ASSERT_NE(titleBar->backgroundRole(), QPalette::Base);

    bgTransparent = true;
    titleBar->setBackgroundTransparent(bgTransparent);
    ASSERT_EQ(titleBar->backgroundRole(), QPalette::NoRole);
}

TEST_F(ut_DTitlebar, testDTitlebarsetSeparatorVisible)
{
    bool separatorVisible = true;
    titleBar->setSeparatorVisible(separatorVisible);

    separatorVisible = false;
    titleBar->setSeparatorVisible(separatorVisible);
    // TODO
}

TEST_F(ut_DTitlebar, testDTitlebarSetTitle)
{
    QString title("testDTitlebarSetTitle");
    titleBar->setTitle(title);
    // TODO
}

TEST_F(ut_DTitlebar, testDTitlebarSetIcon)
{
    QIcon icon(QIcon::fromTheme("preferences-system"));
    titleBar->setIcon(icon);
    // TODO
}

TEST_F(ut_DTitlebar, testDTitlebarSetBlurBackground)
{
    bool blurBackground = true;
    titleBar->setBlurBackground(blurBackground);
    blurBackground = false;
    titleBar->setBlurBackground(blurBackground);
    // TODO
}

TEST_F(ut_DTitlebar, testDTitlebarButtonAreaWidth)
{
    return;
    bool blurBackground = true;
    titleBar->setBlurBackground(blurBackground);
    blurBackground = false;
    titleBar->setBlurBackground(blurBackground);
    // TODO
}