summaryrefslogtreecommitdiffstats
path: root/Source/WebKit/qt/tests/qdeclarativewebview/tst_qdeclarativewebview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/qt/tests/qdeclarativewebview/tst_qdeclarativewebview.cpp')
-rw-r--r--Source/WebKit/qt/tests/qdeclarativewebview/tst_qdeclarativewebview.cpp34
1 files changed, 34 insertions, 0 deletions
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