1 /***************************************************************************
2 *   Copyright (C) 2011 Matthias Fuchs <mat69@gmx.net>                     *
3 *                                                                         *
4 *   This program is free software; you can redistribute it and/or modify  *
5 *   it under the terms of the GNU General Public License as published by  *
6 *   the Free Software Foundation; either version 2 of the License, or     *
7 *   (at your option) any later version.                                   *
8 *                                                                         *
9 *   This program is distributed in the hope that it will be useful,       *
10 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12 *   GNU General Public License for more details.                          *
13 *                                                                         *
14 *   You should have received a copy of the GNU General Public License     *
15 *   along with this program; if not, write to the                         *
16 *   Free Software Foundation, Inc.,                                       *
17 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
18 ***************************************************************************/
19 
20 #ifndef KGET_VERIFIER_TEST_H
21 #define KGET_VERIFIER_TEST_H
22 
23 #include <QStringList>
24 #include <QUrl>
25 
26 #ifdef HAVE_QCA2
27 #include <QtCrypto>
28 #endif
29 
30 class QTemporaryDir;
31 
32 class VerfierTest : public QObject
33 {
34     Q_OBJECT
35 
36     public:
37         explicit VerfierTest(QObject *parent = nullptr);
38 
39     private Q_SLOTS:
40         void testChecksum();
41         void testChecksum_data();
42         void testPartialChecksums();
43         void testPartialChecksums_data();
44         void testIsChecksum();
45         void testIsChecksum_data();
46         void testAvailableChecksum();
47         void testAvailableChecksum_data();
48         void testAvailablePartialChecksum();
49         void testAvailablePartialChecksum_data();
50         void testVerify();
51         void testVerify_data();
52         void testBrokenPieces();
53         void testBrokenPieces_data();
54 
55     private:
56         /**
57          * @returns (expected && Verifier::supportedVerficationTypes().contains(type))
58          */
59         bool expectedResult(bool expected, const QString &type);
60 
61     private:
62 #ifdef HAVE_QCA2
63         QCA::Initializer m_qcaInit;
64 #endif //HAVE_QCA2
65         QScopedPointer<QTemporaryDir> m_tempDir;
66         QUrl m_file;
67         const QStringList m_supported;
68 };
69 
70 #endif
71