From 001b688e54630f753e3ca3933cca2c2290210ec7 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 29 May 2012 15:27:35 +0200 Subject: Changed behavior of QJsonDbConnection::defaultConnection(). It is much more convenient if it is safe to assume that the returned default connection is already connected, or will be autotomatically connected. Change-Id: I5e0d89ad34f156b5cee5ca6e0f25eb79c32a2bca Reviewed-by: Jamey Hicks --- tests/auto/qjsondbrequest/testqjsondbrequest.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/auto/qjsondbrequest/testqjsondbrequest.cpp b/tests/auto/qjsondbrequest/testqjsondbrequest.cpp index 7a4dd110..0a9c7d1b 100644 --- a/tests/auto/qjsondbrequest/testqjsondbrequest.cpp +++ b/tests/auto/qjsondbrequest/testqjsondbrequest.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #include #include @@ -108,6 +109,7 @@ private slots: void bindings(); void replaceFromNull(); void multiplerequests(); + void defaultConnection(); private: bool writeTestObject(QObject* parent, const QString &type, int value, const QString &partition = QString()); @@ -1191,6 +1193,19 @@ void TestQJsonDbRequest::multiplerequests() QCOMPARE(results.size(), 0); } +void TestQJsonDbRequest::defaultConnection() +{ + // make sure that the default connection connects automatically + QJsonDbConnection *connection = QJsonDbConnection::defaultConnection(); + QJsonDbReadRequest request(QStringLiteral("[?_type=\"Foo\"]")); + QEventLoop ev; + QObject::connect(&request, SIGNAL(finished()), &ev, SLOT(quit())); + QTimer::singleShot(10000, &ev, SLOT(quit())); + QVERIFY(connection->send(&request)); + ev.exec(); + QCOMPARE((int)request.status(), (int)QJsonDbRequest::Finished); +} + void TestQJsonDbRequest::bindings() { { -- cgit v1.2.3