equal
deleted
inserted
replaced
50 #ifdef Q_WS_X11 |
50 #ifdef Q_WS_X11 |
51 #include <X11/Xlib.h> |
51 #include <X11/Xlib.h> |
52 #include <QX11Info> |
52 #include <QX11Info> |
53 #endif // Q_WS_X11 |
53 #endif // Q_WS_X11 |
54 |
54 |
|
55 #include "../../shared/util.h" |
|
56 |
|
57 |
55 class tst_QWidget_window : public QWidget |
58 class tst_QWidget_window : public QWidget |
56 { |
59 { |
57 Q_OBJECT |
60 Q_OBJECT |
58 |
61 |
59 public: |
62 public: |
148 } |
151 } |
149 |
152 |
150 class TestWidget : public QWidget |
153 class TestWidget : public QWidget |
151 { |
154 { |
152 public: |
155 public: |
153 int m_first, m_next; |
156 int m_first, m_next; |
154 bool paintEventReceived; |
157 bool paintEventReceived; |
155 |
158 |
156 void reset(){ m_first = m_next = 0; paintEventReceived = false; } |
159 void reset(){ m_first = m_next = 0; paintEventReceived = false; } |
157 bool event(QEvent *event) |
160 bool event(QEvent *event) |
158 { |
161 { |
161 case QEvent::WindowDeactivate: |
164 case QEvent::WindowDeactivate: |
162 case QEvent::Hide: |
165 case QEvent::Hide: |
163 case QEvent::Show: |
166 case QEvent::Show: |
164 if (m_first) |
167 if (m_first) |
165 m_next = event->type(); |
168 m_next = event->type(); |
166 else |
169 else |
167 m_first = event->type(); |
170 m_first = event->type(); |
168 break; |
171 break; |
169 case QEvent::Paint: |
172 case QEvent::Paint: |
170 paintEventReceived = true; |
173 paintEventReceived = true; |
171 break; |
174 break; |
172 default: |
175 default: |
173 break; |
176 break; |
174 } |
177 } |
175 return QWidget::event(event); |
178 return QWidget::event(event); |
176 } |
179 } |
177 }; |
180 }; |
178 |
181 |
179 void tst_QWidget_window::tst_windowFilePathAndwindowTitle_data() |
182 void tst_QWidget_window::tst_windowFilePathAndwindowTitle_data() |
180 { |
183 { |
181 QTest::addColumn<bool>("setWindowTitleBefore"); |
184 QTest::addColumn<bool>("setWindowTitleBefore"); |
287 #ifndef Q_WS_X11 |
290 #ifndef Q_WS_X11 |
288 QSKIP("This test is X11-only.", SkipAll); |
291 QSKIP("This test is X11-only.", SkipAll); |
289 #else |
292 #else |
290 QWidget w; |
293 QWidget w; |
291 w.show(); |
294 w.show(); |
292 qt_x11_wait_for_window_manager(&w); |
295 QTest::qWaitForWindowShown(&w); |
293 QApplication::processEvents(); |
296 QApplication::processEvents(); |
294 |
297 |
295 QApplication::clipboard(); |
298 QApplication::clipboard(); |
296 QLineEdit *lineEdit = new QLineEdit; |
299 QLineEdit *lineEdit = new QLineEdit; |
297 lineEdit->setAttribute(Qt::WA_ShowWithoutActivating, true); |
300 lineEdit->setAttribute(Qt::WA_ShowWithoutActivating, true); |
300 lineEdit->raise(); |
303 lineEdit->raise(); |
301 lineEdit->activateWindow(); |
304 lineEdit->activateWindow(); |
302 |
305 |
303 Window window; |
306 Window window; |
304 int revertto; |
307 int revertto; |
305 XGetInputFocus(QX11Info::display(), &window, &revertto); |
308 QTRY_COMPARE(lineEdit->winId(), |
306 QCOMPARE(lineEdit->winId(), window); |
309 (XGetInputFocus(QX11Info::display(), &window, &revertto), window) ); |
|
310 // Note the use of the , before window because we want the XGetInputFocus to be re-executed |
|
311 // in each iteration of the inside loop of the QTRY_COMPARE macro |
|
312 |
307 #endif // Q_WS_X11 |
313 #endif // Q_WS_X11 |
308 } |
314 } |
309 |
315 |
310 void tst_QWidget_window::tst_paintEventOnSecondShow() |
316 void tst_QWidget_window::tst_paintEventOnSecondShow() |
311 { |
317 { |
313 w.show(); |
319 w.show(); |
314 w.hide(); |
320 w.hide(); |
315 |
321 |
316 w.reset(); |
322 w.reset(); |
317 w.show(); |
323 w.show(); |
318 #ifdef Q_WS_X11 |
324 QTest::qWaitForWindowShown(&w); |
319 QTest::qWait(500); |
|
320 #endif |
|
321 QApplication::processEvents(); |
325 QApplication::processEvents(); |
322 QVERIFY(w.paintEventReceived); |
326 QTRY_VERIFY(w.paintEventReceived); |
323 } |
327 } |
324 |
328 |
325 QTEST_MAIN(tst_QWidget_window) |
329 QTEST_MAIN(tst_QWidget_window) |
326 #include "tst_qwidget_window.moc" |
330 #include "tst_qwidget_window.moc" |