1 | /**************************************************************************** |
---|---|
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the test suite of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
21 | ** included in the packaging of this file. Please review the following |
22 | ** information to ensure the GNU General Public License requirements will |
23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
24 | ** |
25 | ** $QT_END_LICENSE$ |
26 | ** |
27 | ****************************************************************************/ |
28 | |
29 | |
30 | #include <QtTest/QtTest> |
31 | |
32 | |
33 | #include <QRadioButton> |
34 | #include <QPushButton> |
35 | #include <QVBoxLayout> |
36 | #include <QLineEdit> |
37 | |
38 | |
39 | class tst_QRadioButton : public QObject |
40 | { |
41 | Q_OBJECT |
42 | public: |
43 | tst_QRadioButton(){}; |
44 | virtual ~tst_QRadioButton(){}; |
45 | |
46 | private slots: |
47 | void task190739_focus(); |
48 | void minimumSizeHint(); |
49 | |
50 | private: |
51 | }; |
52 | |
53 | void tst_QRadioButton::task190739_focus() |
54 | { |
55 | if (QGuiApplication::platformName().startsWith(s: QLatin1String("wayland"), cs: Qt::CaseInsensitive)) |
56 | QSKIP("Wayland: This fails. Figure out why."); |
57 | |
58 | QWidget widget; |
59 | QPushButton button1(&widget); |
60 | button1.setText("button1"); |
61 | QLineEdit edit(&widget); |
62 | edit.setFocus(); |
63 | |
64 | QRadioButton radio1(&widget); |
65 | radio1.setText("radio1"); |
66 | radio1.setFocusPolicy(Qt::TabFocus); |
67 | radio1.setShortcut(QKeySequence("Ctrl+O")); |
68 | |
69 | QVBoxLayout layout(&widget); |
70 | layout.addWidget(&button1); |
71 | layout.addWidget(&edit); |
72 | layout.addWidget(&radio1); |
73 | |
74 | widget.show(); |
75 | widget.activateWindow(); |
76 | QVERIFY(QTest::qWaitForWindowActive(&widget)); |
77 | |
78 | QVERIFY(edit.hasFocus()); |
79 | QVERIFY(!radio1.isChecked()); |
80 | |
81 | QTest::keyClick(widget: &edit, key: Qt::Key_O, modifier: Qt::ControlModifier, delay: 20); |
82 | QTRY_VERIFY(radio1.isChecked()); |
83 | QVERIFY(edit.hasFocus()); |
84 | QVERIFY(!radio1.hasFocus()); |
85 | } |
86 | |
87 | |
88 | void tst_QRadioButton::minimumSizeHint() |
89 | { |
90 | QRadioButton button(tr(s: "QRadioButtons sizeHint is the same as it's minimumSizeHint")); |
91 | QCOMPARE(button.sizeHint(), button.minimumSizeHint()); |
92 | } |
93 | |
94 | |
95 | QTEST_MAIN(tst_QRadioButton) |
96 | #include "tst_qradiobutton.moc" |
97 |