Fix test fails related to QTBUG-22237
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / qquickflipable / tst_qquickflipable.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the test suite of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 #include <qtest.h>
42 #include <QtDeclarative/qdeclarativeengine.h>
43 #include <QtDeclarative/qdeclarativecomponent.h>
44 #include <QtDeclarative/qquickview.h>
45 #include <private/qquickflipable_p.h>
46 #include <private/qdeclarativevaluetype_p.h>
47 #include <QFontMetrics>
48 #include <private/qquickrectangle_p.h>
49 #include <math.h>
50 #include <QtOpenGL/QGLShaderProgram>
51 #include "../shared/util.h"
52
53 class tst_qquickflipable : public QObject
54 {
55     Q_OBJECT
56 public:
57     tst_qquickflipable();
58
59 private slots:
60     void initTestCase();
61     void cleanupTestCase();
62     void create();
63     void checkFrontAndBack();
64     void setFrontAndBack();
65
66     // below here task issues
67     void QTBUG_9161_crash();
68     void QTBUG_8474_qgv_abort();
69
70 private:
71     QDeclarativeEngine engine;
72 };
73
74 tst_qquickflipable::tst_qquickflipable()
75 {
76 }
77 void tst_qquickflipable::initTestCase()
78 {
79 }
80
81 void tst_qquickflipable::cleanupTestCase()
82 {
83
84 }
85
86 void tst_qquickflipable::create()
87 {
88     QDeclarativeEngine engine;
89     QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("test-flipable.qml")));
90     QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create());
91
92     QVERIFY(obj != 0);
93     delete obj;
94 }
95
96 void tst_qquickflipable::checkFrontAndBack()
97 {
98     QDeclarativeEngine engine;
99     QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("test-flipable.qml")));
100     QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create());
101
102     QVERIFY(obj != 0);
103     QVERIFY(obj->front() != 0);
104     QVERIFY(obj->back() != 0);
105     delete obj;
106 }
107
108 void tst_qquickflipable::setFrontAndBack()
109 {
110     QDeclarativeEngine engine;
111     QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("test-flipable.qml")));
112     QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create());
113
114     QVERIFY(obj != 0);
115     QVERIFY(obj->front() != 0);
116     QVERIFY(obj->back() != 0);
117
118     QString message = c.url().toString() + ":3:1: QML Flipable: front is a write-once property";
119     QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
120     obj->setFront(new QQuickRectangle());
121
122     message = c.url().toString() + ":3:1: QML Flipable: back is a write-once property";
123     QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
124     obj->setBack(new QQuickRectangle());
125     delete obj;
126 }
127
128 void tst_qquickflipable::QTBUG_9161_crash()
129 {
130     QQuickView *canvas = new QQuickView;
131     canvas->setSource(QUrl::fromLocalFile(TESTDATA("crash.qml")));
132     QQuickItem *root = canvas->rootObject();
133     QVERIFY(root != 0);
134     canvas->show();
135     delete canvas;
136 }
137
138 void tst_qquickflipable::QTBUG_8474_qgv_abort()
139 {
140     QQuickView *canvas = new QQuickView;
141     canvas->setSource(QUrl::fromLocalFile(TESTDATA("flipable-abort.qml")));
142     QQuickItem *root = canvas->rootObject();
143     QVERIFY(root != 0);
144     canvas->show();
145     delete canvas;
146 }
147
148 QTEST_MAIN(tst_qquickflipable)
149
150 #include "tst_qquickflipable.moc"