Commit b65d4057 authored by ariya@webkit.org's avatar ariya@webkit.org

2009-05-12 Antonio Gomes <antonio.gomes@openbossa.org>

    Reviewed by Ariya Hidayat.

    Added external CSS test cases to QWebElement::styleProperty() method.

    Also some ::styleProperty() tests cleanup.

    * tests/qwebelement/tst_qwebelement.cpp:
    (tst_QWebElement::style):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@43620 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c32f32e2
2009-05-12 Antonio Gomes <antonio.gomes@openbossa.org>
Reviewed by Ariya Hidayat.
Added external CSS test cases to QWebElement::styleProperty() method.
Also some ::styleProperty() tests cleanup.
* tests/qwebelement/tst_qwebelement.cpp:
(tst_QWebElement::style):
2009-05-12 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org>
Reviewed by Ariya Hidayat.
......
......@@ -2,5 +2,6 @@ TEMPLATE = app
TARGET = tst_qwebelement
include(../../../../WebKit.pri)
SOURCES += tst_qwebelement.cpp
RESOURCES += qwebelement.qrc
QT += testlib network
QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/">
<file>style.css</file>
<file>style2.css</file>
</qresource>
</RCC>
#idP {color: black !important}
#idP {color: green ! important}
......@@ -385,17 +385,14 @@ void tst_QWebElement::frame()
void tst_QWebElement::style()
{
QString html = "<head>"
"<style type=\"text/css\">"
"div,p {color: green !important }"
"#singlep {width: 20px !important ; color: red }"
"</style>"
"<style type=\"text/css\">"
".bg {background-color: #ff0000 !important;}"
" p {height: 11px! important; width : 12px !important; }"
"<style type='text/css'>"
"p { color: green !important }"
"#idP { color: red }"
".classP { color : yellow ! important }"
"</style>"
"</head>"
"<body>"
"<p id=\"singlep\" class=\"bg\" style=\"color: blue;\">some text</p>"
"<p id='idP' class='classP' style='color: blue;'>some text</p>"
"</body>";
m_mainFrame->setHtml(html);
......@@ -408,18 +405,30 @@ void tst_QWebElement::style()
p.setStyleProperty("cursor", "auto");
QCOMPARE(p.styleProperty("color"), QLatin1String("red"));
QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("green"));
QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("yellow"));
QCOMPARE(p.styleProperty("cursor"), QLatin1String("auto"));
p.setStyleProperty("color", "green !important");
QCOMPARE(p.styleProperty("color"), QLatin1String("green"));
QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("green"));
p.setStyleProperty("color", "blue");
QCOMPARE(p.styleProperty("color"), QLatin1String("green"));
QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("green"));
p.setStyleProperty("color", "blue", QWebElement::ImportantStylePriority);
QCOMPARE(p.styleProperty("color"), QLatin1String("blue"));
QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("blue"));
QString html2 = "<head>"
"<style type=\"text/css\">"
"<style type='text/css'>"
"p { color: green }"
"#singlep { color: red }"
".classp { color: yellow }"
"#idP { color: red }"
".classP { color: yellow }"
"</style>"
"</head>"
"<body>"
"<p id=\"singlep\" class=\"classp\" style=\"color: blue;\">some text</p>"
"<p id='idP' class='classP' style='color: blue;'>some text</p>"
"</body>";
m_mainFrame->setHtml(html2);
......@@ -429,14 +438,14 @@ void tst_QWebElement::style()
QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("blue"));
QString html3 = "<head>"
"<style type=\"text/css\">"
"<style type='text/css'>"
"p { color: green !important }"
"#singlep { color: red !important}"
".classp { color: yellow !important}"
"#idP { color: red !important}"
".classP { color: yellow !important}"
"</style>"
"</head>"
"<body>"
"<p id=\"singlep\" class=\"classp\" style=\"color: blue !important;\">some text</p>"
"<p id='idP' class='classP' style='color: blue !important;'>some text</p>"
"</body>";
m_mainFrame->setHtml(html3);
......@@ -445,53 +454,60 @@ void tst_QWebElement::style()
QCOMPARE(p.styleProperty("color"), QLatin1String("blue"));
QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("blue"));
QString html4 = "<head>"
"<style type=\"text/css\">"
"p { color: green !important }"
"#singlep { color: red !important}"
"#singlep { color: black}"
".classp { color: yellow !important}"
QString html5 = "<head>"
"<style type='text/css'>"
"p { color: green }"
"#idP { color: red }"
".classP { color: yellow }"
"</style>"
"</head>"
"<body>"
"<p id=\"singlep\" class=\"classp\" style=\"color: blue;\">some text</p>"
"<p id='idP' class='classP'>some text</p>"
"</body>";
m_mainFrame->setHtml(html4);
m_mainFrame->setHtml(html5);
p = m_mainFrame->documentElement().findAll("p").at(0);
QCOMPARE(p.styleProperty("color"), QLatin1String("blue"));
QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("red"));
p.setStyleProperty("color", "green");
QCOMPARE(p.styleProperty("color"), QLatin1String("green"));
QCOMPARE(p.styleProperty("color"), QLatin1String(""));
QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("red"));
p.setStyleProperty("color", "green !important");
QCOMPARE(p.styleProperty("color"), QLatin1String("green"));
QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("green"));
p.setStyleProperty("color", "blue");
QCOMPARE(p.styleProperty("color"), QLatin1String("green"));
QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("green"));
p.setStyleProperty("color", "blue", QWebElement::ImportantStylePriority);
QCOMPARE(p.styleProperty("color"), QLatin1String("blue"));
QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("blue"));
QString html5 = "<head>"
"<style type=\"text/css\">"
QString html6 = "<head>"
"<link rel='stylesheet' href='qrc:/style.css' type='text/css' />"
"<style type='text/css'>"
"p { color: green }"
"#singlep { color: red }"
".classp { color: yellow }"
"#idP { color: red }"
".classP { color: yellow ! important}"
"</style>"
"</head>"
"<body>"
"<p id=\"singlep\" class=\"classp\">some text</p>"
"<p id='idP' class='classP' style='color: blue;'>some text</p>"
"</body>";
m_mainFrame->setHtml(html5);
// in few seconds, the CSS should be completey loaded
QSignalSpy spy(m_page, SIGNAL(loadFinished(bool)));
m_mainFrame->setHtml(html6);
QTest::qWait(200);
p = m_mainFrame->documentElement().findAll("p").at(0);
QCOMPARE(p.styleProperty("color"), QLatin1String("blue"));
QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("black"));
QCOMPARE(p.styleProperty("color"), QLatin1String(""));
QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("red"));
QString html7 = "<head>"
"<style type='text/css'>"
"@import url(qrc:/style2.css);"
"</style>"
"<link rel='stylesheet' href='qrc:/style.css' type='text/css' />"
"</head>"
"<body>"
"<p id='idP' style='color: blue;'>some text</p>"
"</body>";
// in few seconds, the style should be completey loaded
m_mainFrame->setHtml(html7);
QTest::qWait(200);
p = m_mainFrame->documentElement().findAll("p").at(0);
QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("black"));
}
void tst_QWebElement::computedStyle()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment