Changeset View
Changeset View
Standalone View
Standalone View
Tests/kstars_ui/kstars_ui_tests.h
Show All 9 Lines | |||||
10 | #pragma once | 10 | #pragma once | ||
11 | 11 | | |||
12 | #include "config-kstars.h" | 12 | #include "config-kstars.h" | ||
13 | 13 | | |||
14 | #include <QMutex> | 14 | #include <QMutex> | ||
15 | #include <QObject> | 15 | #include <QObject> | ||
16 | #include <QTimer> | 16 | #include <QTimer> | ||
17 | #include <QApplication> | 17 | #include <QApplication> | ||
18 | #include <QTest> | 18 | #include <QtTest> | ||
19 | 19 | | |||
20 | #include "kstars.h" | 20 | #include "kstars.h" | ||
21 | 21 | | |||
22 | class KStars; | 22 | class KStars; | ||
23 | 23 | | |||
24 | #define KTRY_SHOW_KSTARS(K) do { \ | 24 | #define KTRY_SHOW_KSTARS() do { \ | ||
25 | QTRY_VERIFY_WITH_TIMEOUT((K)->isGUIReady(), 1000); \ | 25 | KStars * const K = KStars::Instance(); \ | ||
26 | QVERIFY(K != nullptr); \ | ||||
27 | QTRY_VERIFY_WITH_TIMEOUT((K)->isGUIReady(), 30000); \ | ||||
26 | (K)->raise(); \ | 28 | (K)->raise(); \ | ||
27 | QTRY_VERIFY_WITH_TIMEOUT((K)->isActiveWindow(), 1000); } while(false) | 29 | QTRY_VERIFY_WITH_TIMEOUT((K)->isActiveWindow(), 1000); } while(false) | ||
28 | 30 | | |||
31 | #define KTRY_ACTION(action_text) do { \ | ||||
32 | QAction * const action = KStars::Instance()->actionCollection()->action(action_text); \ | ||||
33 | QVERIFY2(action != nullptr, QString("Action '%1' is not registered and cannot be triggered").arg(action_text).toStdString().c_str()); \ | ||||
34 | action->trigger(); } while(false) | ||||
35 | | ||||
29 | class KStarsUiTests : public QObject | 36 | class KStarsUiTests : public QObject | ||
30 | { | 37 | { | ||
31 | Q_OBJECT | 38 | Q_OBJECT | ||
39 | public: | ||||
40 | explicit KStarsUiTests(QObject *parent = nullptr); | ||||
32 | 41 | | |||
33 | public: | 42 | public: | ||
34 | KStarsUiTests(); | 43 | static struct _InitialConditions | ||
35 | ~KStarsUiTests() override = default; | 44 | { | ||
45 | QDateTime dateTime; | ||||
46 | bool clockRunning; | ||||
36 | 47 | | |||
37 | private: | 48 | _InitialConditions(): | ||
38 | KStars* K {nullptr}; | 49 | dateTime(QDate(2020, 01, 01), QTime(23, 0, 0), Qt::UTC), | ||
50 | clockRunning(false) {}; | ||||
51 | } | ||||
52 | const m_InitialConditions; | ||||
39 | 53 | | |||
40 | private slots: | 54 | private slots: | ||
41 | void initTestCase(); | 55 | void initTestCase(); | ||
42 | void cleanupTestCase(); | 56 | void cleanupTestCase(); | ||
43 | 57 | | |||
44 | void init(); | 58 | void init(); | ||
45 | void cleanup(); | 59 | void cleanup(); | ||
46 | 60 | | |||
47 | void basicTest(); | 61 | void createInstanceTest(); | ||
48 | void warnTest(); | | |||
49 | void raiseKStarsTest(); | | |||
50 | | ||||
51 | #if defined(HAVE_INDI) | | |||
52 | private: | | |||
53 | QString testProfileName; | | |||
54 | void initEkos(); | | |||
55 | void cleanupEkos(); | | |||
56 | | ||||
57 | private slots: | | |||
58 | // UI | | |||
59 | void openEkosTest(); | | |||
60 | 62 | | |||
61 | // Profiles | 63 | void initialConditionsTest(); | ||
62 | void manipulateEkosProfiles(); | 64 | void raiseKStarsTest(); | ||
63 | void testdriveSimulatorProfile(); | | |||
64 | #endif | | |||
65 | }; | 65 | }; |