summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-03-03 01:06:02 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-03-03 01:06:02 (GMT)
commit4c0b6e0d0a5303861098f653e1c8e8823480ac82 (patch)
tree2529081b4f2d4e20f69bbb77435712db31765bb1 /tests
parentc131c4d922bd381b44164673085fb83547375fd0 (diff)
parentc9e07d69ec084a75fc083baecd46d0b8b422d1c4 (diff)
downloadQt-4c0b6e0d0a5303861098f653e1c8e8823480ac82.zip
Qt-4c0b6e0d0a5303861098f653e1c8e8823480ac82.tar.gz
Qt-4c0b6e0d0a5303861098f653e1c8e8823480ac82.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/declarative.pro1
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp8
-rw-r--r--tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro8
-rw-r--r--tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp (renamed from tests/auto/declarative/qdeclarativewebview/testtypes.h)37
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.1.qml13
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.2.qml11
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.js5
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp28
-rw-r--r--tests/auto/declarative/qdeclarativegridview/data/propertychanges.qml69
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp126
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/propertychanges.qml71
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp168
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/displaypath.qml2
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/pathview.qml2
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/pathview3.qml2
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/propertychanges.qml115
-rw-r--r--tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp167
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/basic.qml1
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/elements.qml1
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/forward.pngbin0 -> 2377 bytes
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/javaScript.qml1
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/loadError.qml1
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/newwindows.qml1
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml3
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/sethtml.qml1
-rw-r--r--tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro3
-rw-r--r--tests/auto/declarative/qdeclarativewebview/testtypes.cpp52
-rw-r--r--tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp346
-rw-r--r--tests/auto/declarative/visual/qfxwebview/autosize/autosize.qml1
-rw-r--r--tests/auto/declarative/visual/webview/embedding/nesting.qml1
-rw-r--r--tests/auto/declarative/visual/webview/javascript/evaluateJavaScript.qml1
-rw-r--r--tests/auto/declarative/visual/webview/javascript/windowObjects.qml1
-rw-r--r--tests/auto/declarative/visual/webview/settings/fontFamily.qml1
-rw-r--r--tests/auto/declarative/visual/webview/settings/fontSize.qml1
-rw-r--r--tests/auto/declarative/visual/webview/settings/noAutoLoadImages.qml1
-rw-r--r--tests/auto/declarative/visual/webview/settings/setFontFamily.qml1
-rw-r--r--tests/auto/declarative/visual/webview/zooming/pageWidth.qml1
-rw-r--r--tests/auto/declarative/visual/webview/zooming/renderControl.qml1
-rw-r--r--tests/auto/declarative/visual/webview/zooming/resolution.qml1
-rw-r--r--tests/auto/declarative/visual/webview/zooming/zoomTextOnly.qml1
-rw-r--r--tests/auto/declarative/visual/webview/zooming/zooming.qml1
-rw-r--r--tests/auto/headers/tst_headers.cpp1
-rw-r--r--tests/auto/qbearertestcommon.h13
-rw-r--r--tests/auto/qmetaobject/tst_qmetaobject.cpp13
-rw-r--r--tests/auto/qnetworksession/lackey/main.cpp13
-rw-r--r--tests/auto/qnetworksession/test/tst_qnetworksession.cpp293
46 files changed, 1308 insertions, 281 deletions
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index 200d831..99a32d9 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -7,6 +7,7 @@ SUBDIRS += \
qdeclarativeanimations \ # Cover
qdeclarativebehaviors \ # Cover
qdeclarativebinding \ # Cover
+ qdeclarativecomponent \ # Cover
qdeclarativeconnection \ # Cover
qdeclarativecontext \ # Cover
qdeclarativedatetimeformatter \ # Cover
diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
index 53c63b5..f5e15fb 100644
--- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
+++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
@@ -217,21 +217,21 @@ void tst_qdeclarativeanimations::resume()
animation.setProperty("x");
animation.setFrom(10);
animation.setTo(200);
- animation.setDuration(500);
+ animation.setDuration(1000);
QVERIFY(animation.from() == 10);
animation.start();
- QTest::qWait(100);
+ QTest::qWait(400);
animation.pause();
qreal x = rect.x();
- QVERIFY(x != qreal(200));
+ QVERIFY(x != qreal(200) && x != qreal(10));
QVERIFY(animation.isRunning());
QVERIFY(animation.isPaused());
animation.resume();
QVERIFY(animation.isRunning());
QVERIFY(!animation.isPaused());
- QTest::qWait(100);
+ QTest::qWait(400);
animation.stop();
QVERIFY(rect.x() > x);
}
diff --git a/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro b/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro
new file mode 100644
index 0000000..c7affb7
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+QT += script network
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativecomponent.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativewebview/testtypes.h b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp
index 8eb703f..c9e304c 100644
--- a/tests/auto/declarative/qdeclarativewebview/testtypes.h
+++ b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp
@@ -38,29 +38,38 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#ifndef TESTTYPES_H
-#define TESTTYPES_H
+#include <qtest.h>
-#include <private/qdeclarativewebview_p.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
-class MyWebView : public QDeclarativeWebView
+class tst_qdeclarativecomponent : public QObject
{
Q_OBJECT
- Q_PROPERTY(int pixelsPainted READ pixelsPainted);
-
public:
- MyWebView() : pp(0) {}
-
- int pixelsPainted() const { return pp; }
+ tst_qdeclarativecomponent() { }
- void drawContents(QPainter *p, const QRect &r);
+private slots:
+ void loadEmptyUrl();
private:
- int pp;
+ QDeclarativeEngine engine;
};
-QML_DECLARE_TYPE(MyWebView);
+void tst_qdeclarativecomponent::loadEmptyUrl()
+{
+ QDeclarativeComponent c(&engine);
+ c.loadUrl(QUrl());
+
+ QVERIFY(c.isError());
+ QCOMPARE(c.errors().count(), 1);
+ QDeclarativeError error = c.errors().first();
+ QCOMPARE(error.url(), QUrl());
+ QCOMPARE(error.line(), -1);
+ QCOMPARE(error.column(), -1);
+ QCOMPARE(error.description(), QLatin1String("Invalid empty URL"));
+}
-void registerTypes();
+QTEST_MAIN(tst_qdeclarativecomponent)
-#endif // TESTTYPES_H
+#include "tst_qdeclarativecomponent.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.1.qml
new file mode 100644
index 0000000..9b11fa9
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.1.qml
@@ -0,0 +1,13 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ property string result
+
+ Script{
+ function f() {
+ result = b
+ }
+
+ }
+ onArgumentSignal: f()
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.2.qml
new file mode 100644
index 0000000..ec727e2
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.2.qml
@@ -0,0 +1,11 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ property string result
+ property string aProp: "hello"
+
+ Script{
+ source: "scriptScope.js"
+ }
+ onBasicSignal: f()
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.js b/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.js
new file mode 100644
index 0000000..5689930
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.js
@@ -0,0 +1,5 @@
+var aProp = "world";
+
+function f() {
+ result = aProp;
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 60c380c..8e7944d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -122,6 +122,7 @@ private slots:
void listToVariant();
void multiEngineObject();
void deletedObject();
+ void scriptScope();
void bug1();
@@ -1657,6 +1658,33 @@ void tst_qdeclarativeecmascript::deletedObject()
delete object;
}
+void tst_qdeclarativeecmascript::scriptScope()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("scriptScope.1.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ emit object->argumentSignal(19, "Hello world!", 10.3);
+ QEXPECT_FAIL("", "QTBUG-8641", Continue);
+ QCOMPARE(object->property("result").toString(), QLatin1String("undefined"));
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("scriptScope.2.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ emit object->basicSignal();
+ QEXPECT_FAIL("", "QTBUG-8641", Continue);
+ QCOMPARE(object->property("result").toString(), QLatin1String("world"));
+
+ delete object;
+ }
+}
+
QTEST_MAIN(tst_qdeclarativeecmascript)
#include "tst_qdeclarativeecmascript.moc"
diff --git a/tests/auto/declarative/qdeclarativegridview/data/propertychanges.qml b/tests/auto/declarative/qdeclarativegridview/data/propertychanges.qml
new file mode 100644
index 0000000..da2e8d0
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativegridview/data/propertychanges.qml
@@ -0,0 +1,69 @@
+import Qt 4.6
+
+Rectangle {
+ width: 360; height: 120; color: "white"
+ Component {
+ id: delegate
+ Item {
+ id: wrapper
+ width: 180; height: 40;
+ Column {
+ x: 5; y: 5
+ Text { text: '<b>Name:</b> ' + name }
+ Text { text: '<b>Number:</b> ' + number }
+ }
+ }
+ }
+ Component {
+ id: highlightRed
+ Rectangle {
+ color: "red"
+ radius: 10
+ opacity: 0.5
+ }
+ }
+ GridView {
+ cellWidth:180
+ cellHeight:40
+ objectName: "gridView"
+ anchors.fill: parent
+ model: listModel
+ delegate: delegate
+ highlight: highlightRed
+ focus: true
+ keyNavigationWraps: true
+ cacheBuffer: 10
+ flow: GridView.LeftToRight
+ }
+
+ data:[
+ ListModel {
+ id: listModel
+ ListElement {
+ name: "Bill Smith"
+ number: "555 3264"
+ }
+ ListElement {
+ name: "John Brown"
+ number: "555 8426"
+ }
+ ListElement {
+ name: "Sam Wise"
+ number: "555 0473"
+ }
+ },
+ ListModel {
+ objectName: "alternateModel"
+ ListElement {
+ name: "Jack"
+ number: "555 8426"
+ }
+ ListElement {
+ name: "Mary"
+ number: "555 3264"
+ }
+ }
+ ]
+}
+
+ \ No newline at end of file
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index 7a6a060..7ade309 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -39,17 +39,17 @@
**
****************************************************************************/
-#include <qdeclarativeengine.h>
-#include <qdeclarativecomponent.h>
-#include <QStringListModel>
#include <QtTest/QtTest>
-#include <private/qlistmodelinterface_p.h>
-#include <qdeclarativeview.h>
-#include <private/qdeclarativegridview_p.h>
-#include <private/qdeclarativetext_p.h>
-#include <private/qdeclarativerectangle_p.h>
-#include <qdeclarativecontext.h>
-#include <qdeclarativeexpression.h>
+#include <QtGui/qstringlistmodel.h>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativecontext.h>
+#include <QtDeclarative/qdeclarativeexpression.h>
+#include <QtDeclarative/private/qlistmodelinterface_p.h>
+#include <QtDeclarative/private/qdeclarativegridview_p.h>
+#include <QtDeclarative/private/qdeclarativetext_p.h>
+#include <QtDeclarative/private/qdeclarativelistmodel_p.h>
class tst_QDeclarativeGridView : public QObject
{
@@ -67,6 +67,9 @@ private slots:
void currentIndex();
void defaultValues();
void properties();
+ void propertyChanges();
+ void componentChanges();
+ void modelChanges();
void positionViewAtIndex();
void resetModel();
void QTBUG_8456();
@@ -92,7 +95,7 @@ public:
setRoleNames(roles);
}
- int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
+ int rowCount(const QModelIndex &parent=QModelIndex()) const { Q_UNUSED(parent); return list.count(); }
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const {
QVariant rv;
if (role == Name)
@@ -803,6 +806,107 @@ void tst_QDeclarativeGridView::properties()
delete obj;
}
+void tst_QDeclarativeGridView::propertyChanges()
+{
+ QDeclarativeView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+
+ QDeclarativeGridView *gridView = canvas->rootObject()->findChild<QDeclarativeGridView*>("gridView");
+ QVERIFY(gridView);
+
+ QSignalSpy keyNavigationWrapsSpy(gridView, SIGNAL(keyNavigationWrapsChanged()));
+ QSignalSpy cacheBufferSpy(gridView, SIGNAL(cacheBufferChanged()));
+ QSignalSpy flowSpy(gridView, SIGNAL(flowChanged()));
+
+ QCOMPARE(gridView->isWrapEnabled(), true);
+ QCOMPARE(gridView->cacheBuffer(), 10);
+ QCOMPARE(gridView->flow(), QDeclarativeGridView::LeftToRight);
+
+ gridView->setWrapEnabled(false);
+ gridView->setCacheBuffer(3);
+ gridView->setFlow(QDeclarativeGridView::TopToBottom);
+
+ QCOMPARE(gridView->isWrapEnabled(), false);
+ QCOMPARE(gridView->cacheBuffer(), 3);
+ QCOMPARE(gridView->flow(), QDeclarativeGridView::TopToBottom);
+
+ QCOMPARE(keyNavigationWrapsSpy.count(),1);
+ QCOMPARE(cacheBufferSpy.count(),1);
+ QCOMPARE(flowSpy.count(),1);
+
+ gridView->setWrapEnabled(false);
+ gridView->setCacheBuffer(3);
+ gridView->setFlow(QDeclarativeGridView::TopToBottom);
+
+ QCOMPARE(keyNavigationWrapsSpy.count(),1);
+ QCOMPARE(cacheBufferSpy.count(),1);
+ QCOMPARE(flowSpy.count(),1);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeGridView::componentChanges()
+{
+ QDeclarativeView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+
+ QDeclarativeGridView *gridView = canvas->rootObject()->findChild<QDeclarativeGridView*>("gridView");
+ QVERIFY(gridView);
+
+ QDeclarativeComponent component(canvas->engine());
+ component.setData("import Qt 4.6; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile(""));
+
+ QDeclarativeComponent delegateComponent(canvas->engine());
+ delegateComponent.setData("import Qt 4.6; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile(""));
+
+ QSignalSpy highlightSpy(gridView, SIGNAL(highlightChanged()));
+ QSignalSpy delegateSpy(gridView, SIGNAL(delegateChanged()));
+
+ gridView->setHighlight(&component);
+ gridView->setDelegate(&delegateComponent);
+
+ QCOMPARE(gridView->highlight(), &component);
+ QCOMPARE(gridView->delegate(), &delegateComponent);
+
+ QCOMPARE(highlightSpy.count(),1);
+ QCOMPARE(delegateSpy.count(),1);
+
+ gridView->setHighlight(&component);
+ gridView->setDelegate(&delegateComponent);
+
+ QCOMPARE(highlightSpy.count(),1);
+ QCOMPARE(delegateSpy.count(),1);
+ delete canvas;
+}
+
+void tst_QDeclarativeGridView::modelChanges()
+{
+ QDeclarativeView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+
+ QDeclarativeGridView *gridView = canvas->rootObject()->findChild<QDeclarativeGridView*>("gridView");
+ QVERIFY(gridView);
+
+ QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel");
+ QVERIFY(alternateModel);
+ QVariant modelVariant = QVariant::fromValue(alternateModel);
+ QSignalSpy modelSpy(gridView, SIGNAL(modelChanged()));
+
+ gridView->setModel(modelVariant);
+ QCOMPARE(gridView->model(), modelVariant);
+ QCOMPARE(modelSpy.count(),1);
+
+ gridView->setModel(modelVariant);
+ QCOMPARE(modelSpy.count(),1);
+
+ gridView->setModel(QVariant());
+ QCOMPARE(modelSpy.count(),2);
+ delete canvas;
+}
+
void tst_QDeclarativeGridView::positionViewAtIndex()
{
QDeclarativeView *canvas = createView();
diff --git a/tests/auto/declarative/qdeclarativelistview/data/propertychanges.qml b/tests/auto/declarative/qdeclarativelistview/data/propertychanges.qml
new file mode 100644
index 0000000..a41f003
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistview/data/propertychanges.qml
@@ -0,0 +1,71 @@
+import Qt 4.6
+
+Rectangle {
+ width: 180; height: 120; color: "white"
+ Component {
+ id: delegate
+ Item {
+ id: wrapper
+ width: 180; height: 40;
+ Column {
+ x: 5; y: 5
+ Text { text: '<b>Name:</b> ' + name }
+ Text { text: '<b>Number:</b> ' + number }
+ }
+ }
+ }
+ Component {
+ id: highlightRed
+ Rectangle {
+ color: "red"
+ radius: 10
+ opacity: 0.5
+ }
+ }
+ ListView {
+ objectName: "listView"
+ anchors.fill: parent
+ model: listModel
+ delegate: delegate
+ highlight: highlightRed
+ focus: true
+ highlightFollowsCurrentItem: true
+ preferredHighlightBegin: 0.0
+ preferredHighlightEnd: 0.0
+ highlightRangeMode: ListView.ApplyRange
+ keyNavigationWraps: true
+ cacheBuffer: 10
+ snapMode: ListView.SnapToItem
+ }
+
+ data:[
+ ListModel {
+ id: listModel
+ ListElement {
+ name: "Bill Smith"
+ number: "555 3264"
+ }
+ ListElement {
+ name: "John Brown"
+ number: "555 8426"
+ }
+ ListElement {
+ name: "Sam Wise"
+ number: "555 0473"
+ }
+ },
+ ListModel {
+ objectName: "alternateModel"
+ ListElement {
+ name: "Jack"
+ number: "555 8426"
+ }
+ ListElement {
+ name: "Mary"
+ number: "555 3264"
+ }
+ }
+ ]
+}
+
+ \ No newline at end of file
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index f15f26b..a36224f 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -38,15 +38,18 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+
#include <QtTest/QtTest>
-#include <QStringListModel>
-#include <private/qlistmodelinterface_p.h>
-#include <qdeclarativeview.h>
-#include <private/qdeclarativelistview_p.h>
-#include <private/qdeclarativetext_p.h>
-#include <private/qdeclarativevisualitemmodel_p.h>
-#include <qdeclarativecontext.h>
-#include <qdeclarativeexpression.h>
+#include <QtGui/QStringListModel>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecontext.h>
+#include <QtDeclarative/qdeclarativeexpression.h>
+#include <QtDeclarative/private/qdeclarativelistview_p.h>
+#include <QtDeclarative/private/qdeclarativetext_p.h>
+#include <QtDeclarative/private/qdeclarativevisualitemmodel_p.h>
+#include <QtDeclarative/private/qdeclarativelistmodel_p.h>
+#include <QtDeclarative/private/qlistmodelinterface_p.h>
class tst_QDeclarativeListView : public QObject
{
@@ -82,6 +85,9 @@ private slots:
void cacheBuffer();
void positionViewAtIndex();
void resetModel();
+ void propertyChanges();
+ void componentChanges();
+ void modelChanges();
private:
template <class T> void items();
@@ -240,7 +246,7 @@ public:
setRoleNames(roles);
}
- int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
+ int rowCount(const QModelIndex &parent=QModelIndex()) const { Q_UNUSED(parent); return list.count(); }
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const {
QVariant rv;
if (role == Name)
@@ -379,6 +385,7 @@ void tst_QDeclarativeListView::items()
delete canvas;
}
+
template <class T>
void tst_QDeclarativeListView::changed()
{
@@ -1275,6 +1282,149 @@ void tst_QDeclarativeListView::resetModel()
}
}
+void tst_QDeclarativeListView::propertyChanges()
+{
+ QDeclarativeView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+
+ QDeclarativeListView *listView = canvas->rootObject()->findChild<QDeclarativeListView*>("listView");
+ QVERIFY(listView);
+
+ QSignalSpy highlightFollowsCurrentItemSpy(listView, SIGNAL(highlightFollowsCurrentItemChanged()));
+ QSignalSpy preferredHighlightBeginSpy(listView, SIGNAL(preferredHighlightBeginChanged()));
+ QSignalSpy preferredHighlightEndSpy(listView, SIGNAL(preferredHighlightEndChanged()));
+ QSignalSpy highlightRangeModeSpy(listView, SIGNAL(highlightRangeModeChanged()));
+ QSignalSpy keyNavigationWrapsSpy(listView, SIGNAL(keyNavigationWrapsChanged()));
+ QSignalSpy cacheBufferSpy(listView, SIGNAL(cacheBufferChanged()));
+ QSignalSpy snapModeSpy(listView, SIGNAL(snapModeChanged()));
+
+ QCOMPARE(listView->highlightFollowsCurrentItem(), true);
+ QCOMPARE(listView->preferredHighlightBegin(), 0.0);
+ QCOMPARE(listView->preferredHighlightEnd(), 0.0);
+ QCOMPARE(listView->highlightRangeMode(), QDeclarativeListView::ApplyRange);
+ QCOMPARE(listView->isWrapEnabled(), true);
+ QCOMPARE(listView->cacheBuffer(), 10);
+ QCOMPARE(listView->snapMode(), QDeclarativeListView::SnapToItem);
+
+ listView->setHighlightFollowsCurrentItem(false);
+ listView->setPreferredHighlightBegin(1.0);
+ listView->setPreferredHighlightEnd(1.0);
+ listView->setHighlightRangeMode(QDeclarativeListView::StrictlyEnforceRange);
+ listView->setWrapEnabled(false);
+ listView->setCacheBuffer(3);
+ listView->setSnapMode(QDeclarativeListView::SnapOneItem);
+
+ QCOMPARE(listView->highlightFollowsCurrentItem(), false);
+ QCOMPARE(listView->preferredHighlightBegin(), 1.0);
+ QCOMPARE(listView->preferredHighlightEnd(), 1.0);
+ QCOMPARE(listView->highlightRangeMode(), QDeclarativeListView::StrictlyEnforceRange);
+ QCOMPARE(listView->isWrapEnabled(), false);
+ QCOMPARE(listView->cacheBuffer(), 3);
+ QCOMPARE(listView->snapMode(), QDeclarativeListView::SnapOneItem);
+
+ QCOMPARE(highlightFollowsCurrentItemSpy.count(),1);
+ QCOMPARE(preferredHighlightBeginSpy.count(),1);
+ QCOMPARE(preferredHighlightEndSpy.count(),1);
+ QCOMPARE(highlightRangeModeSpy.count(),1);
+ QCOMPARE(keyNavigationWrapsSpy.count(),1);
+ QCOMPARE(cacheBufferSpy.count(),1);
+ QCOMPARE(snapModeSpy.count(),1);
+
+ listView->setHighlightFollowsCurrentItem(false);
+ listView->setPreferredHighlightBegin(1.0);
+ listView->setPreferredHighlightEnd(1.0);
+ listView->setHighlightRangeMode(QDeclarativeListView::StrictlyEnforceRange);
+ listView->setWrapEnabled(false);
+ listView->setCacheBuffer(3);
+ listView->setSnapMode(QDeclarativeListView::SnapOneItem);
+
+ QCOMPARE(highlightFollowsCurrentItemSpy.count(),1);
+ QCOMPARE(preferredHighlightBeginSpy.count(),1);
+ QCOMPARE(preferredHighlightEndSpy.count(),1);
+ QCOMPARE(highlightRangeModeSpy.count(),1);
+ QCOMPARE(keyNavigationWrapsSpy.count(),1);
+ QCOMPARE(cacheBufferSpy.count(),1);
+ QCOMPARE(snapModeSpy.count(),1);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeListView::componentChanges()
+{
+ QDeclarativeView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+
+ QDeclarativeListView *listView = canvas->rootObject()->findChild<QDeclarativeListView*>("listView");
+ QVERIFY(listView);
+
+ QDeclarativeComponent component(canvas->engine());
+ component.setData("import Qt 4.6; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile(""));
+
+ QDeclarativeComponent delegateComponent(canvas->engine());
+ delegateComponent.setData("import Qt 4.6; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile(""));
+
+ QSignalSpy highlightSpy(listView, SIGNAL(highlightChanged()));
+ QSignalSpy delegateSpy(listView, SIGNAL(delegateChanged()));
+ QSignalSpy headerSpy(listView, SIGNAL(headerChanged()));
+ QSignalSpy footerSpy(listView, SIGNAL(footerChanged()));
+
+ listView->setHighlight(&component);
+ listView->setHeader(&component);
+ listView->setFooter(&component);
+ listView->setDelegate(&delegateComponent);
+
+ QCOMPARE(listView->highlight(), &component);
+ QCOMPARE(listView->header(), &component);
+ QCOMPARE(listView->footer(), &component);
+ QCOMPARE(listView->delegate(), &delegateComponent);
+
+ QCOMPARE(highlightSpy.count(),1);
+ QCOMPARE(delegateSpy.count(),1);
+ QCOMPARE(headerSpy.count(),1);
+ QCOMPARE(footerSpy.count(),1);
+
+ listView->setHighlight(&component);
+ listView->setHeader(&component);
+ listView->setFooter(&component);
+ listView->setDelegate(&delegateComponent);
+
+ QCOMPARE(highlightSpy.count(),1);
+ QCOMPARE(delegateSpy.count(),1);
+ QCOMPARE(headerSpy.count(),1);
+ QCOMPARE(footerSpy.count(),1);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeListView::modelChanges()
+{
+ QDeclarativeView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+
+ QDeclarativeListView *listView = canvas->rootObject()->findChild<QDeclarativeListView*>("listView");
+ QVERIFY(listView);
+
+ QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel");
+ QVERIFY(alternateModel);
+ QVariant modelVariant = QVariant::fromValue(alternateModel);
+ QSignalSpy modelSpy(listView, SIGNAL(modelChanged()));
+
+ listView->setModel(modelVariant);
+ QCOMPARE(listView->model(), modelVariant);
+ QCOMPARE(modelSpy.count(),1);
+
+ listView->setModel(modelVariant);
+ QCOMPARE(modelSpy.count(),1);
+
+ listView->setModel(QVariant());
+ QCOMPARE(modelSpy.count(),2);
+
+ delete canvas;
+}
+
void tst_QDeclarativeListView::qListModelInterface_items()
{
items<TestModel>();
diff --git a/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml b/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml
index 627f38a..ab1538b 100644
--- a/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml
@@ -33,7 +33,7 @@ Rectangle {
height: 320
model: testModel
delegate: delegate
- snapPosition: 0.01
+ snapPosition: 0.0001
path: Path {
startY: 120
startX: 160
diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview.qml
index 8fa8d59..c5d88cd 100644
--- a/tests/auto/declarative/qdeclarativepathview/data/pathview.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/pathview.qml
@@ -39,7 +39,7 @@ Rectangle {
height: 320
model: testModel
delegate: delegate
- snapPosition: 0.01
+ snapPosition: 0.0001
path: Path {
startY: 120
startX: 160
diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml
index af3ae13..f8ed29f 100644
--- a/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml
@@ -3,7 +3,7 @@ import Qt 4.6
PathView {
id: photoPathView
y: 100; width: 800; height: 330; pathItemCount: 4; offset: 10
- dragMargin: 24; snapPosition: 50
+ dragMargin: 24; snapPosition: 0.50
path: Path {
startX: -50; startY: 40;
diff --git a/tests/auto/declarative/qdeclarativepathview/data/propertychanges.qml b/tests/auto/declarative/qdeclarativepathview/data/propertychanges.qml
new file mode 100644
index 0000000..db70b7b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepathview/data/propertychanges.qml
@@ -0,0 +1,115 @@
+import Qt 4.6
+
+Rectangle {
+ width: 350; height: 220; color: "white"
+ Component {
+ id: myDelegate
+ Item {
+ id: wrapper
+ width: 180; height: 40;
+ opacity: PathView.opacity
+ Column {
+ x: 5; y: 5
+ Text { text: '<b>Name:</b> ' + name }
+ Text { text: '<b>Number:</b> ' + number }
+ }
+ }
+ }
+
+ PathView {
+ snapPosition: 0.1
+ dragMargin: 5.0
+ id: pathView
+ objectName: "pathView"
+ anchors.fill: parent
+ model: listModel
+ delegate: myDelegate
+ focus: true
+ path: Path {
+ id: myPath
+ objectName: "path"
+ startX: 220; startY: 200
+ PathAttribute { name: "opacity"; value: 1.0; objectName: "pathAttribute"; }
+ PathQuad { x: 220; y: 25; controlX: 260; controlY: 75 }
+ PathAttribute { name: "opacity"; value: 0.3 }
+ PathQuad { x: 220; y: 200; controlX: -20; controlY: 75 }
+ }
+ Timer {
+ interval: 2000; running: true; repeat: true
+ onTriggered: {
+ if (pathView.path == alternatePath)
+ pathView.path = myPath;
+ else
+ pathView.path = alternatePath;
+ }
+ }
+ }
+
+ data:[
+ ListModel {
+ id: listModel
+ ListElement {
+ name: "Bill Smith"
+ number: "555 3264"
+ }
+ ListElement {
+ name: "John Brown"
+ number: "555 8426"
+ }
+ ListElement {
+ name: "Sam Wise"
+ number: "555 0473"
+ }
+ ListElement {
+ name: "Bill Smith"
+ number: "555 3264"
+ }
+ ListElement {
+ name: "John Brown"
+ number: "555 8426"
+ }
+ ListElement {
+ name: "Sam Wise"
+ number: "555 0473"
+ }
+ ListElement {
+ name: "Bill Smith"
+ number: "555 3264"
+ }
+ ListElement {
+ name: "John Brown"
+ number: "555 8426"
+ }
+ ListElement {
+ name: "Sam Wise"
+ number: "555 0473"
+ }
+ },
+ ListModel {
+ objectName: "alternateModel"
+ ListElement {
+ name: "Jack"
+ number: "555 8426"
+ }
+ ListElement {
+ name: "Mary"
+ number: "555 3264"
+ }
+ },
+ Path {
+ id: alternatePath
+ objectName: "alternatePath"
+ startX: 100; startY: 40
+ PathAttribute { name: "opacity"; value: 0.0 }
+ PathLine { x: 100; y: 160 }
+ PathAttribute { name: "opacity"; value: 0.2 }
+ PathLine { x: 300; y: 160 }
+ PathAttribute { name: "opacity"; value: 0.0 }
+ PathLine { x: 300; y: 40 }
+ PathAttribute { name: "opacity"; value: 0.2 }
+ PathLine { x: 100; y: 40 }
+ }
+ ]
+}
+
+
diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
index 79bc607..fa4e9d3 100644
--- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
+++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
@@ -38,20 +38,23 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include <private/qdeclarativepathview_p.h>
-#include <private/qdeclarativepath_p.h>
-#include <qdeclarativecontext.h>
-#include <qdeclarativeexpression.h>
-#include <qtest.h>
+
+#include <QtTest/QtTest>
+#include <QtDeclarative/qdeclarativeview.h>
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeview.h>
+#include <QtDeclarative/qdeclarativecontext.h>
+#include <QtDeclarative/qdeclarativeexpression.h>
+#include <QtDeclarative/private/qdeclarativepathview_p.h>
+#include <QtDeclarative/private/qdeclarativepath_p.h>
#include <QtDeclarative/private/qdeclarativetext_p.h>
#include <QtDeclarative/private/qdeclarativerectangle_p.h>
+#include <QtDeclarative/private/qdeclarativelistmodel_p.h>
+#include <QtDeclarative/private/qdeclarativevaluetype_p.h>
#include <QAbstractListModel>
#include <QStringListModel>
#include <QFile>
-#include <private/qdeclarativevaluetype_p.h>
+
#include "../../../shared/util.h"
class tst_QDeclarativePathView : public QObject
@@ -69,6 +72,11 @@ private slots:
void path();
void pathMoved();
void resetModel();
+ void propertyChanges();
+ void pathChanges();
+ void componentChanges();
+ void modelChanges();
+
private:
QDeclarativeView *createView();
@@ -120,7 +128,7 @@ public:
setRoleNames(roles);
}
- int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
+ int rowCount(const QModelIndex &parent=QModelIndex()) const { Q_UNUSED(parent); return list.count(); }
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const {
QVariant rv;
if (role == Name)
@@ -465,6 +473,149 @@ void tst_QDeclarativePathView::resetModel()
}
}
+void tst_QDeclarativePathView::propertyChanges()
+{
+ QDeclarativeView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+
+ QDeclarativePathView *pathView = canvas->rootObject()->findChild<QDeclarativePathView*>("pathView");
+ QVERIFY(pathView);
+
+ QSignalSpy snapPositionSpy(pathView, SIGNAL(snapPositionChanged()));
+ QSignalSpy dragMarginSpy(pathView, SIGNAL(dragMarginChanged()));
+
+ QCOMPARE(pathView->snapPosition(), 0.1);
+ QCOMPARE(pathView->dragMargin(), 5.0);
+
+ pathView->setSnapPosition(0.4);
+ pathView->setDragMargin(20.0);
+
+ QCOMPARE(pathView->snapPosition(), 0.4);
+ QCOMPARE(pathView->dragMargin(), 20.0);
+
+ QCOMPARE(snapPositionSpy.count(), 1);
+ QCOMPARE(dragMarginSpy.count(), 1);
+
+ pathView->setSnapPosition(0.4);
+ pathView->setDragMargin(20.0);
+
+ QCOMPARE(snapPositionSpy.count(), 1);
+ QCOMPARE(dragMarginSpy.count(), 1);
+ delete canvas;
+}
+
+void tst_QDeclarativePathView::pathChanges()
+{
+ QDeclarativeView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+
+ QDeclarativePathView *pathView = canvas->rootObject()->findChild<QDeclarativePathView*>("pathView");
+ QVERIFY(pathView);
+
+ QDeclarativePath *path = canvas->rootObject()->findChild<QDeclarativePath*>("path");
+ QVERIFY(path);
+
+ QSignalSpy startXSpy(path, SIGNAL(startXChanged()));
+ QSignalSpy startYSpy(path, SIGNAL(startYChanged()));
+
+ QCOMPARE(path->startX(), 220.0);
+ QCOMPARE(path->startY(), 200.0);
+
+ path->setStartX(240.0);
+ path->setStartY(220.0);
+
+ QCOMPARE(path->startX(), 240.0);
+ QCOMPARE(path->startY(), 220.0);
+
+ QCOMPARE(startXSpy.count(),1);
+ QCOMPARE(startYSpy.count(),1);
+
+ path->setStartX(240);
+ path->setStartY(220);
+
+ QCOMPARE(startXSpy.count(),1);
+ QCOMPARE(startYSpy.count(),1);
+
+ QDeclarativePath *alternatePath = canvas->rootObject()->findChild<QDeclarativePath*>("alternatePath");
+ QVERIFY(alternatePath);
+
+ QSignalSpy pathSpy(pathView, SIGNAL(pathChanged()));
+
+ QCOMPARE(pathView->path(), path);
+
+ pathView->setPath(alternatePath);
+ QCOMPARE(pathView->path(), alternatePath);
+ QCOMPARE(pathSpy.count(),1);
+
+ pathView->setPath(alternatePath);
+ QCOMPARE(pathSpy.count(),1);
+
+ QDeclarativePathAttribute *pathAttribute = canvas->rootObject()->findChild<QDeclarativePathAttribute*>("pathAttribute");
+ QVERIFY(pathAttribute);
+
+ QSignalSpy nameSpy(pathAttribute, SIGNAL(nameChanged()));
+ QCOMPARE(pathAttribute->name(), QString("opacity"));
+
+ pathAttribute->setName("scale");
+ QCOMPARE(pathAttribute->name(), QString("scale"));
+ QCOMPARE(nameSpy.count(),1);
+
+ pathAttribute->setName("scale");
+ QCOMPARE(nameSpy.count(),1);
+ delete canvas;
+}
+
+void tst_QDeclarativePathView::componentChanges()
+{
+ QDeclarativeView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+
+ QDeclarativePathView *pathView = canvas->rootObject()->findChild<QDeclarativePathView*>("pathView");
+ QVERIFY(pathView);
+
+ QDeclarativeComponent delegateComponent(canvas->engine());
+ delegateComponent.setData("import Qt 4.6; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile(""));
+
+ QSignalSpy delegateSpy(pathView, SIGNAL(delegateChanged()));
+
+ pathView->setDelegate(&delegateComponent);
+ QCOMPARE(pathView->delegate(), &delegateComponent);
+ QCOMPARE(delegateSpy.count(),1);
+
+ pathView->setDelegate(&delegateComponent);
+ QCOMPARE(delegateSpy.count(),1);
+ delete canvas;
+}
+
+void tst_QDeclarativePathView::modelChanges()
+{
+ QDeclarativeView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+
+ QDeclarativePathView *pathView = canvas->rootObject()->findChild<QDeclarativePathView*>("pathView");
+ QVERIFY(pathView);
+
+ QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel");
+ QVERIFY(alternateModel);
+ QVariant modelVariant = QVariant::fromValue(alternateModel);
+ QSignalSpy modelSpy(pathView, SIGNAL(modelChanged()));
+
+ pathView->setModel(modelVariant);
+ QCOMPARE(pathView->model(), modelVariant);
+ QCOMPARE(modelSpy.count(),1);
+
+ pathView->setModel(modelVariant);
+ QCOMPARE(modelSpy.count(),1);
+
+ pathView->setModel(QVariant());
+ QCOMPARE(modelSpy.count(),2);
+
+ delete canvas;
+}
QDeclarativeView *tst_QDeclarativePathView::createView()
{
diff --git a/tests/auto/declarative/qdeclarativewebview/data/basic.qml b/tests/auto/declarative/qdeclarativewebview/data/basic.qml
index 5394837..f0b41ef 100644
--- a/tests/auto/declarative/qdeclarativewebview/data/basic.qml
+++ b/tests/auto/declarative/qdeclarativewebview/data/basic.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import org.webkit 1.0
WebView {
url: "basic.html"
diff --git a/tests/auto/declarative/qdeclarativewebview/data/elements.qml b/tests/auto/declarative/qdeclarativewebview/data/elements.qml
index 7c030e6..16e5788 100644
--- a/tests/auto/declarative/qdeclarativewebview/data/elements.qml
+++ b/tests/auto/declarative/qdeclarativewebview/data/elements.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import org.webkit 1.0
WebView {
url: "elements.html"
diff --git a/tests/auto/declarative/qdeclarativewebview/data/forward.png b/tests/auto/declarative/qdeclarativewebview/data/forward.png
new file mode 100644
index 0000000..a82533e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativewebview/data/forward.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml b/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml
index 07eee88..0e92e0e 100644
--- a/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml
+++ b/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import org.webkit 1.0
WebView {
url: "javaScript.html"
diff --git a/tests/auto/declarative/qdeclarativewebview/data/loadError.qml b/tests/auto/declarative/qdeclarativewebview/data/loadError.qml
index 1460f30..f827238 100644
--- a/tests/auto/declarative/qdeclarativewebview/data/loadError.qml
+++ b/tests/auto/declarative/qdeclarativewebview/data/loadError.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import org.webkit 1.0
WebView {
url: "does-not-exist.html"
diff --git a/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml b/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml
index 0bc8263..4d9df43 100644
--- a/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml
+++ b/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml
@@ -1,6 +1,7 @@
// Demonstrates opening new WebViews from HTML
import Qt 4.6
+import org.webkit 1.0
Grid {
columns: 3
diff --git a/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml b/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml
index 3dd4e51..0770acf 100644
--- a/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml
+++ b/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import org.webkit 1.0
Item {
width: 240
@@ -30,4 +31,4 @@ Item {
pressGrabTime: 200
}
}
-} \ No newline at end of file
+}
diff --git a/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml b/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml
index 063b5a8..9e17597 100644
--- a/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml
+++ b/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import org.webkit 1.0
WebView {
html: "<p>This is a <b>string</b> set on the WebView"
diff --git a/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro b/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro
index 6af0a60..20173c6 100644
--- a/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro
+++ b/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro
@@ -3,8 +3,7 @@ contains(QT_CONFIG,declarative): QT += declarative
contains(QT_CONFIG,webkit): QT += webkit
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativewebview.cpp testtypes.cpp
-HEADERS += testtypes.h
+SOURCES += tst_qdeclarativewebview.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativewebview/testtypes.cpp b/tests/auto/declarative/qdeclarativewebview/testtypes.cpp
deleted file mode 100644
index 7efc214..0000000
--- a/tests/auto/declarative/qdeclarativewebview/testtypes.cpp
+++ /dev/null
@@ -1,52 +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 "testtypes.h"
-
-void MyWebView::drawContents(QPainter *p, const QRect &r)
-{
- pp += r.width()*r.height();
- QDeclarativeWebView::drawContents(p,r);
-}
-
-void registerTypes()
-{
- QML_REGISTER_TYPE(Test,1,0,MyWebView,MyWebView);
-}
diff --git a/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp b/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp
index 6d16056..1d6bedc 100644
--- a/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp
+++ b/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp
@@ -43,15 +43,12 @@
#include "../../../shared/util.h"
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativecomponent.h>
-#include <private/qdeclarativewebview_p.h>
-#include <private/qdeclarativewebview_p_p.h>
#include <private/qdeclarativepositioners_p.h>
#include <QtWebKit/qwebpage.h>
#include <QtWebKit/qwebframe.h>
#include <QtCore/qdir.h>
#include <QtCore/qfile.h>
#include <QtGui/qpainter.h>
-#include "testtypes.h"
class tst_qdeclarativewebview : public QObject
{
@@ -70,7 +67,7 @@ private slots:
void setHtml();
void javaScript();
void cleanupTestCase();
- void pixelCache();
+ //void pixelCache();
void newWindowParent();
void newWindowComponent();
void renderingEnabled();
@@ -89,7 +86,6 @@ private:
void tst_qdeclarativewebview::initTestCase()
{
- registerTypes();
}
static QString strippedHtml(QString html)
@@ -148,81 +144,81 @@ void tst_qdeclarativewebview::basicProperties()
checkNoErrors(component);
QWebSettings::enablePersistentStorage(tmpDir());
- QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create());
+ QObject *wv = component.create();
QVERIFY(wv != 0);
- QTRY_COMPARE(wv->progress(), 1.0);
- QCOMPARE(wv->title(),QString("Basic"));
- QTRY_COMPARE(wv->icon().width(), 48);
- QCOMPARE(wv->icon(),QPixmap(SRCDIR "/data/basic.png"));
- QCOMPARE(wv->statusText(),QString("status here"));
- QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html()));
- QCOMPARE(wv->width(), 123.0);
- QCOMPARE(wv->preferredWidth(), 0);
- QCOMPARE(wv->preferredHeight(), 0);
- QCOMPARE(wv->zoomFactor(), 1.0);
- QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html"));
- QCOMPARE(wv->status(), QDeclarativeWebView::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());
-
- wv->setPixelCacheSize(0); // mainly testing that it doesn't crash or anything!
- QCOMPARE(wv->pixelCacheSize(),0);
- wv->reloadAction()->trigger();
- QTRY_COMPARE(wv->progress(), 1.0);
+ QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
+ QCOMPARE(wv->property("title").toString(),QString("Basic"));
+ QTRY_COMPARE(qvariant_cast<QPixmap>(wv->property("icon")).width(), 48);
+ QCOMPARE(qvariant_cast<QPixmap>(wv->property("icon")),QPixmap(SRCDIR "/data/basic.png"));
+ QCOMPARE(wv->property("statusText").toString(),QString("status here"));
+ QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->property("html").toString()));
+ QCOMPARE(wv->property("width").toDouble(), 123.0);
+ QCOMPARE(wv->property("preferredWidth").toInt(), 0);
+ QCOMPARE(wv->property("preferredHeight").toInt(), 0);
+ QCOMPARE(wv->property("zoomFactor").toDouble(), 1.0);
+ QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/basic.html"));
+ QCOMPARE(wv->property("status").toInt(), 1 /*QDeclarativeWebView::Ready*/);
+ QVERIFY(qvariant_cast<QAction*>(wv->property("reload")));
+ QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))->isEnabled());
+ QVERIFY(qvariant_cast<QAction*>(wv->property("back")));
+ QVERIFY(!qvariant_cast<QAction*>(wv->property("back"))->isEnabled());
+ QVERIFY(qvariant_cast<QAction*>(wv->property("forward")));
+ QVERIFY(!qvariant_cast<QAction*>(wv->property("forward"))->isEnabled());
+ QVERIFY(qvariant_cast<QAction*>(wv->property("stop")));
+ QVERIFY(!qvariant_cast<QAction*>(wv->property("stop"))->isEnabled());
+
+ wv->setProperty("pixelCacheSize", 0); // mainly testing that it doesn't crash or anything!
+ QCOMPARE(wv->property("pixelCacheSize").toInt(),0);
+ qvariant_cast<QAction*>(wv->property("reload"))->trigger();
+ QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
}
void tst_qdeclarativewebview::settings()
{
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml"));
checkNoErrors(component);
- QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create());
+ QObject *wv = component.create();
QVERIFY(wv != 0);
- QTRY_COMPARE(wv->progress(), 1.0);
+ QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
- QDeclarativeWebSettings *s = wv->settingsObject();
+ QObject *s = qvariant_cast<QObject*>(wv->property("settings"));
// merely tests that setting gets stored (in QWebSettings)
// behavioural tests are in WebKit.
for (int b=0; b<=1; ++b) {
bool on = !!b;
- s->setAutoLoadImages(on);
- s->setDeveloperExtrasEnabled(on);
- s->setJavaEnabled(on);
- s->setJavascriptCanAccessClipboard(on);
- s->setJavascriptCanOpenWindows(on);
- s->setJavascriptEnabled(on);
- s->setLinksIncludedInFocusChain(on);
- s->setLocalContentCanAccessRemoteUrls(on);
- s->setLocalStorageDatabaseEnabled(on);
- s->setOfflineStorageDatabaseEnabled(on);
- s->setOfflineWebApplicationCacheEnabled(on);
- s->setPluginsEnabled(on);
- s->setPrintElementBackgrounds(on);
- s->setPrivateBrowsingEnabled(on);
- s->setZoomTextOnly(on);
-
- QVERIFY(s->autoLoadImages() == on);
- QVERIFY(s->developerExtrasEnabled() == on);
- QVERIFY(s->javaEnabled() == on);
- QVERIFY(s->javascriptCanAccessClipboard() == on);
- QVERIFY(s->javascriptCanOpenWindows() == on);
- QVERIFY(s->javascriptEnabled() == on);
- QVERIFY(s->linksIncludedInFocusChain() == on);
- QVERIFY(s->localContentCanAccessRemoteUrls() == on);
- QVERIFY(s->localStorageDatabaseEnabled() == on);
- QVERIFY(s->offlineStorageDatabaseEnabled() == on);
- QVERIFY(s->offlineWebApplicationCacheEnabled() == on);
- QVERIFY(s->pluginsEnabled() == on);
- QVERIFY(s->printElementBackgrounds() == on);
- QVERIFY(s->privateBrowsingEnabled() == on);
- QVERIFY(s->zoomTextOnly() == on);
+ s->setProperty("autoLoadImages", on);
+ s->setProperty("developerExtrasEnabled", on);
+ s->setProperty("javaEnabled", on);
+ s->setProperty("javascriptCanAccessClipboard", on);
+ s->setProperty("javascriptCanOpenWindows", on);
+ s->setProperty("javascriptEnabled", on);
+ s->setProperty("linksIncludedInFocusChain", on);
+ s->setProperty("localContentCanAccessRemoteUrls", on);
+ s->setProperty("localStorageDatabaseEnabled", on);
+ s->setProperty("offlineStorageDatabaseEnabled", on);
+ s->setProperty("offlineWebApplicationCacheEnabled", on);
+ s->setProperty("pluginsEnabled", on);
+ s->setProperty("printElementBackgrounds", on);
+ s->setProperty("privateBrowsingEnabled", on);
+ s->setProperty("zoomTextOnly", on);
+
+ QVERIFY(s->property("autoLoadImages") == on);
+ QVERIFY(s->property("developerExtrasEnabled") == on);
+ QVERIFY(s->property("javaEnabled") == on);
+ QVERIFY(s->property("javascriptCanAccessClipboard") == on);
+ QVERIFY(s->property("javascriptCanOpenWindows") == on);
+ QVERIFY(s->property("javascriptEnabled") == on);
+ QVERIFY(s->property("linksIncludedInFocusChain") == on);
+ QVERIFY(s->property("localContentCanAccessRemoteUrls") == on);
+ QVERIFY(s->property("localStorageDatabaseEnabled") == on);
+ QVERIFY(s->property("offlineStorageDatabaseEnabled") == on);
+ QVERIFY(s->property("offlineWebApplicationCacheEnabled") == on);
+ QVERIFY(s->property("pluginsEnabled") == on);
+ QVERIFY(s->property("printElementBackgrounds") == on);
+ QVERIFY(s->property("privateBrowsingEnabled") == on);
+ QVERIFY(s->property("zoomTextOnly") == on);
QVERIFY(s->property("autoLoadImages") == on);
QVERIFY(s->property("developerExtrasEnabled") == on);
@@ -248,65 +244,65 @@ void tst_qdeclarativewebview::historyNav()
checkNoErrors(component);
QWebSettings::enablePersistentStorage(tmpDir());
- QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create());
+ QObject *wv = component.create();
QVERIFY(wv != 0);
for (int i=1; i<=2; ++i) {
- QTRY_COMPARE(wv->progress(), 1.0);
- QCOMPARE(wv->title(),QString("Basic"));
- QTRY_COMPARE(wv->icon().width(), 48);
- QCOMPARE(wv->icon(),QPixmap(SRCDIR "/data/basic.png"));
- QCOMPARE(wv->statusText(),QString("status here"));
- QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html()));
- QCOMPARE(wv->width(), 123.0);
- QCOMPARE(wv->preferredWidth(), 0);
- QCOMPARE(wv->zoomFactor(), 1.0);
- QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html"));
- QCOMPARE(wv->status(), QDeclarativeWebView::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());
-
- wv->reloadAction()->trigger();
+ QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
+ QCOMPARE(wv->property("title").toString(),QString("Basic"));
+ QTRY_COMPARE(qvariant_cast<QPixmap>(wv->property("icon")).width(), 48);
+ QCOMPARE(qvariant_cast<QPixmap>(wv->property("icon")),QPixmap(SRCDIR "/data/basic.png"));
+ QCOMPARE(wv->property("statusText").toString(),QString("status here"));
+ QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->property("html").toString()));
+ QCOMPARE(wv->property("width").toDouble(), 123.0);
+ QCOMPARE(wv->property("preferredWidth").toDouble(), 0.0);
+ QCOMPARE(wv->property("zoomFactor").toDouble(), 1.0);
+ QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/basic.html"));
+ QCOMPARE(wv->property("status").toInt(), 1 /*QDeclarativeWebView::Ready*/);
+ QVERIFY(qvariant_cast<QAction*>(wv->property("reload")));
+ QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))->isEnabled());
+ QVERIFY(qvariant_cast<QAction*>(wv->property("back")));
+ QVERIFY(!qvariant_cast<QAction*>(wv->property("back"))->isEnabled());
+ QVERIFY(qvariant_cast<QAction*>(wv->property("forward")));
+ QVERIFY(!qvariant_cast<QAction*>(wv->property("forward"))->isEnabled());
+ QVERIFY(qvariant_cast<QAction*>(wv->property("stop")));
+ QVERIFY(!qvariant_cast<QAction*>(wv->property("stop"))->isEnabled());
+
+ qvariant_cast<QAction*>(wv->property("reload"))->trigger();
}
- wv->setUrl(QUrl::fromLocalFile(SRCDIR "/data/forward.html"));
- QTRY_COMPARE(wv->progress(), 1.0);
- QCOMPARE(wv->title(),QString("Forward"));
- QTRY_COMPARE(wv->icon().width(), 32);
- QCOMPARE(wv->icon(),QPixmap(SRCDIR "/data/forward.png"));
- QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/forward.html")), strippedHtml(wv->html()));
- QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/forward.html"));
- QCOMPARE(wv->status(), QDeclarativeWebView::Ready);
- QCOMPARE(wv->statusText(),QString(""));
- 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());
-
- wv->backAction()->trigger();
-
- QTRY_COMPARE(wv->progress(), 1.0);
- QCOMPARE(wv->title(),QString("Basic"));
- QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html()));
- QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html"));
- QCOMPARE(wv->status(), QDeclarativeWebView::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());
+ wv->setProperty("url", QUrl::fromLocalFile(SRCDIR "/data/forward.html"));
+ QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
+ QCOMPARE(wv->property("title").toString(),QString("Forward"));
+ QTRY_COMPARE(qvariant_cast<QPixmap>(wv->property("icon")).width(), 32);
+ QCOMPARE(qvariant_cast<QPixmap>(wv->property("icon")),QPixmap(SRCDIR "/data/forward.png"));
+ QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/forward.html")), strippedHtml(wv->property("html").toString()));
+ QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/forward.html"));
+ QCOMPARE(wv->property("status").toInt(), 1 /*QDeclarativeWebView::Ready*/);
+ QCOMPARE(wv->property("statusText").toString(),QString(""));
+ QVERIFY(qvariant_cast<QAction*>(wv->property("reload")));
+ QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))->isEnabled());
+ QVERIFY(qvariant_cast<QAction*>(wv->property("back")));
+ QVERIFY(qvariant_cast<QAction*>(wv->property("back"))->isEnabled());
+ QVERIFY(qvariant_cast<QAction*>(wv->property("forward")));
+ QVERIFY(!qvariant_cast<QAction*>(wv->property("forward"))->isEnabled());
+ QVERIFY(qvariant_cast<QAction*>(wv->property("stop")));
+ QVERIFY(!qvariant_cast<QAction*>(wv->property("stop"))->isEnabled());
+
+ qvariant_cast<QAction*>(wv->property("back"))->trigger();
+
+ QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
+ QCOMPARE(wv->property("title").toString(),QString("Basic"));
+ QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->property("html").toString()));
+ QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/basic.html"));
+ QCOMPARE(wv->property("status").toInt(), 1 /*QDeclarativeWebView::Ready*/);
+ QVERIFY(qvariant_cast<QAction*>(wv->property("reload")));
+ QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))->isEnabled());
+ QVERIFY(qvariant_cast<QAction*>(wv->property("back")));
+ QVERIFY(!qvariant_cast<QAction*>(wv->property("back"))->isEnabled());
+ QVERIFY(qvariant_cast<QAction*>(wv->property("forward")));
+ QVERIFY(qvariant_cast<QAction*>(wv->property("forward"))->isEnabled());
+ QVERIFY(qvariant_cast<QAction*>(wv->property("stop")));
+ QVERIFY(!qvariant_cast<QAction*>(wv->property("stop"))->isEnabled());
}
void tst_qdeclarativewebview::multipleWindows()
@@ -328,16 +324,16 @@ void tst_qdeclarativewebview::loadError()
checkNoErrors(component);
QWebSettings::enablePersistentStorage(tmpDir());
- QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create());
+ QObject *wv = component.create();
QVERIFY(wv != 0);
for (int i=1; i<=2; ++i) {
- QTRY_COMPARE(wv->progress(), 1.0);
- QCOMPARE(wv->title(),QString(""));
- QCOMPARE(wv->statusText(),QString("")); // HTML 'status bar' text, not error message
- QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/does-not-exist.html")); // Unlike QWebPage, which loses url
- QCOMPARE(wv->status(), QDeclarativeWebView::Error);
+ QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
+ QCOMPARE(wv->property("title").toString(),QString(""));
+ QCOMPARE(wv->property("statusText").toString(),QString("")); // HTML 'status bar' text, not error message
+ QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/does-not-exist.html")); // Unlike QWebPage, which loses url
+ QCOMPARE(wv->property("status").toInt(), 3 /*QDeclarativeWebView::Error*/);
- wv->reloadAction()->trigger();
+ qvariant_cast<QAction*>(wv->property("reload"))->trigger();
}
}
@@ -345,12 +341,12 @@ void tst_qdeclarativewebview::setHtml()
{
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/sethtml.qml"));
checkNoErrors(component);
- QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create());
+ QObject *wv = component.create();
QVERIFY(wv != 0);
- QCOMPARE(wv->html(),QString("<html><head></head><body><p>This is a <b>string</b> set on the WebView</p></body></html>"));
+ QCOMPARE(wv->property("html").toString(),QString("<html><head></head><body><p>This is a <b>string</b> set on the WebView</p></body></html>"));
QSignalSpy spy(wv, SIGNAL(htmlChanged()));
- wv->setHtml(QString("<html><head><title>Basic</title></head><body><p>text</p></body></html>"));
+ wv->setProperty("html", QString("<html><head><title>Basic</title></head><body><p>text</p></body></html>"));
QCOMPARE(spy.count(),1);
}
@@ -358,81 +354,91 @@ void tst_qdeclarativewebview::elementAreaAt()
{
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/elements.qml"));
checkNoErrors(component);
- QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create());
+ QObject *wv = component.create();
QVERIFY(wv != 0);
- QTRY_COMPARE(wv->progress(), 1.0);
+ QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
+ /* not now it's a plugin...
QCOMPARE(wv->elementAreaAt(40,30,100,100),QRect(1,1,75,54)); // Area A in data/elements.html
QCOMPARE(wv->elementAreaAt(130,30,200,100),QRect(78,3,110,50)); // Area B
QCOMPARE(wv->elementAreaAt(40,30,400,400),QRect(0,0,310,100)); // Whole view
QCOMPARE(wv->elementAreaAt(130,30,280,280),QRect(76,1,223,54)); // Area BC
QCOMPARE(wv->elementAreaAt(130,30,400,400),QRect(0,0,310,100)); // Whole view
+ */
}
void tst_qdeclarativewebview::javaScript()
{
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/javaScript.qml"));
checkNoErrors(component);
- QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create());
+ QObject *wv = component.create();
QVERIFY(wv != 0);
- QTRY_COMPARE(wv->progress(), 1.0);
+ QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
+ /* not now it's a plugin...
QCOMPARE(wv->evaluateJavaScript("123").toInt(), 123);
QCOMPARE(wv->evaluateJavaScript("window.status").toString(), QString("status here"));
QCOMPARE(wv->evaluateJavaScript("window.myjsname.qmlprop").toString(), QString("qmlvalue"));
+ */
}
+/*
+Cannot be done now that webkit is a plugin
+
void tst_qdeclarativewebview::pixelCache()
{
+
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/pixelCache.qml"));
checkNoErrors(component);
MyWebView *wv = qobject_cast<MyWebView*>(component.create());
QVERIFY(wv != 0);
- QTRY_COMPARE(wv->progress(), 1.0);
+ QTRY_COMPARE(wv->property("progress"), 1.0);
QPixmap pm(150,150);
QPainter p(&pm);
wv->paint(&p,0,0);
const int expected = 120*(150+128); // 120 = width of HTML page, 150=pixmap height, 128=cache extra area
- QCOMPARE(wv->pixelsPainted(), expected);
+ QCOMPARE(wv->property("pixelsPainted"), expected);
wv->paint(&p,0,0);
- QCOMPARE(wv->pixelsPainted(), expected); // nothing new needed to be painted
- wv->setPixelCacheSize(0); // clears the cache
+ QCOMPARE(wv->property("pixelsPainted"), expected); // nothing new needed to be painted
+ wv->setProperty("pixelCacheSize", 0); // clears the cache
wv->paint(&p,0,0);
- QCOMPARE(wv->pixelsPainted(), expected*2); // everything needed to be painted
+ QCOMPARE(wv->property("pixelsPainted"), expected*2); // everything needed to be painted
// Note that painted things always go into the cache (even if they don't "fit"),
// just that they will be removed if anything else needs to be painted.
- wv->setPixelCacheSize(expected); // won't clear the cache
+ wv->setProperty("pixelCacheSize", expected); // won't clear the cache
wv->paint(&p,0,0);
- QCOMPARE(wv->pixelsPainted(), expected*2); // still there
- wv->setPixelCacheSize(expected-1); // too small - will clear the cache
+ QCOMPARE(wv->property("pixelsPainted"), expected*2); // still there
+ wv->setProperty("pixelCacheSize", expected-1); // too small - will clear the cache
wv->paint(&p,0,0);
- QCOMPARE(wv->pixelsPainted(), expected*3); // repainted
+ QCOMPARE(wv->property("pixelsPainted"), expected*3); // repainted
}
+*/
void tst_qdeclarativewebview::newWindowParent()
{
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
checkNoErrors(component);
QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create());
- QDeclarativeWebView *wv = rootItem->findChild<QDeclarativeWebView*>("webView");
+ QObject *wv = rootItem->findChild<QObject*>("webView");
QVERIFY(rootItem != 0);
QVERIFY(wv != 0);
- QTRY_COMPARE(wv->progress(), 1.0);
+ QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
QDeclarativeItem* oldWindowParent = rootItem->findChild<QDeclarativeItem*>("oldWindowParent");
- QCOMPARE(wv->newWindowParent(), oldWindowParent);
+ QCOMPARE(qvariant_cast<QDeclarativeItem*>(wv->property("newWindowParent")), oldWindowParent);
QSignalSpy newWindowParentSpy(wv, SIGNAL(newWindowParentChanged()));
QDeclarativeItem* newWindowParent = rootItem->findChild<QDeclarativeItem*>("newWindowParent");
- wv->setNewWindowParent(newWindowParent);
+ wv->setProperty("newWindowParent", QVariant::fromValue(newWindowParent));
+ QVERIFY(newWindowParent);
QVERIFY(oldWindowParent);
QVERIFY(oldWindowParent->childItems().count() == 0);
- QCOMPARE(wv->newWindowParent(), newWindowParent);
+ QCOMPARE(wv->property("newWindowParent"), QVariant::fromValue(newWindowParent));
QCOMPARE(newWindowParentSpy.count(),1);
- wv->setNewWindowParent(newWindowParent);
+ wv->setProperty("newWindowParent", QVariant::fromValue(newWindowParent));
QCOMPARE(newWindowParentSpy.count(),1);
- wv->setNewWindowParent(0);
+ wv->setProperty("newWindowParent", QVariant::fromValue((QDeclarativeItem*)0));
QCOMPARE(newWindowParentSpy.count(),2);
}
@@ -441,23 +447,23 @@ void tst_qdeclarativewebview::newWindowComponent()
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
checkNoErrors(component);
QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create());
- QDeclarativeWebView *wv = rootItem->findChild<QDeclarativeWebView*>("webView");
+ QObject *wv = rootItem->findChild<QObject*>("webView");
QVERIFY(rootItem != 0);
QVERIFY(wv != 0);
- QTRY_COMPARE(wv->progress(), 1.0);
+ QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
QDeclarativeComponent substituteComponent(&engine);
substituteComponent.setData("import Qt 4.6; WebView { objectName: 'newWebView'; url: 'basic.html'; }", QUrl::fromLocalFile(""));
QSignalSpy newWindowComponentSpy(wv, SIGNAL(newWindowComponentChanged()));
- wv->setNewWindowComponent(&substituteComponent);
- QCOMPARE(wv->newWindowComponent(), &substituteComponent);
+ wv->setProperty("newWindowComponent", QVariant::fromValue(&substituteComponent));
+ QCOMPARE(wv->property("newWindowComponent"), QVariant::fromValue(&substituteComponent));
QCOMPARE(newWindowComponentSpy.count(),1);
- wv->setNewWindowComponent(&substituteComponent);
+ wv->setProperty("newWindowComponent", QVariant::fromValue(&substituteComponent));
QCOMPARE(newWindowComponentSpy.count(),1);
- wv->setNewWindowComponent(0);
+ wv->setProperty("newWindowComponent", QVariant::fromValue((QDeclarativeComponent*)0));
QCOMPARE(newWindowComponentSpy.count(),2);
}
@@ -466,22 +472,22 @@ void tst_qdeclarativewebview::renderingEnabled()
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
checkNoErrors(component);
QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create());
- QDeclarativeWebView *wv = rootItem->findChild<QDeclarativeWebView*>("webView");
+ QObject *wv = rootItem->findChild<QObject*>("webView");
QVERIFY(rootItem != 0);
QVERIFY(wv != 0);
- QTRY_COMPARE(wv->progress(), 1.0);
+ QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
- QVERIFY(wv->renderingEnabled());
+ QVERIFY(wv->property("renderingEnabled").toBool());
QSignalSpy renderingEnabledSpy(wv, SIGNAL(renderingEnabledChanged()));
- wv->setRenderingEnabled(false);
- QVERIFY(!wv->renderingEnabled());
+ wv->setProperty("renderingEnabled", false);
+ QVERIFY(!wv->property("renderingEnabled").toBool());
QCOMPARE(renderingEnabledSpy.count(),1);
- wv->setRenderingEnabled(false);
+ wv->setProperty("renderingEnabled", false);
QCOMPARE(renderingEnabledSpy.count(),1);
- wv->setRenderingEnabled(true);
+ wv->setProperty("renderingEnabled", true);
QCOMPARE(renderingEnabledSpy.count(),2);
}
@@ -490,21 +496,21 @@ void tst_qdeclarativewebview::pressGrabTime()
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
checkNoErrors(component);
QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create());
- QDeclarativeWebView *wv = rootItem->findChild<QDeclarativeWebView*>("webView");
+ QObject *wv = rootItem->findChild<QObject*>("webView");
QVERIFY(rootItem != 0);
QVERIFY(wv != 0);
- QTRY_COMPARE(wv->progress(), 1.0);
- QCOMPARE(wv->pressGrabTime(), 200);
+ QTRY_COMPARE(wv->property("progress").toDouble(), 1.0);
+ QCOMPARE(wv->property("pressGrabTime").toInt(), 200);
QSignalSpy pressGrabTimeSpy(wv, SIGNAL(pressGrabTimeChanged()));
- wv->setPressGrabTime(100);
- QCOMPARE(wv->pressGrabTime(), 100);
+ wv->setProperty("pressGrabTime", 100);
+ QCOMPARE(wv->property("pressGrabTime").toInt(), 100);
QCOMPARE(pressGrabTimeSpy.count(),1);
- wv->setPressGrabTime(100);
+ wv->setProperty("pressGrabTime", 100);
QCOMPARE(pressGrabTimeSpy.count(),1);
- wv->setPressGrabTime(0);
+ wv->setProperty("pressGrabTime", 0);
QCOMPARE(pressGrabTimeSpy.count(),2);
}
diff --git a/tests/auto/declarative/visual/qfxwebview/autosize/autosize.qml b/tests/auto/declarative/visual/qfxwebview/autosize/autosize.qml
index 74c6844..3c00ee6 100644
--- a/tests/auto/declarative/visual/qfxwebview/autosize/autosize.qml
+++ b/tests/auto/declarative/visual/qfxwebview/autosize/autosize.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import org.webkit 1.0
// The WebView size is determined by the width, height,
// preferredWidth, and preferredHeight properties.
diff --git a/tests/auto/declarative/visual/webview/embedding/nesting.qml b/tests/auto/declarative/visual/webview/embedding/nesting.qml
index 0d76579..5e35306 100644
--- a/tests/auto/declarative/visual/webview/embedding/nesting.qml
+++ b/tests/auto/declarative/visual/webview/embedding/nesting.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import org.webkit 1.0
WebView {
width: 300
diff --git a/tests/auto/declarative/visual/webview/javascript/evaluateJavaScript.qml b/tests/auto/declarative/visual/webview/javascript/evaluateJavaScript.qml
index 78d5cfc..6c01382 100644
--- a/tests/auto/declarative/visual/webview/javascript/evaluateJavaScript.qml
+++ b/tests/auto/declarative/visual/webview/javascript/evaluateJavaScript.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import org.webkit 1.0
Column {
WebView {
diff --git a/tests/auto/declarative/visual/webview/javascript/windowObjects.qml b/tests/auto/declarative/visual/webview/javascript/windowObjects.qml
index a41de9a..8c52aff 100644
--- a/tests/auto/declarative/visual/webview/javascript/windowObjects.qml
+++ b/tests/auto/declarative/visual/webview/javascript/windowObjects.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import org.webkit 1.0
Column {
WebView {
diff --git a/tests/auto/declarative/visual/webview/settings/fontFamily.qml b/tests/auto/declarative/visual/webview/settings/fontFamily.qml
index 2bb2a53..f547b0e 100644
--- a/tests/auto/declarative/visual/webview/settings/fontFamily.qml
+++ b/tests/auto/declarative/visual/webview/settings/fontFamily.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import org.webkit 1.0
WebView {
id: web
diff --git a/tests/auto/declarative/visual/webview/settings/fontSize.qml b/tests/auto/declarative/visual/webview/settings/fontSize.qml
index b970783..7eaa96b 100644
--- a/tests/auto/declarative/visual/webview/settings/fontSize.qml
+++ b/tests/auto/declarative/visual/webview/settings/fontSize.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import org.webkit 1.0
Grid {
columns: 3
diff --git a/tests/auto/declarative/visual/webview/settings/noAutoLoadImages.qml b/tests/auto/declarative/visual/webview/settings/noAutoLoadImages.qml
index 72e672d..67f1633 100644
--- a/tests/auto/declarative/visual/webview/settings/noAutoLoadImages.qml
+++ b/tests/auto/declarative/visual/webview/settings/noAutoLoadImages.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import org.webkit 1.0
Grid {
columns: 2
diff --git a/tests/auto/declarative/visual/webview/settings/setFontFamily.qml b/tests/auto/declarative/visual/webview/settings/setFontFamily.qml
index 26deed8..823469f 100644
--- a/tests/auto/declarative/visual/webview/settings/setFontFamily.qml
+++ b/tests/auto/declarative/visual/webview/settings/setFontFamily.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import org.webkit 1.0
WebView {
url: "test.html"
diff --git a/tests/auto/declarative/visual/webview/zooming/pageWidth.qml b/tests/auto/declarative/visual/webview/zooming/pageWidth.qml
index 86dd7d2..4a876dd 100644
--- a/tests/auto/declarative/visual/webview/zooming/pageWidth.qml
+++ b/tests/auto/declarative/visual/webview/zooming/pageWidth.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import org.webkit 1.0
WebView {
width: 200
diff --git a/tests/auto/declarative/visual/webview/zooming/renderControl.qml b/tests/auto/declarative/visual/webview/zooming/renderControl.qml
index 0c8bb3b..49eb91b 100644
--- a/tests/auto/declarative/visual/webview/zooming/renderControl.qml
+++ b/tests/auto/declarative/visual/webview/zooming/renderControl.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import org.webkit 1.0
Rectangle {
width: 200
diff --git a/tests/auto/declarative/visual/webview/zooming/resolution.qml b/tests/auto/declarative/visual/webview/zooming/resolution.qml
index a9d4e3a..8542768 100644
--- a/tests/auto/declarative/visual/webview/zooming/resolution.qml
+++ b/tests/auto/declarative/visual/webview/zooming/resolution.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import org.webkit 1.0
WebView {
width: 200 * zoomFactor
diff --git a/tests/auto/declarative/visual/webview/zooming/zoomTextOnly.qml b/tests/auto/declarative/visual/webview/zooming/zoomTextOnly.qml
index 4455b43..c2e9348 100644
--- a/tests/auto/declarative/visual/webview/zooming/zoomTextOnly.qml
+++ b/tests/auto/declarative/visual/webview/zooming/zoomTextOnly.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import org.webkit 1.0
WebView {
width: 200
diff --git a/tests/auto/declarative/visual/webview/zooming/zooming.qml b/tests/auto/declarative/visual/webview/zooming/zooming.qml
index 0ea9131..9f0b865 100644
--- a/tests/auto/declarative/visual/webview/zooming/zooming.qml
+++ b/tests/auto/declarative/visual/webview/zooming/zooming.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import org.webkit 1.0
// Note that zooming is better done using zoomFactor and careful
// control of rendering to avoid excessive re-rendering during
diff --git a/tests/auto/headers/tst_headers.cpp b/tests/auto/headers/tst_headers.cpp
index 3745767..12c5843 100644
--- a/tests/auto/headers/tst_headers.cpp
+++ b/tests/auto/headers/tst_headers.cpp
@@ -271,6 +271,7 @@ void tst_Headers::macros()
if (header.endsWith("_p.h") || header.endsWith("_pch.h")
|| header.contains("global/qconfig-") || header.endsWith("/qconfig.h")
|| header.contains("/src/tools/") || header.contains("/src/plugins/")
+ || header.contains("/src/imports/")
|| header.endsWith("/qiconset.h") || header.endsWith("/qfeatures.h")
|| header.endsWith("qt_windows.h"))
return;
diff --git a/tests/auto/qbearertestcommon.h b/tests/auto/qbearertestcommon.h
index 0bfe622..c9df249 100644
--- a/tests/auto/qbearertestcommon.h
+++ b/tests/auto/qbearertestcommon.h
@@ -42,6 +42,19 @@
#ifndef QBEARERTESTCOMMON_H
#define QBEARERTESTCOMMON_H
+// Wait for __expr to happen, while still allowing events to be processed.
+#define QTRY_NOOP(__expr) \
+ do { \
+ const int __step = 50; \
+ const int __timeout = 15000; \
+ if (!(__expr)) { \
+ QTest::qWait(0); \
+ } \
+ for (int __i = 0; __i < __timeout && !(__expr); __i+=__step) { \
+ QTest::qWait(__step); \
+ } \
+ } while(0)
+
// Will try to wait for the condition while allowing event processing
#define QTRY_VERIFY(__expr) \
do { \
diff --git a/tests/auto/qmetaobject/tst_qmetaobject.cpp b/tests/auto/qmetaobject/tst_qmetaobject.cpp
index 15b6204..bd54975 100644
--- a/tests/auto/qmetaobject/tst_qmetaobject.cpp
+++ b/tests/auto/qmetaobject/tst_qmetaobject.cpp
@@ -513,6 +513,19 @@ void tst_QMetaObject::invokeMetaMember()
QVERIFY(QMetaObject::invokeMethod(&obj, "sig1", Q_RETURN_ARG(QString, exp), Q_ARG(QString, "hehe")));
QCOMPARE(exp, QString("yessir"));
QCOMPARE(obj.slotResult, QString("sl1:hehe"));
+
+ QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::doesNotExist()");
+ QVERIFY(!QMetaObject::invokeMethod(&obj, "doesNotExist"));
+ QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString)(QString)");
+ QVERIFY(!QMetaObject::invokeMethod(&obj, "sl1(QString)", Q_ARG(QString, "arg")));
+ QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl3(QString)");
+ QVERIFY(!QMetaObject::invokeMethod(&obj, "sl3", Q_ARG(QString, "arg")));
+ QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString,QString,QString)");
+ QVERIFY(!QMetaObject::invokeMethod(&obj, "sl1", Q_ARG(QString, "arg"), Q_ARG(QString, "arg"), Q_ARG(QString, "arg")));
+
+ //should not have changed since last test.
+ QCOMPARE(exp, QString("yessir"));
+ QCOMPARE(obj.slotResult, QString("sl1:hehe"));
}
void tst_QMetaObject::invokeQueuedMetaMember()
diff --git a/tests/auto/qnetworksession/lackey/main.cpp b/tests/auto/qnetworksession/lackey/main.cpp
index 41e935a..66d6dd4 100644
--- a/tests/auto/qnetworksession/lackey/main.cpp
+++ b/tests/auto/qnetworksession/lackey/main.cpp
@@ -69,14 +69,15 @@ int main(int argc, char** argv)
QNetworkConfigurationManager manager;
QList<QNetworkConfiguration> discovered =
-#if defined (Q_OS_SYMBIAN)
- // On Symbian, on the first query (before updateConfigurations() call
- // the discovered-states are not correct, so defined-state will do.
- manager.allConfigurations(QNetworkConfiguration::Defined);
-#else
manager.allConfigurations(QNetworkConfiguration::Discovered);
-#endif
+
+ foreach(QNetworkConfiguration config, discovered) {
+ qDebug() << "Lackey: Name of the config enumerated: " << config.name();
+ qDebug() << "Lackey: State of the config enumerated: " << config.state();
+ }
+
if (discovered.isEmpty()) {
+ qDebug("Lackey: no discovered configurations, returning empty error.");
return NO_DISCOVERED_CONFIGURATIONS_ERROR;
}
diff --git a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp
index 4ef3a4f..58b1a48 100644
--- a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp
+++ b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp
@@ -54,6 +54,7 @@
QT_USE_NAMESPACE
Q_DECLARE_METATYPE(QNetworkConfiguration)
+Q_DECLARE_METATYPE(QNetworkConfiguration::Type);
Q_DECLARE_METATYPE(QNetworkSession::State);
Q_DECLARE_METATYPE(QNetworkSession::SessionError);
@@ -70,6 +71,11 @@ private slots:
void outOfProcessSession();
void invalidSession();
+ void repeatedOpenClose_data();
+ void repeatedOpenClose();
+
+ void roamingErrorCodes();
+
void sessionProperties_data();
void sessionProperties();
@@ -94,11 +100,17 @@ private:
#endif
};
+// Helper functions
+bool openSession(QNetworkSession *session);
+bool closeSession(QNetworkSession *session, bool lastSessionOnConfiguration = true);
+QNetworkConfiguration suitableConfiguration(QString bearerType, QNetworkConfiguration::Type configType);
+
void tst_QNetworkSession::initTestCase()
{
qRegisterMetaType<QNetworkSession::State>("QNetworkSession::State");
qRegisterMetaType<QNetworkSession::SessionError>("QNetworkSession::SessionError");
qRegisterMetaType<QNetworkConfiguration>("QNetworkConfiguration");
+ qRegisterMetaType<QNetworkConfiguration::Type>("QNetworkConfiguration::Type");
#ifdef Q_WS_MAEMO_6
iapconf = new Maemo::IAPConf("007");
@@ -211,9 +223,42 @@ void tst_QNetworkSession::cleanupTestCase()
void tst_QNetworkSession::invalidSession()
{
+ // Verify that session created with invalid configuration remains in invalid state
QNetworkSession session(QNetworkConfiguration(), 0);
QVERIFY(!session.isOpen());
QVERIFY(session.state() == QNetworkSession::Invalid);
+ QVERIFY(session.error() == QNetworkSession::InvalidConfigurationError);
+
+ // Verify that opening session with invalid configuration both 1) emits invalidconfigurationerror
+ // and 2) sets session's state as invalid.
+ QSignalSpy errorSpy(&session, SIGNAL(error(QNetworkSession::SessionError)));
+ session.open();
+ session.waitForOpened(1000); // Should bail out right away
+ QVERIFY(errorSpy.count() == 1);
+ QNetworkSession::SessionError error =
+ qvariant_cast<QNetworkSession::SessionError> (errorSpy.first().at(0));
+ QVERIFY(error == QNetworkSession::InvalidConfigurationError);
+ QVERIFY(session.error() == QNetworkSession::InvalidConfigurationError);
+ QVERIFY(session.state() == QNetworkSession::Invalid);
+
+ // Check same thing with a config from platform (there are subtle differences
+ // because emtpy configuration does not have private pointer). Test with config
+ // in '(un)defined' state
+ QList<QNetworkConfiguration> allConfigs = manager.allConfigurations();
+ foreach(QNetworkConfiguration config, allConfigs) {
+ if ((config.state() & QNetworkConfiguration::Discovered) != QNetworkConfiguration::Discovered) {
+ QNetworkSession session2(config);
+ QSignalSpy errorSpy2(&session2, SIGNAL(error(QNetworkSession::SessionError)));
+ session2.open();
+ session2.waitForOpened(1000); // Should bail out right away
+ QVERIFY(errorSpy2.count() == 1);
+ QNetworkSession::SessionError error2 =
+ qvariant_cast<QNetworkSession::SessionError> (errorSpy2.first().at(0));
+ QVERIFY(error2 == QNetworkSession::InvalidConfigurationError);
+ QVERIFY(session2.state() == QNetworkSession::Invalid);
+ break; // Once is enough
+ }
+ }
}
void tst_QNetworkSession::sessionProperties_data()
@@ -300,6 +345,100 @@ void tst_QNetworkSession::sessionProperties()
}
}
+void tst_QNetworkSession::repeatedOpenClose_data() {
+ QTest::addColumn<QString>("bearerType");
+ QTest::addColumn<QNetworkConfiguration::Type>("configurationType");
+ QTest::addColumn<int>("repeatTimes");
+
+ QTest::newRow("WLAN_IAP") << "WLAN" << QNetworkConfiguration::InternetAccessPoint << 3;
+ // QTest::newRow("Cellular_IAP") << "cellular" << QNetworkConfiguration::InternetAccessPoint << 3;
+ // QTest::newRow("SNAP") << "bearer_type_not_relevant_with_SNAPs" << QNetworkConfiguration::ServiceNetwork << 3;
+}
+
+// Tests repeated-open close.
+void tst_QNetworkSession::repeatedOpenClose() {
+ QFETCH(QString, bearerType);
+ QFETCH(QNetworkConfiguration::Type, configurationType);
+ QFETCH(int, repeatTimes);
+
+ // First check that opening once succeeds and determine if repeatable testing is doable
+ QNetworkConfiguration config = suitableConfiguration(bearerType, configurationType);
+ if (!config.isValid()) {
+ QSKIP("No suitable configurations, skipping this round of repeated open-close test.", SkipSingle);
+ }
+ qDebug() << "Using following configuratio to repeatedly open and close: " << config.name();
+ QNetworkSession permanentSession(config);
+ if (!openSession(&permanentSession) ||
+ !closeSession(&permanentSession)) {
+ QSKIP("Unable to open/close session, skipping this round of repeated open-close test.", SkipSingle);
+ }
+ for (int i = repeatTimes; i > 0; i--) {
+ QVERIFY(openSession(&permanentSession));
+ QVERIFY(closeSession(&permanentSession));
+ }
+}
+
+void tst_QNetworkSession::roamingErrorCodes() {
+
+#ifndef Q_OS_SYMBIAN
+ QSKIP("Roaming supported on Symbian.", SkipAll);
+#else
+ QNetworkConfiguration wlanIapConfig = suitableConfiguration("WLAN", QNetworkConfiguration::InternetAccessPoint);
+ if (!wlanIapConfig.isValid()) {
+ QSKIP("No WLAN IAP accessible, skipping test.", SkipAll);
+ }
+ // Check that opening and closing two sessions on same config work gracefully:
+ QNetworkSession iapSession(wlanIapConfig);
+ QVERIFY(openSession(&iapSession));
+ QNetworkSession adminIapSession(wlanIapConfig);
+ QVERIFY(openSession(&adminIapSession));
+ QVERIFY(closeSession(&iapSession, false)); // false == not a last session based on the configuration
+ QVERIFY(closeSession(&adminIapSession));
+
+ // Open configurations again, force close bearer and check that errors are emitted correctly
+ // on the other session
+ QVERIFY(openSession(&iapSession));
+ QVERIFY(openSession(&adminIapSession));
+ QSignalSpy errorSpy(&iapSession, SIGNAL(error(QNetworkSession::SessionError)));
+ adminIapSession.stop(); // requires NetworkControl capabilities
+ QTRY_VERIFY(!errorSpy.isEmpty()); // wait for error signals
+ QNetworkSession::SessionError error = qvariant_cast<QNetworkSession::SessionError>(errorSpy.first().at(0));
+ QVERIFY(error == QNetworkSession::SessionAbortedError);
+ QVERIFY(iapSession.state() == QNetworkSession::Disconnected);
+ QVERIFY(adminIapSession.state() == QNetworkSession::Disconnected);
+#endif // Q_OS_SYMBIAN
+ /*
+ // Check for roaming error. Challenging to automate, therefore commented out.
+ // Case requires that you have controllable WLAN in Internet SNAP (only).
+ QNetworkConfiguration snapConfig = suitableConfiguration("bearer_not_relevant_with_snaps", QNetworkConfiguration::ServiceNetwork);
+ if (!snapConfig.isValid()) {
+ QSKIP("No SNAP accessible, skipping test.", SkipAll);
+ }
+ QNetworkSession snapSession(snapConfig);
+ QVERIFY(openSession(&snapSession));
+ QSignalSpy errorSpySnap(&snapSession, SIGNAL(error(QNetworkSession::SessionError)));
+ qDebug("Disconnect the WLAN now");
+ QTRY_VERIFY(!errorSpySnap.isEmpty()); // wait for error signals
+ QVERIFY(errorSpySnap.count() == 1);
+ error = qvariant_cast<QNetworkSession::SessionError>(errorSpySnap.first().at(0));
+ qDebug() << "Error received when turning off wlan on SNAP: " << error;
+ QVERIFY(error == QNetworkSession::RoamingError);
+
+ qDebug("Connect the WLAN now");
+ QTest::qWait(60000); // Wait for WLAN to get up
+ QNetworkConfiguration wlanIapConfig2 = suitableConfiguration("WLAN", QNetworkConfiguration::InternetAccessPoint);
+ QNetworkSession iapSession2(wlanIapConfig2);
+ QVERIFY(openSession(&iapSession2));
+ QSignalSpy errorSpy2(&iapSession2, SIGNAL(error(QNetworkSession::SessionError)));
+ qDebug("Disconnect the WLAN now");
+ QTRY_VERIFY(!errorSpy2.isEmpty()); // wait for error signals
+ QVERIFY(errorSpy2.count() == 1);
+ error = qvariant_cast<QNetworkSession::SessionError>(errorSpy2.first().at(0));
+ QVERIFY(error == QNetworkSession::SessionAbortedError);
+ QVERIFY(iapSession2.state() == QNetworkSession::Disconnected);
+ */
+}
+
void tst_QNetworkSession::userChoiceSession_data()
{
QTest::addColumn<QNetworkConfiguration>("configuration");
@@ -810,7 +949,7 @@ QDebug operator<<(QDebug debug, const QList<QNetworkConfiguration> &list)
}
// Note: outOfProcessSession requires that at least one configuration is
-// at Discovered -state (Defined is ok for symbian as well, as long as it is possible to open).
+// at Discovered -state.
void tst_QNetworkSession::outOfProcessSession()
{
qDebug() << "START";
@@ -913,6 +1052,158 @@ void tst_QNetworkSession::outOfProcessSession()
qDebug("STOP");
}
+// A convinience / helper function for testcases. Return the first matching configuration.
+// Ignores configurations in other than 'discovered' -state. Returns invalid (QNetworkConfiguration())
+// if none found.
+QNetworkConfiguration suitableConfiguration(QString bearerType, QNetworkConfiguration::Type configType) {
+ // Refresh configurations and derive configurations matching given parameters.
+ QNetworkConfigurationManager mgr;
+ QSignalSpy updateSpy(&mgr, SIGNAL(updateCompleted()));
+ mgr.updateConfigurations();
+ QTRY_NOOP(updateSpy.count() == 1);
+ if (updateSpy.count() != 1) {
+ qDebug("tst_QNetworkSession::suitableConfiguration() failure: unable to update configurations");
+ return QNetworkConfiguration();
+ }
+ QList<QNetworkConfiguration> discoveredConfigs = mgr.allConfigurations(QNetworkConfiguration::Discovered);
+ foreach(QNetworkConfiguration config, discoveredConfigs) {
+ if ((config.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
+ // qDebug() << "Dumping config because is active: " << config.name();
+ discoveredConfigs.removeOne(config);
+ } else if (config.type() != configType) {
+ // qDebug() << "Dumping config because type (IAP/SNAP) mismatches: " << config.name();
+ discoveredConfigs.removeOne(config);
+ } else if ((config.type() == QNetworkConfiguration::InternetAccessPoint) &&
+ bearerType == "cellular") { // 'cellular' bearertype is for convinience
+ if (config.bearerName() != "2G" &&
+ config.bearerName() != "CDMA2000" &&
+ config.bearerName() != "WCDMA" &&
+ config.bearerName() != "HSPA") {
+ // qDebug() << "Dumping config because bearer mismatches (cellular): " << config.name();
+ discoveredConfigs.removeOne(config);
+ }
+ } else if ((config.type() == QNetworkConfiguration::InternetAccessPoint) &&
+ bearerType != config.bearerName()) {
+ // qDebug() << "Dumping config because bearer mismatches (WLAN): " << config.name();
+ discoveredConfigs.removeOne(config);
+ }
+ }
+ if (discoveredConfigs.isEmpty()) {
+ qDebug("tst_QNetworkSession::suitableConfiguration() failure: no suitable configurations present.");
+ return QNetworkConfiguration();
+ } else {
+ return discoveredConfigs.first();
+ }
+}
+
+// A convinience function for test-cases: opens the given configuration and return
+// true if it was done gracefully.
+bool openSession(QNetworkSession *session) {
+ QNetworkConfigurationManager mgr;
+ QSignalSpy openedSpy(session, SIGNAL(opened()));
+ QSignalSpy stateChangeSpy(session, SIGNAL(stateChanged(QNetworkSession::State)));
+ QSignalSpy errorSpy(session, SIGNAL(error(QNetworkSession::SessionError)));
+ QSignalSpy configChangeSpy(&mgr, SIGNAL(configurationChanged(QNetworkConfiguration)));
+ // Store some initial statuses, because expected signals differ if the config is already
+ // active by some other session
+ QNetworkConfiguration::StateFlags configInitState = session->configuration().state();
+ QNetworkSession::State sessionInitState = session->state();
+
+ if (session->isOpen() ||
+ !session->sessionProperty("ActiveConfiguration").toString().isEmpty()) {
+ qDebug("tst_QNetworkSession::openSession() failure: session was already open / active.");
+ return false;
+ } else {
+ session->open();
+ session->waitForOpened(120000); // Bringing interfaces up and down may take time at platform
+ }
+ // Check that connection opening went by the book. Add checks here if more strictness needed.
+ if (!session->isOpen()) {
+ qDebug("tst_QNetworkSession::openSession() failure: QNetworkSession::open() failed.");
+ return false;
+ }
+ if (openedSpy.count() != 1) {
+ qDebug("tst_QNetworkSession::openSession() failure: QNetworkSession::opened() - signal not received.");
+ return false;
+ }
+ if (!errorSpy.isEmpty()) {
+ qDebug("tst_QNetworkSession::openSession() failure: QNetworkSession::error() - signal was detected.");
+ return false;
+ }
+ if (sessionInitState != QNetworkSession::Connected &&
+ stateChangeSpy.isEmpty()) {
+ qDebug("tst_QNetworkSession::openSession() failure: QNetworkSession::stateChanged() - signals not detected.");
+ return false;
+ }
+ if (configInitState != QNetworkConfiguration::Active &&
+ configChangeSpy.isEmpty()) {
+ qDebug("tst_QNetworkSession::openSession() failure: QNetworkConfigurationManager::configurationChanged() - signals not detected.");
+ return false;
+ }
+ if (session->configuration().state() != QNetworkConfiguration::Active) {
+ qDebug("tst_QNetworkSession::openSession() failure: session's configuration is not in 'Active' -state.");
+ return false;
+ }
+ return true;
+}
+
+// Helper function for closing opened session. Performs checks that
+// session is closed gradefully (e.g. signals). Function does not delete
+// the session. The lastSessionOnConfiguration (true by default) is used to
+// tell if there are more sessions open, basing on same configration. This
+// impacts the checks made.
+bool closeSession(QNetworkSession *session, bool lastSessionOnConfiguration) {
+ if (!session) {
+ qDebug("tst_QNetworkSession::closeSession() failure: NULL session given");
+ return false;
+ }
+ if (session->state() != QNetworkSession::Connected ||
+ !session->isOpen()) {
+ qDebug("tst_QNetworkSession::closeSession() failure: session is not opened.");
+ return false;
+ }
+ QNetworkConfigurationManager mgr;
+ QSignalSpy sessionClosedSpy(session, SIGNAL(closed()));
+ QSignalSpy sessionStateChangedSpy(session, SIGNAL(stateChanged(QNetworkSession::State)));
+ QSignalSpy sessionErrorSpy(session, SIGNAL(error(QNetworkSession::SessionError)));
+ QSignalSpy configChangeSpy(&mgr, SIGNAL(configurationChanged(QNetworkConfiguration)));
+
+ session->close();
+
+ if (!sessionErrorSpy.isEmpty()) {
+ qDebug("tst_QNetworkSession::closeSession() failure: QNetworkSession::error() received.");
+ return false;
+ }
+ if (sessionClosedSpy.count() != 1) {
+ qDebug("tst_QNetworkSession::closeSession() failure: QNetworkSession::closed() signal not received.");
+ return false;
+ }
+ if (lastSessionOnConfiguration &&
+ sessionStateChangedSpy.isEmpty()) {
+ qDebug("tst_QNetworkSession::closeSession() failure: QNetworkSession::stateChanged() signals not received.");
+ return false;
+ }
+ if (lastSessionOnConfiguration &&
+ session->state() != QNetworkSession::Disconnected) {
+ qDebug("tst_QNetworkSession::closeSession() failure: QNetworkSession is not in Disconnected -state");
+ return false;
+ }
+ QTRY_NOOP(!configChangeSpy.isEmpty());
+ if (lastSessionOnConfiguration &&
+ configChangeSpy.isEmpty()) {
+ qDebug("tst_QNetworkSession::closeSession() failure: QNetworkConfigurationManager::configurationChanged() - signal not detected.");
+ return false;
+ }
+ if (lastSessionOnConfiguration &&
+ session->configuration().state() != QNetworkConfiguration::Discovered) {
+ qDebug("tst_QNetworkSession::closeSession() failure: session's configuration is not back in 'Discovered' -state.");
+ return false;
+ }
+ return true;
+}
+
+
+
QTEST_MAIN(tst_QNetworkSession)
#include "tst_qnetworksession.moc"