1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef UT_QVERSITREADER_H |
|
43 #define UT_QVERSITREADER_H |
|
44 |
|
45 #include <QObject> |
|
46 #include <QBuffer> |
|
47 #include <qmobilityglobal.h> |
|
48 #include "qversitreader.h" |
|
49 |
|
50 QTM_BEGIN_NAMESPACE |
|
51 |
|
52 class QVersitReaderPrivate; |
|
53 class LineReader; |
|
54 |
|
55 QTM_END_NAMESPACE |
|
56 QTM_USE_NAMESPACE |
|
57 |
|
58 // Poor man's QSignalSpy because I couldn't get QSignalSpy to work with the user type QVR::State. |
|
59 class SignalCatcher : public QObject |
|
60 { |
|
61 Q_OBJECT |
|
62 public: |
|
63 SignalCatcher() : mResultsCount(0) {} |
|
64 public slots: |
|
65 void stateChanged(QVersitReader::State state) { |
|
66 mStateChanges.append(state); |
|
67 } |
|
68 void resultsAvailable() { |
|
69 mResultsCount += 1; |
|
70 } |
|
71 |
|
72 public: |
|
73 QList<QVersitReader::State> mStateChanges; |
|
74 int mResultsCount; |
|
75 }; |
|
76 |
|
77 class UT_QVersitReader : public QObject |
|
78 { |
|
79 Q_OBJECT |
|
80 |
|
81 private slots: // Tests |
|
82 |
|
83 void init(); |
|
84 void cleanup(); |
|
85 |
|
86 void testDevice(); |
|
87 void testDefaultCodec(); |
|
88 void testReading(); |
|
89 void testResult(); |
|
90 void testSetVersionFromProperty(); |
|
91 void testParseNextVersitPropertyVCard21(); |
|
92 void testParseNextVersitPropertyVCard30(); |
|
93 void testParseVersitDocument(); |
|
94 void testParseVersitDocument_data(); |
|
95 void testDecodeQuotedPrintable(); |
|
96 void testParamName(); |
|
97 void testParamValue(); |
|
98 void testExtractPart(); |
|
99 void testExtractParts(); |
|
100 void testExtractPropertyGroupsAndName(); |
|
101 void testExtractVCard21PropertyParams(); |
|
102 void testExtractVCard30PropertyParams(); |
|
103 void testExtractParams(); |
|
104 |
|
105 void testReadLine(); |
|
106 void testReadLine_data(); |
|
107 private: // Data |
|
108 QVersitReader* mReader; |
|
109 QVersitReaderPrivate* mReaderPrivate; |
|
110 QBuffer* mInputDevice; |
|
111 QTextCodec* mAsciiCodec; |
|
112 SignalCatcher* mSignalCatcher; |
|
113 }; |
|
114 |
|
115 #endif // UT_VERSITREADER_H |
|