author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Thu, 22 Apr 2010 16:15:11 +0300 | |
branch | RCL_3 |
changeset 14 | 8c4229025c0b |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 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 |
#if defined(Q_WS_QWS) |
|
46 |
||
47 |
//TESTED_CLASS= |
|
48 |
//TESTED_FILES= |
|
49 |
||
50 |
#include <qdesktopwidget.h> |
|
51 |
#include <qwindowsystem_qws.h> |
|
52 |
#include <qscreen_qws.h> |
|
53 |
#include <qscreendriverfactory_qws.h> |
|
54 |
#include <qwsdisplay_qws.h> |
|
55 |
||
56 |
#ifdef QT_NO_QWS_TRANSFORMED |
|
57 |
# undef QT_NO_QWS_TRANSFORMED |
|
58 |
#endif |
|
59 |
||
60 |
#include <qscreentransformed_qws.h> |
|
61 |
||
62 |
class tst_QTransformedScreen : public QObject |
|
63 |
{ |
|
64 |
Q_OBJECT |
|
65 |
||
66 |
public: |
|
67 |
tst_QTransformedScreen() {} |
|
68 |
~tst_QTransformedScreen() { } |
|
69 |
||
70 |
private slots: |
|
71 |
void initTestCase(); |
|
72 |
void cleanupTestCase(); |
|
73 |
void setTransformation_data(); |
|
74 |
void setTransformation(); |
|
75 |
void qwsDisplay_setTransformation(); |
|
76 |
||
77 |
private: |
|
78 |
QTransformedScreen *screen; |
|
79 |
QScreen *oldScreen; |
|
80 |
int id; |
|
81 |
}; |
|
82 |
||
83 |
Q_DECLARE_METATYPE(QTransformedScreen::Transformation); |
|
84 |
||
85 |
void tst_QTransformedScreen::initTestCase() |
|
86 |
{ |
|
87 |
oldScreen = qt_screen; |
|
88 |
||
89 |
QVERIFY(QScreenDriverFactory::keys().contains(QLatin1String("Transformed"))); |
|
90 |
QVERIFY(QScreenDriverFactory::keys().contains(QLatin1String("VNC"))); |
|
91 |
||
92 |
id = 10; |
|
93 |
screen = static_cast<QTransformedScreen*>(QScreenDriverFactory::create("Transformed", id)); |
|
94 |
QVERIFY(screen); |
|
95 |
QVERIFY(screen->connect(QString("Transformed:Rot90:VNC:%1").arg(id))); |
|
96 |
QVERIFY(screen->initDevice()); |
|
97 |
} |
|
98 |
||
99 |
void tst_QTransformedScreen::cleanupTestCase() |
|
100 |
{ |
|
101 |
screen->shutdownDevice(); |
|
102 |
screen->disconnect(); |
|
103 |
delete screen; |
|
104 |
screen = 0; |
|
105 |
||
106 |
qt_screen = oldScreen; |
|
107 |
} |
|
108 |
||
109 |
void tst_QTransformedScreen::setTransformation_data() |
|
110 |
{ |
|
111 |
QTest::addColumn<QTransformedScreen::Transformation>("transformation"); |
|
112 |
QTest::addColumn<bool>("swap"); |
|
113 |
||
114 |
QTest::newRow("Rot0") << QTransformedScreen::None << false; |
|
115 |
QTest::newRow("Rot90") << QTransformedScreen::Rot90 << true; |
|
116 |
QTest::newRow("Rot180") << QTransformedScreen::Rot180 << false; |
|
117 |
QTest::newRow("Rot270") << QTransformedScreen::Rot270 << true; |
|
118 |
} |
|
119 |
||
120 |
void tst_QTransformedScreen::setTransformation() |
|
121 |
{ |
|
122 |
// Not really failures but equal height and width makes this test useless |
|
123 |
QVERIFY(screen->deviceWidth() != screen->deviceHeight()); |
|
124 |
||
125 |
screen->setTransformation(QTransformedScreen::None); |
|
126 |
int dw = screen->deviceWidth(); |
|
127 |
int dh = screen->deviceHeight(); |
|
128 |
int mmw = screen->physicalWidth(); |
|
129 |
int mmh = screen->physicalHeight(); |
|
130 |
||
131 |
QFETCH(QTransformedScreen::Transformation, transformation); |
|
132 |
QFETCH(bool, swap); |
|
133 |
||
134 |
screen->setTransformation(transformation); |
|
135 |
QCOMPARE(screen->deviceWidth(), dw); |
|
136 |
QCOMPARE(screen->deviceHeight(), dh); |
|
137 |
||
138 |
if (swap) { |
|
139 |
QCOMPARE(screen->width(), dh); |
|
140 |
QCOMPARE(screen->height(), dw); |
|
141 |
QCOMPARE(screen->physicalWidth(), mmh); |
|
142 |
QCOMPARE(screen->physicalHeight(), mmw); |
|
143 |
} else { |
|
144 |
QCOMPARE(screen->width(), dw); |
|
145 |
QCOMPARE(screen->height(), dh); |
|
146 |
QCOMPARE(screen->physicalWidth(), mmw); |
|
147 |
QCOMPARE(screen->physicalHeight(), mmh); |
|
148 |
} |
|
149 |
} |
|
150 |
||
151 |
void tst_QTransformedScreen::qwsDisplay_setTransformation() |
|
152 |
{ |
|
153 |
QDesktopWidget *desktop = QApplication::desktop(); |
|
154 |
||
155 |
// test maximized windows |
|
156 |
{ |
|
157 |
QWidget w; |
|
158 |
w.showMaximized(); |
|
159 |
QApplication::processEvents(); |
|
160 |
||
161 |
const int screen = desktop->screenNumber(&w); |
|
162 |
QCOMPARE(desktop->availableGeometry(screen), w.frameGeometry()); |
|
163 |
||
164 |
for (int i = QTransformedScreen::None; i <= QTransformedScreen::Rot270; ++i) { |
|
165 |
QWSDisplay::instance()->setTransformation(i, screen); |
|
166 |
QApplication::processEvents(); |
|
167 |
QCOMPARE(desktop->availableGeometry(screen), w.frameGeometry()); |
|
168 |
} |
|
169 |
} |
|
170 |
||
171 |
// test fullscreen windows |
|
172 |
{ |
|
173 |
QWidget w; |
|
174 |
w.showFullScreen(); |
|
175 |
QApplication::processEvents(); |
|
176 |
||
177 |
const int screen = desktop->screenNumber(&w); |
|
178 |
QCOMPARE(desktop->screenGeometry(screen), w.geometry()); |
|
179 |
||
180 |
for (int i = QTransformedScreen::None; i <= QTransformedScreen::Rot270; ++i) { |
|
181 |
QWSDisplay::instance()->setTransformation(i, screen); |
|
182 |
QApplication::processEvents(); |
|
183 |
QCOMPARE(desktop->screenGeometry(screen), w.geometry()); |
|
184 |
} |
|
185 |
} |
|
186 |
} |
|
187 |
||
188 |
QTEST_MAIN(tst_QTransformedScreen) |
|
189 |
||
190 |
#include "tst_qtransformedscreen.moc" |
|
191 |
||
192 |
#else // Q_WS_QWS |
|
193 |
QTEST_NOOP_MAIN |
|
194 |
#endif |