File: ut_dquickopacitymask.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,151 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 "dquickopacitymask_p.h"

#include <QQuickItem>

DQUICK_USE_NAMESPACE

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

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

    QQuickItem *rectItem1 = helper.object->findChild<QQuickItem *>("rect1");
    ASSERT_TRUE(rectItem1);

    QQuickItem *rectItem2 = helper.object->findChild<QQuickItem *>("rect2");
    ASSERT_TRUE(rectItem2);

    EXPECT_EQ(target->source(), rectItem1);
    EXPECT_EQ(target->maskSource(), rectItem2);
    EXPECT_EQ(target->invert(), true);
}

TEST(ut_DQuickOpacityMask, image)
{
    TEST_NOTSOFTWARE_SKIP();

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

    auto img = helper.object->window()->grabWindow();
    EXPECT_NE(img.pixelColor(QPoint(125, 125)), Qt::red); //TODO: render abnormal!!!
}