diff options
author | Yann Bodson <yann.bodson@nokia.com> | 2009-10-06 02:29:32 (GMT) |
---|---|---|
committer | Yann Bodson <yann.bodson@nokia.com> | 2009-10-06 02:29:32 (GMT) |
commit | abf7649fb60a87208a3d915d97f4fee9bee02f26 (patch) | |
tree | a789b810f5bfb822992b4caf1f14b81fd2b02ee4 | |
parent | c3abf1a4ae82a57bbc6cc324fa6f9a99615ab066 (diff) | |
parent | e559d97aa8e37c63b9e0090fe5dfa4b9bdeb079e (diff) | |
download | Qt-abf7649fb60a87208a3d915d97f4fee9bee02f26.zip Qt-abf7649fb60a87208a3d915d97f4fee9bee02f26.tar.gz Qt-abf7649fb60a87208a3d915d97f4fee9bee02f26.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r-- | demos/declarative/contacts/Contact.qml | 4 | ||||
-rw-r--r-- | examples/declarative/velocity/Day.qml | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 42 | ||||
-rw-r--r-- | tests/auto/declarative/qfxwebview/data/basic.html | 12 | ||||
-rw-r--r-- | tests/auto/declarative/qfxwebview/data/basic.qml | 5 | ||||
-rw-r--r-- | tests/auto/declarative/qfxwebview/qfxwebview.pro | 6 | ||||
-rw-r--r-- | tests/auto/declarative/qfxwebview/tst_qfxwebview.cpp | 100 | ||||
-rw-r--r-- | tests/auto/declarative/sql/tst_sql.cpp | 27 |
8 files changed, 150 insertions, 48 deletions
diff --git a/demos/declarative/contacts/Contact.qml b/demos/declarative/contacts/Contact.qml index 91510c7..e12cd3b 100644 --- a/demos/declarative/contacts/Contact.qml +++ b/demos/declarative/contacts/Contact.qml @@ -82,8 +82,8 @@ Item { } Column { id: layout - width: contents.width - height:contents.height + width: childrenRect.width + height: childrenRect.height anchors.centerIn: parent spacing: 5 ContactField { diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml index 4001a3e..052f690 100644 --- a/examples/declarative/velocity/Day.qml +++ b/examples/declarative/velocity/Day.qml @@ -22,7 +22,7 @@ Rectangle { font.bold: true width: 370 text: day - style: Outline + style: "Outline" styleColor: "#dedede" } Repeater { diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 72603ed..f34d790 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -114,43 +114,9 @@ QScriptValue desktopOpenUrl(QScriptContext *ctxt, QScriptEngine *e) return e->newVariant(QVariant(ret)); } -// XXX Something like this should be exported by Qt. static QString userLocalDataPath(const QString& app) { - QString result; - -#ifdef Q_OS_WIN -#ifndef Q_OS_WINCE - QLibrary library(QLatin1String("shell32")); -#else - QLibrary library(QLatin1String("coredll")); -#endif // Q_OS_WINCE - typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, LPWSTR, int, BOOL); - GetSpecialFolderPath SHGetSpecialFolderPath = (GetSpecialFolderPath)library.resolve("SHGetSpecialFolderPathW"); - if (SHGetSpecialFolderPath) { - wchar_t path[MAX_PATH]; - SHGetSpecialFolderPath(0, path, CSIDL_APPDATA, FALSE); - result = QString::fromWCharArray(path); - } -#endif // Q_OS_WIN - -#ifdef Q_OS_MAC - result = QLatin1String(qgetenv("HOME")); - result += "/Library/Application Support"; -#else - if (result.isEmpty()) { - // Fallback: UNIX style - result = QLatin1String(qgetenv("XDG_DATA_HOME")); - if (result.isEmpty()) { - result = QLatin1String(qgetenv("HOME")); - result += QLatin1String("/.local/share"); - } - } -#endif - - result += QLatin1Char('/'); - result += app; - return result; + return QDesktopServices::storageLocation(QDesktopServices::DataLocation) + QLatin1String("/") + app; } QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) @@ -166,7 +132,7 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) qtObject.setProperty(QLatin1String("DesktopServices"), desktopObject); scriptEngine.globalObject().setProperty(QLatin1String("Qt"), qtObject); - offlineStoragePath = userLocalDataPath(QLatin1String("Nokia/Qt/QML/OfflineStorage")); + offlineStoragePath = userLocalDataPath(QLatin1String("QML/OfflineStorage")); qt_add_qmlxmlhttprequest(&scriptEngine); qt_add_qmlsqldatabase(&scriptEngine); @@ -1602,7 +1568,7 @@ public: if (s->find(unqualifiedtype,vmajor,vminor,type_return,url_return)) return true; if (s->urls.count() == 1 && !s->isBuiltin[0] && !s->isLibrary[0] && url_return) { - *url_return = QUrl(s->urls[0]+"/").resolved(QUrl(QLatin1String(unqualifiedtype + ".qml"))); + *url_return = QUrl(s->urls[0]+QLatin1String("/")).resolved(QUrl(QLatin1String(unqualifiedtype + ".qml"))); return true; } } @@ -1697,7 +1663,7 @@ void QmlEngine::addImportPath(const QString& path) QFxWebView and the SQL databases created with openDatabase() are stored here. - The default is Nokia/Qt/QML/Databases/ in the platform-standard + The default is QML/OfflineStorage/ in the platform-standard user application data directory. */ void QmlEngine::setOfflineStoragePath(const QString& dir) diff --git a/tests/auto/declarative/qfxwebview/data/basic.html b/tests/auto/declarative/qfxwebview/data/basic.html new file mode 100644 index 0000000..254317c --- /dev/null +++ b/tests/auto/declarative/qfxwebview/data/basic.html @@ -0,0 +1,12 @@ +<html> +<head><title>Basic</title> +<link rel="shortcut icon" type="image/x-icon" href="basic.ico"> +</head> +<body leftmargin="0" marginwidth="0"> +<table width="123"> +<tbody> +<tr><td>This is a basic test.</td></tr> +</tbody> +</table> +</body> +</html> diff --git a/tests/auto/declarative/qfxwebview/data/basic.qml b/tests/auto/declarative/qfxwebview/data/basic.qml new file mode 100644 index 0000000..5394837 --- /dev/null +++ b/tests/auto/declarative/qfxwebview/data/basic.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +WebView { + url: "basic.html" +} diff --git a/tests/auto/declarative/qfxwebview/qfxwebview.pro b/tests/auto/declarative/qfxwebview/qfxwebview.pro new file mode 100644 index 0000000..ee78950 --- /dev/null +++ b/tests/auto/declarative/qfxwebview/qfxwebview.pro @@ -0,0 +1,6 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qfxwebview.cpp + +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qfxwebview/tst_qfxwebview.cpp b/tests/auto/declarative/qfxwebview/tst_qfxwebview.cpp new file mode 100644 index 0000000..834c07f --- /dev/null +++ b/tests/auto/declarative/qfxwebview/tst_qfxwebview.cpp @@ -0,0 +1,100 @@ +#include <qtest.h> +#include "../../../shared/util.h" +#include <QtDeclarative/qmlengine.h> +#include <QtDeclarative/qmlcomponent.h> +#include <QtDeclarative/qfxwebview.h> +#include <QtWebKit/qwebpage.h> +#include <QtWebKit/qwebframe.h> +#include <QtCore/qdir.h> +#include <QtCore/qfile.h> + +class tst_qfxwebview : public QObject +{ + Q_OBJECT +public: + tst_qfxwebview() {} + +private slots: + void testBasicProperties(); + void cleanupTestCase(); + + +private: + void checkNoErrors(const QmlComponent& component); + QmlEngine engine; + QString tmpDir() const + { + static QString tmpd = QDir::tempPath()+"/tst_qfxwebview-" + + QDateTime::currentDateTime().toString(QLatin1String("yyyyMMddhhmmss")); + return tmpd; + } +}; + +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_qfxwebview::cleanupTestCase() +{ + removeRecursive(tmpDir()); +} + +void tst_qfxwebview::checkNoErrors(const QmlComponent& component) +{ + if (component.isError()) { + QList<QmlError> errors = component.errors(); + for (int ii = 0; ii < errors.count(); ++ii) { + const QmlError &error = errors.at(ii); + QByteArray errorStr = QByteArray::number(error.line()) + ":" + + QByteArray::number(error.column()) + ":" + + error.description().toUtf8(); + qWarning() << errorStr; + } + } + QVERIFY(!component.isError()); +} + +void tst_qfxwebview::testBasicProperties() +{ + QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml")); + checkNoErrors(component); + QWebSettings::enablePersistentStorage(tmpDir()); + + QFxWebView *wv = qobject_cast<QFxWebView*>(component.create()); + QVERIFY(wv != 0); + QTRY_COMPARE(wv->progress(), 1.0); + QCOMPARE(wv->title(),QString("Basic")); + wv->icon().save("test.png"); + //QCOMPARE(wv->icon(),QPixmap(SRCDIR "/data/basic.ico")); + QCOMPARE(wv->statusText(),QString("")); + QFile htmlfile(SRCDIR "/data/basic.html"); + QVERIFY(htmlfile.open(QIODevice::ReadOnly)); + QString actualhtml____ = wv->html(); // "____" is to make errors line up for easier reading + QString expectedhtml = htmlfile.readAll(); + actualhtml____.replace(QRegExp("\\s+"),""); + expectedhtml.replace(QRegExp("\\s+"),""); + QCOMPARE(actualhtml____,expectedhtml); // same, ignoring whitespace + QCOMPARE(wv->width(), 123.0); + QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html")); + QCOMPARE(wv->status(), QFxWebView::Ready); + QVERIFY(wv->reloadAction()); + QVERIFY(wv->reloadAction()->isEnabled()); + QVERIFY(wv->backAction()); + QVERIFY(!wv->backAction()->isEnabled()); + QVERIFY(wv->forwardAction()); + QVERIFY(!wv->forwardAction()->isEnabled()); + QVERIFY(wv->stopAction()); + QVERIFY(!wv->stopAction()->isEnabled()); +} + +QTEST_MAIN(tst_qfxwebview) + +#include "tst_qfxwebview.moc" diff --git a/tests/auto/declarative/sql/tst_sql.cpp b/tests/auto/declarative/sql/tst_sql.cpp index 10ce6d8..22e9ba4 100644 --- a/tests/auto/declarative/sql/tst_sql.cpp +++ b/tests/auto/declarative/sql/tst_sql.cpp @@ -14,7 +14,18 @@ class tst_sql : public QObject { Q_OBJECT public: - tst_sql() {} + tst_sql() + { + qApp->setApplicationName("tst_sql"); + qApp->setOrganizationName("Nokia"); + qApp->setOrganizationDomain("nokia.com"); + engine = new QmlEngine; + } + + ~tst_sql() + { + delete engine; + } private slots: void initTestCase(); @@ -31,7 +42,7 @@ private slots: private: QString dbDir() const; - QmlEngine engine; + QmlEngine *engine; }; class QWebPageWithJavaScriptConsoleMessages : public QWebPage { @@ -67,14 +78,16 @@ void tst_sql::cleanupTestCase() QString tst_sql::dbDir() const { - return QString(SRCDIR)+"/output"; + 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("Nokia")); - QVERIFY(engine.offlineStoragePath().contains("OfflineStorage")); + QVERIFY(engine->offlineStoragePath().contains("Nokia")); + QVERIFY(engine->offlineStoragePath().contains("OfflineStorage")); } void tst_sql::testQml_data() @@ -142,8 +155,8 @@ void tst_sql::testQml() "import Qt 4.6\n" "Text { Script { source: \""+jsfile+"\" } text: test() }"; - engine.setOfflineStoragePath(dbDir()); - QmlComponent component(&engine, qml.toUtf8(), QUrl::fromLocalFile(SRCDIR "/empty.qml")); // just a file for relative local imports + engine->setOfflineStoragePath(dbDir()); + QmlComponent component(engine, qml.toUtf8(), QUrl::fromLocalFile(SRCDIR "/empty.qml")); // just a file for relative local imports QFxText *text = qobject_cast<QFxText*>(component.create()); QVERIFY(text != 0); QCOMPARE(text->text(),result); |