summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorninerider <qt-info@nokia.com>2009-09-24 11:27:35 (GMT)
committerninerider <qt-info@nokia.com>2009-09-25 07:51:16 (GMT)
commit10392eef4fd4f9206038d795ea9e32e06131bf9a (patch)
tree8dba71ad1f5fcf6a3fbab01efacc627a80a2c813 /tests
parentb50ed5fcd6b733ce0a928d7f3fa7383b810076c6 (diff)
downloadQt-10392eef4fd4f9206038d795ea9e32e06131bf9a.zip
Qt-10392eef4fd4f9206038d795ea9e32e06131bf9a.tar.gz
Qt-10392eef4fd4f9206038d795ea9e32e06131bf9a.tar.bz2
Fixes for Windows CE.
Tests showAndMoveChild and rectOutsideCoordinatesLimit_task144779 were made desktop client area dependent so the screen capturing targets meaningfull rectangles on Windows CE. Reviewed-by: Joerg
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp75
1 files changed, 42 insertions, 33 deletions
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 2e66da2..4536ed7 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -5274,24 +5274,26 @@ public:
QRegion r;
};
-#define VERIFY_COLOR(region, color) { \
- const QRegion r = QRegion(region); \
- for (int i = 0; i < r.rects().size(); ++i) { \
- const QRect rect = r.rects().at(i); \
- for (int t = 0; t < 5; t++) { \
- const QPixmap pixmap = QPixmap::grabWindow(QDesktopWidget().winId(), \
- rect.left(), rect.top(), \
- rect.width(), rect.height()); \
- QCOMPARE(pixmap.size(), rect.size()); \
- QPixmap expectedPixmap(pixmap); /* ensure equal formats */ \
- expectedPixmap.fill(color); \
- if (pixmap.toImage().pixel(0,0) != QColor(color).rgb() && t < 4 ) \
- { QTest::qWait(200); continue; } \
- QCOMPARE(pixmap.toImage().pixel(0,0), QColor(color).rgb()); \
- QCOMPARE(pixmap, expectedPixmap); \
- break; \
- } \
- } \
+template<typename R, typename C>
+void verifyColor(R const& region, C const& color)
+{
+ const QRegion r = QRegion(region);
+ for (int i = 0; i < r.rects().size(); ++i) {
+ const QRect rect = r.rects().at(i);
+ for (int t = 0; t < 5; t++) {
+ const QPixmap pixmap = QPixmap::grabWindow(QDesktopWidget().winId(),
+ rect.left(), rect.top(),
+ rect.width(), rect.height());
+ QCOMPARE(pixmap.size(), rect.size());
+ QPixmap expectedPixmap(pixmap); /* ensure equal formats */
+ expectedPixmap.fill(color);
+ if (pixmap.toImage().pixel(0,0) != QColor(color).rgb() && t < 4 )
+ { QTest::qWait(200); continue; }
+ QCOMPARE(pixmap.toImage().pixel(0,0), QColor(color).rgb());
+ QCOMPARE(pixmap, expectedPixmap);
+ break;
+ }
+ }
}
void tst_QWidget::moveChild_data()
@@ -5332,9 +5334,9 @@ void tst_QWidget::moveChild()
#endif
QTRY_COMPARE(parent.r, QRegion(parent.rect()) - child.geometry());
QTRY_COMPARE(child.r, QRegion(child.rect()));
- VERIFY_COLOR(child.geometry().translated(tlwOffset),
+ verifyColor(child.geometry().translated(tlwOffset),
child.color);
- VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset),
+ verifyColor(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset),
parent.color);
parent.reset();
child.reset();
@@ -5353,10 +5355,10 @@ void tst_QWidget::moveChild()
// should be scrolled in backingstore
QCOMPARE(child.r, QRegion());
#endif
- VERIFY_COLOR(child.geometry().translated(tlwOffset),
- child.color);
- VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset),
- parent.color);
+ verifyColor(child.geometry().translated(tlwOffset),
+ child.color);
+ verifyColor(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset),
+ parent.color);
}
void tst_QWidget::showAndMoveChild()
@@ -5364,7 +5366,11 @@ void tst_QWidget::showAndMoveChild()
QWidget parent(0, Qt::FramelessWindowHint);
// prevent custom styles
parent.setStyle(new QWindowsStyle);
- parent.resize(300, 300);
+
+ QDesktopWidget desktop;
+ QRect desktopDimensions = desktop.availableGeometry(&parent);
+
+ parent.setGeometry(desktopDimensions);
parent.setPalette(Qt::red);
parent.show();
QTest::qWaitForWindowShown(&parent);
@@ -5372,18 +5378,18 @@ void tst_QWidget::showAndMoveChild()
const QPoint tlwOffset = parent.geometry().topLeft();
QWidget child(&parent);
- child.resize(100, 100);
+ child.resize(desktopDimensions.width()/2, desktopDimensions.height()/2);
child.setPalette(Qt::blue);
child.setAutoFillBackground(true);
// Ensure that the child is repainted correctly when moved right after show.
// NB! Do NOT processEvents() (or qWait()) in between show() and move().
child.show();
- child.move(150, 150);
+ child.move(desktopDimensions.width()/2, desktopDimensions.height()/2);
qApp->processEvents();
- VERIFY_COLOR(child.geometry().translated(tlwOffset), Qt::blue);
- VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), Qt::red);
+ verifyColor(child.geometry().translated(tlwOffset), Qt::blue);
+ verifyColor(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), Qt::red);
}
void tst_QWidget::subtractOpaqueSiblings()
@@ -9150,16 +9156,19 @@ void tst_QWidget::rectOutsideCoordinatesLimit_task144779()
QPalette palette;
palette.setColor(QPalette::Window, Qt::red);
main.setPalette(palette);
- main.resize(400, 400);
+ QDesktopWidget desktop;
+ QRect desktopDimensions = desktop.availableGeometry(&main);
+ main.setGeometry(desktopDimensions);
QWidget *offsetWidget = new QWidget(&main);
- offsetWidget->setGeometry(0, -14600, 400, 15000);
+ offsetWidget->setGeometry(0, -14600, desktopDimensions.width(), 15000);
// big widget is too big for the coordinates, it must be limited by wrect
// if wrect is not at the right position because of offsetWidget, bigwidget
// is not painted correctly
QWidget *bigWidget = new QWidget(offsetWidget);
- bigWidget->setGeometry(0, 0, 400, 50000);
+
+ bigWidget->setGeometry(0, 0, desktopDimensions.width(), 50000);
palette.setColor(QPalette::Window, Qt::green);
bigWidget->setPalette(palette);
bigWidget->setAutoFillBackground(true);
@@ -9173,7 +9182,7 @@ void tst_QWidget::rectOutsideCoordinatesLimit_task144779()
QPixmap correct(main.size());
correct.fill(Qt::green);
- QRect center(100, 100, 200, 200); // to avoid the decorations
+ QRect center(desktopDimensions.width()/4,desktopDimensions.width()/4, desktopDimensions.width()/2, desktopDimensions.width()/2); // to avoid the decorations
QTRY_COMPARE(QPixmap::grabWindow(main.winId()).toImage().copy(center), correct.toImage().copy(center));
}