File: ut_dquickrectangle.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 (42 lines) | stat: -rw-r--r-- 1,289 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
// 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 <QTest>
#include <QQuickItem>

#include "dquickrectangle_p.h"
DQUICK_USE_NAMESPACE

TEST(ut_DQuickRectangle, properties)
{
    ControlHelper<DQuickRectangle> helper("qrc:/qml/DQuickRectangle.qml");
    ASSERT_TRUE(helper.object);

    EXPECT_EQ(helper.object->color(), Qt::red);
    EXPECT_EQ(helper.object->radius(), 8);
    EXPECT_EQ(helper.object->corners(), DQuickRectangle::TopLeftCorner | DQuickRectangle::TopRightCorner);
}

TEST(ut_DQuickRectangle, updateProperties)
{
    TEST_OFFSCREEN_SKIP();

    QuickViewHelper<DQuickRectangle> helper("qrc:/qml/DQuickRectangle.qml");
    ASSERT_TRUE(helper.object);

    helper.object->setRadius(16);
    helper.object->setColor(Qt::blue);
    helper.object->setCorners(DQuickRectangle::TopLeftCorner | DQuickRectangle::TopRightCorner);

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

    const QPoint inCornerPoint(3, 3);
    const QPoint outCornerPoint(helper.object->boundingRect().center().toPoint());
    EXPECT_EQ(windowImange.pixelColor(outCornerPoint), Qt::blue);
    EXPECT_NE(windowImange.pixelColor(inCornerPoint), Qt::blue);
}