| 1 | /* |
| 2 | This file is part of the KDE libraries |
| 3 | SPDX-FileCopyrightText: 2019 David Faure <[email protected]> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.1-or-later |
| 6 | */ |
| 7 | #include <kcharselect.h> |
| 8 | |
| 9 | #include <QComboBox> |
| 10 | #include <QLineEdit> |
| 11 | #include <QTest> |
| 12 | |
| 13 | class KCharSelectTest : public QObject |
| 14 | { |
| 15 | Q_OBJECT |
| 16 | |
| 17 | private Q_SLOTS: |
| 18 | void initTestCase() |
| 19 | { |
| 20 | } |
| 21 | |
| 22 | void createInstance() |
| 23 | { |
| 24 | KCharSelect selector(nullptr, nullptr); |
| 25 | QCOMPARE(selector.displayedCodePoints().count(), 128); |
| 26 | QCOMPARE(selector.currentCodePoint(), 0); |
| 27 | } |
| 28 | |
| 29 | void changeBlock() |
| 30 | { |
| 31 | KCharSelect selector(nullptr, nullptr); |
| 32 | QComboBox *blockCombo = selector.findChild<QComboBox *>(QStringLiteral("blockCombo")); |
| 33 | QVERIFY(blockCombo); |
| 34 | blockCombo->setCurrentIndex(1); |
| 35 | QCOMPARE(selector.currentCodePoint(), 128); |
| 36 | } |
| 37 | |
| 38 | void search2Chars() |
| 39 | { |
| 40 | KCharSelect selector(nullptr, nullptr); |
| 41 | QLineEdit *searchLineEdit = selector.findChild<QLineEdit *>(); |
| 42 | QVERIFY(searchLineEdit); |
| 43 | searchLineEdit->setText(QStringLiteral("pi")); |
| 44 | Q_EMIT searchLineEdit->returnPressed(); |
| 45 | QVERIFY(selector.displayedChars().contains(QChar(960))); // 960 == π |
| 46 | } |
| 47 | }; |
| 48 | |
| 49 | QTEST_MAIN(KCharSelectTest) |
| 50 | |
| 51 | #include "kcharselect_unittest.moc" |