0
|
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 test suite of the Qt Toolkit.
|
|
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 |
|
|
43 |
#include <QtTest/QtTest>
|
|
44 |
|
|
45 |
#ifdef Q_WS_X11
|
|
46 |
|
|
47 |
#include <QApplication>
|
|
48 |
#include <QX11Info>
|
|
49 |
|
|
50 |
class tst_QX11Info : public QObject
|
|
51 |
{
|
|
52 |
Q_OBJECT
|
|
53 |
|
|
54 |
private slots:
|
|
55 |
void staticFunctionsBeforeQApplication();
|
|
56 |
};
|
|
57 |
|
|
58 |
void tst_QX11Info::staticFunctionsBeforeQApplication()
|
|
59 |
{
|
|
60 |
QVERIFY(!QApplication::instance());
|
|
61 |
|
|
62 |
// none of these functions should crash if QApplication hasn't
|
|
63 |
// been constructed
|
|
64 |
|
|
65 |
Display *display = QX11Info::display();
|
|
66 |
QCOMPARE(display, (Display *)0);
|
|
67 |
const char *appClass = QX11Info::appClass();
|
|
68 |
QCOMPARE(appClass, (const char *)0);
|
|
69 |
int appScreen = QX11Info::appScreen();
|
|
70 |
QCOMPARE(appScreen, 0);
|
|
71 |
int appDepth = QX11Info::appDepth();
|
|
72 |
QCOMPARE(appDepth, 32);
|
|
73 |
int appCells = QX11Info::appCells();
|
|
74 |
QCOMPARE(appCells, 0);
|
|
75 |
Qt::HANDLE appColormap = QX11Info::appColormap();
|
|
76 |
QCOMPARE(appColormap, static_cast<Qt::HANDLE>(0));
|
|
77 |
void *appVisual = QX11Info::appVisual();
|
|
78 |
QCOMPARE(appVisual, static_cast<void *>(0));
|
|
79 |
Qt::HANDLE appRootWindow = QX11Info::appRootWindow();
|
|
80 |
QCOMPARE(appRootWindow, static_cast<Qt::HANDLE>(0));
|
|
81 |
|
|
82 |
bool appDefaultColormap = QX11Info::appDefaultColormap();
|
|
83 |
QCOMPARE(appDefaultColormap, true);
|
|
84 |
bool appDefaultVisual = QX11Info::appDefaultVisual();
|
|
85 |
QCOMPARE(appDefaultVisual, true);
|
|
86 |
|
|
87 |
int appDpiX = QX11Info::appDpiX();
|
|
88 |
int appDpiY = QX11Info::appDpiY();
|
|
89 |
QCOMPARE(appDpiX, 75);
|
|
90 |
QCOMPARE(appDpiY, 75);
|
|
91 |
|
|
92 |
// the setAppDpi{X,Y} calls do nothing if QApplication hasn't been
|
|
93 |
// constructed
|
|
94 |
QX11Info::setAppDpiX(-1, 120);
|
|
95 |
QX11Info::setAppDpiY(-1, 120);
|
|
96 |
appDpiX = QX11Info::appDpiX();
|
|
97 |
appDpiY = QX11Info::appDpiY();
|
|
98 |
QCOMPARE(appDpiX, 75);
|
|
99 |
QCOMPARE(appDpiY, 75);
|
|
100 |
|
|
101 |
unsigned long appTime = QX11Info::appTime();
|
|
102 |
unsigned long appUserTime = QX11Info::appUserTime();
|
|
103 |
QCOMPARE(appTime, 0ul);
|
|
104 |
QCOMPARE(appTime, 0ul);
|
|
105 |
// setApp*Time do nothing without QApplication
|
|
106 |
QX11Info::setAppTime(1234);
|
|
107 |
QX11Info::setAppUserTime(5678);
|
|
108 |
appTime = QX11Info::appTime();
|
|
109 |
appUserTime = QX11Info::appUserTime();
|
|
110 |
QCOMPARE(appTime, 0ul);
|
|
111 |
QCOMPARE(appTime, 0ul);
|
|
112 |
}
|
|
113 |
|
|
114 |
QTEST_APPLESS_MAIN(tst_QX11Info)
|
|
115 |
|
|
116 |
#include "tst_qx11info.moc"
|
|
117 |
|
|
118 |
#else // !Q_WS_X11
|
|
119 |
|
|
120 |
QTEST_NOOP_MAIN
|
|
121 |
|
|
122 |
#endif
|