~ci-train-bot/ubuntu-system-settings/ubuntu-system-settings-ubuntu-zesty-1721

« back to all changes in this revision

Viewing changes to tests/test-plugin.cpp

  • Committer: Iain Lane
  • Date: 2014-02-28 17:14:49 UTC
  • mto: This revision was merged to the branch mainline in revision 863.
  • Revision ID: iain.lane@canonical.com-20140228171449-s2zlo2vzhsvw6h3l
Add some tests for the new reset api

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
                                          QObject *parent = 0);
39
39
    virtual QQmlComponent *pageComponent(QQmlEngine *engine,
40
40
                                         QObject *parent = 0);
 
41
private:
 
42
    QQmlComponent *m_pageComponent;
41
43
};
42
44
 
43
45
TestItem::TestItem(const QVariantMap &staticData, QObject *parent):
44
 
    ItemBase(staticData, parent)
 
46
    ItemBase(staticData, parent),
 
47
    m_pageComponent(0)
45
48
{
46
49
    QStringList keywords;
47
50
    keywords << "one" << "two" << "three";
61
64
 
62
65
QQmlComponent *TestItem::pageComponent(QQmlEngine *engine, QObject *parent)
63
66
{
64
 
    QQmlComponent *page = new QQmlComponent(engine, parent);
65
 
    page->setData("import QtQuick 2.0\n"
66
 
                  "Rectangle {\n"
67
 
                  "  width: 200; height: 200;\n"
68
 
                  "  objectName: \"myRect\"\n"
69
 
                  "  color: \"red\""
70
 
                  "}",
71
 
                  QUrl());
72
 
    return page;
 
67
    if (m_pageComponent == NULL) {
 
68
        QQmlComponent *page = new QQmlComponent(engine, parent);
 
69
        page->setData("import QtQuick 2.0\n"
 
70
                      "Rectangle {\n"
 
71
                      " property bool reset: false\n"
 
72
                      " function reset() { console.log('Hello') }\n"
 
73
                      "  width: 200; height: 200;\n"
 
74
                      "  objectName: \"myRect\"\n"
 
75
                      "  color: \"red\""
 
76
                      "}",
 
77
                      QUrl());
 
78
        m_pageComponent = page;
 
79
    }
 
80
    return m_pageComponent;
73
81
}
74
82
 
75
83
TestPlugin::TestPlugin():