summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gestures/tst_gestures.cpp66
-rw-r--r--tests/auto/qapplication/tst_qapplication.cpp19
-rw-r--r--tests/auto/qtextformat/tst_qtextformat.cpp5
-rw-r--r--tests/auto/qtextlayout/tst_qtextlayout.cpp9
-rw-r--r--tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp9
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp6
-rw-r--r--tests/auto/xmlpatternsxqts/tst_suitetest.cpp4
7 files changed, 89 insertions, 29 deletions
diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp
index 7c1170c..a968520 100644
--- a/tests/auto/gestures/tst_gestures.cpp
+++ b/tests/auto/gestures/tst_gestures.cpp
@@ -334,6 +334,7 @@ private slots:
void gestureOverChild();
void multipleWidgetOnlyGestureInTree();
void conflictingGestures();
+ void conflictingGesturesInGraphicsView();
void finishedWithoutStarted();
void unknownGesture();
void graphicsItemGesture();
@@ -2235,5 +2236,70 @@ void tst_Gestures::testReuseCanceledGestures()
QCOMPARE(target->canceled(), 1);
}
+void tst_Gestures::conflictingGesturesInGraphicsView()
+{
+ QGraphicsScene scene;
+ GraphicsView view(&scene);
+ view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+
+ GestureItem *item1 = new GestureItem("item1");
+ item1->grabGesture(CustomGesture::GestureType);
+ item1->size = QRectF(0, 0, 100, 100);
+ item1->setZValue(2);
+ scene.addItem(item1);
+
+ GestureItem *item2 = new GestureItem("item2");
+ item2->grabGesture(CustomGesture::GestureType);
+ item2->size = QRectF(0, 0, 100, 100);
+ item2->setZValue(5);
+ scene.addItem(item2);
+
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ view.ensureVisible(scene.sceneRect());
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+
+ CustomEvent event;
+
+ // nobody accepts override
+ item1->acceptGestureOverride = false;
+ item2->acceptGestureOverride = false;
+ event.hotSpot = mapToGlobal(item2->boundingRect().center(), item2, &view);
+ event.hasHotSpot = true;
+ sendCustomGesture(&event, item2, &scene);
+ QCOMPARE(item2->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item1->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item1->gestureEventsReceived, 0);
+
+ item1->reset(); item2->reset();
+
+ // the original target accepts override
+ item1->acceptGestureOverride = false;
+ item2->acceptGestureOverride = true;
+ event.hotSpot = mapToGlobal(item2->boundingRect().center(), item2, &view);
+ event.hasHotSpot = true;
+ sendCustomGesture(&event, item2, &scene);
+ QCOMPARE(item2->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item1->gestureOverrideEventsReceived, 0);
+ QCOMPARE(item1->gestureEventsReceived, 0);
+
+ item1->reset(); item2->reset();
+
+ // the item behind accepts override
+ item1->acceptGestureOverride = true;
+ item2->acceptGestureOverride = false;
+ event.hotSpot = mapToGlobal(item2->boundingRect().center(), item2, &view);
+ event.hasHotSpot = true;
+ sendCustomGesture(&event, item2, &scene);
+
+ QCOMPARE(item2->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item2->gestureEventsReceived, 0);
+ QCOMPARE(item1->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
+}
+
QTEST_MAIN(tst_Gestures)
#include "tst_gestures.moc"
diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp
index 43fbba1..1a38070 100644
--- a/tests/auto/qapplication/tst_qapplication.cpp
+++ b/tests/auto/qapplication/tst_qapplication.cpp
@@ -189,15 +189,22 @@ void tst_QApplication::getSetCheck()
{
int argc = 0;
QApplication obj1(argc, 0, QApplication::GuiServer);
- // QInputContext * QApplication::inputContext()
- // void QApplication::setInputContext(QInputContext *)
MyInputContext *var1 = new MyInputContext;
+
+ // QApplication takes ownership, so check for reparenting:
obj1.setInputContext(var1);
- QCOMPARE((QInputContext *)var1, obj1.inputContext());
+ QCOMPARE(var1->parent(), static_cast<QObject *>(&obj1));
+
+ // Test for self-assignment:
+ obj1.setInputContext(obj1.inputContext());
+ QVERIFY(obj1.inputContext());
+ QCOMPARE(static_cast<QInputContext *>(var1), obj1.inputContext());
+
+ // Resetting the input context to 0 is not allowed:
QTest::ignoreMessage(QtWarningMsg, "QApplication::setInputContext: called with 0 input context");
- obj1.setInputContext((QInputContext *)0);
- QCOMPARE((QInputContext *)var1, obj1.inputContext());
- // delete var1; // No delete, since QApplication takes ownership
+ obj1.setInputContext(0);
+
+ QCOMPARE(static_cast<QInputContext *>(var1), obj1.inputContext());
}
class CloseEventTestWindow : public QWidget
diff --git a/tests/auto/qtextformat/tst_qtextformat.cpp b/tests/auto/qtextformat/tst_qtextformat.cpp
index ee1f4b5..9b71481 100644
--- a/tests/auto/qtextformat/tst_qtextformat.cpp
+++ b/tests/auto/qtextformat/tst_qtextformat.cpp
@@ -308,10 +308,7 @@ void tst_QTextFormat::getSetTabs()
format.setTabPositions(tabs);
Comparator c2(tabs, format.tabPositions());
- QTextOption::Tab tab2;
- tab2.position = 3456;
- tab2.type = QTextOption::RightTab;
- tab2.delimiter = QChar('x');
+ QTextOption::Tab tab2(3456, QTextOption::RightTab, QChar('x'));
tabs.append(tab2);
format.setTabPositions(tabs);
Comparator c3(tabs, format.tabPositions());
diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp
index 1a5f493..a631f3d 100644
--- a/tests/auto/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp
@@ -980,9 +980,7 @@ void tst_QTextLayout::testCenteredTab()
// test if centering the tab works. We expect the center of 'Bar.' to be at the tab point.
QTextOption option = layout.textOption();
QList<QTextOption::Tab> tabs;
- QTextOption::Tab tab;
- tab.type = QTextOption::CenterTab;
- tab.position = 150;
+ QTextOption::Tab tab(150, QTextOption::CenterTab);
tabs.append(tab);
option.setTabs(tabs);
layout.setTextOption(option);
@@ -1002,10 +1000,7 @@ void tst_QTextLayout::testDelimiterTab()
// try the different delimiter characters to see if the alignment works there.
QTextOption option = layout.textOption();
QList<QTextOption::Tab> tabs;
- QTextOption::Tab tab;
- tab.type = QTextOption::DelimiterTab;
- tab.delimiter = QChar('.');
- tab.position = 100;
+ QTextOption::Tab tab(100, QTextOption::DelimiterTab, QChar('.'));
tabs.append(tab);
option.setTabs(tabs);
layout.setTextOption(option);
diff --git a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp
index 64c42bb..a463d86 100644
--- a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp
+++ b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp
@@ -198,14 +198,9 @@ void tst_QTextOdfWriter::testWriteStyle2()
{
QTextBlockFormat bf; // = cursor.blockFormat();
QList<QTextOption::Tab> tabs;
- QTextOption::Tab tab1;
- tab1.position = 40;
- tab1.type = QTextOption::RightTab;
+ QTextOption::Tab tab1(40, QTextOption::RightTab);
tabs << tab1;
- QTextOption::Tab tab2;
- tab2.position = 80;
- tab2.type = QTextOption::DelimiterTab;
- tab2.delimiter = 'o';
+ QTextOption::Tab tab2(80, QTextOption::DelimiterTab, 'o');
tabs << tab2;
bf.setTabPositions(tabs);
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index a1fc607..9e80eec 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -606,10 +606,14 @@ void tst_QWidget::getSetCheck()
obj1.setAttribute(Qt::WA_InputMethodEnabled);
obj1.setInputContext(var13);
QCOMPARE(static_cast<QInputContext *>(var13), obj1.inputContext());
+ // QWidget takes ownership, so check parent
+ QCOMPARE(var13->parent(), static_cast<QObject *>(&obj1));
+ // Check self assignment
+ obj1.setInputContext(obj1.inputContext());
+ QCOMPARE(static_cast<QInputContext *>(var13), obj1.inputContext());
obj1.setInputContext((QInputContext *)0);
QCOMPARE(qApp->inputContext(), obj1.inputContext());
QVERIFY(qApp->inputContext() != var13);
- //delete var13; // No delete, since QWidget takes ownership
// bool QWidget::autoFillBackground()
// void QWidget::setAutoFillBackground(bool)
diff --git a/tests/auto/xmlpatternsxqts/tst_suitetest.cpp b/tests/auto/xmlpatternsxqts/tst_suitetest.cpp
index ec63858..6e10e3f 100644
--- a/tests/auto/xmlpatternsxqts/tst_suitetest.cpp
+++ b/tests/auto/xmlpatternsxqts/tst_suitetest.cpp
@@ -141,8 +141,6 @@ void tst_SuiteTest::checkTestSuiteResult() const
/* Passed to ResultThreader so it knows what kind of file it is handling. */
ResultThreader::Type type = ResultThreader::Baseline;
- QProcess::execute(QLatin1String("p4 edit ") + m_existingBaseline);
-
for(QFileInfoList::const_iterator it(list.constBegin()); it != end; ++it)
{
QFileInfo i(*it);
@@ -167,8 +165,6 @@ void tst_SuiteTest::checkTestSuiteResult() const
const int exitCode = eventLoop.exec();
- QProcess::execute(QLatin1String("p4 revert -a ") + m_existingBaseline);
-
QCOMPARE(exitCode, 0);
}