1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the test suite of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL21$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 or version 3 as published by the Free
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22** following information to ensure the GNU Lesser General Public License
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25**
26** As a special exception, The Qt Company gives you certain additional
27** rights. These rights are described in The Qt Company LGPL Exception
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29**
30** $QT_END_LICENSE$
31**
32****************************************************************************/
33
34#ifndef tst_QVERSITREADER_H
35#define tst_QVERSITREADER_H
36
37#include <QObject>
38#include <QBuffer>
39#include <QtVersit/qversitreader.h>
40
41QT_BEGIN_NAMESPACE_VERSIT
42class QVersitReaderPrivate;
43class LineReader;
44QT_END_NAMESPACE_VERSIT
45
46QTVERSIT_USE_NAMESPACE
47
48// Poor man's QSignalSpy because I couldn't get QSignalSpy to work with the user type QVR::State.
49class SignalCatcher : public QObject
50{
51Q_OBJECT
52public:
53 SignalCatcher() : mResultsCount(0) {}
54public slots:
55 void stateChanged(QVersitReader::State state) {
56 mStateChanges.append(t: state);
57 }
58 void resultsAvailable() {
59 mResultsCount += 1;
60 }
61
62public:
63 QList<QVersitReader::State> mStateChanges;
64 int mResultsCount;
65};
66
67class tst_QVersitReader : public QObject
68{
69 Q_OBJECT
70
71private slots: // Tests
72 void init();
73 void cleanup();
74
75 void testDevice();
76 void testNullDevice();
77 void testDefaultCodec();
78 void testValidateUtf8();
79 void testValidateUtf8_data();
80 void testDetectCodec();
81 void testDetectCodec_data();
82 void testReading();
83 void testResult();
84 void testParseNextVersitProperty();
85 void testParseNextVersitProperty_data();
86 void testParseVersitDocument();
87 void testParseVersitDocument_data();
88 void testDecodeQuotedPrintable();
89 void testDecodeQuotedPrintable_data();
90 void testParamName();
91 void testParamValue();
92 void testExtractPart();
93 void testExtractParts();
94 void testExtractPropertyGroupsAndName();
95 void testExtractVCard21PropertyParams();
96 void testExtractVCard30PropertyParams();
97 void testExtractParams();
98 void testReadLine();
99 void testReadLine_data();
100 void testByteArrayInput();
101 void testRemoveBackSlashEscaping();
102
103private: // Data
104 QVersitReader* mReader;
105#ifdef QT_BUILD_INTERNAL
106 QVersitReaderPrivate* mReaderPrivate;
107#endif
108 QBuffer* mInputDevice;
109 QTextCodec* mAsciiCodec;
110 SignalCatcher* mSignalCatcher;
111};
112
113#endif // tst_VERSITREADER_H
114

source code of qtpim/tests/auto/versit/qversitreader/tst_qversitreader.h