2
* Copyright 2013-2014 Canonical Ltd.
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.
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.
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/>.
16
* Author: Christian Dywan <christian.dywan@canonical.com>
19
#include "uctestcase.h"
23
#include <QtQml/QQmlEngine>
24
#include <QtCore/QDir>
25
#include <QtCore/QDebug>
26
#include <QtTest/QtTest>
27
#include <QtQuick/QQuickItem>
31
* \brief UbuntuTestCase is the C++ pendant to the QML UbuntuTestCase.
33
UbuntuTestCase::UbuntuTestCase(const QString& file, QWindow* parent) : QQuickView(parent)
35
QString modules("../../../modules");
36
Q_ASSERT(QDir(modules).exists());
37
QString modulePath(QDir(modules).absolutePath());
38
engine()->addImportPath(modulePath);
40
m_spy = new QSignalSpy(engine(), SIGNAL(warnings(QList<QQmlError>)));
41
m_spy->setParent(this);
43
Q_ASSERT(!file.isEmpty());
44
setSource(QUrl::fromLocalFile(file));
45
Q_ASSERT(status() == QQuickView::Ready);
46
Q_ASSERT(rootObject());
48
QTest::qWaitForWindowExposed(this);