File: ut_dquickarrowboxpath.cpp

package info (click to toggle)
dtkdeclarative 5.7.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 29,848 kB
  • sloc: cpp: 20,566; ansic: 66; makefile: 29; sh: 25
file content (63 lines) | stat: -rw-r--r-- 1,762 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
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include <gtest/gtest.h>

#include "test_helper.hpp"

#include <QQuickItem>

#include "dquickarrowboxpath_p.h"
DQUICK_USE_NAMESPACE

class ut_DQuickArrowBoxPath : public ::testing::Test
{
public:
    virtual void SetUp()
    {
        ASSERT_TRUE(helper.load("qrc:/qml/ArrowBoxPath.qml"));

        target = helper.object->findChild<DQuickArrowBoxPath *>();
        ASSERT_TRUE(target);
    }

    ControlHelper<QQuickItem> helper;
    DQuickArrowBoxPath *target = nullptr;
};

TEST_F(ut_DQuickArrowBoxPath, properties)
{
    EXPECT_EQ(target->width(), 100);
    EXPECT_EQ(target->arrowX(), 50);
    EXPECT_EQ(target->arrowY(), 10);
    EXPECT_EQ(target->arrowWidth(), 20);
    EXPECT_EQ(target->arrowHeight(), 20);
    EXPECT_EQ(target->arrowDirection(), DQuickArrowBoxPath::Up);
    EXPECT_EQ(target->roundedRadius(), 8);
}

TEST_F(ut_DQuickArrowBoxPath, updateProperties)
{
    target->setArrowDirection(DQuickArrowBoxPath::Down);
    EXPECT_EQ(target->arrowDirection(), DQuickArrowBoxPath::Down);

    target->setSpread(5);
    EXPECT_EQ(target->spread(), 5);
}

TEST(ut_DQuickArrowBoxPath2, shapes)
{
    QuickViewHelper<> helper("qrc:/qml/ArrowBoxPath.qml");
    ASSERT_TRUE(helper.object);

    auto windowImange = helper.object->window()->grabWindow();

    const QColor inArrowColor(Qt::blue);
    EXPECT_EQ(windowImange.pixelColor(QPoint(50, 12)), inArrowColor);
    EXPECT_EQ(windowImange.pixelColor(QPoint(50, 20)), inArrowColor);

    const QColor outsideArrowColor(Qt::red);
    EXPECT_EQ(windowImange.pixelColor(QPoint(50, 9)), outsideArrowColor);
    EXPECT_EQ(windowImange.pixelColor(QPoint(10, 10)), outsideArrowColor);
}