File indexing completed on 2024-04-14 14:12:11
0001 /* 0002 SPDX-FileCopyrightText: 2017 Csaba Kertesz <csaba.kertesz@gmail.com> 0003 SPDX-FileCopyrightText: 2020 Eric Dejouhanet <eric.dejouhanet@gmail.com> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef TEST_KSTARS_STARTUP_H 0009 #define TEST_KSTARS_STARTUP_H 0010 0011 #include "../testhelpers.h" 0012 #include <QDate> 0013 #include <QDateTime> 0014 #include <KActionCollection> 0015 0016 #define KTRY_SHOW_KSTARS() do { \ 0017 KStars * const K = KStars::Instance(); \ 0018 QVERIFY(K != nullptr); \ 0019 QTRY_VERIFY_WITH_TIMEOUT((K)->isGUIReady(), 30000); \ 0020 (K)->raise(); \ 0021 QTRY_VERIFY_WITH_TIMEOUT((K)->isActiveWindow(), 1000); } while(false) 0022 0023 #define KTRY_ACTION(action_text) do { \ 0024 QAction * const action = KStars::Instance()->actionCollection()->action(action_text); \ 0025 QVERIFY2(action != nullptr, QString("Action '%1' is not registered and cannot be triggered").arg(action_text).toStdString().c_str()); \ 0026 action->trigger(); } while(false) 0027 0028 class TestKStarsStartup : public QObject 0029 { 0030 Q_OBJECT 0031 0032 public: 0033 explicit TestKStarsStartup(QObject *parent = nullptr); 0034 0035 public: 0036 static struct _InitialConditions 0037 { 0038 QDateTime dateTime; 0039 bool clockRunning; 0040 0041 _InitialConditions(): 0042 dateTime(QDate(2020, 01, 01), QTime(23, 0, 0), Qt::UTC), 0043 clockRunning(false) {}; 0044 } 0045 const m_InitialConditions; 0046 0047 private slots: 0048 void initTestCase(); 0049 void cleanupTestCase(); 0050 0051 void init(); 0052 void cleanup(); 0053 0054 void createInstanceTest(); 0055 void testInitialConditions(); 0056 }; 0057 0058 #endif // TEST_KSTARS_STARTUP_H