File: ut_dquickdciiconimage.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 (37 lines) | stat: -rw-r--r-- 1,188 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
// 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 "dquickdciiconimage_p.h"

#include <QQuickItem>

DQUICK_USE_NAMESPACE

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

    DQuickDciIconImage *target = helper.object->findChild<DQuickDciIconImage *>();
    EXPECT_EQ(target->name(), "switch_button");
    EXPECT_EQ(target->mode(), DTK_QUICK_NAMESPACE::DQMLGlobalObject::NormalState);
    EXPECT_EQ(target->theme(), DGuiApplicationHelper::LightType);
    EXPECT_EQ(target->sourceSize(), QSize(0, 0));
    EXPECT_EQ(target->mirror(), false);
    EXPECT_EQ(target->fallbackToQIcon(), true);
    QTest::qWait(1); // TODO: Resolve crash
    EXPECT_EQ(target->isNull("switch_button"), false);
}

TEST(ut_DQuickDciIconImage, image)
{
    QuickViewHelper<> helper("qrc:/qml/DciIcon.qml");
    ASSERT_TRUE(helper.object);

    auto windowImange = helper.object->window()->grabWindow();
    EXPECT_EQ(windowImange.pixelColor(QPoint(50, 50)), QColor(16, 131, 245)); // NOTICE: color ?
}