~tpeeters/ubuntu-ui-toolkit/10-tabsModelIndex

« back to all changes in this revision

Viewing changes to modules/Ubuntu/Test/plugin/uctestcase.cpp

  • Committer: tpeeters
  • Date: 2014-03-24 19:13:15 UTC
  • mfrom: (967.1.15 ubuntu-ui-toolkit)
  • Revision ID: tim.peeters@canonical.com-20140324191315-cgmt5x2h6v2xq1jh
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2013-2014 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
 * Author: Christian Dywan <christian.dywan@canonical.com>
 
17
 */
 
18
 
 
19
#include "uctestcase.h"
 
20
 
 
21
#include <stdlib.h>
 
22
 
 
23
#include <QtQml/QQmlEngine>
 
24
#include <QtCore/QDir>
 
25
#include <QtCore/QDebug>
 
26
#include <QtTest/QtTest>
 
27
#include <QtQuick/QQuickItem>
 
28
 
 
29
/*!
 
30
 * \ingroup ubuntu
 
31
 * \brief UbuntuTestCase is the C++ pendant to the QML UbuntuTestCase.
 
32
 */
 
33
UbuntuTestCase::UbuntuTestCase(const QString& file, QWindow* parent) : QQuickView(parent)
 
34
{
 
35
    QString modules("../../../modules");
 
36
    Q_ASSERT(QDir(modules).exists());
 
37
    QString modulePath(QDir(modules).absolutePath());
 
38
    engine()->addImportPath(modulePath);
 
39
 
 
40
    m_spy = new QSignalSpy(engine(), SIGNAL(warnings(QList<QQmlError>)));
 
41
    m_spy->setParent(this);
 
42
 
 
43
    Q_ASSERT(!file.isEmpty());
 
44
    setSource(QUrl::fromLocalFile(file));
 
45
    Q_ASSERT(status() == QQuickView::Ready);
 
46
    Q_ASSERT(rootObject());
 
47
    show();
 
48
    QTest::qWaitForWindowExposed(this);
 
49
}
 
50