Debian Codegraph @

tests/unit/recreateview11/tst_recreateview.cpp

raw
1 /*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 #include <QtCore/QCoreApplication>
18 #include <QtQml/QQmlEngine>
19 #include <QtQuick/QQuickItem>
20 #include <QtQuick/QQuickView>
21 #include <QtTest/QtTest>
22
23 class RecreateViewTest : public QObject
24 {
25 Q_OBJECT
26
27 public:
28 RecreateViewTest() {}
29
30 private Q_SLOTS:
31 void initTestCase();
32 void testCase_recreateView();
33
34 private:
35 QString m_modulePath;
36 };
37
38 void RecreateViewTest::initTestCase()
39 {
40 QString modules(LOMIRI_QML_IMPORT_PATH);
41 QVERIFY(QDir(modules).exists());
42
43 m_modulePath = QDir(modules).absolutePath();
44 }
45
46 void RecreateViewTest::testCase_recreateView()
47 {
48 QQuickView *view = new QQuickView;
49 view->engine()->addImportPath(m_modulePath);
50
51 view->setSource(QUrl::fromLocalFile("SimpleApp.qml"));
52 QVERIFY(view->rootObject() != 0);
53 view->show();
54 QVERIFY(QTest::qWaitForWindowExposed(view));
55 delete view;
56
57 view = new QQuickView;
58 view->engine()->addImportPath(m_modulePath);
59
60 view->setSource(QUrl::fromLocalFile("SimpleApp.qml"));
61 QVERIFY(view->rootObject() != 0);
62 view->show();
63 QVERIFY(QTest::qWaitForWindowExposed(view));
64 delete view;
65 }
66
67 QTEST_MAIN(RecreateViewTest)
68
69 #include "tst_recreateview.moc"