summaryrefslogtreecommitdiffstats
path: root/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-04-27 16:23:55 +0100
committerSteve Block <steveblock@google.com>2010-04-27 17:07:03 +0100
commit692e5dbf12901edacf14812a6fae25462920af42 (patch)
treed62802373a429e0a9dc093b6046c166b2c514285 /WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
parente24bea4efef1c414137d36a9778aa4e142e10c7d (diff)
downloadexternal_webkit-692e5dbf12901edacf14812a6fae25462920af42.zip
external_webkit-692e5dbf12901edacf14812a6fae25462920af42.tar.gz
external_webkit-692e5dbf12901edacf14812a6fae25462920af42.tar.bz2
Merge webkit.org at r55033 : Initial merge by git
Change-Id: I98a4af828067cc243ec3dc5e5826154dd88074b5
Diffstat (limited to 'WebKit/qt/tests/qwebframe/tst_qwebframe.cpp')
-rw-r--r--WebKit/qt/tests/qwebframe/tst_qwebframe.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
index 0fb0bd6..5ac3769 100644
--- a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
+++ b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
@@ -66,6 +66,7 @@ class MyQObject : public QObject
Q_PROPERTY(int readOnlyProperty READ readOnlyProperty)
Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut)
Q_PROPERTY(CustomType propWithCustomType READ propWithCustomType WRITE setPropWithCustomType)
+ Q_PROPERTY(QWebElement webElementProperty READ webElementProperty WRITE setWebElementProperty)
Q_ENUMS(Policy Strategy)
Q_FLAGS(Ability)
@@ -181,6 +182,14 @@ public:
m_shortcut = seq;
}
+ QWebElement webElementProperty() const {
+ return m_webElement;
+ }
+
+ void setWebElementProperty(const QWebElement& element) {
+ m_webElement = element;
+ }
+
CustomType propWithCustomType() const {
return m_customType;
}
@@ -433,6 +442,10 @@ public Q_SLOTS:
m_qtFunctionInvoked = 35;
m_actuals << arg;
}
+ void myOverloadedSlot(const QWebElement &arg) {
+ m_qtFunctionInvoked = 36;
+ m_actuals << QVariant::fromValue<QWebElement>(arg);
+ }
void qscript_call(int arg) {
m_qtFunctionInvoked = 40;
@@ -467,6 +480,7 @@ private:
int m_writeOnlyValue;
int m_readOnlyValue;
QKeySequence m_shortcut;
+ QWebElement m_webElement;
CustomType m_customType;
int m_qtFunctionInvoked;
QVariantList m_actuals;
@@ -570,6 +584,7 @@ private slots:
void hasSetFocus();
void render();
void scrollPosition();
+ void scrollToAnchor();
void evaluateWillCauseRepaint();
void qObjectWrapperWithSameIdentity();
void scrollRecursively();
@@ -685,6 +700,7 @@ void tst_QWebFrame::cleanup()
void tst_QWebFrame::getSetStaticProperty()
{
+ m_page->mainFrame()->setHtml("<html><head><body></body></html>");
QCOMPARE(evalJS("typeof myObject.noSuchProperty"), sUndefined);
// initial value (set in MyQObject constructor)
@@ -824,6 +840,8 @@ void tst_QWebFrame::getSetStaticProperty()
QCOMPARE(evalJS("myObject.stringListProperty[1]"), QLatin1String("two"));
QCOMPARE(evalJS("typeof myObject.stringListProperty[2]"), sString);
QCOMPARE(evalJS("myObject.stringListProperty[2]"), QLatin1String("true"));
+ evalJS("myObject.webElementProperty=document.body;");
+ QCOMPARE(evalJS("myObject.webElementProperty.tagName"), QLatin1String("BODY"));
// try to delete
QCOMPARE(evalJS("delete myObject.intProperty"), sFalse);
@@ -1886,6 +1904,12 @@ void tst_QWebFrame::overloadedSlots()
f.call(QString(), QStringList() << m_engine->newVariant(QVariant("ciao")));
QCOMPARE(m_myObject->qtFunctionInvoked(), 35);
*/
+
+ // should pick myOverloadedSlot(QRegExp)
+ m_myObject->resetQtFunctionInvoked();
+ evalJS("myObject.myOverloadedSlot(document.body)");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 36);
+
// should pick myOverloadedSlot(QObject*)
m_myObject->resetQtFunctionInvoked();
evalJS("myObject.myOverloadedSlot(myObject)");
@@ -2741,6 +2765,38 @@ void tst_QWebFrame::scrollPosition()
QCOMPARE(y, 29);
}
+void tst_QWebFrame::scrollToAnchor()
+{
+ QWebPage page;
+ page.setViewportSize(QSize(480, 800));
+ QWebFrame* frame = page.mainFrame();
+
+ QString html("<html><body><p style=\"margin-bottom: 1500px;\">Hello.</p>"
+ "<p><a id=\"foo\">This</a> is an anchor</p>"
+ "<p style=\"margin-bottom: 1500px;\"><a id=\"bar\">This</a> is another anchor</p>"
+ "</body></html>");
+ frame->setHtml(html);
+ frame->setScrollPosition(QPoint(0, 0));
+ QCOMPARE(frame->scrollPosition().x(), 0);
+ QCOMPARE(frame->scrollPosition().y(), 0);
+
+ QWebElement fooAnchor = frame->findFirstElement("a[id=foo]");
+
+ frame->scrollToAnchor("foo");
+ QCOMPARE(frame->scrollPosition().y(), fooAnchor.geometry().top());
+
+ frame->scrollToAnchor("bar");
+ frame->scrollToAnchor("foo");
+ QCOMPARE(frame->scrollPosition().y(), fooAnchor.geometry().top());
+
+ frame->scrollToAnchor("top");
+ QCOMPARE(frame->scrollPosition().y(), 0);
+
+ frame->scrollToAnchor("bar");
+ frame->scrollToAnchor("notexist");
+ QVERIFY(frame->scrollPosition().y() != 0);
+}
+
void tst_QWebFrame::evaluateWillCauseRepaint()
{
QWebView view;