File indexing completed on 2024-04-28 04:42:40
0001 /* 0002 * SPDX-FileCopyrightText: 2020-2021 Han Young <hanyoung@protonmail.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include <kweathercore/weatherforecastsource.h> 0008 0009 #include <QSignalSpy> 0010 #include <QStandardPaths> 0011 #include <QTest> 0012 0013 using namespace KWeatherCore; 0014 0015 class PendingWeatherForecastTest : public QObject 0016 { 0017 Q_OBJECT 0018 private Q_SLOTS: 0019 void initTestCase() 0020 { 0021 QStandardPaths::setTestModeEnabled(true); 0022 } 0023 0024 void testFetch() 0025 { 0026 WeatherForecastSource d; 0027 auto p = d.requestData(50, 50); 0028 QSignalSpy finishedSpy(p, &PendingWeatherForecast::finished); 0029 QVERIFY(finishedSpy.wait(30000)); 0030 if (p->error() == PendingWeatherForecast::NoError) { 0031 QVERIFY(p->value().dailyWeatherForecast().size() > 0); 0032 } else { 0033 QVERIFY(!p->errorMessage().isEmpty()); 0034 } 0035 delete p; 0036 } 0037 }; 0038 0039 QTEST_GUILESS_MAIN(PendingWeatherForecastTest) 0040 0041 #include "pendingweatherforecasttest.moc"