summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-05-02 03:12:14 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-05-02 03:12:14 (GMT)
commitf101d46ccd4795fc672b5b6c9e24151df319d725 (patch)
tree82d67c71ad3ea8659c8e1277a4960e788c55c4d8 /tests/auto
parent5fa83d8e2ad78272a1013c45387adffb5e551357 (diff)
parent0da9aa430240cefc7486efb3a68421423bc4fb76 (diff)
downloadQt-f101d46ccd4795fc672b5b6c9e24151df319d725.zip
Qt-f101d46ccd4795fc672b5b6c9e24151df319d725.tar.gz
Qt-f101d46ccd4795fc672b5b6c9e24151df319d725.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (29 commits) bye bye QMakeProjectEnv short-cut evaluation inside if() tests eliminate special splitting of INCLUDEPATH and DEPENDPATH do not env-expand cache file path s/QMAKE_FRAMEWORKDIR_FLAGS/QMAKE_FRAMEWORKPATH_FLAGS/ s/INCPATH/INCLUDEPATH/ s/QMAKE_RPATH/QMAKE_LFLAGS_RPATH/ teach configure QMAKE_LFLAGS_RPATH (in addition to obsolete QMAKE_RPATH) warn about usage of deprecated variables warn about using non-lowercased replace $$function()s add -Wdeprecated option (on by default) make QMakeProject::isEmpty() consider legacy mappings document some functions' scope fix $$size() not using function-scoped variables doc: Fixed some qdoc errors. qdoc: Added breadcrumbs for namespaces. Autotest: check that we receive key events on toplevel widgets Cocoa: key events stopped working Update Polish translations qdoc: Added "All namespaces" to the API Lookup box. ...
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/macnativeevents/expectedeventlist.cpp43
-rw-r--r--tests/auto/macnativeevents/tst_macnativeevents.cpp23
-rw-r--r--tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp15
-rw-r--r--tests/auto/qtabwidget/tst_qtabwidget.cpp9
4 files changed, 79 insertions, 11 deletions
diff --git a/tests/auto/macnativeevents/expectedeventlist.cpp b/tests/auto/macnativeevents/expectedeventlist.cpp
index b1fb9a6..0679dcb 100644
--- a/tests/auto/macnativeevents/expectedeventlist.cpp
+++ b/tests/auto/macnativeevents/expectedeventlist.cpp
@@ -97,6 +97,9 @@ void ExpectedEventList::compareMouseEvents(QEvent *received, QEvent *expected)
{
QMouseEvent *e1 = static_cast<QMouseEvent *>(received);
QMouseEvent *e2 = static_cast<QMouseEvent *>(expected);
+
+ // Do a manual check first to be able to write more sensible
+ // debug output if we know we're going to fail:
if (e1->pos() == e2->pos()
&& (e1->globalPos() == e2->globalPos())
&& (e1->button() == e2->button())
@@ -104,6 +107,9 @@ void ExpectedEventList::compareMouseEvents(QEvent *received, QEvent *expected)
&& (e1->modifiers() == e2->modifiers()))
return; // equal
+ // INVARIANT: The two events are not equal. So we fail. Depending
+ // on whether debug mode is no or not, we let QTest fail. Otherwise
+ // we let the test continue for debugging puposes.
int eventListNr = eventCount - eventList.size();
if (!debug) {
qWarning() << "Expected event" << eventListNr << "differs from received event:";
@@ -119,12 +125,34 @@ void ExpectedEventList::compareMouseEvents(QEvent *received, QEvent *expected)
}
}
-void ExpectedEventList::compareKeyEvents(QEvent *event1, QEvent *event2)
+void ExpectedEventList::compareKeyEvents(QEvent *received, QEvent *expected)
{
- QKeyEvent *e1 = static_cast<QKeyEvent *>(event1);
- QKeyEvent *e2 = static_cast<QKeyEvent *>(event2);
- Q_UNUSED(e1);
- Q_UNUSED(e2);
+ QKeyEvent *e1 = static_cast<QKeyEvent *>(received);
+ QKeyEvent *e2 = static_cast<QKeyEvent *>(expected);
+
+ // Do a manual check first to be able to write more sensible
+ // debug output if we know we're going to fail:
+ if (e1->key() == e2->key()
+ && (e1->modifiers() == e2->modifiers())
+ && (e1->count() == e2->count())
+ && (e1->isAutoRepeat() == e2->isAutoRepeat()))
+ return; // equal
+
+ // INVARIANT: The two events are not equal. So we fail. Depending
+ // on whether debug mode is no or not, we let QTest fail. Otherwise
+ // we let the test continue for debugging puposes.
+ int eventListNr = eventCount - eventList.size();
+ if (!debug) {
+ qWarning() << "Expected event" << eventListNr << "differs from received event:";
+ QCOMPARE(e1->key(), e2->key());
+ QCOMPARE(e1->modifiers(), e2->modifiers());
+ QCOMPARE(e1->count(), e2->count());
+ QCOMPARE(e1->isAutoRepeat(), e2->isAutoRepeat());
+ } else {
+ qWarning() << "*** FAIL *** : Expected event" << eventListNr << "differs from received event:";
+ qWarning() << "Received:" << e1 << e1->key();
+ qWarning() << "Expected:" << e2 << e2->key();
+ }
}
bool ExpectedEventList::eventFilter(QObject *, QEvent *received)
@@ -149,10 +177,9 @@ bool ExpectedEventList::eventFilter(QObject *, QEvent *received)
compareMouseEvents(received, expected);
break;
}
- case QEvent::KeyPress: {
- break;
- }
+ case QEvent::KeyPress:
case QEvent::KeyRelease: {
+ compareKeyEvents(received, expected);
break;
}
case QEvent::Resize: {
diff --git a/tests/auto/macnativeevents/tst_macnativeevents.cpp b/tests/auto/macnativeevents/tst_macnativeevents.cpp
index 70a14f5..ffd0596 100644
--- a/tests/auto/macnativeevents/tst_macnativeevents.cpp
+++ b/tests/auto/macnativeevents/tst_macnativeevents.cpp
@@ -67,6 +67,7 @@ private slots:
void testDragWindow();
void testMouseEnter();
void testChildDialogInFrontOfModalParent();
+ void testKeyPressOnToplevel();
};
void tst_MacNativeEvents::testMouseMoveLocation()
@@ -307,6 +308,28 @@ void tst_MacNativeEvents::testChildDialogInFrontOfModalParent()
QVERIFY(!child.isVisible());
}
+void tst_MacNativeEvents::testKeyPressOnToplevel()
+{
+ // Check that we receive keyevents for
+ // toplevel widgets. For leagacy reasons, and according to Qt on
+ // other platforms (carbon port + linux), we should get these events
+ // even when the focus policy is set to Qt::NoFocus when there is no
+ // other focus widget on screen:
+ QWidget w;
+ w.show();
+
+ NativeEventList native;
+ native.append(new QNativeKeyEvent(QNativeKeyEvent::Key_A, true, Qt::NoModifier));
+ native.append(new QNativeKeyEvent(QNativeKeyEvent::Key_A, false, Qt::NoModifier));
+
+ ExpectedEventList expected(&w);
+ expected.append(new QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier));
+ expected.append(new QKeyEvent(QEvent::KeyRelease, Qt::Key_A, Qt::NoModifier));
+
+ native.play();
+ QVERIFY2(expected.waitForAllEvents(), "the test did not receive all expected events!");
+}
+
#include "tst_macnativeevents.moc"
QTEST_MAIN(tst_MacNativeEvents)
diff --git a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
index f4c4429..01b9c0c 100644
--- a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
+++ b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
@@ -304,6 +304,21 @@ void tst_QNetworkCookieJar::cookiesForUrl_data()
QTest::newRow("path-match-2") << allCookies << "http://nokia.com/web/" << result;
QTest::newRow("path-match-3") << allCookies << "http://nokia.com/web/content" << result;
+ // secure cookies
+ allCookies.clear();
+ result.clear();
+ QNetworkCookie secureCookie;
+ secureCookie.setName("a");
+ secureCookie.setPath("/web");
+ secureCookie.setDomain(".nokia.com");
+ secureCookie.setSecure(true);
+ allCookies += secureCookie;
+ QTest::newRow("no-match-secure-1") << allCookies << "http://nokia.com/web" << result;
+ QTest::newRow("no-match-secure-2") << allCookies << "http://qt.nokia.com/web" << result;
+ result += secureCookie;
+ QTest::newRow("match-secure-1") << allCookies << "https://nokia.com/web" << result;
+ QTest::newRow("match-secure-2") << allCookies << "https://qt.nokia.com/web" << result;
+
}
void tst_QNetworkCookieJar::cookiesForUrl()
diff --git a/tests/auto/qtabwidget/tst_qtabwidget.cpp b/tests/auto/qtabwidget/tst_qtabwidget.cpp
index 4491fb3..504579f 100644
--- a/tests/auto/qtabwidget/tst_qtabwidget.cpp
+++ b/tests/auto/qtabwidget/tst_qtabwidget.cpp
@@ -259,11 +259,14 @@ void tst_QTabWidget::tabEnabled()
int index = addPage();
tw->setTabEnabled(index, true);
- QVERIFY(tw->isTabEnabled(index) == true);
+ QVERIFY(tw->isTabEnabled(index));
+ QVERIFY(tw->widget(index)->isEnabled());
tw->setTabEnabled(index, false);
- QVERIFY(tw->isTabEnabled(index) == false);
+ QVERIFY(!tw->isTabEnabled(index));
+ QVERIFY(!tw->widget(index)->isEnabled());
tw->setTabEnabled(index, true);
- QVERIFY(tw->isTabEnabled(index) == true);
+ QVERIFY(tw->isTabEnabled(index));
+ QVERIFY(tw->widget(index)->isEnabled());
removePage(index);
}