Esempio n. 1
0
void TestViewHelper::buttonToFunction()
{
    ViewHelper view;
    THtmlAttribute attr;
    attr.append("onclick", "return 0;");
    attr.append("style", "none");
    QString actual = view.buttonToFunction("hoge", "function", attr);
    QString result = "<input type=\"button\" value=\"hoge\" onclick=\"function; return false;\" onclick=\"return 0;\" style=\"none\" />";
    QCOMPARE(actual, result);
}
Esempio n. 2
0
void TestViewHelper::stylesheetTag()
{
    ViewHelper view;
    THtmlAttribute attr;
    attr.append("onclick", "return 0;");
    attr.append("style", "none");
    QString actual = view.stylesheetTag("hoge.png", attr);
    QString result = "<link href=\"/css/hoge.png\" rel=\"stylesheet\" type=\"text/css\" onclick=\"return 0;\" style=\"none\" />";
    QCOMPARE(actual, result);
}
Esempio n. 3
0
void TestViewHelper::imageTag()
{
    ViewHelper view;
    THtmlAttribute attr;
    attr.append("onclick", "return 0;");
    attr.append("style", "none");
    QString actual = view.imageTag("hoge.png", QSize(100, 200), "stop", attr);
    QString result = "<img src=\"/images/hoge.png\" width=\"100\" height=\"200\" alt=\"stop\" onclick=\"return 0;\" style=\"none\" />";
    QCOMPARE(actual, result); 
}
Esempio n. 4
0
void TestViewHelper::resetTag()
{
    ViewHelper view;
    THtmlAttribute attr;
    attr.append("onclick", "return 0;");
    attr.append("style", "none");
    QString actual = view.resetTag("hoge", attr);
    QString result = "<input type=\"reset\" value=\"hoge\" onclick=\"return 0;\" style=\"none\" />";
    QCOMPARE(actual, result);  
}
Esempio n. 5
0
void TestViewHelper::submitImageTag()
{
    ViewHelper view;
    THtmlAttribute attr;
    attr.append("onclick", "return 0;");
    attr.append("style", "none");
    QString actual = view.submitImageTag("hoge.png", attr);
    QString result = "<input type=\"image\" src=\"/images/hoge.png\" onclick=\"return 0;\" style=\"none\" />";
    QCOMPARE(actual, result);   
}
Esempio n. 6
0
void TestViewHelper::inputTag_data()
{
    QTest::addColumn<QString>("type");
    QTest::addColumn<QString>("name");
    QTest::addColumn<QString>("value");
    QTest::addColumn<THtmlAttribute>("attr");
    QTest::addColumn<QString>("result");

    THtmlAttribute attr;
    attr.append("onclick", "return 0;");
    attr.append("style", "none");
    QTest::newRow("1") << "hidden" << "hoge" << "50" << attr
                       << "<input type=\"hidden\" name=\"hoge\" value=\"50\" onclick=\"return 0;\" style=\"none\" />";
}
Esempio n. 7
0
void TestViewHelper::textAreaTag_data()
{
    QTest::addColumn<QString>("name");
    QTest::addColumn<int>("rows");
    QTest::addColumn<int>("columns");
    QTest::addColumn<QString>("content");
    QTest::addColumn<THtmlAttribute>("attr");
    QTest::addColumn<QString>("result");

    THtmlAttribute attr;
    attr.append("onclick", "return 0;");
    attr.append("style", "none");
    QTest::newRow("1") << "hoge" << 30 << 20 << "hello" << attr
                       << "<textarea name=\"hoge\" rows=\"30\" cols=\"20\" onclick=\"return 0;\" style=\"none\">hello</textarea>";
}
/*!
  Creates a input tag with type="radio", name=\a "name" and value=\a "value".
*/
QString TViewHelper::radioButtonTag(const QString &name, const QVariant &value, bool checked, const THtmlAttribute &attributes) const
{
    THtmlAttribute attr = attributes;
    if (checked)
        attr.append("checked", "checked");
    return inputTag("radio", name, value, attr);
}
/*!
  Creates and returns a THtmlAttribute object with \a key =\a "value".
*/
THtmlAttribute TViewHelper::a(const QString &key, const QString &value) const
{
    THtmlAttribute attr;
    attr.append(key, value);
    return attr;
}