summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-06-12 12:35:46 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-06-12 12:35:46 (GMT)
commitc53414e11b3f980f81a4470b3fb52f9d1aa80d56 (patch)
tree7d51540148af638b1c4fb7cda939d34739245457 /tests/auto
parentf2b93868f48a3e2d6e462ca8a051ab47eefef49d (diff)
parent304bf2ef0a99882d2d969347f85a330523086fb3 (diff)
downloadQt-c53414e11b3f980f81a4470b3fb52f9d1aa80d56.zip
Qt-c53414e11b3f980f81a4470b3fb52f9d1aa80d56.tar.gz
Qt-c53414e11b3f980f81a4470b3fb52f9d1aa80d56.tar.bz2
Merge commit 'origin/4.5'
Conflicts: demos/boxes/glshaders.cpp src/gui/graphicsview/qgraphicsitem.cpp tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp tools/linguist/shared/cpp.cpp translations/linguist_ja.qm translations/qt_ru.qm
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qcombobox/tst_qcombobox.cpp2
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp49
-rw-r--r--tests/auto/qinputdialog/tst_qinputdialog.cpp15
-rw-r--r--tests/auto/qitemdelegate/tst_qitemdelegate.cpp28
-rw-r--r--tests/auto/qmake/tst_qmake.cpp3
-rw-r--r--tests/auto/selftests/tst_selftests.cpp2
6 files changed, 82 insertions, 17 deletions
diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp
index 816b2e8..5321348 100644
--- a/tests/auto/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/qcombobox/tst_qcombobox.cpp
@@ -2197,8 +2197,8 @@ void tst_QComboBox::noScrollbar()
{
QTableWidget *table = new QTableWidget(2,2);
QComboBox comboBox;
- comboBox.setView(table);
comboBox.setModel(table->model());
+ comboBox.setView(table);
comboBox.show();
QTest::qWait(100);
comboBox.resize(200, comboBox.height());
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 481dc6b..d2a059a 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -210,6 +210,7 @@ private slots:
void opacity_data();
void opacity();
void opacity2();
+ void opacityZeroUpdates();
void itemStacksBehindParent();
void nestedClipping();
void nestedClippingTransforms();
@@ -5798,6 +5799,54 @@ void tst_QGraphicsItem::opacity2()
QCOMPARE(grandChild->repaints, 0);
}
+void tst_QGraphicsItem::opacityZeroUpdates()
+{
+ EventTester *parent = new EventTester;
+ EventTester *child = new EventTester(parent);
+
+ child->setPos(10, 10);
+
+ QGraphicsScene scene;
+ scene.addItem(parent);
+
+ class MyGraphicsView : public QGraphicsView
+ { public:
+ int repaints;
+ QRegion paintedRegion;
+ MyGraphicsView(QGraphicsScene *scene) : QGraphicsView(scene), repaints(0) {}
+ void paintEvent(QPaintEvent *e)
+ {
+ ++repaints;
+ paintedRegion += e->region();
+ QGraphicsView::paintEvent(e);
+ }
+ void reset() { repaints = 0; paintedRegion = QRegion(); }
+ };
+
+ MyGraphicsView view(&scene);
+ view.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&view);
+#endif
+ QTest::qWait(250);
+
+ view.reset();
+ parent->setOpacity(0.0);
+
+ QTest::qWait(200);
+
+ // transforming items bounding rect to view coordinates
+ const QRect childDeviceBoundingRect = child->deviceTransform(view.viewportTransform())
+ .mapRect(child->boundingRect()).toRect();
+ const QRect parentDeviceBoundingRect = parent->deviceTransform(view.viewportTransform())
+ .mapRect(parent->boundingRect()).toRect();
+
+ QRegion expectedRegion = parentDeviceBoundingRect.adjusted(-2, -2, 2, 2);
+ expectedRegion += childDeviceBoundingRect.adjusted(-2, -2, 2, 2);
+
+ QCOMPARE(view.paintedRegion, expectedRegion);
+}
+
class StacksBehindParentHelper : public QGraphicsRectItem
{
public:
diff --git a/tests/auto/qinputdialog/tst_qinputdialog.cpp b/tests/auto/qinputdialog/tst_qinputdialog.cpp
index 0f763fc..c635381 100644
--- a/tests/auto/qinputdialog/tst_qinputdialog.cpp
+++ b/tests/auto/qinputdialog/tst_qinputdialog.cpp
@@ -67,6 +67,7 @@ private slots:
void getInteger();
void getDouble_data();
void getDouble();
+ void task255502getDouble();
void getText_data();
void getText();
void getItem_data();
@@ -318,6 +319,20 @@ void tst_QInputDialog::getDouble()
delete parent;
}
+void tst_QInputDialog::task255502getDouble()
+{
+ parent = new QWidget;
+ testFunc = &tst_QInputDialog::testFuncGetDouble;
+ startTimer(0);
+ bool ok = false;
+ const double value = 0.001;
+ const double result =
+ QInputDialog::getDouble(parent, "", "", value, -1, 1, 4, &ok);
+ QVERIFY(ok);
+ QCOMPARE(result, value);
+ delete parent;
+}
+
void tst_QInputDialog::getText_data()
{
QTest::addColumn<QString>("text");
diff --git a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
index 615ac01..50e1ff0 100644
--- a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
@@ -1034,7 +1034,7 @@ void tst_QItemDelegate::editorEvent()
option.rect = rect;
option.state |= QStyle::State_Enabled;
- const int checkMargin = qApp->style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1;
+ const int checkMargin = qApp->style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1;
QPoint pos = inCheck ? qApp->style()->subElementRect(QStyle::SE_ViewItemCheckIndicator, &option, 0).center() + QPoint(checkMargin, 0) : QPoint(200,200);
QEvent *event = new QMouseEvent((QEvent::Type)type,
@@ -1057,7 +1057,7 @@ void tst_QItemDelegate::enterKey_data()
QTest::addColumn<int>("widget");
QTest::addColumn<int>("key");
QTest::addColumn<bool>("expectedFocus");
-
+
QTest::newRow("lineedit enter") << 1 << int(Qt::Key_Enter) << false;
QTest::newRow("textedit enter") << 2 << int(Qt::Key_Enter) << true;
QTest::newRow("plaintextedit enter") << 3 << int(Qt::Key_Enter) << true;
@@ -1071,17 +1071,17 @@ void tst_QItemDelegate::enterKey()
QFETCH(int, widget);
QFETCH(int, key);
QFETCH(bool, expectedFocus);
-
+
QStandardItemModel model;
model.appendRow(new QStandardItem());
-
+
QListView view;
view.setModel(&model);
view.show();
QApplication::setActiveWindow(&view);
view.setFocus();
QTest::qWait(30);
-
+
struct TestDelegate : public QItemDelegate
{
int widgetType;
@@ -1089,7 +1089,7 @@ void tst_QItemDelegate::enterKey()
{
QWidget *editor = 0;
switch(widgetType) {
- case 1:
+ case 1:
editor = new QLineEdit(parent);
break;
case 2:
@@ -1103,25 +1103,25 @@ void tst_QItemDelegate::enterKey()
return editor;
}
} delegate;
-
+
delegate.widgetType = widget;
-
+
view.setItemDelegate(&delegate);
QModelIndex index = model.index(0, 0);
view.setCurrentIndex(index); // the editor will only selectAll on the current index
view.edit(index);
QTest::qWait(30);
-
+
QList<QWidget*> lineEditors = qFindChildren<QWidget *>(view.viewport(), QString::fromLatin1("TheEditor"));
QCOMPARE(lineEditors.count(), 1);
-
- QWidget *editor = lineEditors.at(0);
+
+ QPointer<QWidget> editor = lineEditors.at(0);
QCOMPARE(editor->hasFocus(), true);
-
+
QTest::keyClick(editor, Qt::Key(key));
QApplication::processEvents();
-
- QCOMPARE(editor->hasFocus(), expectedFocus);
+
+ QCOMPARE(editor && editor->hasFocus(), expectedFocus);
}
diff --git a/tests/auto/qmake/tst_qmake.cpp b/tests/auto/qmake/tst_qmake.cpp
index 1178c81..1ba81bd 100644
--- a/tests/auto/qmake/tst_qmake.cpp
+++ b/tests/auto/qmake/tst_qmake.cpp
@@ -39,13 +39,14 @@
**
****************************************************************************/
+#include <QtTest/QtTest>
+
#if !defined(QMAKE_CROSS_COMPILED)
#include "testcompiler.h"
#include <QObject>
#include <QDir>
-#include <QtTest/QtTest>
class tst_qmake : public QObject
{
diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp
index 603e730..eca9aa6 100644
--- a/tests/auto/selftests/tst_selftests.cpp
+++ b/tests/auto/selftests/tst_selftests.cpp
@@ -101,7 +101,7 @@ inline bool qCompare
variance = 0.001;
}
else if (r1.unit == "ticks") {
- variance = 0.0001;
+ variance = 0.001;
}
if (variance == 0.) {
/* No variance allowed - compare whole string */