Fix binary incompatibility between openssl versions
[profile/ivi/qtbase.git] / src / testlib / qtest_gui.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtTest module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
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 Digia.  For licensing terms and
14 ** conditions see http://qt.digia.com/licensing.  For further information
15 ** use the contact form at http://qt.digia.com/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 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights.  These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file.  Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QTEST_GUI_H
43 #define QTEST_GUI_H
44
45 // enable GUI features
46 #ifndef QT_GUI_LIB
47 #define QT_GUI_LIB
48 #endif
49 #if 0
50 #pragma qt_class(QtTestGui)
51 #endif
52
53 #include <QtTest/qtestassert.h>
54 #include <QtTest/qtest.h>
55 #include <QtTest/qtestevent.h>
56 #include <QtTest/qtestmouse.h>
57 #include <QtTest/qtesttouch.h>
58 #include <QtTest/qtestkeyboard.h>
59
60 #include <QtGui/qpixmap.h>
61 #include <QtGui/qimage.h>
62
63 #ifdef QT_WIDGETS_LIB
64 #include <QtGui/qicon.h>
65 #endif
66
67 #if 0
68 // inform syncqt
69 #pragma qt_no_master_include
70 #endif
71
72 QT_BEGIN_HEADER
73
74 QT_BEGIN_NAMESPACE
75
76
77 namespace QTest
78 {
79
80 inline bool qCompare(QIcon const &t1, QIcon const &t2, const char *actual, const char *expected,
81                     const char *file, int line)
82 {
83     QTEST_ASSERT(sizeof(QIcon) == sizeof(void *));
84     return qCompare(*reinterpret_cast<void * const *>(&t1),
85                    *reinterpret_cast<void * const *>(&t2), actual, expected, file, line);
86 }
87
88 inline bool qCompare(QImage const &t1, QImage const &t2,
89                      const char *actual, const char *expected, const char *file, int line)
90 {
91     char msg[1024];
92     msg[0] = '\0';
93     const bool t1Null = t1.isNull();
94     const bool t2Null = t2.isNull();
95     if (t1Null != t2Null) {
96         qsnprintf(msg, 1024, "Compared QImages differ.\n"
97                   "   Actual   (%s).isNull(): %d\n"
98                   "   Expected (%s).isNull(): %d", actual, t1Null, expected, t2Null);
99         return compare_helper(false, msg, 0, 0, actual, expected, file, line);
100     }
101     if (t1Null && t2Null)
102         return compare_helper(true, 0, 0, 0, actual, expected, file, line);
103     if (t1.width() != t2.width() || t2.height() != t2.height()) {
104         qsnprintf(msg, 1024, "Compared QImages differ in size.\n"
105                   "   Actual   (%s): %dx%d\n"
106                   "   Expected (%s): %dx%d",
107                   actual, t1.width(), t1.height(),
108                   expected, t2.width(), t2.height());
109         return compare_helper(false, msg, 0, 0, actual, expected, file, line);
110     }
111     if (t1.format() != t2.format()) {
112         qsnprintf(msg, 1024, "Compared QImages differ in format.\n"
113                   "   Actual   (%s): %d\n"
114                   "   Expected (%s): %d",
115                   actual, t1.format(), expected, t2.format());
116         return compare_helper(false, msg, 0, 0, actual, expected, file, line);
117     }
118     return compare_helper(t1 == t2, "Compared values are not the same",
119                           toString(t1), toString(t2), actual, expected, file, line);
120 }
121
122 inline bool qCompare(QPixmap const &t1, QPixmap const &t2, const char *actual, const char *expected,
123                     const char *file, int line)
124 {
125     char msg[1024];
126     msg[0] = '\0';
127     const bool t1Null = t1.isNull();
128     const bool t2Null = t2.isNull();
129     if (t1Null != t2Null) {
130         qsnprintf(msg, 1024, "Compared QPixmaps differ.\n"
131                   "   Actual   (%s).isNull(): %d\n"
132                   "   Expected (%s).isNull(): %d", actual, t1Null, expected, t2Null);
133         return compare_helper(false, msg, 0, 0, actual, expected, file, line);
134     }
135     if (t1Null && t2Null)
136         return compare_helper(true, 0, 0, 0, actual, expected, file, line);
137     if (t1.width() != t2.width() || t2.height() != t2.height()) {
138         qsnprintf(msg, 1024, "Compared QPixmaps differ in size.\n"
139                   "   Actual   (%s): %dx%d\n"
140                   "   Expected (%s): %dx%d",
141                   actual, t1.width(), t1.height(),
142                   expected, t2.width(), t2.height());
143         return compare_helper(false, msg, 0, 0, actual, expected, file, line);
144     }
145     return qCompare(t1.toImage(), t2.toImage(), actual, expected, file, line);
146 }
147
148 }
149
150 QT_END_NAMESPACE
151
152 QT_END_HEADER
153
154 #endif