summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2009-10-27 14:24:02 (GMT)
committeraxis <qt-info@nokia.com>2009-10-27 14:24:02 (GMT)
commit83e25326c7fb6aa2e239b220e608446f52aeff34 (patch)
treec0688f424065bdd471dc1930b732f511a1b89c6b /tests
parent8135af2cebdaaccefb95f0be149328077d237a89 (diff)
parent51bfafed59d77b791f0266fa1bfc36634597c5c4 (diff)
downloadQt-83e25326c7fb6aa2e239b220e608446f52aeff34.zip
Qt-83e25326c7fb6aa2e239b220e608446f52aeff34.tar.gz
Qt-83e25326c7fb6aa2e239b220e608446f52aeff34.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt-s60-public into 4.6
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/networkselftest/tst_networkselftest.cpp5
-rw-r--r--tests/auto/qapplication/tst_qapplication.cpp63
-rw-r--r--tests/auto/qcompleter/tst_qcompleter.cpp2
-rw-r--r--tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp25
4 files changed, 87 insertions, 8 deletions
diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp
index d58402b..a09d998 100644
--- a/tests/auto/networkselftest/tst_networkselftest.cpp
+++ b/tests/auto/networkselftest/tst_networkselftest.cpp
@@ -333,6 +333,11 @@ QHostAddress tst_NetworkSelfTest::serverIpAddress()
if (cachedIpAddress.protocol() == QAbstractSocket::UnknownNetworkLayerProtocol) {
// need resolving
QHostInfo resolved = QHostInfo::fromName(QtNetworkSettings::serverName());
+ if(resolved.error() != QHostInfo::NoError ||
+ !resolved.addresses().isEmpty()) {
+ qWarning("QHostInfo::fromName failed (%d).", resolved.error());
+ return QHostAddress(QHostAddress::Null);
+ }
cachedIpAddress = resolved.addresses().first();
}
return cachedIpAddress;
diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp
index 97aa092..675e559 100644
--- a/tests/auto/qapplication/tst_qapplication.cpp
+++ b/tests/auto/qapplication/tst_qapplication.cpp
@@ -136,6 +136,9 @@ private slots:
void windowsCommandLine();
void touchEventPropagation();
+
+ void symbianNeedForTraps();
+ void symbianLeaveThroughMain();
};
class EventSpy : public QObject
@@ -2011,6 +2014,66 @@ void tst_QApplication::touchEventPropagation()
}
}
+#ifdef Q_OS_SYMBIAN
+class CBaseDummy : public CBase
+{
+public:
+ CBaseDummy(int *numDestroyed) : numDestroyed(numDestroyed)
+ {
+ }
+ ~CBaseDummy()
+ {
+ (*numDestroyed)++;
+ }
+
+private:
+ int *numDestroyed;
+};
+
+static void fakeMain(int *numDestroyed)
+{
+ // Push a few objects, just so that the cleanup stack has something to clean up.
+ CleanupStack::PushL(new (ELeave) CBaseDummy(numDestroyed));
+ int argc = 0;
+ QApplication app(argc, 0);
+ CleanupStack::PushL(new (ELeave) CBaseDummy(numDestroyed));
+
+ User::Leave(KErrGeneral); // Fake error
+}
+#endif
+
+void tst_QApplication::symbianNeedForTraps()
+{
+#ifndef Q_OS_SYMBIAN
+ QSKIP("This is a Symbian-only test", SkipAll);
+#else
+ int argc = 0;
+ QApplication app(argc, 0);
+ int numDestroyed = 0;
+
+ // This next part should not require a trap. If it does, the test will crash.
+ CleanupStack::PushL(new (ELeave) CBaseDummy(&numDestroyed));
+ CleanupStack::PopAndDestroy();
+
+ QCOMPARE(numDestroyed, 1);
+
+ // No other failure condition. The program will crash if it does not pass.
+#endif
+}
+
+void tst_QApplication::symbianLeaveThroughMain()
+{
+#ifndef Q_OS_SYMBIAN
+ QSKIP("This is a Symbian-only test", SkipAll);
+#else
+ int numDestroyed = 0;
+ TInt err;
+ TRAP(err, fakeMain(&numDestroyed));
+
+ QCOMPARE(numDestroyed, 2);
+#endif
+}
+
//QTEST_APPLESS_MAIN(tst_QApplication)
int main(int argc, char *argv[])
{
diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp
index 43205e1..2a17984 100644
--- a/tests/auto/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/qcompleter/tst_qcompleter.cpp
@@ -267,7 +267,7 @@ void tst_QCompleter::filter()
//QModelIndex si = completer->currentIndex();
//QCOMPARE(completer->model()->data(si).toString(), completion);
- QCOMPARE(completer->currentCompletion(), completionText);
+ QVERIFY(0 == QString::compare(completer->currentCompletion(), completionText, completer->caseSensitivity()));
}
// Testing get/set functions
diff --git a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp
index 6efa85b..87e0533 100644
--- a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp
+++ b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp
@@ -47,6 +47,10 @@
#include "qdialogbuttonbox.h"
#include "private/qsoftkeymanager_p.h"
+#ifdef Q_OS_SYMBIAN
+#include "qsymbianevent.h"
+#endif
+
#ifdef Q_WS_S60
static const int s60CommandStart = 6000;
#endif
@@ -69,6 +73,13 @@ private slots:
void updateSoftKeysCompressed();
void handleCommand();
void checkSoftkeyEnableStates();
+
+private: // utils
+ inline void simulateSymbianCommand(int command)
+ {
+ QSymbianEvent event1(QSymbianEvent::CommandEvent, command);
+ qApp->symbianProcessEvent(&event1);
+ };
};
class EventListener : public QObject
@@ -167,8 +178,8 @@ void tst_QSoftKeyManager::handleCommand()
// QTest::keyPress(&w, Qt::Key_Context1);
// QTest::keyPress(&w, Qt::Key_Context2);
- qApp->symbianHandleCommand(6000);
- qApp->symbianHandleCommand(6001);
+ simulateSymbianCommand(6000);
+ simulateSymbianCommand(6001);
QApplication::processEvents();
@@ -200,9 +211,9 @@ void tst_QSoftKeyManager::checkSoftkeyEnableStates()
//disabled button gets none.
for (int i = 0; i < 10; i++) {
//simulate "Restore Defaults" softkey press
- qApp->symbianHandleCommand(s60CommandStart);
+ simulateSymbianCommand(s60CommandStart);
//simulate "help" softkey press
- qApp->symbianHandleCommand(s60CommandStart + 1);
+ simulateSymbianCommand(s60CommandStart + 1);
}
QApplication::processEvents();
QCOMPARE(spy0.count(), 10);
@@ -212,16 +223,16 @@ void tst_QSoftKeyManager::checkSoftkeyEnableStates()
for (int i = 0; i < 10; i++) {
//simulate "Restore Defaults" softkey press
- qApp->symbianHandleCommand(s60CommandStart);
+ simulateSymbianCommand(s60CommandStart);
//simulate "help" softkey press
- qApp->symbianHandleCommand(s60CommandStart + 1);
+ simulateSymbianCommand(s60CommandStart + 1);
//switch enabled button to disabled and vice versa
pBHelp->setEnabled(!pBHelp->isEnabled());
pBDefaults->setEnabled(!pBDefaults->isEnabled());
}
QApplication::processEvents();
QCOMPARE(spy0.count(), 5);
- QCOMPARE(spy1.count(), 5);
+ QCOMPARE(spy1.count(), 5);
}
QTEST_MAIN(tst_QSoftKeyManager)