diff options
Diffstat (limited to 'Source/WebKit/qt/tests/qdeclarativewebview')
3 files changed, 45 insertions, 0 deletions
diff --git a/Source/WebKit/qt/tests/qdeclarativewebview/resources/webviewbackgroundcolor.qml b/Source/WebKit/qt/tests/qdeclarativewebview/resources/webviewbackgroundcolor.qml new file mode 100644 index 0000000..2edc794 --- /dev/null +++ b/Source/WebKit/qt/tests/qdeclarativewebview/resources/webviewbackgroundcolor.qml @@ -0,0 +1,10 @@ +import Qt 4.7 +import QtWebKit 1.1 + +WebView { + id: myweb + height: 300 + width: 300 + focus: true + backgroundColor : "red" +} diff --git a/Source/WebKit/qt/tests/qdeclarativewebview/tst_qdeclarativewebview.cpp b/Source/WebKit/qt/tests/qdeclarativewebview/tst_qdeclarativewebview.cpp index 0025d6c..8fcab71 100644 --- a/Source/WebKit/qt/tests/qdeclarativewebview/tst_qdeclarativewebview.cpp +++ b/Source/WebKit/qt/tests/qdeclarativewebview/tst_qdeclarativewebview.cpp @@ -1,4 +1,5 @@ #include "../util.h" +#include <QColor> #include <QDebug> #include <QDeclarativeComponent> #include <QDeclarativeEngine> @@ -22,6 +23,9 @@ private slots: void preferredHeightTest(); void preferredWidthDefaultTest(); void preferredHeightDefaultTest(); +#if QT_VERSION >= 0x040703 + void backgroundColor(); +#endif private: void checkNoErrors(const QDeclarativeComponent&); @@ -82,6 +86,36 @@ void tst_QDeclarativeWebView::preferredHeightDefaultTest() QCOMPARE(wv->property("prefHeight").toDouble(), view.preferredHeight()); } +#if QT_VERSION >= 0x040703 +void tst_QDeclarativeWebView::backgroundColor() +{ + // We test here the rendering of the background. + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, QUrl("qrc:///resources/webviewbackgroundcolor.qml")); + checkNoErrors(component); + QObject* wv = component.create(); + QVERIFY(wv); + QCOMPARE(wv->property("backgroundColor").value<QColor>(), QColor(Qt::red)); + QDeclarativeView view; + view.setSource(QUrl("qrc:///resources/webviewbackgroundcolor.qml")); + view.show(); + QTest::qWaitForWindowShown(&view); + QPixmap result(view.width(), view.height()); + QPainter painter(&result); + view.render(&painter); + QPixmap reference(view.width(), view.height()); + reference.fill(Qt::red); + QCOMPARE(reference, result); + + // We test the emission of the backgroundColorChanged signal. + QSignalSpy spyColorChanged(wv, SIGNAL(backgroundColorChanged())); + wv->setProperty("backgroundColor", Qt::red); + QCOMPARE(spyColorChanged.count(), 0); + wv->setProperty("backgroundColor", Qt::green); + QCOMPARE(spyColorChanged.count(), 1); +} +#endif + void tst_QDeclarativeWebView::checkNoErrors(const QDeclarativeComponent& component) { // Wait until the component is ready diff --git a/Source/WebKit/qt/tests/qdeclarativewebview/tst_qdeclarativewebview.qrc b/Source/WebKit/qt/tests/qdeclarativewebview/tst_qdeclarativewebview.qrc index 9c27409..e14c333 100644 --- a/Source/WebKit/qt/tests/qdeclarativewebview/tst_qdeclarativewebview.qrc +++ b/Source/WebKit/qt/tests/qdeclarativewebview/tst_qdeclarativewebview.qrc @@ -3,5 +3,6 @@ <file>resources/webviewtestdefault.qml</file> <file>resources/webviewtest.qml</file> <file>resources/sample.html</file> + <file>resources/webviewbackgroundcolor.qml</file> </qresource> </RCC> |