File: tst_window.cpp

package info (click to toggle)
kddockwidgets 2.4.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,412 kB
  • sloc: cpp: 50,019; ansic: 765; python: 239; xml: 61; makefile: 14; sh: 7
file content (122 lines) | stat: -rw-r--r-- 2,672 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
/*
  This file is part of KDDockWidgets.

  SPDX-FileCopyrightText: 2019 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
  Author: Sérgio Martins <sergio.martins@kdab.com>

  SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only

  Contact KDAB at <info@kdab.com> for commercial licensing options.
*/

// There's a benign warning:
// Group.qml:221: ReferenceError: parent is not defined
#define KDDW_TESTS_NO_FATAL_WARNINGS

#include "core/View_p.h"
#include "core/Platform.h"
#include "core/Window_p.h"
#include "utils.h"

#include <QTest>

using namespace KDDockWidgets;
using namespace KDDockWidgets::Core;

class TestWindow : public QObject
{
    Q_OBJECT
private Q_SLOTS:
    void tst_windowCtor();
    void tst_setVisible();
    void tst_handle();
    void tst_resize();
    void tst_activate();
    void tst_equals();
    void tst_geometry();
};

void TestWindow::tst_windowCtor()
{
    auto window = Platform::instance()->tests_createWindow();
    QVERIFY(window);
    QVERIFY(window->isVisible());

    window->destroy();
}

void TestWindow::tst_setVisible()
{
    auto window = Platform::instance()->tests_createWindow();
    QVERIFY(window);
    QVERIFY(window->isVisible());

    window->setVisible(false);
    QVERIFY(!window->isVisible());

    window->setVisible(true);
    QVERIFY(window->isVisible());

    window->destroy();
}

void TestWindow::tst_handle()
{
    auto window = Platform::instance()->tests_createWindow();
    QVERIFY(window->handle());
    window->destroy();
}

void TestWindow::tst_resize()
{
    auto window = Platform::instance()->tests_createWindow();
    const KDDockWidgets::Size newSize(501, 502);
    window->resize(newSize.width(), newSize.height());

    QTest::qWait(100);

    QCOMPARE(window->size(), newSize);

    window->destroy();
}

void TestWindow::tst_activate()
{
    auto window = Platform::instance()->tests_createWindow();
    // QVERIFY(window->isActive());

    // TODO

    window->destroy();
}

void TestWindow::tst_equals()
{
    auto window1 = Platform::instance()->tests_createWindow();
    auto window2 = Platform::instance()->tests_createWindow();

    QVERIFY(window1->equals(window1));
    QVERIFY(!window1->equals(window2));
    QVERIFY(!window1->equals({}));

    window1->destroy();
    window2->destroy();
}

void TestWindow::tst_geometry()
{
    auto window = Platform::instance()->tests_createWindow();

    const auto geo = KDDockWidgets::Rect(100, 100, 1000, 1000);
    window->setGeometry(geo);

    QTest::qWait(100);
    QCOMPARE(window->geometry(), geo);

    window->destroy();
}

#define KDDW_TEST_NAME TestWindow
#include "test_main_qt.h"

#include "tst_window.moc"