File indexing completed on 2024-05-12 05:40:53

0001 /***************************************************************************
0002  *   Copyright (C) 2022 by Renaud Guezennec                                *
0003  *   http://renaudguezennec.homelinux.org/accueil,3.html                   *
0004  *                                                                         *
0005  *   Rolisteam is free software; you can redistribute it and/or modify     *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
0019  ***************************************************************************/
0020 #include <QtTest/QtTest>
0021 
0022 #include <QImage>
0023 #include <QPainter>
0024 #include <QRect>
0025 #include <QString>
0026 #include <memory>
0027 
0028 #include "helper.h"
0029 #include "services/tipchecker.h"
0030 
0031 class TipCheckerTest : public QObject
0032 {
0033     Q_OBJECT
0034 
0035 public:
0036     TipCheckerTest();
0037 
0038 private slots:
0039     void init();
0040     void cleanupTestCase();
0041 
0042     void doTest();
0043 
0044 private:
0045     std::unique_ptr<TipChecker> m_tip;
0046 };
0047 
0048 TipCheckerTest::TipCheckerTest() {}
0049 
0050 void TipCheckerTest::init()
0051 {
0052     m_tip.reset(new TipChecker);
0053 }
0054 
0055 void TipCheckerTest::cleanupTestCase() {}
0056 
0057 void TipCheckerTest::doTest()
0058 {
0059     QSignalSpy spy(m_tip.get(), &TipChecker::checkFinished);
0060     m_tip->startChecking();
0061 
0062     spy.wait(1000);
0063     QCOMPARE(spy.count(), 1);
0064 
0065     QVERIFY(!m_tip->getArticleContent().isEmpty());
0066     QVERIFY(!m_tip->getArticleTitle().isEmpty());
0067     QVERIFY(m_tip->getUrl().isEmpty());
0068     QVERIFY(m_tip->hasArticle());
0069 
0070     auto id= Helper::generate<int>(0, 50000);
0071     m_tip->setId(id);
0072     QCOMPARE(m_tip->getId(), id);
0073 }
0074 
0075 QTEST_MAIN(TipCheckerTest);
0076 
0077 #include "tst_tipchecker.moc"