diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-04-14 04:53:13 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-04-15 04:48:55 (GMT) |
commit | 35afac3d3a275aa69c74e174cfeb5e411816e94a (patch) | |
tree | 533d0c13a2bb52eaf914aedce87e4076dedd6635 /tests/auto/declarative/sql | |
parent | fa93b3fb3956f77f36c520e41b0c5065e51a56ce (diff) | |
download | Qt-35afac3d3a275aa69c74e174cfeb5e411816e94a.zip Qt-35afac3d3a275aa69c74e174cfeb5e411816e94a.tar.gz Qt-35afac3d3a275aa69c74e174cfeb5e411816e94a.tar.bz2 |
Rename "sql" test so autotester doesn't get confused.
Diffstat (limited to 'tests/auto/declarative/sql')
19 files changed, 0 insertions, 608 deletions
diff --git a/tests/auto/declarative/sql/data/README b/tests/auto/declarative/sql/data/README deleted file mode 100644 index 7efca3a..0000000 --- a/tests/auto/declarative/sql/data/README +++ /dev/null @@ -1,3 +0,0 @@ -These tests are executed in sequence - the database persist until the end of the -testing. This is done to better exercise the persistence of the database, since -that is how it is used. diff --git a/tests/auto/declarative/sql/data/changeversion.js b/tests/auto/declarative/sql/data/changeversion.js deleted file mode 100644 index 680d7a6..0000000 --- a/tests/auto/declarative/sql/data/changeversion.js +++ /dev/null @@ -1,53 +0,0 @@ -function test() { - var r="transaction_not_finished"; - - var db = openDatabaseSync("QmlTestDB-changeversion", "", "Test database from Qt autotests", 1000000, - function(db) { - db.changeVersion("","1.0") - db.transaction(function(tx){ - tx.executeSql('CREATE TABLE Greeting(salutation TEXT, salutee TEXT)'); - }) - }); - - db.transaction(function(tx){ - tx.executeSql('INSERT INTO Greeting VALUES ("Hello", "world")'); - tx.executeSql('INSERT INTO Greeting VALUES ("Goodbye", "cruel world")'); - }); - - - db = openDatabaseSync("QmlTestDB-changeversion", "", "Test database from Qt autotests", 1000000); - - if (db.version == "1.0") - db.changeVersion("1.0","2.0",function(tx) - { - tx.executeSql('CREATE TABLE Utterance(type TEXT, phrase TEXT)') - var rs = tx.executeSql('SELECT * FROM Greeting'); - for (var i=0; i<rs.rows.length; ++i) { - var type = "Greeting"; - var phrase = rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee; - if (rs.rows.item(i).salutation == "Goodbye" - || rs.rows.item(i).salutation == "Farewell" - || rs.rows.item(i).salutation == "Good-bye") type = "Valediction"; - var ins = tx.executeSql('INSERT INTO Utterance VALUES(?,?)',[type,phrase]); - } - tx.executeSql('DROP TABLE Greeting'); - }); - else - return "db.version should be 1.0, but is " + db.version; - - var db = openDatabaseSync("QmlTestDB-changeversion", "2.0", "Test database from Qt autotests", 1000000); - - db.transaction(function(tx){ - var rs = tx.executeSql('SELECT * FROM Utterance'); - r = "" - for (var i=0; i<rs.rows.length; ++i) { - r += "(" + rs.rows.item(i).type + ": " + rs.rows.item(i).phrase + ")"; - } - if (r == "(Greeting: Hello, world)(Valediction: Goodbye, cruel world)") - r = "passed" - else - r = "WRONG DATA: " + r; - }) - - return r; -} diff --git a/tests/auto/declarative/sql/data/creation-a.js b/tests/auto/declarative/sql/data/creation-a.js deleted file mode 100644 index bd7d5c5..0000000 --- a/tests/auto/declarative/sql/data/creation-a.js +++ /dev/null @@ -1,18 +0,0 @@ -function test() { - var r="transaction_not_finished"; - - var db = openDatabaseSync("QmlTestDB-creation-a", "1.0", "Test database from Qt autotests", 1000000, - function(db) { - db.transaction(function(tx){ - tx.executeSql('CREATE TABLE Greeting(salutation TEXT, salutee TEXT)'); - r = "passed"; - }) - }); - - var db = openDatabaseSync("QmlTestDB-creation-a", "1.0", "Test database from Qt autotests", 1000000, - function(db) { - r = "FAILED: should have already been created"; - }); - - return r; -} diff --git a/tests/auto/declarative/sql/data/creation.js b/tests/auto/declarative/sql/data/creation.js deleted file mode 100644 index 317b4c1..0000000 --- a/tests/auto/declarative/sql/data/creation.js +++ /dev/null @@ -1,14 +0,0 @@ -function test() { - var r="transaction_not_finished"; - var db = openDatabaseSync("QmlTestDB-creation", "1.0", "Test database from Qt autotests", 1000000); - - db.transaction( - function(tx) { - tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)'); - tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); - r = "passed"; - } - ); - - return r; -} diff --git a/tests/auto/declarative/sql/data/error-a.js b/tests/auto/declarative/sql/data/error-a.js deleted file mode 100644 index 10a23f6..0000000 --- a/tests/auto/declarative/sql/data/error-a.js +++ /dev/null @@ -1,20 +0,0 @@ -function test() { - var db = openDatabaseSync("QmlTestDB-error-a", "1.0", "Test database from Qt autotests", 1000000); - var r="transaction_not_finished"; - - try { - db.transaction( - function(tx) { - var rs = tx.executeSql('SELECT * FROM NotExists'); - r = "SHOULD NOT SUCCEED"; - } - ); - } catch (err) { - if (err.message == "no such table: NotExists Unable to execute statement") - r = "passed"; - else - r = "WRONG ERROR="+err.message; - } - - return r; -} diff --git a/tests/auto/declarative/sql/data/error-b.js b/tests/auto/declarative/sql/data/error-b.js deleted file mode 100644 index 4dd0ecf..0000000 --- a/tests/auto/declarative/sql/data/error-b.js +++ /dev/null @@ -1,13 +0,0 @@ -function test() { - var db = openDatabaseSync("QmlTestDB-error-b", "1.0", "Test database from Qt autotests", 1000000); - var r="transaction_not_finished"; - - db.transaction( - function(tx) { - tx.executeSql('INSERT INTO Greeting VALUES("junk","junk")'); - notexist[123] = "oops" - } - ); - - return r; -} diff --git a/tests/auto/declarative/sql/data/error-creation.js b/tests/auto/declarative/sql/data/error-creation.js deleted file mode 100644 index 0ab2a35..0000000 --- a/tests/auto/declarative/sql/data/error-creation.js +++ /dev/null @@ -1,14 +0,0 @@ -function test() { - var r="transaction_not_finished"; - try { - var db = openDatabaseSync("QmlTestDB-creation", "2.0", "Test database from Qt autotests", 1000000); - } catch (err) { - if (err.code != SQLException.VERSION_ERR) - r = "WRONG ERROR CODE="+err.code; - else if (err.message != "SQL: database version mismatch") - r = "WRONG ERROR="+err.message; - else - r = "passed"; - } - return r; -} diff --git a/tests/auto/declarative/sql/data/error-notransaction.js b/tests/auto/declarative/sql/data/error-notransaction.js deleted file mode 100644 index b9cc647..0000000 --- a/tests/auto/declarative/sql/data/error-notransaction.js +++ /dev/null @@ -1,15 +0,0 @@ -function test() { - var db = openDatabaseSync("QmlTestDB-data/error-notransaction", "1.0", "Test database from Qt autotests", 1000000); - var r="transaction_not_finished"; - - try { - db.transaction(); - } catch (err) { - if (err.message == "transaction: missing callback") - r = "passed"; - else - r = "WRONG ERROR="+err.message; - } - - return r; -} diff --git a/tests/auto/declarative/sql/data/error-outsidetransaction.js b/tests/auto/declarative/sql/data/error-outsidetransaction.js deleted file mode 100644 index a7af3bd..0000000 --- a/tests/auto/declarative/sql/data/error-outsidetransaction.js +++ /dev/null @@ -1,17 +0,0 @@ -function test() { - var db = openDatabaseSync("QmlTestDB-data/error-notransaction", "1.0", "Test database from Qt autotests", 1000000); - var r="transaction_not_finished"; - var v; - - try { - db.transaction(function(tx) { v = tx }); - v.executeSql("SELECT 'bad'") - } catch (err) { - if (err.message == "executeSql called outside transaction()") - r = "passed"; - else - r = "WRONG ERROR="+err.message; - } - - return r; -} diff --git a/tests/auto/declarative/sql/data/iteration-forwardonly.js b/tests/auto/declarative/sql/data/iteration-forwardonly.js deleted file mode 100644 index 45947c0..0000000 --- a/tests/auto/declarative/sql/data/iteration-forwardonly.js +++ /dev/null @@ -1,29 +0,0 @@ -function test() { - var db = openDatabaseSync("QmlTestDB-iteration-forwardonly", "", "Test database from Qt autotests", 1000000); - var r="transaction_not_finished"; - - db.transaction( - function(tx) { - tx.executeSql('CREATE TABLE Greeting(salutation TEXT, salutee TEXT)'); - tx.executeSql('INSERT INTO Greeting VALUES ("Hello", "world")'); - tx.executeSql('INSERT INTO Greeting VALUES ("Goodbye", "cruel world")'); - } - ) - - db.transaction( - function(tx) { - var rs = tx.executeSql('SELECT * FROM Greeting'); - rs.forwardOnly = !rs.forwardOnly - var r1="" - for(var i = 0; i < rs.rows.length; i++) - r1 += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + ";" - if (r1 != "hello, world;hello, world;hello, world;hello, world;") - if (r1 != "Hello, world;Goodbye, cruel world;") - r = "SELECTED DATA WRONG: "+r1; - else - r = "passed"; - } - ); - - return r; -} diff --git a/tests/auto/declarative/sql/data/iteration.js b/tests/auto/declarative/sql/data/iteration.js deleted file mode 100644 index c34cbbb..0000000 --- a/tests/auto/declarative/sql/data/iteration.js +++ /dev/null @@ -1,28 +0,0 @@ -function test() { - var db = openDatabaseSync("QmlTestDB-iteration", "", "Test database from Qt autotests", 1000000); - var r="transaction_not_finished"; - - db.transaction( - function(tx) { - tx.executeSql('CREATE TABLE Greeting(salutation TEXT, salutee TEXT)'); - tx.executeSql('INSERT INTO Greeting VALUES ("Hello", "world")'); - tx.executeSql('INSERT INTO Greeting VALUES ("Goodbye", "cruel world")'); - } - ) - - db.transaction( - function(tx) { - var rs = tx.executeSql('SELECT * FROM Greeting'); - var r1="" - for(var i = 0; i < rs.rows.length; i++) - r1 += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + ";" - if (r1 != "hello, world;hello, world;hello, world;hello, world;") - if (r1 != "Hello, world;Goodbye, cruel world;") - r = "SELECTED DATA WRONG: "+r1; - else - r = "passed"; - } - ); - - return r; -} diff --git a/tests/auto/declarative/sql/data/readonly-error.js b/tests/auto/declarative/sql/data/readonly-error.js deleted file mode 100644 index 69ec67f..0000000 --- a/tests/auto/declarative/sql/data/readonly-error.js +++ /dev/null @@ -1,27 +0,0 @@ -function test() { - var r="transaction_not_finished"; - var db = openDatabaseSync("QmlTestDB-readonly-error", "1.0", "Test database from Qt autotests", 1000000); - - db.transaction( - function(tx) { - tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)'); - tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); - } - ); - - try { - db.readTransaction( - function(tx) { - tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); - r = "FAILED"; - } - ); - } catch (err) { - if (err.message == "Read-only Transaction") - r = "passed"; - else - r = "WRONG ERROR="+err.message; - } - - return r; -} diff --git a/tests/auto/declarative/sql/data/readonly.js b/tests/auto/declarative/sql/data/readonly.js deleted file mode 100644 index 5ee862c..0000000 --- a/tests/auto/declarative/sql/data/readonly.js +++ /dev/null @@ -1,24 +0,0 @@ -function test() { - var r="transaction_not_finished"; - var db = openDatabaseSync("QmlTestDB-readonly", "1.0", "Test database from Qt autotests", 1000000); - - db.transaction( - function(tx) { - tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)'); - tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); - r = "passed"; - } - ); - - db.readTransaction( - function(tx) { - var rs = tx.executeSql('SELECT * FROM Greeting'); - if (rs.rows.item(0).salutation == 'hello') - r = "passed"; - else - r = "FAILED"; - } - ); - - return r; -} diff --git a/tests/auto/declarative/sql/data/reopen1.js b/tests/auto/declarative/sql/data/reopen1.js deleted file mode 100644 index c1a8157..0000000 --- a/tests/auto/declarative/sql/data/reopen1.js +++ /dev/null @@ -1,14 +0,0 @@ -function test() { - var r="transaction_not_finished"; - var db = openDatabaseSync("QmlTestDB-reopen", "1.0", "Test database from Qt autotests", 1000000); - - db.transaction( - function(tx) { - tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)'); - tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); - r = "passed"; - } - ); - - return r; -} diff --git a/tests/auto/declarative/sql/data/reopen2.js b/tests/auto/declarative/sql/data/reopen2.js deleted file mode 100644 index 4f7248f..0000000 --- a/tests/auto/declarative/sql/data/reopen2.js +++ /dev/null @@ -1,16 +0,0 @@ -function test() { - var r="transaction_not_finished"; - var db = openDatabaseSync("QmlTestDB-reopen", "1.0", "Test database from Qt autotests", 1000000); - - db.transaction( - function(tx) { - var rs = tx.executeSql('SELECT * FROM Greeting'); - if (rs.rows.item(0).salutation == 'hello') - r = "passed"; - else - r = "FAILED"; - } - ); - - return r; -} diff --git a/tests/auto/declarative/sql/data/selection-bindnames.js b/tests/auto/declarative/sql/data/selection-bindnames.js deleted file mode 100644 index 9786821..0000000 --- a/tests/auto/declarative/sql/data/selection-bindnames.js +++ /dev/null @@ -1,26 +0,0 @@ -function test() { - var db = openDatabaseSync("QmlTestDB-bindnames", "", "Test database from Qt autotests", 1000000); - var r="transaction_not_finished"; - - db.transaction( - function(tx) { - tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)'); - tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); - tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'goodbye', 'world' ]); - tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); - tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'there' ]); - } - ); - - db.transaction( - function(tx) { - var rs = tx.executeSql('SELECT * FROM Greeting WHERE salutation=:p2 AND salutee=:p1', {':p1':'world', ':p2':'hello'}); - if ( rs.rows.length != 2 ) - r = "SELECT RETURNED WRONG VALUE "+rs.rows.length+rs.rows.item(0)+rs.rows.item(1) - else - r = "passed"; - } - ); - - return r; -} diff --git a/tests/auto/declarative/sql/data/selection.js b/tests/auto/declarative/sql/data/selection.js deleted file mode 100644 index f116eff..0000000 --- a/tests/auto/declarative/sql/data/selection.js +++ /dev/null @@ -1,26 +0,0 @@ -function test() { - var db = openDatabaseSync("QmlTestDB-selection", "", "Test database from Qt autotests", 1000000); - var r="transaction_not_finished"; - - db.transaction( - function(tx) { - tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)'); - tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); - tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); - } - ); - - db.transaction( - function(tx) { - tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); - tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); - var rs = tx.executeSql('SELECT * FROM Greeting'); - if ( rs.rows.length != 4 ) - r = "SELECT RETURNED WRONG VALUE "+rs.rows.length+rs.rows[0]+rs.rows[1] - else - r = "passed"; - } - ); - - return r; -} diff --git a/tests/auto/declarative/sql/sql.pro b/tests/auto/declarative/sql/sql.pro deleted file mode 100644 index 7e4fdd8..0000000 --- a/tests/auto/declarative/sql/sql.pro +++ /dev/null @@ -1,12 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative -QT += sql script -macx:CONFIG -= app_bundle - -SOURCES += tst_sql.cpp - -# Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - diff --git a/tests/auto/declarative/sql/tst_sql.cpp b/tests/auto/declarative/sql/tst_sql.cpp deleted file mode 100644 index c8b8dc3..0000000 --- a/tests/auto/declarative/sql/tst_sql.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include <qtest.h> -#include "../../../shared/util.h" -#include <QtDeclarative/qdeclarativeengine.h> -#include <QtDeclarative/qdeclarativecomponent.h> -#include <private/qdeclarativetext_p.h> -#include <private/qdeclarativeengine_p.h> -#include <QtCore/qcryptographichash.h> -#include <QtWebKit/qwebpage.h> -#include <QtWebKit/qwebframe.h> -#include <QtWebKit/qwebdatabase.h> -#include <QtWebKit/qwebsecurityorigin.h> -#include <QtSql/qsqldatabase.h> -#include <QtCore/qdir.h> -#include <QtCore/qfile.h> - -class tst_sql : public QObject -{ - Q_OBJECT -public: - tst_sql() - { - qApp->setApplicationName("tst_sql"); - qApp->setOrganizationName("Nokia"); - qApp->setOrganizationDomain("nokia.com"); - engine = new QDeclarativeEngine; - } - - ~tst_sql() - { - delete engine; - } - -private slots: - void initTestCase(); - - void checkDatabasePath(); - - void testQml_data(); - void testQml(); - void testQml_cleanopen_data(); - void testQml_cleanopen(); - void totalDatabases(); - - void cleanupTestCase(); - -private: - QString dbDir() const; - QDeclarativeEngine *engine; -}; - -class QWebPageWithJavaScriptConsoleMessages : public QWebPage { -public: - void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID) - { - qWarning() << sourceID << ":" << lineNumber << ":" << message; - } -}; - -void removeRecursive(const QString& dirname) -{ - QDir dir(dirname); - QFileInfoList entries(dir.entryInfoList(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot)); - for (int i = 0; i < entries.count(); ++i) - if (entries[i].isDir()) - removeRecursive(entries[i].filePath()); - else - dir.remove(entries[i].fileName()); - QDir().rmdir(dirname); -} - -void tst_sql::initTestCase() -{ - removeRecursive(dbDir()); - QDir().mkpath(dbDir()); -} - -void tst_sql::cleanupTestCase() -{ - removeRecursive(dbDir()); -} - -QString tst_sql::dbDir() const -{ - static QString tmpd = QDir::tempPath()+"/tst_sql_output-" - + QDateTime::currentDateTime().toString(QLatin1String("yyyyMMddhhmmss")); - return tmpd; -} - -void tst_sql::checkDatabasePath() -{ - // Check default storage path (we can't use it since we don't want to mess with user's data) - QVERIFY(engine->offlineStoragePath().contains("tst_sql")); - QVERIFY(engine->offlineStoragePath().contains("OfflineStorage")); -} - -static const int total_databases_created_by_tests = 12; -void tst_sql::testQml_data() -{ - QTest::addColumn<QString>("jsfile"); // The input file - - // Each test should use a newly named DB to avoid inter-test dependencies - QTest::newRow("creation") << "data/creation.js"; - QTest::newRow("creation-a") << "data/creation-a.js"; - QTest::newRow("creation") << "data/creation.js"; - QTest::newRow("error-creation") << "data/error-creation.js"; // re-uses above DB - QTest::newRow("changeversion") << "data/changeversion.js"; - QTest::newRow("readonly") << "data/readonly.js"; - QTest::newRow("readonly-error") << "data/readonly-error.js"; - QTest::newRow("selection") << "data/selection.js"; - QTest::newRow("selection-bindnames") << "data/selection-bindnames.js"; - QTest::newRow("iteration") << "data/iteration.js"; - QTest::newRow("iteration-forwardonly") << "data/iteration-forwardonly.js"; - QTest::newRow("error-a") << "data/error-a.js"; - QTest::newRow("error-notransaction") << "data/error-notransaction.js"; - QTest::newRow("error-outsidetransaction") << "data/error-outsidetransaction.js"; // reuse above - QTest::newRow("reopen1") << "data/reopen1.js"; - QTest::newRow("reopen2") << "data/reopen2.js"; // re-uses above DB - - // If you add a test, you should usually use a new database in the - // test - in which case increment total_databases_created_by_tests above. -} - -/* -void tst_sql::validateAgainstWebkit() -{ - // Validates tests against WebKit (HTML5) support. - // - QFETCH(QString, jsfile); - QFETCH(QString, result); - QFETCH(int, databases); - - QFile f(jsfile); - QVERIFY(f.open(QIODevice::ReadOnly)); - QString js=f.readAll(); - - QWebPageWithJavaScriptConsoleMessages webpage; - webpage.settings()->setOfflineStoragePath(dbDir()); - webpage.settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); - - QEXPECT_FAIL("","WebKit doesn't support openDatabaseSync yet", Continue); - QCOMPARE(webpage.mainFrame()->evaluateJavaScript(js).toString(),result); - - QTest::qWait(100); // WebKit crashes if you quit it too fast - - QWebSecurityOrigin origin = webpage.mainFrame()->securityOrigin(); - QList<QWebDatabase> dbs = origin.databases(); - QCOMPARE(dbs.count(), databases); -} -*/ - -void tst_sql::testQml() -{ - // Tests QML SQL Database support with tests - // that have been validated against Webkit. - // - QFETCH(QString, jsfile); - - QString qml= - "import Qt 4.7\n" - "import \""+jsfile+"\" as JS\n" - "Text { text: JS.test() }"; - - engine->setOfflineStoragePath(dbDir()); - QDeclarativeComponent component(engine); - component.setData(qml.toUtf8(), QUrl::fromLocalFile(SRCDIR "/empty.qml")); // just a file for relative local imports - QVERIFY(!component.isError()); - QDeclarativeText *text = qobject_cast<QDeclarativeText*>(component.create()); - QVERIFY(text != 0); - QCOMPARE(text->text(),QString("passed")); -} - -void tst_sql::testQml_cleanopen_data() -{ - QTest::addColumn<QString>("jsfile"); // The input file - QTest::newRow("reopen1") << "data/reopen1.js"; - QTest::newRow("reopen2") << "data/reopen2.js"; - QTest::newRow("error-creation") << "data/error-creation.js"; // re-uses creation DB -} - -void tst_sql::testQml_cleanopen() -{ - // Same as testQml, but clean connections between tests, - // making it more like the tests are running in new processes. - testQml(); - - QDeclarativeEnginePrivate::getScriptEngine(engine)->collectGarbage(); // close databases - foreach (QString dbname, QSqlDatabase::connectionNames()) { - QSqlDatabase::removeDatabase(dbname); - } -} - -void tst_sql::totalDatabases() -{ - QCOMPARE(QDir(dbDir()+"/Databases").entryInfoList(QDir::Files|QDir::NoDotAndDotDot).count(), total_databases_created_by_tests*2); -} - -QTEST_MAIN(tst_sql) - -#include "tst_sql.moc" |