summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/animations/tst_animations.cpp
blob: 889d9b75fb28cc6d95545d59124f49377a8cdaef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <qtest.h>
#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlcomponent.h>
#include <QtDeclarative/qfxview.h>
#include <QtDeclarative/qfxrect.h>

class tst_animations : public QObject
{
    Q_OBJECT
public:
    tst_animations() {}

private slots:
    void badTypes();
    void badProperties();
    //void mixedTypes();
};

void tst_animations::badTypes()
{
    //don't crash
    {
        QFxView *view = new QFxView;
        view->setUrl(QUrl("file://" SRCDIR "/data/badtype1.qml"));

        view->execute();
        qApp->processEvents();

        delete view;
    }

    //make sure we get a compiler error
    {
        QmlEngine engine;
        QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/badtype2.qml"));
        QTest::ignoreMessage(QtWarningMsg, "QmlComponent: Component is not ready");
        c.create();

        QVERIFY(c.errors().count() == 1);
        QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: double expected"));
    }

    //make sure we get a compiler error
    {
        QmlEngine engine;
        QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/badtype3.qml"));
        QTest::ignoreMessage(QtWarningMsg, "QmlComponent: Component is not ready");
        c.create();

        QVERIFY(c.errors().count() == 1);
        QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: color expected"));
    }
}

void tst_animations::badProperties()
{
    //don't crash (should be runtime error)
    {
        QFxView *view = new QFxView;
        view->setUrl(QUrl("file://" SRCDIR "/data/badproperty1.qml"));

        view->execute();
        qApp->processEvents();

        delete view;
    }
}

/*//test animating mixed types with property animation
  //for example, int + real; color + real; etc
void tst_animations::mixedTypes()
{
    //### this one isn't real robust because width will likely change to real as well
    {
        QFxView *view = new QFxView;
        view->setUrl(QUrl("file://" SRCDIR "/data/mixedtype1.qml"));

        view->execute();
        qApp->processEvents();

        delete view;
    }

    {
        QFxView *view = new QFxView;
        view->setUrl(QUrl("file://" SRCDIR "/data/mixedtype2.qml"));

        view->execute();
        qApp->processEvents();

        delete view;
    }
}*/

QTEST_MAIN(tst_animations)

#include "tst_animations.moc"