File indexing completed on 2024-04-21 14:47:28
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 #include "kstars_ui_tests.h" 0009 0010 #if defined(HAVE_INDI) 0011 0012 #include "Options.h" 0013 #include "test_ekos_wizard.h" 0014 #include "test_ekos.h" 0015 #include "ekos/manager.h" 0016 #include "kswizard.h" 0017 #include "auxiliary/kspaths.h" 0018 #include "ekos/profilewizard.h" 0019 0020 #include <KActionCollection> 0021 0022 TestEkosWizard::TestEkosWizard(QObject *parent) : QObject(parent) 0023 { 0024 } 0025 0026 void TestEkosWizard::init() 0027 { 0028 } 0029 0030 void TestEkosWizard::cleanup() 0031 { 0032 foreach (QDialog * d, KStars::Instance()->findChildren<QDialog*>()) 0033 if (d->isVisible()) 0034 d->hide(); 0035 } 0036 0037 void TestEkosWizard::testProfileWizard() 0038 { 0039 // Update our INDI installation specs 0040 Options::setIndiDriversAreInternal(true); 0041 0042 // Locate INDI server - this is highly suspicious, but will cover most of the installation cases I suppose 0043 if (QFile("/usr/local/bin/indiserver").exists()) 0044 Options::setIndiServer("/usr/local/bin/indiserver"); 0045 else if (QFile("/usr/bin/indiserver").exists()) 0046 Options::setIndiServer("/usr/bin/indiserver"); 0047 QVERIFY(QDir(Options::indiDriversDir()).exists()); 0048 0049 // Locate INDI drivers - the XML list of drivers is the generic data path 0050 QFile drivers(KSPaths::locate(QStandardPaths::AppLocalDataLocation, "indidrivers.xml")); 0051 if (drivers.exists()) 0052 Options::setIndiDriversDir(QFileInfo(drivers).dir().path()); 0053 QVERIFY(QDir(Options::indiDriversDir()).exists()); 0054 0055 // The Ekos new profile wizard opens when starting Ekos for the first time 0056 bool wizardDone = false; 0057 std::function <void()> closeWizard = [&] 0058 { 0059 KStars * const k = KStars::Instance(); 0060 QVERIFY(k != nullptr); 0061 0062 // Wait for the KStars Wizard to appear 0063 if(k->findChild <ProfileWizard*>() == nullptr) 0064 { 0065 QTimer::singleShot(500, KStars::Instance(), closeWizard); 0066 return; 0067 } 0068 ProfileWizard * const w = k->findChild <ProfileWizard*>(); 0069 QVERIFY(w != nullptr); 0070 QTRY_VERIFY_WITH_TIMEOUT(w->isVisible(), 1000); 0071 0072 // Just dismiss the wizard for now 0073 QDialogButtonBox* buttons = w->findChild<QDialogButtonBox*>(); 0074 QVERIFY(nullptr != buttons); 0075 QTest::mouseClick(buttons->button(QDialogButtonBox::Close), Qt::LeftButton); 0076 QTRY_VERIFY_WITH_TIMEOUT(!w->isVisible(), 1000); 0077 wizardDone = true; 0078 }; 0079 QTimer::singleShot(500, Ekos::Manager::Instance(), closeWizard); 0080 0081 KTRY_OPEN_EKOS(); 0082 KVERIFY_EKOS_IS_OPENED(); 0083 QTRY_VERIFY_WITH_TIMEOUT(wizardDone, 1000); 0084 0085 KTRY_CLOSE_EKOS(); 0086 KVERIFY_EKOS_IS_HIDDEN(); 0087 } 0088 0089 // There is no test-main macro in this test because that sequence is done systematically 0090 0091 #endif // HAVE_INDI