./ 0000755 0000156 0000165 00000000000 12700370716 011100 5 ustar jenkins jenkins ./scripts/ 0000755 0000156 0000165 00000000000 12700370701 012561 5 ustar jenkins jenkins ./scripts/pre-execution.sh 0000755 0000156 0000165 00000001226 12700370701 015710 0 ustar jenkins jenkins #!/bin/bash
#
# Copyright 2012 Canonical Ltd.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see .
#
cd $1
qmake
make
./ubuntu-sdk.pro 0000644 0000156 0000165 00000002000 12700370701 013705 0 ustar jenkins jenkins #include( documentation/documentation.pri )
BUILD_PATH_CONTENTS="SRC_DIR=\"$$PWD\"" \
"BUILD_DIR=\"$$OUT_PWD\""
write_file($$PWD/build_paths.inc,BUILD_PATH_CONTENTS)
requires(qtHaveModule(quick))
load(qt_parts)
SUBDIRS += po documentation app-launch-profiler ubuntu-ui-toolkit-launcher apicheck
sub_tests.CONFIG -= no_default_target
sub_tests.CONFIG -= no_default_install
# additional 'make test' target required by continuous integration system
test.target = test
test.commands = make check
test.depends = license sub_src
QMAKE_EXTRA_TARGETS += test
license.target = license
license.commands = cd $$PWD; $$PWD/tests/license/checklicense.sh
QMAKE_EXTRA_TARGETS += license
check.target = check
check.commands = $$PWD/tests/checkresults.sh $$OUT_PWD/tests/test_tst_*.xml
#helper files
OTHER_FILES += \
features/ubuntu_qml_module.prf \
features/ubuntu_qml_plugin.prf \
features/ubuntu_qt_module.prf \
features/ubuntu_enable_testing.prf \
features/coverage.prf \
.qmake.conf
./gallery.sh 0000755 0000156 0000165 00000001376 12700370701 013077 0 ustar jenkins jenkins #!/bin/bash
#
# Copyright 2012 Canonical Ltd.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see .
#
if [ "$1" == "--autopilot" ]
then
tests/Gallery/gallery -testability &
autopilot vis
else
tests/Gallery/gallery $@
fi
./mkspecs/ 0000755 0000156 0000165 00000000000 12700370700 012536 5 ustar jenkins jenkins ./export_qml_dir.sh 0000755 0000156 0000165 00000002675 12700370714 014477 0 ustar jenkins jenkins #!/bin/sh
#
# Copyright 2012 - 2016 Canonical Ltd.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see .
#
# Get the current script directory (compatible with Bash and ZSH)
SCRIPT_DIR=`dirname ${BASH_SOURCE[0]-$0}`
SCRIPT_DIR=`cd $SCRIPT_DIR && pwd`
source "$SCRIPT_DIR/build_paths.inc" || return 1
export QML_IMPORT_PATH=$BUILD_DIR/qml
export QML2_IMPORT_PATH=$BUILD_DIR/qml
export UBUNTU_UI_TOOLKIT_THEMES_PATH=$BUILD_DIR/qml
UBUNTU_QML_ROOT=$BUILD_DIR/qml/Ubuntu
UBUNTU_QML_DIRS=$UBUNTU_QML_ROOT/Components:$UBUNTU_QML_ROOT/Test:$UBUNTU_QML_ROOT/Layouts:$UBUNTU_QML_ROOT/PerformanceMetrics
export LD_LIBRARY_PATH=$BUILD_DIR/lib:$UBUNTU_QML_DIRS$LD_LIBRARY_PATH
/sbin/initctl set-env --global QML_IMPORT_PATH=$BUILD_DIR/qml
/sbin/initctl set-env --global QML2_IMPORT_PATH=$BUILD_DIR/qml
/sbin/initctl set-env --global UBUNTU_UI_TOOLKIT_THEMES_PATH=$BUILD_DIR/qml
/sbin/initctl set-env --global LD_LIBRARY_PATH=$BUILD_DIR/lib
./sync.profile 0000644 0000156 0000165 00000002110 12700370701 013422 0 ustar jenkins jenkins %modules = ( # path to module name map
"UbuntuGestures" => "$basedir/src/Ubuntu/UbuntuGestures",
"UbuntuToolkit" => "$basedir/src/Ubuntu/UbuntuToolkit",
);
%moduleheaders = ( # restrict the module headers to those found in relative path
);
%classnames = (
#add classnames that are not automatically detected
#e.g. "someheader.h" => "SomeType"
"debughelpers.h" => "DebugHelpers",
"pool.h" => "Pool",
"touchregistry.h" => "TouchRegistry",
"touchownershipevent.h" => "TouchOwnershipEvent",
"unownedtouchevent.h" => "UnownedTouchEvent"
);
# Module dependencies.
# Every module that is required to build this module should have one entry.
# Each of the module version specifiers can take one of the following values:
# - A specific Git revision.
# - any git symbolic ref resolvable from the module's repository (e.g. "refs/heads/master" to track master branch)
#
%dependencies = (
"qtbase" => "",
"qtdeclarative" => "",
"qtfeedback" => "",
"qtpim" => "",
);
#export all classes that are in a Ubuntu* namespace
$publicclassregexp = "^Ubuntu[A-Za-z0-9]*::[^:]*\$"
./tests/ 0000755 0000156 0000165 00000000000 12700370716 012242 5 ustar jenkins jenkins ./tests/api/ 0000755 0000156 0000165 00000000000 12700370701 013005 5 ustar jenkins jenkins ./tests/api/Extinct/ 0000755 0000156 0000165 00000000000 12700370701 014423 5 ustar jenkins jenkins ./tests/api/Extinct/Extinct.pro 0000644 0000156 0000165 00000000046 12700370701 016563 0 ustar jenkins jenkins TEMPLATE = subdirs
SUBDIRS = Animals
./tests/api/Extinct/Animals/ 0000755 0000156 0000165 00000000000 12700370701 016007 5 ustar jenkins jenkins ./tests/api/Extinct/Animals/Paratriisodon.qml 0000644 0000156 0000165 00000001614 12700370701 021342 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Author: Christian Dywan
*/
import QtQuick 2.0
Item {
id: body
/*!
\qmlproperty real skullSize
*/
property real skullSize
/*!
\qmlproperty real saggitalCrestSize
*/
property real saggitalCrestSize
}
./tests/api/Extinct/Animals/AnimalModule.pro 0000644 0000156 0000165 00000000406 12700370701 021100 0 ustar jenkins jenkins CXX_MODULE = qml
TARGET = ExtinctAnimals
TARGETPATH = Extinct/Animals
IMPORT_VERSION = 0.1
include(plugin/plugin.pri)
QML_FILES += \
Andrewsarchus.qml \
Paratriisodon.qml \
Gigantophis.qml \
test.qml \
digger.js \
load(ubuntu_qml_plugin)
./tests/api/Extinct/Animals/digger.js 0000644 0000156 0000165 00000001375 12700370701 017614 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
/*!
Return true if the object is a Flickable that can be flicked in vertical direction.
*/
function makeHole(){
}
./tests/api/Extinct/Animals/plugin/ 0000755 0000156 0000165 00000000000 12700370701 017305 5 ustar jenkins jenkins ./tests/api/Extinct/Animals/plugin/rune.cpp 0000644 0000156 0000165 00000003171 12700370701 020764 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Christian Dywan
*/
#include
#include "rune.h"
QHash > UCQQuickImageExtension::s_rewrittenSciFiles;
/*!
\internal
The UCQQuickImageExtension class makes sure that for images loaded via
QQuickImageBase the right version is loaded and that they are scaled
appropriately. It does so by overriding the QQuickImageBase's
'source' property.
*/
UCQQuickImageExtension::UCQQuickImageExtension(QObject *parent) :
QObject(parent),
m_image(static_cast(parent))
{
// connect sourceChanged signal to extendedSourceChanged
QObject::connect(m_image, &QQuickImageBase::sourceChanged,
this, &UCQQuickImageExtension::extendedSourceChanged);
}
QUrl UCQQuickImageExtension::source() const
{
return m_source;
}
void UCQQuickImageExtension::setSource(const QUrl& url)
{
if (url != m_source) {
m_source = url;
}
}
./tests/api/Extinct/Animals/plugin/rune.h 0000644 0000156 0000165 00000002666 12700370701 020441 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Christian Dywan
*/
#ifndef EA_RUNE_H
#define EA_RUNE_H
#include
#include
#include
#include
class QQuickImageBase;
class UCQQuickImageExtension : public QObject
{
Q_OBJECT
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY extendedSourceChanged)
Q_PROPERTY(QUrl fountain READ source WRITE setSource NOTIFY extendedSourceChanged)
public:
explicit UCQQuickImageExtension(QObject *parent = 0);
QUrl source() const;
virtual void setSource(const QUrl& url);
Q_SIGNALS:
void extendedSourceChanged();
private:
QQuickImageBase* m_image;
QUrl m_source;
static QHash > s_rewrittenSciFiles;
};
#endif // EA_RUNE_H
./tests/api/Extinct/Animals/plugin/plugin.h 0000644 0000156 0000165 00000002062 12700370701 020754 0 ustar jenkins jenkins /*
* Copyright 2014 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef EXTINCT_ANIMALS_PLUGIN_H
#define EXTINCT_ANIMALS_PLUGIN_H
#include
#include
class ExtinctAnimalsPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
public:
void registerTypes(const char *uri);
void initializeEngine(QQmlEngine *engine, const char *uri);
};
#endif // EXTINCT_ANIMALS_PLUGIN_H
./tests/api/Extinct/Animals/plugin/plugin.qrc 0000644 0000156 0000165 00000000207 12700370701 021311 0 ustar jenkins jenkins
../Paratriisodon.qml
../digger.js
./tests/api/Extinct/Animals/plugin/smilodon.cpp 0000644 0000156 0000165 00000002700 12700370701 021634 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Christian Dywan
*/
#include "smilodon.h"
/*!
* \qmltype Smilodon
* \instantiates EASmilodon
* \inqmlmodule Extinct.Animals 1.0
* \ingroup ubuntu-commandline
* \brief The Smilodon class specifies the behavior of an extinct big cat.
*
* \sa Andrewsarchus
*/
EASmilodon::EASmilodon(QObject *parent) :
QObject(parent)
{
}
/*!
* \qmlproperty string Smilodon::name
*
* Name identifying the smilodon.
*
*/
QString EASmilodon::name() const
{
return m_name;
}
void EASmilodon::setName(const QString &name)
{
m_name = name;
Q_EMIT(nameChanged());
}
/*!
* \qmlmethod string Smilodon::paw(int i)
*
* Returns the \e{i}th paw of the smilodon.
* Values are counted from 0.
*
*/
QString EASmilodon::paw(int i) const
{
return QString("Paw #%1").arg(i);
}
./tests/api/Extinct/Animals/plugin/pangaea.cpp 0000644 0000156 0000165 00000003402 12700370701 021404 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Christian Dywan
*/
#include "pangaea.h"
/*!
* \qmltype Ubuntu
* \instantiates EAPangaea
* \inqmlmodule Extinct.Animals 1.2
* \ingroup ubuntu
* \since Extinct.Animals 1.2
* \brief Provides global object with different enums.
*
* \section2 Enums
*
* \section4 ModernContinent enum
* The enumeration identifies the modern concept of a continent.
* \table
* \header
* \li Enum
* \li Description
* \row
* \li America
* \li Originally part of Laurasia, Laurentia split from Eurasia, now known as America.
* \row
* \li Europe
* \li The second smallest continent today, part of Eurasia.
* \endtable
*/
EAPangaea::EAPangaea(QObject *parent)
: QObject(parent)
{
}
/*!
* \qmlproperty uint16 Extinct::toolkitVersion
* \since Extinct.Animals 4.0
* \readonly
* The property holds the tectonic formation of the current continent.
*/
/*!
* \qmlmethod uint16 Extinct::era(int year)
* \since Extinct.Animals 4.0
* The function builds a tectonic identifier using the year.
*/
quint16 EAPangaea4::era(quint8 year)
{
Q_UNUSED(year);
return 0;
}
./tests/api/Extinct/Animals/plugin/smilodon.h 0000644 0000156 0000165 00000002277 12700370701 021312 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Christian Dywan
*/
#ifndef UCARGUMENT_H
#define UCARGUMENT_H
#include
#include
#include
class EASmilodon : public QObject
{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
public:
explicit EASmilodon(QObject *parent = 0);
QString name() const;
void setName(const QString &name);
Q_INVOKABLE QString paw(int i) const;
Q_SIGNALS:
void nameChanged();
private:
QString m_name;
};
#endif // UCARGUMENT_H
./tests/api/Extinct/Animals/plugin/plugin.cpp 0000644 0000156 0000165 00000005010 12700370701 021303 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Christian Dywan
*/
#include "plugin.h"
#include "tarpan.h"
#include "smilodon.h"
#include "pangaea.h"
#include "rune.h"
#include "europe.h"
#include
static QObject *registerPangaea(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
return new EAPangaea();
}
static QObject *registerPangaea4(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
return new EAPangaea4();
}
void ExtinctAnimalsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
{
Q_UNUSED(uri);
Q_UNUSED(engine);
}
void ExtinctAnimalsPlugin::registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("Extinct.Animals"));
qmlRegisterType();
qmlRegisterType(uri, 1, 0, "Smilodon");
qmlRegisterType(uri, 0, 1, "ScimitarCat");
qmlRegisterType(QUrl(baseUrl().toString() + "/Andrewsarchus.qml"), uri, 0, 1, "Andrewsarchus");
// The second call overrrides the previous one, only the last version will show up
qmlRegisterType(QUrl(baseUrl().toString() + "/Paratriisodon.qml"), uri, 2, 0, "Andrewsarchus");
qmlRegisterType(QUrl("qrc:///ea/Paratriisodon.qml"), uri, 2, 3, "AndrewsarchusMongoliensis");
// The second call overrrides the previous one, only the last version will show up
qmlRegisterType(QUrl("qrc:///ea/Paratriisodon.qml"), uri, 2, 4, "AndrewsarchusMongoliensis");
qmlRegisterSingletonType(uri, 1, 0, "Pangaea", registerPangaea);
qmlRegisterSingletonType(uri, 4, 0, "Pangaea", registerPangaea4);
qmlRegisterUncreatableType(uri, 4, 1, "Europe", "");
qmlRegisterUncreatableType(uri, 4, 2, "Europe", "");
qmlRegisterExtendedType(uri, 3, 3, "QQuickImageBase");
}
./tests/api/Extinct/Animals/plugin/europe.cpp 0000644 0000156 0000165 00000003363 12700370701 021315 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Christian Dywan
*/
#include "europe.h"
/*!
* \qmltype Ubuntu
* \instantiates EAEurope
* \inqmlmodule Extinct.Animals 1.2
* \ingroup ubuntu
* \since Extinct.Animals 1.2
* \brief Provides global object with different enums.
*
* \section2 Enums
*
* \section4 ModernContinent enum
* The enumeration identifies the modern concept of a continent.
* \table
* \header
* \li Enum
* \li Description
* \row
* \li America
* \li Originally part of Laurasia, Laurentia split from Eurasia, now known as America.
* \row
* \li Europe
* \li The second smallest continent today, part of Eurasia.
* \endtable
*/
EAEurope::EAEurope(QObject *parent)
: QObject(parent)
{
}
/*!
* \qmlproperty uint16 Extinct::era
* \since Extinct.Animals 4.2
* \readonly
* The property holds the tectonic formation of the current continent.
*/
/*!
* \qmlmethod uint16 Extinct::era(int year)
* \since Extinct.Animals 4.2
* The function builds a tectonic identifier using the year.
*/
quint16 EAEurope42::era(quint8 year)
{
Q_UNUSED(year);
return 0;
}
./tests/api/Extinct/Animals/plugin/tarpan.h 0000644 0000156 0000165 00000002217 12700370701 020745 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Christian Dywan
*/
#ifndef UCTARPAN_H
#define UCTARPAN_H
#include
#include
class EATarpan : public QObject
{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
public:
explicit EATarpan(QObject *parent = 0);
QString name() const;
void setName(const QString &name);
Q_INVOKABLE void kick() const;
Q_SIGNALS:
void nameChanged();
private:
QString m_name;
};
#endif // UCTARPAN_H
./tests/api/Extinct/Animals/plugin/tarpan.cpp 0000644 0000156 0000165 00000002535 12700370701 021303 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Christian Dywan
*/
#include "tarpan.h"
/*!
* \qmltype EATarpan
* \instantiates EATarpan
* \inqmlmodule Extinct.Animals 1.0
* \ingroup ubuntu-commandline
* \brief The Tarpan class specifies the behavior of a Eurasian wild horse.
*/
EATarpan::EATarpan(QObject *parent) :
QObject(parent)
{
}
/*!
* \qmlproperty string EATarpan::name
*
* Name identifying the wild horse.
*
*/
QString EATarpan::name() const
{
return m_name;
}
void EATarpan::setName(const QString &name)
{
m_name = name;
Q_EMIT(nameChanged());
}
/*!
* \qmlmethod string EATarpan::kick()
*
* A generous kick, commonly towards someone's groin area.
*
*/
void EATarpan::kick() const
{
}
./tests/api/Extinct/Animals/plugin/europe.h 0000644 0000156 0000165 00000002657 12700370701 020767 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Christian Dywan
*/
#ifndef EA_EUROPE_H
#define EA_EUROPE_H
#include
class EAEurope : public QObject
{
Q_OBJECT
Q_ENUMS(ModernContinent)
public:
static EAEurope& instance() {
static EAEurope instance;
return instance;
}
enum ModernContinent {
America,
Europe,
};
explicit EAEurope(QObject *parent = 0);
};
class EAEurope42 : public EAEurope
{
Q_OBJECT
Q_PROPERTY(quint16 era READ era NOTIFY eraChanged REVISION 1)
public:
explicit EAEurope42(QObject *parent = 0) : EAEurope(parent)
{
}
Q_INVOKABLE quint16 era(quint8 year);
Q_SIGNALS:
void eraChanged();
protected:
virtual quint16 era() const
{
return 0;
}
};
#endif // EA_EUROPE_H
./tests/api/Extinct/Animals/plugin/plugin.pri 0000644 0000156 0000165 00000001231 12700370701 021314 0 ustar jenkins jenkins QT *= core-private qml qml-private quick quick-private gui-private
equals(QT_MAJOR_VERSION, 5):lessThan(QT_MINOR_VERSION, 2) {
QT *= v8-private
}
CONFIG += no_keywords
DEFINES += UBUNTU_QML_IMPORT_PATH='\\"$${ROOT_BUILD_DIR}/qml\\"'
DEFINES += QT_USE_QSTRINGBUILDER
TARGET = $$qtLibraryTarget($$TARGET)
uri = Extinct.Animals
HEADERS += \
$$PWD/plugin.h \
$$PWD/tarpan.h \
$$PWD/smilodon.h \
$$PWD/pangaea.h \
$$PWD/rune.h \
$$PWD/europe.h \
SOURCES += \
$$PWD/plugin.cpp \
$$PWD/tarpan.cpp \
$$PWD/smilodon.cpp \
$$PWD/pangaea.cpp \
$$PWD/rune.cpp \
$$PWD/europe.cpp \
RESOURCES += \
$$PWD/plugin.qrc
./tests/api/Extinct/Animals/plugin/pangaea.h 0000644 0000156 0000165 00000002670 12700370701 021057 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Christian Dywan
*/
#ifndef EA_PANGAEA_H
#define EA_PANGAEA_H
#include
class EAPangaea : public QObject
{
Q_OBJECT
Q_ENUMS(ModernContinent)
public:
static EAPangaea& instance() {
static EAPangaea instance;
return instance;
}
enum ModernContinent {
America,
Europe,
};
explicit EAPangaea(QObject *parent = 0);
};
class EAPangaea4 : public EAPangaea
{
Q_OBJECT
Q_PROPERTY(quint16 era READ era NOTIFY eraChanged REVISION 1)
public:
explicit EAPangaea4(QObject *parent = 0) : EAPangaea(parent)
{
}
Q_INVOKABLE quint16 era(quint8 year);
Q_SIGNALS:
void eraChanged();
protected:
virtual quint16 era() const
{
return 0;
}
};
#endif // EA_PANGAEA_H
./tests/api/Extinct/Animals/Gigantophis.qml 0000644 0000156 0000165 00000001564 12700370701 021004 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Extinct.Animals 4.2
Titanoboa {
// Overridden
property string eggs: "brown spotted"
function first() {
console.log('Hihi!')
}
// New API
property bool extinct: true
function fourth() { }
}
./tests/api/Extinct/Animals/Andrewsarchus.qml 0000644 0000156 0000165 00000001357 12700370701 021341 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
Item {
id: body
/*!
\qmlproperty real skullSize
*/
property real skullSize
}
./tests/api/Extinct/Animals/Animals.pro 0000644 0000156 0000165 00000000060 12700370701 020111 0 ustar jenkins jenkins TEMPLATE = subdirs
SUBDIRS += AnimalModule.pro
./tests/api/Extinct/Animals/test.qml 0000644 0000156 0000165 00000003203 12700370701 017477 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
Item {
id: foo
property string spam
/*!
\qmlproperty string eggs
*/
property string eggs: "white"
/*!
\qmlproperty string bar
\since Extinct.Animals 1.1
*/
property alias bar: foo.eggs
/*!
\internal
*/
property var basket: ['brown', 'white']
property list- buckets
states: [
State {
name: ""
}
]
signal jump()
/*!
\since 2.2
*/
signal bounce(int length)
/*!
\qmlproperty url bazz
*/
property url bazz:"http://example.com"
/*!
\qmlmethod void fly(Wing wing)
*/
signal fly(var wing)
function first() {
console.log('Haha!')
}
/*!
\since 3.3
*/
function second(sliff) {
}
function third(sloff) { }
// Member name may overlap with internal name in apicheck
property var type
property var version
Item {
id: one
function two() {
}
function three() { }
}
}
./tests/api/Extinct/Animals/qmldir 0000644 0000156 0000165 00000000425 12700370701 017223 0 ustar jenkins jenkins module Extinct.Animals
plugin ExtinctAnimals
Titanoboa 4.2 test.qml
Gigantophis 4.3 Gigantophis.qml
internal WoollyMammoth mammoth.qml
MonsterSnake 3.1 test.qml
Excavator 1.0 digger.js
Excavator 1.1 qrc:///ea/digger.js
AndrewsarchusMongoliensis 2.5 qrc:///ea/Paratriisodon.qml
./tests/api/api.pro 0000644 0000156 0000165 00000000152 12700370701 014276 0 ustar jenkins jenkins TEMPLATE = subdirs
SUBDIRS = Extinct
OTHER_FILES += test.sh
check.commands += $$PWD/test.sh || exit 1;
./tests/api/test.sh 0000755 0000156 0000165 00000002362 12700370701 014326 0 ustar jenkins jenkins #!/usr/bin/env sh
#
# Copyright 2015 Canonical Ltd.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see .
#
################################################################################
. `dirname $0`/../../build_paths.inc
if [ ! -e $BUILD_DIR/apicheck/apicheck ]; then
echo API check tool not built!
exit 1
elif [ ! -e $BUILD_DIR/qml/Extinct/Animals/libExtinctAnimals.so ]; then
echo You need to build Extinct.Animals before you can dump QML API!
exit 1
fi
echo Self-testing API dump
env QML2_IMPORT_PATH=$BUILD_DIR/qml \
$BUILD_DIR/apicheck/apicheck --qml Extinct.Animals | \
diff -F '[.0-9]' -u $SRC_DIR/tests/api/components.api -
test $? != 0 && echo Error: Mismatch && exit 1
echo All fine.
./tests/api/components.api 0000644 0000156 0000165 00000002677 12700370701 015701 0 ustar jenkins jenkins Extinct.Animals.Andrewsarchus 2.0 Paratriisodon: Item
property double saggitalCrestSize
property double skullSize
Extinct.Animals.AndrewsarchusMongoliensis 2.5 Paratriisodon: Item
property double saggitalCrestSize
property double skullSize
EATarpan: QtObject
function kick()
property string name
Extinct.Animals.Europe 4.1: QtObject
Extinct.Animals.Europe 4.2: Europe
readonly property ushort era 4.2
function ushort era(uchar year)
Extinct.Animals.Europe.ModernContinent: Enum
America
Europe
Extinct.Animals.Excavator 1.0 1.1
Extinct.Animals.Gigantophis 4.3: QQuickItem
property bool extinct
function var first()
function var fourth()
Extinct.Animals.Pangaea 1.0: QtObject singleton
Extinct.Animals.Pangaea 4.0: Pangaea singleton
readonly property ushort era 4.0
function ushort era(uchar year)
Extinct.Animals.Pangaea.ModernContinent: Enum
America
Europe
Extinct.Animals.Smilodon 1.0 ScimitarCat 0.1 EASmilodon: QtObject
function string paw(int i)
property string name
Extinct.Animals.Titanoboa 4.2 MonsterSnake 3.1 test: Item
property string bar
property var basket
property url bazz
property list
- buckets
property string eggs
signal jump()
signal bounce(int length)
signal fly(var wing)
function var first()
function var second(var sliff)
function var third(var sloff)
property string spam
property var type
property var version
./tests/tests.pro 0000644 0000156 0000165 00000000604 12700370714 014124 0 ustar jenkins jenkins TEMPLATE = subdirs
SUBDIRS += unit unit_x11 autopilot
autopilot_module.path = $$[QT_INSTALL_PREFIX]/lib/python3/dist-packages/ubuntuuitoolkit
autopilot_module.files = autopilot/ubuntuuitoolkit/*
SUBDIRS += Gallery api
INSTALLS += autopilot_module
OTHER_FILES += qmlapicheck.sh
check.commands += $$PWD/packaging-sorting.sh || exit 1;
check.commands += $$PWD/qmlapicheck.sh || exit 1;
./tests/unit_x11/ 0000755 0000156 0000165 00000000000 12700370716 013712 5 ustar jenkins jenkins ./tests/unit_x11/test-include.pri 0000644 0000156 0000165 00000000253 12700370701 017020 0 ustar jenkins jenkins include( ../unit/plugin_dependency.pri )
include( layout_dependency.pri )
include( add_makecheck.pri )
TEMPLATE = app
QT += testlib qml quick
CONFIG += no_keywords c++11
./tests/unit_x11/tst_asyncloader/ 0000755 0000156 0000165 00000000000 12700370716 017110 5 ustar jenkins jenkins ./tests/unit_x11/tst_asyncloader/Document.qml 0000644 0000156 0000165 00000001525 12700370714 021402 0 ustar jenkins jenkins /*
* Copyright 2016 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
Column {
anchors.fill: parent
spacing: 1
Repeater {
model: 200
TextField {
width: parent.width
}
}
}
./tests/unit_x11/tst_asyncloader/FaultyDocument.qml 0000644 0000156 0000165 00000001247 12700370714 022570 0 ustar jenkins jenkins /*
* Copyright 2016 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
*/
import QtQuick 2.4
Label {}
./tests/unit_x11/tst_asyncloader/tst_asyncloader.cpp 0000644 0000156 0000165 00000024662 12700370714 023022 0 ustar jenkins jenkins /*
* Copyright 2016 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
*/
#include
#include "uctestcase.h"
#include "uctestextras.h"
#include
#include
#include
class LoaderSpy : public QObject
{
Q_OBJECT
public:
UbuntuToolkit::AsyncLoader *m_loader;
QScopedPointer m_object;
bool m_done = false;
bool m_error = false;
QList m_statusList;
public:
LoaderSpy(UbuntuToolkit::AsyncLoader *loader)
: QObject(0)
, m_loader(loader)
{
connect(loader, &UbuntuToolkit::AsyncLoader::loadingStatus,
this, &LoaderSpy::onLoadingStatusChanged);
}
protected Q_SLOTS:
virtual void onLoadingStatusChanged(UbuntuToolkit::AsyncLoader::LoadingStatus status, QObject *object)
{
m_statusList << status;
if (status == UbuntuToolkit::AsyncLoader::Ready) {
m_done = true;
m_object.reset(object);
}
if (status == UbuntuToolkit::AsyncLoader::Error) {
m_error = true;
}
}
};
class ResetLoaderSpy : public LoaderSpy
{
Q_OBJECT
public:
bool m_reset = false;
public:
ResetLoaderSpy(UbuntuToolkit::AsyncLoader *loader)
: LoaderSpy(loader)
{
}
void onLoadingStatusChanged(UbuntuToolkit::AsyncLoader::LoadingStatus status, QObject *object) override
{
if (status == UbuntuToolkit::AsyncLoader::Loading) {
m_loader->reset();
m_reset = true;
}
LoaderSpy::onLoadingStatusChanged(status, object);
}
};
class SecondLoaderSpy : public LoaderSpy
{
Q_OBJECT
public:
bool m_loadResult = false;
public:
SecondLoaderSpy(UbuntuToolkit::AsyncLoader *loader, UbuntuToolkit::AsyncLoader::LoadingStatus loadAt,
const QUrl &url, QQmlContext *context)
: LoaderSpy(loader)
, m_loadAt(loadAt)
, m_url(url)
, m_context(context)
{
}
void onLoadingStatusChanged(UbuntuToolkit::AsyncLoader::LoadingStatus status, QObject *object) override
{
if (status == (UbuntuToolkit::AsyncLoader::LoadingStatus)m_loadAt) {
m_loadAt = -1;
delete object;
object = nullptr;
m_loadResult = m_loader->load(m_url, m_context);
}
LoaderSpy::onLoadingStatusChanged(status, object);
}
private:
int m_loadAt;
QUrl m_url;
QQmlContext *m_context;
};
/********************************************************************
* Test
********************************************************************/
class tst_AsyncLoader : public QObject
{
Q_OBJECT
private Q_SLOTS:
void test_load_data()
{
QTest::addColumn("loadAsDocument");
QTest::addColumn("document");
QTest::addColumn("mode");
QTest::addColumn< QList >("statuses");
QTest::newRow("document") << true << "Document.qml" << (int)QQmlComponent::Asynchronous
<< (QList()
<< UbuntuToolkit::AsyncLoader::Compiling
<< UbuntuToolkit::AsyncLoader::Loading
<< UbuntuToolkit::AsyncLoader::Initializing
<< UbuntuToolkit::AsyncLoader::Ready
);
QTest::newRow("component, asynchronous") << false << "Document.qml" << (int)QQmlComponent::Asynchronous
<< (QList()
<< UbuntuToolkit::AsyncLoader::Compiling
<< UbuntuToolkit::AsyncLoader::Loading
<< UbuntuToolkit::AsyncLoader::Initializing
<< UbuntuToolkit::AsyncLoader::Ready
);
QTest::newRow("component, synchronous") << false << "Document.qml" << (int)QQmlComponent::PreferSynchronous
<< (QList()
<< UbuntuToolkit::AsyncLoader::Loading
<< UbuntuToolkit::AsyncLoader::Initializing
<< UbuntuToolkit::AsyncLoader::Ready
);
}
void test_load()
{
QFETCH(bool, loadAsDocument);
QFETCH(QString, document);
QFETCH(int, mode);
QFETCH(QList, statuses);
QScopedPointer view(new UbuntuTestCase("TestApp.qml"));
UbuntuToolkit::AsyncLoader loader;
LoaderSpy spy(&loader);
QScopedPointer component;
if (loadAsDocument) {
loader.load(QUrl::fromLocalFile(document), view->rootContext());
} else {
// create a component
component.reset(new QQmlComponent(view->engine(), QUrl::fromLocalFile(document), (QQmlComponent::CompilationMode)mode));
loader.load(component.data(), view->rootContext());
}
QTRY_VERIFY(spy.m_object != nullptr);
// check the statuses
QCOMPARE(spy.m_statusList.length(), statuses.length());
for (int i = 0; i < spy.m_statusList.length(); i++) {
QVERIFY2((int)spy.m_statusList[i] == statuses[i], (QString(" Status at index %1 differs").arg(i)).toLocal8Bit().constData());
}
}
void test_load_with_error()
{
QUrl document = QUrl::fromLocalFile("FaultyDocument.qml");
UbuntuTestCase::ignoreWarning("FaultyDocument.qml", 20, "Label is not a type");
QScopedPointer view(new UbuntuTestCase("TestApp.qml"));
UbuntuToolkit::AsyncLoader loader;
LoaderSpy spy(&loader);
loader.load(document, view->rootContext());
QTRY_VERIFY(spy.m_error == true);
}
void test_load_no_context()
{
UbuntuToolkit::AsyncLoader loader;
QVERIFY(!loader.load(nullptr, nullptr));
QVERIFY(!loader.load(QUrl(), nullptr));
}
void test_load_invalid_url()
{
QQmlEngine engine;
UbuntuToolkit::AsyncLoader loader;
LoaderSpy spy(&loader);
QVERIFY(!loader.load(QUrl(), engine.rootContext()));
}
void test_load_null_component()
{
QQmlEngine engine;
UbuntuToolkit::AsyncLoader loader;
LoaderSpy spy(&loader);
QVERIFY(!loader.load(nullptr, engine.rootContext()));
}
void test_load_and_cancel_data()
{
QTest::addColumn("loadAsDocument");
QTest::addColumn("document");
QTest::addColumn("mode");
QTest::newRow("document") << true << "HeavyDocument.qml" << (int)QQmlComponent::Asynchronous;
QTest::newRow("component, asynchronous") << false << "HeavyDocument.qml" << (int)QQmlComponent::Asynchronous;
QTest::newRow("component, synchronous") << false << "HeavyDocument.qml" << (int)QQmlComponent::PreferSynchronous;
}
void test_load_and_cancel()
{
QFETCH(bool, loadAsDocument);
QFETCH(QString, document);
QFETCH(int, mode);
QScopedPointer view(new UbuntuTestCase("TestApp.qml"));
UbuntuToolkit::AsyncLoader loader;
ResetLoaderSpy spy(&loader);
QScopedPointer component;
if (loadAsDocument) {
loader.load(QUrl::fromLocalFile(document), view->rootContext());
} else {
// create a component
component.reset(new QQmlComponent(view->engine(), QUrl::fromLocalFile(document), (QQmlComponent::CompilationMode)mode));
loader.load(component.data(), view->rootContext());
}
if (loader.status() < UbuntuToolkit::AsyncLoader::Loading) {
// cannot reset yet!
QVERIFY(!loader.reset());
}
QTRY_VERIFY(spy.m_reset);
}
void test_second_load_scenarios_data()
{
QTest::addColumn ("doc1");
QTest::addColumn ("doc2");
QTest::addColumn ("when");
QTest::addColumn ("success");
QTest::newRow("status = Compiling")
<< "Document.qml" << "HeavyDocument.qml"
<< (int)UbuntuToolkit::AsyncLoader::Compiling << false;
QTest::newRow("status = Loading")
<< "Document.qml" << "HeavyDocument.qml"
<< (int)UbuntuToolkit::AsyncLoader::Loading << true;
QTest::newRow("status = Initializing")
<< "Document.qml" << "HeavyDocument.qml"
<< (int)UbuntuToolkit::AsyncLoader::Initializing << true;
QTest::newRow("status = Ready")
<< "Document.qml" << "HeavyDocument.qml"
<< (int)UbuntuToolkit::AsyncLoader::Ready << true;
QTest::newRow("status = Error")
<< "FaultyDocument.qml" << "HeavyDocument.qml"
<< (int)UbuntuToolkit::AsyncLoader::Error << true;
}
void test_second_load_scenarios()
{
QFETCH(QString, doc1);
QFETCH(QString, doc2);
QFETCH(int, when);
QFETCH(bool, success);
QScopedPointer view(new UbuntuTestCase("TestApp.qml"));
UbuntuToolkit::AsyncLoader loader;
if (when == (int)UbuntuToolkit::AsyncLoader::Error) {
UbuntuTestCase::ignoreWarning("FaultyDocument.qml", 20, "Label is not a type");
}
SecondLoaderSpy spy(&loader, (UbuntuToolkit::AsyncLoader::LoadingStatus)when, QUrl::fromLocalFile(doc2), view->rootContext());
// load the first document
QVERIFY(loader.load(QUrl::fromLocalFile(doc1), view->rootContext()));
QTRY_VERIFY(spy.m_object != nullptr);
QCOMPARE(spy.m_loadResult, success);
}
};
QTEST_MAIN(tst_AsyncLoader)
#include "tst_asyncloader.moc"
./tests/unit_x11/tst_asyncloader/TestApp.qml 0000644 0000156 0000165 00000001250 12700370714 021177 0 ustar jenkins jenkins /*
* Copyright 2016 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
*/
import QtQuick 2.4
Item {
}
./tests/unit_x11/tst_asyncloader/HeavyDocument.qml 0000644 0000156 0000165 00000001537 12700370714 022402 0 ustar jenkins jenkins /*
* Copyright 2016 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
Column {
anchors.fill: parent
spacing: units.dp(1)
Repeater {
model: 200
TextField {
width: parent.width
}
}
}
./tests/unit_x11/tst_asyncloader/tst_asyncloader.pro 0000644 0000156 0000165 00000000356 12700370714 023032 0 ustar jenkins jenkins include(../test-include.pri)
QT += core-private qml-private quick-private gui-private UbuntuToolkit
SOURCES += \
tst_asyncloader.cpp
DISTFILES += \
Document.qml \
TestApp.qml \
HeavyDocument.qml \
FaultyDocument.qml
./tests/unit_x11/tst_layouts/ 0000755 0000156 0000165 00000000000 12700370701 016276 5 ustar jenkins jenkins ./tests/unit_x11/tst_layouts/DialerCrash.qml 0000644 0000156 0000165 00000002616 12700370701 021177 0 ustar jenkins jenkins /*
* Copyright 2014 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Components.Pickers 1.0
import Ubuntu.Layouts 1.0
MainView {
width: units.gu(40)
height: units.gu(71)
backgroundColor: "#A55263"
property bool wide: true
Layouts {
objectName: "layoutManager"
layouts: [
ConditionalLayout {
name: "wideAspect"
when: wide
ItemLayout {
item: "object1"
}
},
ConditionalLayout {
name: "regularAspect"
when: !wide
ItemLayout {
item: "object2"
}
}
]
Dialer {
Layouts.item: "object1"
}
}
}
./tests/unit_x11/tst_layouts/ResizingContainers.qml 0000644 0000156 0000165 00000006365 12700370701 022643 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Layouts 1.0
Item {
id: root
width: units.gu(40)
height: units.gu(30)
property alias currentLayout: layouts.currentLayout
Layouts {
objectName: "layouts"
id: layouts
anchors.fill: parent
layouts: [
ConditionalLayout {
name: "xlarge"
when: layouts.width >= units.gu(80)
Column {
anchors.fill: parent
ItemLayout {
item: "item1"
width: units.gu(30)
height: units.gu(30)
}
ItemLayout {
item: "item3"
width: units.gu(30)
height: units.gu(30)
}
ItemLayout {
item: "item2"
width: units.gu(40)
height: units.gu(50)
}
}
},
ConditionalLayout {
name: "large"
when: layouts.width >= units.gu(60)
Column {
anchors.fill: parent
ItemLayout {
item: "item1"
width: units.gu(22)
height: units.gu(22)
}
ItemLayout {
item: "item2"
width: units.gu(22)
height: units.gu(22)
}
ItemLayout {
item: "item3"
width: units.gu(22)
height: units.gu(22)
}
}
},
ConditionalLayout {
name: "small"
when: layouts.width > units.gu(40)
Row {
anchors.fill: parent
ItemLayout {
item: "item1"
width: units.gu(10)
height: units.gu(10)
}
ItemLayout {
item: "item2"
width: units.gu(10)
height: units.gu(10)
}
ItemLayout {
item: "item3"
width: units.gu(10)
height: units.gu(10)
}
}
}
]
// default layout
SizedDefaultLayout{
}
}
}
./tests/unit_x11/tst_layouts/LaidOutItemsOutsideOfLayout.qml 0000644 0000156 0000165 00000002474 12700370701 024403 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Layouts 1.0
Rectangle {
id: root
width: 360
height: 360
Layouts {
objectName: "layoutManager"
id: layoutManager
anchors.fill: parent
layouts: [
ConditionalLayout {
name: "portrait"
when: root.width < root.height
ItemLayout {
item: "red"
anchors.right: parent.right
anchors.bottom: parent.bottom
}
}
]
}
Rectangle {
objectName: "itemLaidOut"
width: 40
height: 30
color: "red"
Layouts.item: "red"
}
}
./tests/unit_x11/tst_layouts/SizedDefaultLayout.qml 0000644 0000156 0000165 00000003016 12700370701 022572 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Layouts 1.0
Item {
objectName: "defaultLayout"
anchors.fill: parent
Button {
objectName: "item1"
id: label1
Layouts.item: "item1"
text: "item1"
anchors {
left: parent.left
right: parent.right
}
}
Button {
objectName: "item2"
id: label2
anchors.bottom: label1.bottom
Layouts.item: "item2"
text: "item2"
anchors {
left: parent.left
top: label1.bottom
right: parent.right
}
}
Button {
objectName: "item3"
id: label3
anchors.bottom: label2.bottom
Layouts.item: "item3"
text: "item3"
anchors {
left: parent.left
top: label2.bottom
right: parent.right
}
}
}
./tests/unit_x11/tst_layouts/ItemInstanceAsProperty.qml 0000644 0000156 0000165 00000003221 12700370701 023423 0 ustar jenkins jenkins /*
* Copyright 2014 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Layouts 1.0
Item {
property bool wide: true
width: units.gu(40)
height: units.gu(71)
function changeLayout() {
loader.sourceComponent = undefined; wide = false
}
Layouts {
objectName: "layoutManager"
layouts: [
ConditionalLayout {
name: "wideAspect"
when: wide
ItemLayout {
item: "object1"
}
},
ConditionalLayout {
name: "regularAspect"
when: !wide
ItemLayout {
item: "object2"
anchors.left: parent.left
}
}
]
Item {
Layouts.item: "object1"
Loader {
id: loader
sourceComponent: ShaderEffectSource {
sourceItem: Item {
}
}
}
}
}
}
./tests/unit_x11/tst_layouts/ExcludedItemDeleted.qml 0000644 0000156 0000165 00000003377 12700370701 022666 0 ustar jenkins jenkins /*
* Copyright 2014 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Layouts 1.0
Item {
property bool wide: true
width: units.gu(40)
height: units.gu(71)
function changeLayout() {
loader2.sourceComponent = undefined; wide = false
}
Layouts {
objectName: "layoutManager"
layouts: [
ConditionalLayout {
name: "wideAspect"
when: wide
ItemLayout {
item: "object1"
}
},
ConditionalLayout {
name: "regularAspect"
when: !wide
ItemLayout {
item: "object1"
anchors.left: parent.left
}
}
]
Column {
Loader {
Layouts.item: "object1"
id: loader
sourceComponent: ShaderEffectSource {
sourceItem: Item {
}
}
}
Loader {
id: loader2
sourceComponent: Item{}
}
}
}
}
./tests/unit_x11/tst_layouts/AnchorRight.qml 0000644 0000156 0000165 00000002631 12700370701 021223 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Layouts 1.0
Rectangle {
id: root
width: 300
height: 360
Layouts {
objectName: "layoutManager"
id: layoutManager
anchors.fill: parent
layouts: [
ConditionalLayout {
name: "landscape"
when: root.width > root.height
ItemLayout {
objectName: "testLayout"
anchors.fill: parent
item: "test"
}
}
]
Rectangle {
width: 100
height: 100
color: "red"
objectName: "testItem"
Layouts.item: "test"
anchors.right: parent.right
anchors.rightMargin: 10
}
}
}
./tests/unit_x11/tst_layouts/PositioningOnLayoutChange.qml 0000644 0000156 0000165 00000002757 12700370701 024127 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Layouts 1.0
Rectangle {
id: root
width: 360
height: 360
Layouts {
objectName: "layoutManager"
id: layoutManager
anchors.fill: parent
layouts: [
ConditionalLayout {
name: "portrait"
when: root.width < root.height
ItemLayout {
item: "red"
anchors.right: parent.right
anchors.bottom: parent.bottom
}
},
ConditionalLayout {
name: "landscape"
when: root.width > root.height
}
]
Rectangle { anchors.fill: parent; color: 'yellow'}
Rectangle {
width: 40
height: 30
color: "red"
Layouts.item: "red"
}
}
}
./tests/unit_x11/tst_layouts/AnchorCenteredInDefault.qml 0000644 0000156 0000165 00000002562 12700370701 023476 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Layouts 1.0
Rectangle {
id: root
width: 300
height: 360
Layouts {
objectName: "layoutManager"
id: layoutManager
anchors.fill: parent
layouts: [
ConditionalLayout {
name: "landscape"
when: root.width > root.height
ItemLayout {
objectName: "testLayout"
anchors.fill: parent
item: "test"
}
}
]
Rectangle {
width: 100
height: 100
color: "red"
objectName: "testItem"
Layouts.item: "test"
anchors.centerIn: parent
}
}
}
./tests/unit_x11/tst_layouts/AnchorLeft.qml 0000644 0000156 0000165 00000002626 12700370701 021044 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Layouts 1.0
Rectangle {
id: root
width: 300
height: 360
Layouts {
objectName: "layoutManager"
id: layoutManager
anchors.fill: parent
layouts: [
ConditionalLayout {
name: "landscape"
when: root.width > root.height
ItemLayout {
objectName: "testLayout"
anchors.fill: parent
item: "test"
}
}
]
Rectangle {
width: 100
height: 100
color: "red"
objectName: "testItem"
Layouts.item: "test"
anchors.left: parent.left
anchors.leftMargin: 10
}
}
}
./tests/unit_x11/tst_layouts/Visibility.qml 0000644 0000156 0000165 00000005221 12700370701 021140 0 ustar jenkins jenkins /*
* Copyright 2014 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Components 1.3
import Ubuntu.Layouts 1.0
MainView {
id: main
objectName: "mainView"
applicationName: "test-app"
/*
This property enables the application to change orientation
when the device is rotated. The default is false.
*/
automaticOrientation: true // TODO: support wide aspect ratios, esp. on prepareGamePage
property bool boundValue: true
width: units.gu(100)
height: units.gu(75)
function portraitLayout() {
width = units.gu(50);
}
function landscapeLayout() {
width = units.gu(100);
}
PageStack {
Component.onCompleted: push(testPage)
Page {
title: i18n.tr("Conditional Layouts with PageStack")
id: testPage
visible: false
Layouts {
id: layouts
objectName: "layoutManager"
width: parent.width
height: parent.height
layouts: [
ConditionalLayout {
name: "wide"
when: layouts.width < units.gu(60)
UbuntuShape {
width: units.gu(20)
height: units.gu(20)
backgroundColor: "red"
Label { text: "wide" }
}
}
]
// This is a default layout.
// When using a PageStack and layouts is not empty, it won't display or switch to the default layout.
// However it only works when putting it into the layouts list with an inversed condition.
UbuntuShape {
objectName: "DefaultLayout"
width: units.gu(20)
height: units.gu(20)
backgroundColor: "green"
visible: main.boundValue
Label { text: "default" }
}
}
}
}
}
./tests/unit_x11/tst_layouts/AnchorHorizontalCenterOffset.qml 0000644 0000156 0000165 00000002674 12700370701 024616 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Layouts 1.0
Rectangle {
id: root
width: 300
height: 360
Layouts {
objectName: "layoutManager"
id: layoutManager
anchors.fill: parent
layouts: [
ConditionalLayout {
name: "landscape"
when: root.width > root.height
ItemLayout {
objectName: "testLayout"
anchors.fill: parent
item: "test"
}
}
]
Rectangle {
width: 100
height: 100
color: "red"
objectName: "testItem"
Layouts.item: "test"
anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenterOffset: 50.0
}
}
}
./tests/unit_x11/tst_layouts/NestedLayouts.qml 0000644 0000156 0000165 00000004111 12700370701 021611 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Layouts 1.0
Item {
id: root
width: units.gu(40)
height: units.gu(30)
property string nestedLayout: ""
Layouts {
objectName: "layouts"
id: layouts
anchors.fill: parent
layouts: [
ConditionalLayout {
name: "extra-large"
when: layouts.width > units.gu(80)
Item {
anchors.fill: parent
Item {
id: header
ItemLayout {
item: "item3"
}
}
Row {
anchors.fill: parent
anchors.topMargin: header.height
ItemLayout {
item: "item1"
}
ItemLayout {
item: "item2"
}
}
}
},
ConditionalLayout {
name: "simple"
when: layouts.width <= units.gu(100)
SimpleLayouts{
id: nested
anchors.fill: parent
onCurrentLayoutChanged: root.nestedLayout = nested.currentLayout
}
}
]
// default layout
DefaultLayout{
}
}
}
./tests/unit_x11/tst_layouts/AnchorFilledMargins.qml 0000644 0000156 0000165 00000002537 12700370701 022673 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Layouts 1.0
Rectangle {
id: root
width: 300
height: 360
Layouts {
objectName: "layoutManager"
id: layoutManager
anchors.fill: parent
layouts: [
ConditionalLayout {
name: "landscape"
when: root.width > root.height
ItemLayout {
objectName: "testLayout"
anchors.fill: parent
item: "test"
}
}
]
Rectangle {
color: "red"
objectName: "testItem"
Layouts.item: "test"
anchors.fill: parent
anchors.margins: 10
}
}
}
./tests/unit_x11/tst_layouts/tst_layouts.pro 0000644 0000156 0000165 00000002103 12700370701 021406 0 ustar jenkins jenkins include(../test-include.pri)
include(../../unit/qtprivate_dependency.pri)
QT += gui
SOURCES += \
tst_layouts.cpp
OTHER_FILES += \
SimpleLayouts.qml \
NoLayouts.qml \
OverlappingCondition.qml \
SmallLayout.qml \
MediumLayout.qml \
LargeLayout.qml \
ExternalLayouts.qml \
NestedLayouts.qml \
DefaultLayout.qml \
ResizingContainers.qml \
SizedDefaultLayout.qml \
CurrentLayoutChange.qml \
PositioningOnLayoutChange.qml \
LaidOutItemsOutsideOfLayout.qml \
OverlaidInItemLayout.qml \
AnchorFilledReparenting.qml \
AnchorCenteredInDefault.qml \
AnchorFilledMargins.qml \
AnchorFilledSeparateMargins.qml \
AnchorVerticalCenter.qml \
AnchorVerticalCenterOffset.qml \
AnchorCenterWithOffset.qml \
AnchorHorizontalCenter.qml \
AnchorHorizontalCenterOffset.qml \
AnchorLeft.qml \
AnchorRight.qml \
AnchorTop.qml \
AnchorBottom.qml \
AnchorAll.qml \
ItemInstanceAsProperty.qml \
DialerCrash.qml \
ExcludedItemDeleted.qml \
Visibility.qml \
NestedVisibility.qml
./tests/unit_x11/tst_layouts/NestedVisibility.qml 0000644 0000156 0000165 00000014446 12700370701 022314 0 ustar jenkins jenkins /*
* Copyright 2014 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Layouts 1.0
MainView {
id: main
objectName: "mainView"
applicationName: "test-app"
/*
This property enables the application to change orientation
when the device is rotated. The default is false.
*/
automaticOrientation: true // TODO: support wide aspect ratios, esp. on prepareGamePage
width: units.gu(40)
height: units.gu(75)
function phoneLayout() {
width = units.gu(50);
}
function tabletPortraitLayout() {
width = units.gu(70);
}
function tabletLandscapeLayout() {
width = units.gu(100);
}
PageStack {
Component.onCompleted: push(testPage)
Page {
title: i18n.tr("Conditional Layouts with PageStack")
id: testPage
visible: false
Layouts {
id: layouts
objectName: "mainLayout"
width: parent.width
height: parent.height
layouts: [
ConditionalLayout {
name: "tabletPortrait"
when: main.width > units.gu(50)
Layouts {
anchors.fill: parent
objectName: "nestedLayout"
layouts: [
ConditionalLayout {
name: "tabletLandscape"
when: main.width > units.gu(70)
Row {
objectName: "tabletLandscape"
anchors.fill: parent
Rectangle {
height: parent.height
color: "white"
width: parent.width / 5
}
Flow {
spacing: units.gu(2)
ItemLayout {
objectName: "nestedMagentaContainer"
item: "mainMagenta"
width: units.gu(20)
height: width
}
ItemLayout {
objectName: "nestedGreenContainer"
item: "mainGreen"
width: units.gu(60)
height: width
}
}
}
}
]
// Default layout, but can have ItemLayouts
// as those will belong to the previous Layouts
// and attaching Layouts.item we can layout it further
Flow {
objectName: "tabletPortrait"
anchors.fill: parent
ItemLayout {
objectName: "greenContainer"
item: "mainGreen"
width: units.gu(40)
height: width
Layouts.item: item
}
ItemLayout {
objectName: "magentaContainer"
item: "mainMagenta"
width: units.gu(60)
height: width
Layouts.item: item
}
}
}
}
]
// default layout for mainLayout
Flow {
objectName: "mainDefaultLayout"
anchors.fill: parent
Rectangle {
objectName: "mainRed"
width: units.gu(15)
height: width
color: "red"
Layouts.item: "mainRed"
}
Rectangle {
objectName: "mainGreen"
width: units.gu(15)
height: width
color: "green"
Layouts.item: "mainGreen"
}
Rectangle {
objectName: "mainBlue"
width: units.gu(15)
height: width
color: "blue"
Layouts.item: "mainBlue"
}
Rectangle {
objectName: "mainMagenta"
width: units.gu(15)
height: width
color: "magenta"
Layouts.item: "mainMagenta"
}
Rectangle {
objectName: "mainHidden"
width: units.gu(15)
height: width
color: "yellow"
visible: false
}
}
}
}
}
}
./tests/unit_x11/tst_layouts/SimpleLayouts.qml 0000644 0000156 0000165 00000004755 12700370701 021636 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Layouts 1.0
Item {
id: root
width: units.gu(40)
height: units.gu(30)
property alias currentLayout: layouts.currentLayout
Layouts {
objectName: "layouts"
id: layouts
anchors.fill: parent
layouts: [
ConditionalLayout {
name: "small"
when: layouts.width <= units.gu(40)
Column {
anchors.fill: parent
ItemLayout {
item: "item1"
}
ItemLayout {
item: "item2"
}
ItemLayout {
item: "item3"
}
}
},
ConditionalLayout {
name: "medium"
when: layouts.width > units.gu(40) && layouts.width <= units.gu(60)
Flow {
anchors.fill: parent
ItemLayout {
item: "item1"
}
ItemLayout {
item: "item2"
}
ItemLayout {
item: "item3"
}
}
},
ConditionalLayout {
name: "large"
when: layouts.width > units.gu(60)
Row {
anchors.fill: parent
ItemLayout {
item: "item1"
}
ItemLayout {
item: "item2"
}
ItemLayout {
item: "item3"
}
}
}
]
// default layout
DefaultLayout{
}
}
}
./tests/unit_x11/tst_layouts/AnchorBottom.qml 0000644 0000156 0000165 00000002634 12700370701 021415 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Layouts 1.0
Rectangle {
id: root
width: 300
height: 360
Layouts {
objectName: "layoutManager"
id: layoutManager
anchors.fill: parent
layouts: [
ConditionalLayout {
name: "landscape"
when: root.width > root.height
ItemLayout {
objectName: "testLayout"
anchors.fill: parent
item: "test"
}
}
]
Rectangle {
width: 100
height: 100
color: "red"
objectName: "testItem"
Layouts.item: "test"
anchors.bottom: parent.bottom
anchors.bottomMargin: 10
}
}
}
./tests/unit_x11/tst_layouts/DefaultLayout.qml 0000644 0000156 0000165 00000002277 12700370701 021603 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Layouts 1.0
Item {
objectName: "defaultLayout"
anchors.fill: parent
Label {
objectName: "item1"
id: label1
Layouts.item: "item1"
text: "item1"
}
Label {
objectName: "item2"
id: label2
anchors.bottom: label1.bottom
Layouts.item: "item2"
text: "item2"
}
Label {
objectName: "item3"
id: label3
anchors.bottom: label2.bottom
Layouts.item: "item3"
text: "item3"
}
}
./tests/unit_x11/tst_layouts/AnchorTop.qml 0000644 0000156 0000165 00000002623 12700370701 020711 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Layouts 1.0
Rectangle {
id: root
width: 300
height: 360
Layouts {
objectName: "layoutManager"
id: layoutManager
anchors.fill: parent
layouts: [
ConditionalLayout {
name: "landscape"
when: root.width > root.height
ItemLayout {
objectName: "testLayout"
anchors.fill: parent
item: "test"
}
}
]
Rectangle {
width: 100
height: 100
color: "red"
objectName: "testItem"
Layouts.item: "test"
anchors.top: parent.top
anchors.topMargin: 10
}
}
}
./tests/unit_x11/tst_layouts/AnchorFilledReparenting.qml 0000644 0000156 0000165 00000002477 12700370701 023554 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Layouts 1.0
Rectangle {
id: root
width: 300
height: 360
Layouts {
objectName: "layoutManager"
id: layoutManager
anchors.fill: parent
layouts: [
ConditionalLayout {
name: "landscape"
when: root.width > root.height
ItemLayout {
objectName: "testLayout"
anchors.fill: parent
item: "test"
}
}
]
Rectangle {
color: "red"
objectName: "testItem"
Layouts.item: "test"
anchors.fill: parent
}
}
}
./tests/unit_x11/tst_layouts/LargeLayout.qml 0000644 0000156 0000165 00000001771 12700370701 021247 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Layouts 1.0
ConditionalLayout {
name: "large"
when: layouts.width > units.gu(60)
Row {
anchors.fill: parent
ItemLayout {
item: "item1"
}
ItemLayout {
item: "item2"
}
ItemLayout {
item: "item3"
}
}
}
./tests/unit_x11/tst_layouts/OverlappingCondition.qml 0000644 0000156 0000165 00000003663 12700370701 023156 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Layouts 1.0
Item {
id: root
width: units.gu(40)
height: units.gu(30)
Layouts {
objectName: "layouts"
id: layouts
anchors.fill: parent
layouts: [
ConditionalLayout {
name: "small"
when: layouts.width <= units.gu(40)
Column {
anchors.fill: parent
ItemLayout {
item: "item1"
}
ItemLayout {
item: "item2"
}
ItemLayout {
item: "item3"
}
}
},
ConditionalLayout {
name: "medium"
when: layouts.width >= units.gu(40) && layouts.width <= units.gu(60)
Flow {
anchors.fill: parent
ItemLayout {
item: "item1"
}
ItemLayout {
item: "item2"
}
ItemLayout {
item: "item3"
}
}
}
]
DefaultLayout{
}
}
}
./tests/unit_x11/tst_layouts/OverlaidInItemLayout.qml 0000644 0000156 0000165 00000003223 12700370701 023062 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Layouts 1.0
Rectangle {
id: root
width: 300
height: 360
Layouts {
id: layoutManager
objectName: "layoutManager"
anchors.fill: parent
layouts: [
ConditionalLayout {
name: "portrait"
when: root.width < root.height
ItemLayout {
objectName: "layout"
item: "red"
x: 20
y: 30
width: 40
height: 30
Rectangle {
objectName: "overlay"
width: 10
height: 10
color: "green"
z: 100
}
}
}
]
Rectangle {
objectName: "hostedItem"
id: red
width: 40
height: 30
color: "red"
Layouts.item: "red"
}
}
}
./tests/unit_x11/tst_layouts/AnchorFilledSeparateMargins.qml 0000644 0000156 0000165 00000002715 12700370701 024356 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Layouts 1.0
Rectangle {
id: root
width: 300
height: 360
Layouts {
objectName: "layoutManager"
id: layoutManager
anchors.fill: parent
layouts: [
ConditionalLayout {
name: "landscape"
when: root.width > root.height
ItemLayout {
objectName: "testLayout"
anchors.fill: parent
item: "test"
}
}
]
Rectangle {
color: "red"
objectName: "testItem"
Layouts.item: "test"
anchors.fill: parent
anchors.leftMargin: 10
anchors.topMargin: 20
anchors.rightMargin: 30
anchors.bottomMargin: 40
}
}
}
./tests/unit_x11/tst_layouts/SmallLayout.qml 0000644 0000156 0000165 00000001775 12700370701 021271 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Layouts 1.0
ConditionalLayout {
name: "small"
when: layouts.width <= units.gu(40)
Column {
anchors.fill: parent
ItemLayout {
item: "item1"
}
ItemLayout {
item: "item2"
}
ItemLayout {
item: "item3"
}
}
}
./tests/unit_x11/tst_layouts/AnchorAll.qml 0000644 0000156 0000165 00000003011 12700370701 020647 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Layouts 1.0
Rectangle {
id: root
width: 300
height: 360
Layouts {
objectName: "layoutManager"
id: layoutManager
anchors.fill: parent
layouts: [
ConditionalLayout {
name: "landscape"
when: root.width > root.height
ItemLayout {
objectName: "testLayout"
anchors.fill: parent
item: "test"
}
}
]
Rectangle {
width: 100
height: 100
color: "red"
objectName: "testItem"
Layouts.item: "test"
anchors.left: parent.left
anchors.top: parent.top
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.margins: 20
}
}
}
./tests/unit_x11/tst_layouts/ExternalLayouts.qml 0000644 0000156 0000165 00000002051 12700370701 022152 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Layouts 1.0
Item {
id: root
width: units.gu(40)
height: units.gu(30)
Layouts {
objectName: "layouts"
id: layouts
anchors.fill: parent
layouts: [
SmallLayout{},
MediumLayout {},
LargeLayout {}
]
// default layout
DefaultLayout{
}
}
}
./tests/unit_x11/tst_layouts/NoLayouts.qml 0000644 0000156 0000165 00000001575 12700370701 020756 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Layouts 1.0
Item {
id: root
width: units.gu(40)
height: units.gu(30)
Layouts {
objectName: "layouts"
id: layouts
anchors.fill: parent
}
}
./tests/unit_x11/tst_layouts/MediumLayout.qml 0000644 0000156 0000165 00000002034 12700370701 021426 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Layouts 1.0
ConditionalLayout {
name: "medium"
when: layouts.width > units.gu(40) && layouts.width <= units.gu(60)
Flow {
anchors.fill: parent
ItemLayout {
item: "item1"
}
ItemLayout {
item: "item2"
}
ItemLayout {
item: "item3"
}
}
}
./tests/unit_x11/tst_layouts/AnchorVerticalCenterOffset.qml 0000644 0000156 0000165 00000002664 12700370701 024235 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Layouts 1.0
Rectangle {
id: root
width: 300
height: 360
Layouts {
objectName: "layoutManager"
id: layoutManager
anchors.fill: parent
layouts: [
ConditionalLayout {
name: "landscape"
when: root.width > root.height
ItemLayout {
objectName: "testLayout"
anchors.fill: parent
item: "test"
}
}
]
Rectangle {
width: 100
height: 100
color: "red"
objectName: "testItem"
Layouts.item: "test"
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: 50
}
}
}
./tests/unit_x11/tst_layouts/AnchorHorizontalCenter.qml 0000644 0000156 0000165 00000002613 12700370701 023440 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Layouts 1.0
Rectangle {
id: root
width: 300
height: 360
Layouts {
objectName: "layoutManager"
id: layoutManager
anchors.fill: parent
layouts: [
ConditionalLayout {
name: "landscape"
when: root.width > root.height
ItemLayout {
objectName: "testLayout"
anchors.fill: parent
item: "test"
}
}
]
Rectangle {
width: 100
height: 100
color: "red"
objectName: "testItem"
Layouts.item: "test"
anchors.horizontalCenter: parent.horizontalCenter
}
}
}
./tests/unit_x11/tst_layouts/tst_layouts.cpp 0000644 0000156 0000165 00000116637 12700370701 021412 0 ustar jenkins jenkins /*
* Copyright 2012 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "ullayouts.h"
#include "ucunits.h"
#include "uctestcase.h"
#include
#include
#define QCOMPARE_RET(actual, expected) \
do {\
if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\
return false;\
} while (0)
#define QVERIFY_RET(statement, resturns) \
do {\
if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__))\
return resturns;\
} while (0)
class tst_Layouts : public QObject
{
Q_OBJECT
private:
QString m_modulePath;
public:
tst_Layouts()
{
}
QQuickView * loadTest(const QString &file)
{
UbuntuTestCase* testCase = new UbuntuTestCase(file);
return qobject_cast(testCase);
}
QQuickItem *testItem(QQuickItem *that, const QString &identifier)
{
if (that->property(identifier.toLocal8Bit()).isValid())
return that->property(identifier.toLocal8Bit()).value();
QList children = that->findChildren(identifier);
return (children.count() > 0) ? children[0] : 0;
}
bool hasChildItem(QQuickItem *child, QQuickItem *parent)
{
QQuickItem *pl = child->parentItem();
while (pl) {
if (pl == parent) {
return true;
}
pl = pl->parentItem();
}
return false;
}
QQuickItem *prevSibling(QQuickItem *item)
{
QList children = item->parentItem()->childItems();
int index = children.indexOf(item);
return (index > 0) ? children.at(index - 1) : 0;
}
private Q_SLOTS:
void initTestCase()
{
}
void cleanupTestCase()
{
}
void testCase_NoLayouts()
{
QScopedPointer testCase(new UbuntuTestCase("NoLayouts.qml"));
ULLayouts *layouts = testCase->findItem("layouts");
QVERIFY(layouts->layoutList().isEmpty());
}
void testCase_SimpleLayout()
{
QScopedPointer view(loadTest("SimpleLayouts.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layouts = qobject_cast(testItem(root, "layouts"));
QVERIFY(layouts);
QVERIFY(!layouts->layoutList().isEmpty());
QSignalSpy currentLayout(layouts, SIGNAL(currentLayoutChanged()));
currentLayout.wait(300);
QCOMPARE(layouts->currentLayout(), QString("small"));
QQuickItem *item = testItem(root, "item1");
QVERIFY(item);
QVERIFY(item->parentItem()->parentItem()->inherits("QQuickColumn"));
item = testItem(root, "item2");
QVERIFY(item);
QVERIFY(item->parentItem()->parentItem()->inherits("QQuickColumn"));
item = testItem(root, "item3");
QVERIFY(item);
QVERIFY(item->parentItem()->parentItem()->inherits("QQuickColumn"));
}
void testCase_SimpleLayout_Medium()
{
QScopedPointer view(loadTest("SimpleLayouts.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layouts = qobject_cast(testItem(root, "layouts"));
QVERIFY(layouts);
QVERIFY(!layouts->layoutList().isEmpty());
QSignalSpy layoutChangeSpy(layouts, SIGNAL(currentLayoutChanged()));
root->setWidth(UCUnits::instance()->gu(55));
QCOMPARE(root->width(), UCUnits::instance()->gu(55));
layoutChangeSpy.wait(100);
QCOMPARE(layoutChangeSpy.count(), 1);
QCOMPARE(layouts->currentLayout(), QString("medium"));
QQuickItem *item = testItem(root, "item1");
QVERIFY(item);
QVERIFY(item->parentItem()->parentItem()->inherits("QQuickFlow"));
item = testItem(root, "item2");
QVERIFY(item);
QVERIFY(item->parentItem()->parentItem()->inherits("QQuickFlow"));
item = testItem(root, "item3");
QVERIFY(item);
QVERIFY(item->parentItem()->parentItem()->inherits("QQuickFlow"));
}
void testCase_SimpleLayout_Large()
{
QScopedPointer view(loadTest("SimpleLayouts.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layouts = qobject_cast(testItem(root, "layouts"));
QVERIFY(layouts);
QVERIFY(!layouts->layoutList().isEmpty());
QSignalSpy layoutChangeSpy(layouts, SIGNAL(currentLayoutChanged()));
root->setWidth(UCUnits::instance()->gu(65));
QCOMPARE(root->width(), UCUnits::instance()->gu(65));
layoutChangeSpy.wait(100);
QCOMPARE(layoutChangeSpy.count(), 1);
QCOMPARE(layouts->currentLayout(), QString("large"));
QQuickItem *item = testItem(root, "item1");
QVERIFY(item);
QVERIFY(item->parentItem()->parentItem()->inherits("QQuickRow"));
item = testItem(root, "item2");
QVERIFY(item);
QVERIFY(item->parentItem()->parentItem()->inherits("QQuickRow"));
item = testItem(root, "item3");
QVERIFY(item);
QVERIFY(item->parentItem()->parentItem()->inherits("QQuickRow"));
}
void testCase_OverlappingCondition()
{
QScopedPointer view(loadTest("OverlappingCondition.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layouts = qobject_cast(testItem(root, "layouts"));
QVERIFY(layouts);
QVERIFY(!layouts->layoutList().isEmpty());
QSignalSpy currentLayout(layouts, SIGNAL(currentLayoutChanged()));
currentLayout.wait(300);
QCOMPARE(layouts->currentLayout(), QString("small"));
}
void testCase_ExternalLayouts()
{
QScopedPointer view(loadTest("ExternalLayouts.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layouts = qobject_cast(testItem(root, "layouts"));
QVERIFY(layouts);
QVERIFY(!layouts->layoutList().isEmpty());
QSignalSpy currentLayout(layouts, SIGNAL(currentLayoutChanged()));
currentLayout.wait(300);
QCOMPARE(layouts->currentLayout(), QString("small"));
}
void testCase_ExternalLayouts_Medium()
{
QScopedPointer view(loadTest("ExternalLayouts.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layouts = qobject_cast(testItem(root, "layouts"));
QVERIFY(layouts);
QVERIFY(!layouts->layoutList().isEmpty());
QSignalSpy layoutChangeSpy(layouts, SIGNAL(currentLayoutChanged()));
root->setWidth(UCUnits::instance()->gu(55));
layoutChangeSpy.wait(100);
QCOMPARE(layoutChangeSpy.count(), 1);
QCOMPARE(layouts->currentLayout(), QString("medium"));
}
void testCase_ExternalLayouts_Large()
{
QScopedPointer view(loadTest("ExternalLayouts.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layouts = qobject_cast(testItem(root, "layouts"));
QVERIFY(layouts);
QVERIFY(!layouts->layoutList().isEmpty());
QSignalSpy layoutChangeSpy(layouts, SIGNAL(currentLayoutChanged()));
root->setWidth(UCUnits::instance()->gu(65));
layoutChangeSpy.wait(100);
QCOMPARE(layoutChangeSpy.count(), 1);
QCOMPARE(layouts->currentLayout(), QString("large"));
}
void testCase_NestedLayouts()
{
QScopedPointer view(loadTest("NestedLayouts.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layouts = qobject_cast(testItem(root, "layouts"));
QVERIFY(layouts);
QVERIFY(!layouts->layoutList().isEmpty());
QSignalSpy currentLayout(layouts, SIGNAL(currentLayoutChanged()));
currentLayout.wait(300);
QCOMPARE(layouts->currentLayout(), QString("simple"));
}
void testCase_NestedLayouts_ExtraLarge()
{
QTest::ignoreMessage(QtWarningMsg, "\"There are still \"1\" items in the process of being created at engine destruction.\"");
QScopedPointer view(loadTest("NestedLayouts.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layouts = qobject_cast(testItem(root, "layouts"));
QVERIFY(layouts);
QVERIFY(!layouts->layoutList().isEmpty());
QSignalSpy layoutChangeSpy(layouts, SIGNAL(currentLayoutChanged()));
root->setWidth(UCUnits::instance()->gu(90));
layoutChangeSpy.wait(100);
QCOMPARE(layoutChangeSpy.count(), 1);
QCOMPARE(layouts->currentLayout(), QString("extra-large"));
root->setWidth(UCUnits::instance()->gu(50));
layoutChangeSpy.wait(100);
QCOMPARE(layoutChangeSpy.count(), 2);
QCOMPARE(root->property("nestedLayout").toString(), QString("medium"));
}
void testCase_ResizingContainers()
{
QScopedPointer view(loadTest("ResizingContainers.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
// fetch the current size of one item
QQuickItem *item = testItem(root, "item1");
qreal width = item->width();
qreal height = item->height();
QQuickItem *item2 = testItem(root, "item2");
qreal width2 = item2->width();
qreal height2 = item2->height();
ULLayouts *layouts = qobject_cast(testItem(root, "layouts"));
QVERIFY(layouts);
QVERIFY(!layouts->layoutList().isEmpty());
QSignalSpy layoutChangeSpy(layouts, SIGNAL(currentLayoutChanged()));
root->setWidth(UCUnits::instance()->gu(50));
layoutChangeSpy.wait(100);
QCOMPARE(layouts->currentLayout(), QString("small"));
QCOMPARE(item->width(), UCUnits::instance()->gu(10));
QCOMPARE(item->height(), UCUnits::instance()->gu(10));
root->setWidth(UCUnits::instance()->gu(60));
layoutChangeSpy.wait(100);
QCOMPARE(layouts->currentLayout(), QString("large"));
QCOMPARE(item->width(), UCUnits::instance()->gu(22));
QCOMPARE(item->height(), UCUnits::instance()->gu(22));
root->setWidth(UCUnits::instance()->gu(80));
layoutChangeSpy.wait(100);
QCOMPARE(layouts->currentLayout(), QString("xlarge"));
QCOMPARE(item->width(), UCUnits::instance()->gu(30));
QCOMPARE(item->height(), UCUnits::instance()->gu(30));
QCOMPARE(item2->width(), UCUnits::instance()->gu(40));
QCOMPARE(item2->height(), UCUnits::instance()->gu(50));
root->setWidth(UCUnits::instance()->gu(40));
layoutChangeSpy.wait(100);
QCOMPARE(item->width(), width);
QCOMPARE(item->height(), height);
QCOMPARE(item2->width(), width2);
QCOMPARE(item2->height(), height2);
}
void testCase_CurrentLayoutChange()
{
UbuntuTestCase::ignoreWarning("CurrentLayoutChange.qml", 30, 13,
"QML ConditionalLayout: ERROR: no container specified for layout \"portrait\". ConditionalLayout cannot be activated without a container.");
UbuntuTestCase::ignoreWarning("CurrentLayoutChange.qml", 35, 13,
"QML ConditionalLayout: ERROR: no container specified for layout \"landscape\". ConditionalLayout cannot be activated without a container.");
UbuntuTestCase::ignoreWarning("CurrentLayoutChange.qml", 30, 13,
"QML ConditionalLayout: WARNING: Cannot activate layout \"portrait\" with no container specified. Falling back to default layout.");
QScopedPointer view(loadTest("CurrentLayoutChange.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layouts = qobject_cast(testItem(root, "layoutManager"));
QVERIFY(layouts);
QSignalSpy spy(layouts, SIGNAL(currentLayoutChanged()));
root->setWidth(root->height() - 10);
spy.wait(100);
QEXPECT_FAIL(0, "Layout change should not happen when component is not defined", Continue);
QCOMPARE(spy.count(), 1);
}
void testCase_PositioningOnLayoutChange()
{
UbuntuTestCase::ignoreWarning("PositioningOnLayoutChange.qml", 42, 13,
"QML ConditionalLayout: WARNING: Cannot activate layout \"landscape\" with no container specified. Falling back to default layout.", 2);
UbuntuTestCase::ignoreWarning("PositioningOnLayoutChange.qml", 42, 13,
"QML ConditionalLayout: ERROR: no container specified for layout \"landscape\". ConditionalLayout cannot be activated without a container.");
QScopedPointer view(loadTest("PositioningOnLayoutChange.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layouts = qobject_cast(testItem(root, "layoutManager"));
QVERIFY(layouts);
QSignalSpy spy(layouts, SIGNAL(currentLayoutChanged()));
root->setWidth(root->height() + 10);
spy.wait(100);
QEXPECT_FAIL(0, "Layout change should not happen when component is not defined", Continue);
QCOMPARE(spy.count(), 1);
spy.clear();
root->setWidth(root->height() - 10);
spy.wait(100);
QCOMPARE(spy.count(), 1);
}
void testCase_LaidOutItemsOutsideOfLayout()
{
UbuntuTestCase::ignoreWarning("LaidOutItemsOutsideOfLayout.qml", 44, 5,
"QML Rectangle: ERROR: Item that is not a child of a Layouts component will not be laid out.");
QScopedPointer view(loadTest("LaidOutItemsOutsideOfLayout.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
QQuickItem *item = qobject_cast(testItem(root, "itemLaidOut"));
QVERIFY(item);
ULLayoutsAttached *marker = qobject_cast(
qmlAttachedPropertiesObject(item, false));
QVERIFY(marker);
QVERIFY(!marker->isValid());
}
void testCase_OverlaidInItemLayout()
{
QScopedPointer view(loadTest("OverlaidInItemLayout.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layouts = qobject_cast(testItem(root, "layoutManager"));
QVERIFY(layouts);
QSignalSpy currentLayout(layouts, SIGNAL(currentLayoutChanged()));
currentLayout.wait(300);
QQuickItem *layout = qobject_cast(testItem(root, "layout"));
QVERIFY(layout);
QQuickItem *item = qobject_cast(testItem(root, "hostedItem"));
QVERIFY(item);
QCOMPARE(layout->childItems()[0], item);
}
void testCase_AnchorFilledReparenting()
{
QScopedPointer view(new UbuntuTestCase("AnchorFilledReparenting.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layout = view->findItem("layoutManager");
QVERIFY(layout);
QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
QQuickItem *item = view->findItem("testItem");
QVERIFY(item);
QQuickAnchors *anchors = item->property("anchors").value();
QVERIFY(anchors);
root->setWidth(root->width() + 100);
layoutChangeSpy.wait(100);
QQuickItem *testLayout = view->findItem("testLayout");
QVERIFY(testLayout);
QCOMPARE(anchors->fill(), testLayout);
root->setWidth(root->width() - 100);
layoutChangeSpy.wait(100);
QCOMPARE(anchors->fill(), layout->contentItem());
}
void testCase_AnchorFilledMargins()
{
QScopedPointer view(new UbuntuTestCase("AnchorFilledMargins.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layout = view->findItem("layoutManager");
QVERIFY(layout);
QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
QQuickItem *item = view->findItem("testItem");
QVERIFY(item);
QQuickAnchors *anchors = item->property("anchors").value();
QVERIFY(anchors);
root->setWidth(root->width() + 100);
layoutChangeSpy.wait(100);
QQuickItem *testLayout = view->findItem("testLayout");
QVERIFY(testLayout);
QCOMPARE(anchors->fill(), testLayout);
QCOMPARE(anchors->margins(), 0.0);
root->setWidth(root->width() - 100);
layoutChangeSpy.wait(100);
QCOMPARE(anchors->fill(), layout->contentItem());
QCOMPARE(anchors->margins(), 10.0);
}
void testCase_AnchorFilledSeparateMargins()
{
QScopedPointer view(new UbuntuTestCase("AnchorFilledSeparateMargins.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layout = view->findItem("layoutManager");
QVERIFY(layout);
QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
QQuickItem *item = view->findItem("testItem");
QVERIFY(item);
QQuickAnchors *anchors = item->property("anchors").value();
QVERIFY(anchors);
root->setWidth(root->width() + 100);
layoutChangeSpy.wait(100);
QQuickItem *testLayout = view->findItem("testLayout");
QVERIFY(testLayout);
QCOMPARE(anchors->fill(), testLayout);
QCOMPARE(anchors->margins(), 0.0);
QCOMPARE(anchors->leftMargin(), 0.0);
QCOMPARE(anchors->rightMargin(), 0.0);
QCOMPARE(anchors->topMargin(), 0.0);
QCOMPARE(anchors->bottomMargin(), 0.0);
root->setWidth(root->width() - 100);
layoutChangeSpy.wait(100);
QCOMPARE(anchors->fill(), layout->contentItem());
QCOMPARE(anchors->leftMargin(), 10.0);
QCOMPARE(anchors->topMargin(), 20.0);
QCOMPARE(anchors->rightMargin(), 30.0);
QCOMPARE(anchors->bottomMargin(), 40.0);
}
void testCase_AnchorCenteredInDefault()
{
QScopedPointer view(new UbuntuTestCase("AnchorCenteredInDefault.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layout = view->findItem("layoutManager");
QVERIFY(layout);
QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
QQuickItem *item = view->findItem("testItem");
QVERIFY(item);
QQuickAnchors *anchors = item->property("anchors").value();
QVERIFY(anchors);
root->setWidth(root->width() + 100);
layoutChangeSpy.wait(100);
QQuickItem *testLayout = view->findItem("testLayout");
QVERIFY(testLayout);
QCOMPARE(anchors->fill(), testLayout);
root->setWidth(root->width() - 100);
layoutChangeSpy.wait(100);
QCOMPARE(anchors->centerIn(), layout->contentItem());
}
void testCase_AnchorVerticalCenter()
{
QScopedPointer view(new UbuntuTestCase("AnchorVerticalCenter.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layout = view->findItem("layoutManager");
QVERIFY(layout);
QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
QQuickItem *item = view->findItem("testItem");
QVERIFY(item);
QQuickAnchors *anchors = item->property("anchors").value();
QVERIFY(anchors);
QCOMPARE(anchors->verticalCenter().item, layout->contentItem());
root->setWidth(root->width() + 100);
layoutChangeSpy.wait(100);
QQuickItem *testLayout = view->findItem("testLayout");
QVERIFY(testLayout);
QCOMPARE(anchors->fill(), testLayout);
root->setWidth(root->width() - 100);
layoutChangeSpy.wait(100);
QCOMPARE(anchors->verticalCenter().item, layout->contentItem());
}
void testCase_AnchorVerticalCenterOffset()
{
QScopedPointer view(new UbuntuTestCase("AnchorVerticalCenterOffset.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layout = view->findItem("layoutManager");
QVERIFY(layout);
QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
QQuickItem *item = view->findItem("testItem");
QVERIFY(item);
QQuickAnchors *anchors = item->property("anchors").value();
QVERIFY(anchors);
QCOMPARE(anchors->verticalCenter().item, layout->contentItem());
QCOMPARE(anchors->verticalCenterOffset(), 50.0);
root->setWidth(root->width() + 100);
layoutChangeSpy.wait(100);
QQuickItem *testLayout = view->findItem("testLayout");
QVERIFY(testLayout);
QCOMPARE(anchors->fill(), testLayout);
// no need to check offset as it does not affect the fill
root->setWidth(root->width() - 100);
layoutChangeSpy.wait(100);
QCOMPARE(anchors->verticalCenter().item, layout->contentItem());
QCOMPARE(anchors->verticalCenterOffset(), 50.0);
}
void testCase_AnchorHorizontalCenter()
{
QScopedPointer view(new UbuntuTestCase("AnchorHorizontalCenter.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layout = view->findItem("layoutManager");
QVERIFY(layout);
QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
QQuickItem *item = view->findItem("testItem");
QVERIFY(item);
QQuickAnchors *anchors = item->property("anchors").value();
QVERIFY(anchors);
QCOMPARE(anchors->horizontalCenter().item, layout->contentItem());
root->setWidth(root->width() + 100);
layoutChangeSpy.wait(100);
QQuickItem *testLayout = view->findItem("testLayout");
QVERIFY(testLayout);
QCOMPARE(anchors->fill(), testLayout);
root->setWidth(root->width() - 100);
layoutChangeSpy.wait(100);
QCOMPARE(anchors->horizontalCenter().item, layout->contentItem());
}
void testCase_AnchorHorizontalCenterOffset()
{
QScopedPointer view(new UbuntuTestCase("AnchorHorizontalCenterOffset.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layout = view->findItem("layoutManager");
QVERIFY(layout);
QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
QQuickItem *item = view->findItem("testItem");
QVERIFY(item);
QQuickAnchors *anchors = item->property("anchors").value();
QVERIFY(anchors);
QCOMPARE(anchors->horizontalCenter().item, layout->contentItem());
QCOMPARE(anchors->horizontalCenterOffset(), 50.0);
root->setWidth(root->width() + 100);
layoutChangeSpy.wait(100);
QQuickItem *testLayout = view->findItem("testLayout");
QVERIFY(testLayout);
QCOMPARE(anchors->fill(), testLayout);
// no need to check offset as it does not affect the fill
root->setWidth(root->width() - 100);
layoutChangeSpy.wait(100);
QCOMPARE(anchors->horizontalCenter().item, layout->contentItem());
QCOMPARE(anchors->horizontalCenterOffset(), 50.0);
}
void testCase_AnchorCenterWithOffset()
{
QScopedPointer view(new UbuntuTestCase("AnchorCenterWithOffset.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layout = view->findItem("layoutManager");
QVERIFY(layout);
QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
QQuickItem *item = view->findItem("testItem");
QVERIFY(item);
QQuickAnchors *anchors = item->property("anchors").value();
QVERIFY(anchors);
QCOMPARE(anchors->centerIn(), layout->contentItem());
QCOMPARE(anchors->verticalCenterOffset(), 50.0);
QCOMPARE(anchors->horizontalCenterOffset(), 40.0);
root->setWidth(root->width() + 100);
layoutChangeSpy.wait(100);
QQuickItem *testLayout = view->findItem("testLayout");
QVERIFY(testLayout);
QCOMPARE(anchors->fill(), testLayout);
// no need to check offsets as it does not affect the fill
root->setWidth(root->width() - 100);
layoutChangeSpy.wait(100);
QCOMPARE(anchors->centerIn(), layout->contentItem());
QCOMPARE(anchors->verticalCenterOffset(), 50.0);
QCOMPARE(anchors->horizontalCenterOffset(), 40.0);
}
void testCase_AnchorLeft()
{
QScopedPointer view(new UbuntuTestCase("AnchorLeft.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layout = view->findItem("layoutManager");
QVERIFY(layout);
QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
QQuickItem *item = view->findItem("testItem");
QVERIFY(item);
QQuickAnchors *anchors = item->property("anchors").value();
QVERIFY(anchors);
QCOMPARE(anchors->left().item, layout->contentItem());
QCOMPARE(anchors->leftMargin(), 10.0);
root->setWidth(root->width() + 100);
layoutChangeSpy.wait(100);
QQuickItem *testLayout = view->findItem("testLayout");
QVERIFY(testLayout);
QCOMPARE(anchors->fill(), testLayout);
QCOMPARE(anchors->leftMargin(), 0.0);
root->setWidth(root->width() - 100);
layoutChangeSpy.wait(100);
QCOMPARE(anchors->left().item, layout->contentItem());
QCOMPARE(anchors->leftMargin(), 10.0);
}
void testCase_AnchorTop()
{
QScopedPointer view(new UbuntuTestCase("AnchorTop.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layout = view->findItem("layoutManager");
QVERIFY(layout);
QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
QQuickItem *item = view->findItem("testItem");
QVERIFY(item);
QQuickAnchors *anchors = item->property("anchors").value();
QVERIFY(anchors);
QCOMPARE(anchors->top().item, layout->contentItem());
QCOMPARE(anchors->topMargin(), 10.0);
root->setWidth(root->width() + 100);
layoutChangeSpy.wait(100);
QQuickItem *testLayout = view->findItem("testLayout");
QVERIFY(testLayout);
QCOMPARE(anchors->fill(), testLayout);
QCOMPARE(anchors->topMargin(), 0.0);
root->setWidth(root->width() - 100);
layoutChangeSpy.wait(100);
QCOMPARE(anchors->top().item, layout->contentItem());
QCOMPARE(anchors->topMargin(), 10.0);
}
void testCase_AnchorRight()
{
QScopedPointer view(new UbuntuTestCase("AnchorRight.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layout = view->findItem("layoutManager");
QVERIFY(layout);
QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
QQuickItem *item = view->findItem("testItem");
QVERIFY(item);
QQuickAnchors *anchors = item->property("anchors").value();
QVERIFY(anchors);
QCOMPARE(anchors->right().item, layout->contentItem());
QCOMPARE(anchors->rightMargin(), 10.0);
root->setWidth(root->width() + 100);
layoutChangeSpy.wait(100);
QQuickItem *testLayout = view->findItem("testLayout");
QVERIFY(testLayout);
QCOMPARE(anchors->fill(), testLayout);
QCOMPARE(anchors->rightMargin(), 0.0);
root->setWidth(root->width() - 100);
layoutChangeSpy.wait(100);
QCOMPARE(anchors->right().item, layout->contentItem());
QCOMPARE(anchors->rightMargin(), 10.0);
}
void testCase_AnchorBottom()
{
QScopedPointer view(new UbuntuTestCase("AnchorBottom.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layout = view->findItem("layoutManager");
QVERIFY(layout);
QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
QQuickItem *item = view->findItem("testItem");
QVERIFY(item);
QQuickAnchors *anchors = item->property("anchors").value();
QVERIFY(anchors);
QCOMPARE(anchors->bottom().item, layout->contentItem());
QCOMPARE(anchors->bottomMargin(), 10.0);
root->setWidth(root->width() + 100);
layoutChangeSpy.wait(100);
QQuickItem *testLayout = view->findItem("testLayout");
QVERIFY(testLayout);
QCOMPARE(anchors->fill(), testLayout);
QCOMPARE(anchors->bottomMargin(), 0.0);
root->setWidth(root->width() - 100);
layoutChangeSpy.wait(100);
QCOMPARE(anchors->bottom().item, layout->contentItem());
QCOMPARE(anchors->bottomMargin(), 10.0);
}
void testCase_AnchorAll()
{
QScopedPointer view(new UbuntuTestCase("AnchorAll.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layout = view->findItem("layoutManager");
QVERIFY(layout);
QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
QQuickItem *item = view->findItem("testItem");
QVERIFY(item);
QQuickAnchors *anchors = item->property("anchors").value();
QVERIFY(anchors);
QCOMPARE(anchors->left().item, layout->contentItem());
QCOMPARE(anchors->top().item, layout->contentItem());
QCOMPARE(anchors->right().item, layout->contentItem());
QCOMPARE(anchors->bottom().item, layout->contentItem());
QVERIFY(!anchors->fill());
QCOMPARE(anchors->margins(), 20.0);
root->setWidth(root->width() + 100);
layoutChangeSpy.wait(100);
QQuickItem *testLayout = view->findItem("testLayout");
QVERIFY(testLayout);
QCOMPARE(anchors->fill(), testLayout);
QVERIFY(!anchors->left().item);
QVERIFY(!anchors->top().item);
QVERIFY(!anchors->right().item);
QVERIFY(!anchors->bottom().item);
QCOMPARE(anchors->margins(), 0.0);
root->setWidth(root->width() - 100);
layoutChangeSpy.wait(100);
QCOMPARE(anchors->left().item, layout->contentItem());
QCOMPARE(anchors->top().item, layout->contentItem());
QCOMPARE(anchors->right().item, layout->contentItem());
QCOMPARE(anchors->bottom().item, layout->contentItem());
QVERIFY(!anchors->fill());
QCOMPARE(anchors->margins(), 20.0);
}
// the following tests guard bug #1280359
void testCase_ItemInstanceAsProperty()
{
UbuntuTestCase::ignoreWarning("ItemInstanceAsProperty.qml", 45, 17,
"QML ItemLayout: WARNING: item \"object2\" not specified or has been specified for layout by more than one active ItemLayout");
QScopedPointer view(loadTest("ItemInstanceAsProperty.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
QQuickItem *layout = testItem(root, "layoutManager");
QVERIFY(layout);
QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
// invoke layout change
view->rootObject()->metaObject()->invokeMethod(view->rootObject(), "changeLayout");
layoutChangeSpy.wait();
QCOMPARE(layoutChangeSpy.count(), 1);
}
void testCase_DialerCrash()
{
UbuntuTestCase::ignoreWarning("DialerCrash.qml", 45, 17,
"QML ItemLayout: WARNING: item \"object2\" not specified or has been specified for layout by more than one active ItemLayout");
QScopedPointer view(loadTest("DialerCrash.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
QQuickItem *layout = testItem(root, "layoutManager");
QVERIFY(layout);
QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
// invoke layout change
view->rootObject()->setProperty("wide", false);
layoutChangeSpy.wait();
QCOMPARE(layoutChangeSpy.count(), 1);
}
void testCase_ExcludedItemDeleted()
{
QScopedPointer view(loadTest("ExcludedItemDeleted.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
QQuickItem *layout = testItem(root, "layoutManager");
QVERIFY(layout);
QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
// invoke layout change
view->rootObject()->metaObject()->invokeMethod(view->rootObject(), "changeLayout");
layoutChangeSpy.wait();
QCOMPARE(layoutChangeSpy.count(), 1);
}
// guard bug #1204834 and #1300668
void testCase_Visibility()
{
QScopedPointer view(new UbuntuTestCase("Visibility.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *layout = view->findItem("layoutManager");
QVERIFY(layout);
QSignalSpy layoutChangeSpy(layout, SIGNAL(currentLayoutChanged()));
QQuickItem *defaultLayout = testItem(root, "DefaultLayout");
QVERIFY(defaultLayout);
// invoke layout change
view->rootObject()->metaObject()->invokeMethod(view->rootObject(), "portraitLayout");
layoutChangeSpy.wait(1000);
QCOMPARE(defaultLayout->parentItem(), layout->contentItem());
// despite of visible property binding, the visibility of the component is false
// while its parent is set to invisible
QCOMPARE(defaultLayout->isVisible(), false);
QCOMPARE(layout->contentItem()->isVisible(), false);
// change layout back
layoutChangeSpy.clear();
view->rootObject()->metaObject()->invokeMethod(view->rootObject(), "landscapeLayout");
layoutChangeSpy.wait(1000);
QCOMPARE(defaultLayout->parentItem(), layout->contentItem());
QCOMPARE(defaultLayout->isVisible(), true);
QCOMPARE(layout->contentItem()->isVisible(), true);
}
void testCase_NestedVisibility_data() {
QTest::addColumn("layoutFunction");
QTest::addColumn("layoutName");
QTest::newRow("portrait") << "tabletPortraitLayout" << "tabletPortrait";
QTest::newRow("landscape") << "tabletLandscapeLayout" << "tabletLandscape";
}
void testCase_NestedVisibility()
{
QFETCH(QString, layoutFunction);
QFETCH(QString, layoutName);
QScopedPointer view(new UbuntuTestCase("NestedVisibility.qml"));
QVERIFY(view);
QQuickItem *root = view->rootObject();
QVERIFY(root);
ULLayouts *mainLayout = view->findItem("mainLayout");
QVERIFY(mainLayout);
QQuickItem *red = testItem(mainLayout, "mainRed");
QVERIFY(red);
QQuickItem *green = testItem(mainLayout, "mainGreen");
QVERIFY(green);
QQuickItem *blue = testItem(mainLayout, "mainBlue");
QVERIFY(blue);
QQuickItem *magenta = testItem(mainLayout, "mainMagenta");
QVERIFY(magenta);
QQuickItem *hidden = testItem(mainLayout, "mainHidden");
QVERIFY(hidden);
QCOMPARE(hidden->isVisible(), false);
// default is phone layout, get layd out items' neighbors
QQuickItem *greenPrev = prevSibling(green);
QQuickItem *magentaPrev = prevSibling(magenta);
QSizeF greenSize(green->width(), green->height());
QSizeF magentaSize(magenta->width(), magenta->height());
// invoke tablet layout change
QSignalSpy mainLayoutChangeSpy(mainLayout, SIGNAL(currentLayoutChanged()));
view->rootObject()->metaObject()->invokeMethod(view->rootObject(), layoutFunction.toLocal8Bit().data());
mainLayoutChangeSpy.wait(1000);
// get the nested layout
ULLayouts *nestedLayout = qobject_cast(testItem(mainLayout, "nestedLayout"));
QVERIFY(nestedLayout);
QQuickItem *nestedActiveLayout = testItem(nestedLayout, layoutName);
QVERIFY(nestedActiveLayout);
QCOMPARE(red->isVisible(), false);
QCOMPARE(green->isVisible(), true);
QCOMPARE(blue->isVisible(), false);
QCOMPARE(magenta->isVisible(), true);
QCOMPARE(hidden->isVisible(), false);
// we cannot use findChild() to locate green and magenta boxes, as reparenting only
// changes the parentItem, not the parent object itself; therefore we only check if
// their container is in the layout
QVERIFY(hasChildItem(green, nestedActiveLayout));
QVERIFY(hasChildItem(magenta, nestedActiveLayout));
// go back to default layout of main
mainLayoutChangeSpy.clear();
view->rootObject()->metaObject()->invokeMethod(view->rootObject(), "phoneLayout");
mainLayoutChangeSpy.wait(1000);
QCOMPARE(red->isVisible(), true);
QCOMPARE(green->isVisible(), true);
QCOMPARE(blue->isVisible(), true);
QCOMPARE(magenta->isVisible(), true);
QCOMPARE(hidden->isVisible(), false);
QCOMPARE(prevSibling(green), greenPrev);
QCOMPARE(prevSibling(magenta), magentaPrev);
QCOMPARE(green->width(), greenSize.width());
QCOMPARE(green->height(), greenSize.height());
QCOMPARE(magenta->width(), magentaSize.width());
QCOMPARE(magenta->height(), magentaSize.height());
QVERIFY(hasChildItem(green, mainLayout->contentItem()));
QVERIFY(hasChildItem(magenta, mainLayout->contentItem()));
}
};
QTEST_MAIN(tst_Layouts)
#include "tst_layouts.moc"
./tests/unit_x11/tst_layouts/AnchorVerticalCenter.qml 0000644 0000156 0000165 00000002607 12700370701 023063 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Layouts 1.0
Rectangle {
id: root
width: 300
height: 360
Layouts {
objectName: "layoutManager"
id: layoutManager
anchors.fill: parent
layouts: [
ConditionalLayout {
name: "landscape"
when: root.width > root.height
ItemLayout {
objectName: "testLayout"
anchors.fill: parent
item: "test"
}
}
]
Rectangle {
width: 100
height: 100
color: "red"
objectName: "testItem"
Layouts.item: "test"
anchors.verticalCenter: parent.verticalCenter
}
}
}
./tests/unit_x11/tst_layouts/AnchorCenterWithOffset.qml 0000644 0000156 0000165 00000002716 12700370701 023375 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Layouts 1.0
Rectangle {
id: root
width: 300
height: 360
Layouts {
objectName: "layoutManager"
id: layoutManager
anchors.fill: parent
layouts: [
ConditionalLayout {
name: "landscape"
when: root.width > root.height
ItemLayout {
objectName: "testLayout"
anchors.fill: parent
item: "test"
}
}
]
Rectangle {
width: 100
height: 100
color: "red"
objectName: "testItem"
Layouts.item: "test"
anchors.centerIn: parent
anchors.verticalCenterOffset: 50
anchors.horizontalCenterOffset: 40
}
}
}
./tests/unit_x11/tst_layouts/CurrentLayoutChange.qml 0000644 0000156 0000165 00000002140 12700370701 022734 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Layouts 1.0
Rectangle {
id: root
width: 360
height: 360
Layouts {
objectName: "layoutManager"
id: layoutManager
layouts: [
ConditionalLayout {
name: "portrait"
when: root.width < root.height
},
ConditionalLayout {
name: "landscape"
when: root.width >= root.height
}
]
}
}
./tests/unit_x11/tst_test/ 0000755 0000156 0000165 00000000000 12700370701 015555 5 ustar jenkins jenkins ./tests/unit_x11/tst_test/tst_test.pro 0000644 0000156 0000165 00000000220 12700370701 020142 0 ustar jenkins jenkins TESTS += $$system(ls tst_*.qml)
include(../qmltest-include.pri)
TARGET = tst_test
SOURCES += tst_test.cpp
OTHER_FILES += $$system(ls *.qml)
./tests/unit_x11/tst_test/tst_test.cpp 0000644 0000156 0000165 00000001302 12700370701 020126 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
*/
#include
QUICK_TEST_MAIN(test)
./tests/unit_x11/tst_test/tst_ubuntutestcase.qml 0000644 0000156 0000165 00000021703 12700370701 022243 0 ustar jenkins jenkins /*
* Copyright 2012 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import QtTest 1.0
import Ubuntu.Test 1.0
import Ubuntu.Components 1.0
Rectangle {
id: root
width: 800
height: 1000
Column {
anchors.fill: parent
MultiPointTouchArea {
id: topTouchArea
width: parent.width
height: 100
touchPoints: TouchPoint {
// id: point
}
}
MouseArea {
id: mouseArea
objectName: "myMouseArea"
width: parent.width
height: 200
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
property int testX : 0
property int testY : 0
property int steps : 0
onPositionChanged: {
testX = mouseX;
testY = mouseY;
steps++;
}
}
MultiPointTouchArea {
id: touchArea
width: parent.width
height: 100
touchPoints: TouchPoint {
id: point
}
}
Flickable {
id: flicker
width: parent.width
height: 400
contentWidth: rect.width
contentHeight: rect.height
clip: true
Rectangle {
id: rect
color: "blue"
width: 1000
height: 1000
}
}
TextField {
id: textField
}
}
UbuntuTestCase {
name: "TestTheUbuntuTestCase"
when: windowShown
function initTestCase() {
TestExtras.registerTouchDevice();
}
function init() {
mouseArea.steps = 0;
}
function cleanup() {
movementSpy.clear();
longPressSpy.clear();
touchPressSpy.clear();
touchReleaseSpy.clear();
touchUpdateSpy.clear();
touchPressSpy.target = null;
touchReleaseSpy.target = null;
touchUpdateSpy.target = null;
}
function test_mouseMoveSlowly() {
mouseMoveSlowly(mouseArea,0,0,800,200,10,100);
compare(mouseArea.testX,800);
compare(mouseArea.testY,200);
compare(mouseArea.steps,10);
}
function test_findChild() {
var child = findChild(root,"myMouseArea");
compare(child!==null,true, "When a child is found, it is returned");
compare(child.objectName,"myMouseArea");
child = findChild(root,"NoSuchChildHere");
compare(child===null,true,"When there is no child, function should return null");
}
SignalSpy {
id: longPressSpy
target: mouseArea
signalName: "onPressAndHold"
}
function test_longPress_left() {
longPressSpy.clear();
mouseLongPress(mouseArea, mouseArea.width / 2, mouseArea.height / 2);
longPressSpy.wait();
// cleanup
mouseRelease(mouseArea, mouseArea.width / 2, mouseArea.height / 2);
}
function test_longPress_right() {
longPressSpy.clear();
mouseLongPress(mouseArea, mouseArea.width / 2, mouseArea.height / 2, Qt.RightButton);
longPressSpy.wait();
// cleanup
mouseRelease(mouseArea, mouseArea.width / 2, mouseArea.height / 2, Qt.RightButton);
}
function test_longPress_middle() {
longPressSpy.clear();
mouseLongPress(mouseArea, mouseArea.width / 2, mouseArea.height / 2, Qt.MiddleButton);
longPressSpy.wait();
// cleanup
mouseRelease(mouseArea, mouseArea.width / 2, mouseArea.height / 2, Qt.MiddleButton);
}
SignalSpy {
id: movementSpy
target: flicker
signalName: "onMovementEnded"
}
function test_flick_default() {
flick(flicker, 0, 0, flicker.width, flicker.height);
movementSpy.wait();
}
function test_flick_long() {
flick(flicker, 0, 0, flicker.width, flicker.height, -1, 10);
movementSpy.wait();
}
function test_flick_short() {
flick(flicker, 0, 0, flicker.width, flicker.height, -1, 1);
movementSpy.wait();
}
function test_flick_pressTimeout() {
flick(flicker, 0, 0, flicker.width, flicker.height, 400);
movementSpy.wait();
}
function test_flick_pressTimeout_short() {
flick(flicker, flicker.width, flicker.height, -flicker.width, -flicker.height, 400, 1);
movementSpy.wait();
}
function test_flick_pressTimeout_long() {
flick(flicker, flicker.width, flicker.height, -flicker.width, -flicker.height, 400, 100);
movementSpy.wait();
}
function test_typeString() {
textField.forceActiveFocus();
typeString("Hello Ubuntu");
tryCompare(textField, "text", "Hello Ubuntu");
}
SignalSpy {
id: touchPressSpy
signalName: "onPressed"
target: touchArea
}
SignalSpy {
id: touchReleaseSpy
signalName: "onReleased"
target: touchArea
}
SignalSpy {
id: touchUpdateSpy
signalName: "onUpdated"
target: touchArea
}
function test_has_property() {
verify(TestExtras.hasOwnProperty("touchPresent"), "touchPresent property missing");
}
function test_touchPress_data() {
return [
{touch: touchArea},
{touch: topTouchArea}
];
}
function test_touchPress(data) {
touchPressSpy.target = data.touch;
TestExtras.touchPress(0, data.touch, Qt.point(10, 10));
touchPressSpy.wait();
// cleanup
TestExtras.touchRelease(0, data.touch, Qt.point(10, 10));
}
function test_touchRelease_data() {
return [
{touch: touchArea},
{touch: topTouchArea}
];
}
function test_touchRelease(data) {
// prerequisite: do a press so we get a release
TestExtras.touchPress(0, data.touch, Qt.point(10, 10));
touchReleaseSpy.target = data.touch;
TestExtras.touchRelease(0, data.touch, Qt.point(10, 10));
touchReleaseSpy.wait();
}
function test_touchClick_data() {
return [
{touch: touchArea},
{touch: topTouchArea}
];
}
function test_touchClick(data) {
touchPressSpy.target = data.touch;
touchReleaseSpy.target = data.touch;
TestExtras.touchClick(0, data.touch, Qt.point(10, 10));
touchReleaseSpy.wait();
compare(touchPressSpy.count, 1, "Not pressed?");
compare(touchReleaseSpy.count, 1, "Not released?");
}
function test_touchDoubleClick_data() {
return [
{touch: touchArea},
{touch: topTouchArea}
];
}
function test_touchDoubleClick(data) {
touchPressSpy.target = data.touch;
touchReleaseSpy.target = data.touch;
TestExtras.touchDoubleClick(0, data.touch, Qt.point(10, 10));
compare(touchPressSpy.count, 2, "Not pressed twice?");
compare(touchReleaseSpy.count, 2, "Not released twice?");
}
function test_touchMove_data() {
return [
{touch: touchArea},
{touch: topTouchArea}
];
}
function test_touchMove(data) {
touchUpdateSpy.target = data.touch;
TestExtras.touchPress(0, data.touch, Qt.point(0, 0));
TestExtras.touchMove(0, data.touch, Qt.point(10, 10));
touchUpdateSpy.wait();
TestExtras.touchRelease(0, data.touch, Qt.point(10, 10));
}
function test_touchDrag_default_steps_data() {
return [
{touch: touchArea},
{touch: topTouchArea}
];
}
function test_touchDrag_default_steps(data) {
touchPressSpy.target = data.touch;
touchReleaseSpy.target = data.touch;
touchUpdateSpy.target = data.touch;
TestExtras.touchDrag(0, data.touch, Qt.point(0, 0), Qt.point(10, 10));
compare(touchPressSpy.count, 1, "Not pressed?");
compare(touchReleaseSpy.count, 1, "Not released?");
compare(touchUpdateSpy.count, 5, "Not moved?");
}
function test_touchDrag_10_steps_data() {
return [
{touch: touchArea},
{touch: topTouchArea}
];
}
function test_touchDrag_10_steps(data) {
touchPressSpy.target = data.touch;
touchReleaseSpy.target = data.touch;
touchUpdateSpy.target = data.touch;
TestExtras.touchDrag(0, data.touch, Qt.point(0, 0), Qt.point(100, 100), 10);
compare(touchPressSpy.count, 1, "Not pressed?");
compare(touchReleaseSpy.count, 1, "Not released?");
compare(touchUpdateSpy.count, 10, "Not moved?");
}
}
}
./tests/unit_x11/tst_ubuntu_shape/ 0000755 0000156 0000165 00000000000 12700370701 017300 5 ustar jenkins jenkins ./tests/unit_x11/tst_ubuntu_shape/no_distortion_expected.png 0000644 0000156 0000165 00000010370 12700370701 024562 0 ustar jenkins jenkins PNG
IHDR t sBITO tEXtSoftware gnome-screenshot> IDATxݱwB6f)-+"^U.x
k.(HRmnL@wFXFwf>eYl 8\( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1,CnGW/_|w}_?o_^^^^^O͛o~7zw}~7oܸ>ݎEyXlqJrJY>|WUT*Ç?>hX>9B?8pOχso~'ܺu+}Q*Dv;<}zzz>cgϞ
S ٳgC\1F8;;K8^c_~%} zmQ*^x>pJ6(@^J8^c?#} zmQ*P1Fl?IJ6( 1oiT*Sʲz@RujjJR9,T*]ld 1
@1
@1
@1
@1
@1
@1
@1
@1
@1
@1
@2}XT*erJrlT*ieY\R\e& Q bQ bQ bQ bQ bQ bQ bQ bQ bQ bQ bhJR9,T*]ΠݴeRTN+Je-G7 =g c c c c c c c c c c L`G4V*)eY\R\5p-JrZYV/T*.m<* 9c c c c c c c c c c c e ;ڧRTN)Je35F7m٨T*ʲz@RunQM ` ,>JrJYV/T*.WA1iFRV*ʮu[6o2 { f>iT*Sʲz@RujjM[6*J崲^.PTv]۲yT~ s( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1vOcRR*ʮUgPknڲQT*erJrݖͣ 3F 1F 1F 1F 1F 1F 1F 1F 1F 1F 1F Y}+J唲^.PTv]?8ZctӖJR9,T*]ld 1
@1
@1
@1
@1
@1
@1
@1
@1
@1
@1
@2}XT*erJrlT*ieY\R\e& Q bQ bQ bQ bQ bQ bQ bQ bQ bQ bQ bhJR9,T*]ΠݴeRTN+Je-G7 =g c c c c c c c c c c L`G4V*)eY\R\5p-JrZYV/T*.m<* 9c c c c c c c c c c c e ;ڧRTN)Je35F7m٨T*ʲz@RunQM ` ,>JrJYV/T*.WA1iFRV*ʮu[6o2 { f>iT*Sʲz@RujjM[6*J崲^.PTv]۲yT~ s( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1vOcRR*ʮUgPknڲQT*erJrݖͣ 3F 1F 1F 1F 1F 1F 1F 1F 1F 1F 1F Y}+J唲^.PTv]?8ZctӖJR9,T*]ld 1
@1
@1
@1
@1
@1
@1
@1
@1
@1
@1
@2}XT*erJrlT*ieY\R\e& Q bQ bQ bQ bQ bQ bQ bQ bQ bQ bQ bhJR9,T*]ΠݴeRTN+Je-G7 =g c c c c c c c c c c L`G4V*)eY\R\5p-JrZYV/T*.m<* 9c c c c c c c c c c c e ;ڧRTN)Je35F7m٨T*ʲz@RunQM ` ,>JrJYV/T*.WA1iFRV*ʮu[6o2 { f>iT*Sʲz@RujjM[6*J崲^.PTv]۲yT~ s( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1( 1vOcRR*ʮUgPknڲQT*erJrݖͣ 3F 1F 1F 1F 1F 1F 1F 1F 1F 1F 1F Y}+J唲^.PTv]?8ZctӖJR9,T*]ld 1
PQA( U,~u
W^ck R1
PG B# kcT믧 R1
PŽ{ѳ{C\TΝ)}w҇bTqrrxp\}sÓ9 Uܿxhqr2ܼ>n\ݿ?}+)[.oggëWs~}qw>pxR~ngbH8u짟~_|l.//Gptt47_{[nݹsݻS1
; ?n\^$ IENDB` ./tests/unit_x11/tst_ubuntu_shape/no_distortion.qml 0000644 0000156 0000165 00000002014 12700370701 022702 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Components 1.1
Item {
width: 900
height: 500
Row {
spacing: 50
anchors.centerIn: parent
Image {
id: grid
source: "no_distortion_source.png"
}
Shape {
id: shape
width: grid.width
height: grid.height
image: grid
}
}
}
./tests/unit_x11/tst_ubuntu_shape/tst_ubuntu_shape.cpp 0000644 0000156 0000165 00000003605 12700370701 023404 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Florian Boucault
*/
#include
#include
#include
class tst_UbuntuShape: public QObject
{
Q_OBJECT
private:
QQuickView *m_quickView;
private Q_SLOTS:
void initTestCase()
{
m_quickView = new QQuickView;
m_quickView->setGeometry(0, 0, 900, 500);
m_quickView->show();
// add modules folder so we have access to the plugin from QML
QQmlEngine *engine = m_quickView->engine();
QString modules(UBUNTU_QML_IMPORT_PATH);
QStringList imports = engine->importPathList();
imports.prepend(QDir(modules).absolutePath());
engine->setImportPathList(imports);
}
void noDistortion() {
QSKIP("This test passes on local machines but not in CI as it requires working OpenGL");
m_quickView->setSource(QUrl::fromLocalFile("no_distortion.qml"));
QCoreApplication::processEvents();
QImage result = m_quickView->grabWindow();
QVERIFY(!result.isNull());
QImage expected = QImage("no_distortion_expected.png");
QVERIFY(!expected.isNull());
QCOMPARE(result, expected);
}
};
QTEST_MAIN(tst_UbuntuShape)
#include "tst_ubuntu_shape.moc"
./tests/unit_x11/tst_ubuntu_shape/tst_ubuntu_shape.pro 0000644 0000156 0000165 00000000264 12700370701 023420 0 ustar jenkins jenkins include(../test-include.pri)
SOURCES += tst_ubuntu_shape.cpp
OTHER_FILES += no_distortion.qml \
no_distortion_source.png \
no_distortion_expected.png
./tests/unit_x11/tst_ubuntu_shape/no_distortion_source.png 0000644 0000156 0000165 00000002616 12700370701 024265 0 ustar jenkins jenkins PNG
IHDR { n `%# bKGD pHYs tIME223[ %tEXtComment clip2gif 0.7.2 by Yves Piguet@ IDATxܱ 1ñTؑz.$ 0$O;;;;ӽ' b = b = yKy^K = = b = b = e|8K;;;z { @{ @ ziggg_/ b = b = _/% @{ @{ { 2^륝]|`= b = b b /.^0@ @{ @{ @(%^K = = b = b = e|8K;;;z { @{ @ ziggg_/ b = b = _/% @{ @{ { 2^륝]|`= b = b bPK| { @{ @{ @{ z pvvvvb = b = b= b@_/.^0@ @{ @{ @(%^K = = b = b = e|8K;;;z { @{ @ ziggg_/ b = b = _/% @{ @{ { 2^륝]|`= b = b bPK| { @{ @{ @{ z pvvvvb = b = b= b@_/.^0@ @{ @{ @(%^K = = b = b = e|8K;;;z { @{ @ ziggg_/ b = b = /UjN IENDB` ./tests/unit_x11/tst_orientation/ 0000755 0000156 0000165 00000000000 12700370701 017131 5 ustar jenkins jenkins ./tests/unit_x11/tst_orientation/tst_orientation.cpp 0000644 0000156 0000165 00000004407 12700370701 023067 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Christian Dywan
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "uctestcase.h"
class tst_OrientationTest : public QObject
{
Q_OBJECT
public:
tst_OrientationTest() {}
private Q_SLOTS:
void test_defaults()
{
QScopedPointer testCase(new UbuntuTestCase("Defaults.qml"));
QQuickItem *helper = testCase->findItem("helper");
QCOMPARE(helper->property("automaticOrientation").toBool(), true);
// No warnings expected
QCOMPARE(testCase->warnings(), 0);
}
void test_manualAngle()
{
QScopedPointer testCase(new UbuntuTestCase("ManualAngle.qml"));
QQuickItem *helper = testCase->findItem("helper");
// No warning about "window" being undefined must appear
QSKIP("TypeError: Cannot set property 'contentOrientation' of null");
QCOMPARE(testCase->warnings(), 0);
QCOMPARE(helper->property("orientationAngle").toInt(), 90);
// Verify expected values
QQuickItem *checkpoint = testCase->findItem("checkpoint");
// window.contentOrientation
QCOMPARE(checkpoint->property("contentOrientation").toInt(), helper->property("orientationAngle").toInt());
}
};
QTEST_MAIN(tst_OrientationTest)
#include "tst_orientation.moc"
./tests/unit_x11/tst_orientation/Defaults.qml 0000644 0000156 0000165 00000001434 12700370701 021415 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Components 1.1
Item {
width: 100
height: 100
OrientationHelper {
objectName: "helper"
}
}
./tests/unit_x11/tst_orientation/tst_orientation.pro 0000644 0000156 0000165 00000000243 12700370701 023077 0 ustar jenkins jenkins include(../test-include.pri)
DEFINES += SRCDIR=\\\"$$PWD/\\\"
SOURCES += \
tst_orientation.cpp
OTHER_FILES += \
Defaults.qml \
ManualOrientation.qml
./tests/unit_x11/tst_orientation/ManualAngle.qml 0000644 0000156 0000165 00000001760 12700370701 022034 0 ustar jenkins jenkins /*
* Copyright 2013 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import Ubuntu.Components 1.1
import QtQuick.Window 2.0
Item {
width: 100
height: 100
OrientationHelper {
objectName: "helper"
orientationAngle: 90
}
Window {
id: window
}
Item {
objectName: "checkpoint"
property int contentOrientation: window.contentOrientation
}
}
./tests/unit_x11/tst_subtheming/ 0000755 0000156 0000165 00000000000 12700370716 016751 5 ustar jenkins jenkins ./tests/unit_x11/tst_subtheming/ChangeDefaultPaletteInChildren.qml 0000644 0000156 0000165 00000002055 12700370701 025431 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
import Ubuntu.Components.Themes 1.3
StyledItem {
theme.objectName: "MasterTheme"
Loader {
objectName: "loader"
anchors.fill: parent
sourceComponent: dynamicItem
}
Component {
id: dynamicItem
StyledItem {
theme.palette: Palette {
normal.background: "blue"
}
}
}
}
./tests/unit_x11/tst_subtheming/ParentChanges.qml 0000644 0000156 0000165 00000002100 12700370701 022171 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
StyledItem {
objectName: "main"
width: units.gu(40)
height: units.gu(71)
theme: ThemeSettings{ objectName: "top" }
Item {
anchors.fill: parent
StyledItem {
objectName: "testItem"
theme: ThemeSettings {
objectName: "testSet"
name: "Ubuntu.Components.Themes.SuruDark"
}
}
}
}
./tests/unit_x11/tst_subtheming/StyleHintsElsewhere.qml 0000644 0000156 0000165 00000001444 12700370701 023433 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
Item {
width: units.gu(40)
height: units.gu(71)
StyleHints {
anyProperty: true
}
}
./tests/unit_x11/tst_subtheming/TestStyleChange.qml 0000644 0000156 0000165 00000004133 12700370701 022525 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
StyledItem {
width: units.gu(40)
height: units.gu(71)
objectName: "mainStyled"
ThemeSettings {
objectName: "Theme"
}
Component {
id: dynamicComponent
Item {
property alias nestedStyled: innerItem
StyledItem {
id: innerItem
anchors.fill: parent
}
}
}
Column {
objectName: "simpleColumn"
anchors.fill: parent
StyledItem {
objectName: "firstLevelStyled"
width: parent.width
height: units.gu(20)
Item {
anchors.fill: parent
objectName: "simpleItem"
StyledItem {
objectName: "secondLevelStyled"
anchors.fill: parent
Loader {
objectName: "thirdLevelLoader"
anchors.fill: parent
onItemChanged: if (item) item.nestedStyled.objectName = "thirdLevelLoaderStyled"
sourceComponent: dynamicComponent
}
}
}
}
Loader {
objectName: "firstLevelLoader"
width: parent.width
height: units.gu(40)
onItemChanged: if (item) item.nestedStyled.objectName = "firstLevelLoaderStyled"
sourceComponent: dynamicComponent
}
}
}
./tests/unit_x11/tst_subtheming/themes/ 0000755 0000156 0000165 00000000000 12700370716 020236 5 ustar jenkins jenkins ./tests/unit_x11/tst_subtheming/themes/TestModule/ 0000755 0000156 0000165 00000000000 12700370701 022315 5 ustar jenkins jenkins ./tests/unit_x11/tst_subtheming/themes/TestModule/TestTheme/ 0000755 0000156 0000165 00000000000 12700370701 024217 5 ustar jenkins jenkins ./tests/unit_x11/tst_subtheming/themes/TestModule/TestTheme/1.3/ 0000755 0000156 0000165 00000000000 12700370701 024520 5 ustar jenkins jenkins ./tests/unit_x11/tst_subtheming/themes/TestModule/TestTheme/1.3/TestStyle.qml 0000644 0000156 0000165 00000001356 12700370701 027200 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
Item {
objectName: "TestStyle"
property string newProperty: "version1.3"
}
./tests/unit_x11/tst_subtheming/themes/TestModule/TestTheme/1.2/ 0000755 0000156 0000165 00000000000 12700370701 024517 5 ustar jenkins jenkins ./tests/unit_x11/tst_subtheming/themes/TestModule/TestTheme/1.2/TestStyle.qml 0000644 0000156 0000165 00000001300 12700370701 027164 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
Item {
objectName: "TestStyle"
}
./tests/unit_x11/tst_subtheming/themes/TestModule/TestTheme/qmldir 0000644 0000156 0000165 00000000143 12700370701 025430 0 ustar jenkins jenkins module TestTheme
TestStyle 1.0 ./1.2/TestStyle.qml
#version 1.3
TestStyle 1.3 ./1.3/TestStyle.qml
./tests/unit_x11/tst_subtheming/themes/CustomTheme/ 0000755 0000156 0000165 00000000000 12700370701 022465 5 ustar jenkins jenkins ./tests/unit_x11/tst_subtheming/themes/CustomTheme/1.3/ 0000755 0000156 0000165 00000000000 12700370701 022766 5 ustar jenkins jenkins ./tests/unit_x11/tst_subtheming/themes/CustomTheme/1.3/TestStyle.qml 0000644 0000156 0000165 00000001317 12700370701 025443 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import TestTheme 1.3 as Parent
Parent.TestStyle {
}
./tests/unit_x11/tst_subtheming/themes/CustomTheme/Palette.qml 0000644 0000156 0000165 00000001752 12700370701 024603 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
import Ubuntu.Components.Themes.Ambiance 1.3 as Suru
Suru.Palette {
normal.selection: "#A21E1C"
selected.selection: "#1C1EA2"
selected.base: "lightblue"
selected.baseText: "pink"
selected.overlay: "#ABCDEF"
selected.overlayText: "#FEDCBA"
selected.fieldText: UbuntuColors.red
}
./tests/unit_x11/tst_subtheming/themes/CustomTheme/TestStyle.qml 0000644 0000156 0000165 00000001317 12700370701 025142 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
import TestTheme 1.0 as Parent
Parent.TestStyle {
}
./tests/unit_x11/tst_subtheming/themes/CustomTheme/parent_theme 0000644 0000156 0000165 00000000012 12700370701 025054 0 ustar jenkins jenkins TestTheme
./tests/unit_x11/tst_subtheming/themes/DerivedTheme/ 0000755 0000156 0000165 00000000000 12700370716 022603 5 ustar jenkins jenkins ./tests/unit_x11/tst_subtheming/themes/DerivedTheme/1.3/ 0000755 0000156 0000165 00000000000 12700370714 023102 5 ustar jenkins jenkins ./tests/unit_x11/tst_subtheming/themes/DerivedTheme/1.3/Palette.qml 0000644 0000156 0000165 00000002001 12700370714 025204 0 ustar jenkins jenkins /*
* Copyright 2016 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
import Ubuntu.Components.Themes.Ambiance 1.3 as Suru
Suru.Palette {
normal.selection: UbuntuColors.orange
selected.selection: UbuntuColors.lightGrey
selected.base: "lightblue"
selected.baseText: "pink"
selected.overlay: "#ABCDEF"
selected.overlayText: "#FEDCBA"
selected.fieldText: UbuntuColors.red
}
./tests/unit_x11/tst_subtheming/themes/DerivedTheme/1.2/ 0000755 0000156 0000165 00000000000 12700370714 023101 5 ustar jenkins jenkins ./tests/unit_x11/tst_subtheming/themes/DerivedTheme/1.2/TestStyle.qml 0000644 0000156 0000165 00000001300 12700370714 025546 0 ustar jenkins jenkins /*
* Copyright 2016 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.0
Item {
objectName: "TestStyle"
}
./tests/unit_x11/tst_subtheming/themes/DerivedTheme/parent_theme 0000644 0000156 0000165 00000000012 12700370714 025170 0 ustar jenkins jenkins TestTheme
./tests/unit_x11/tst_subtheming/themes/BuggyTheme/ 0000755 0000156 0000165 00000000000 12700370701 022270 5 ustar jenkins jenkins ./tests/unit_x11/tst_subtheming/themes/BuggyTheme/Palette.qml 0000644 0000156 0000165 00000001512 12700370701 024400 0 ustar jenkins jenkins /*
* Copyright 2016 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
import Ubuntu.Components.Themes 1.3
Palette {
normal.selection: "#A21E1C"
selected.selection: "#1C1EA2"
imaginary.selection: "pink"
}
./tests/unit_x11/tst_subtheming/ChangePaletteValueWhenParentChanges.qml 0000644 0000156 0000165 00000002037 12700370701 026446 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
import Ubuntu.Components.Themes 1.3
// the style of the root object will be changed
StyledItem {
theme.objectName: "MasterTheme"
StyledItem {
theme: ThemeSettings {
objectName: "firstTheme"
name: parentTheme.name
palette: Palette {
normal.background: "blue"
}
}
}
}
./tests/unit_x11/tst_subtheming/PropertyBindingHints.qml 0000644 0000156 0000165 00000001617 12700370701 023610 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
Item {
width: units.gu(40)
height: units.gu(71)
Button {
objectName: "Button"
id: button
StyleHints {
defaultColor: button.pressed ? "tan" : "blue"
}
}
}
./tests/unit_x11/tst_subtheming/MoreStyleHints.qml 0000644 0000156 0000165 00000001653 12700370701 022414 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
Item {
width: units.gu(40)
height: units.gu(71)
Button {
objectName: "Button"
StyleHints {
minimumWidth: units.gu(20)
}
StyleHints {
defaultColor: "brown"
}
}
}
./tests/unit_x11/tst_subtheming/GroupPropertyBindingHints.qml 0000644 0000156 0000165 00000001713 12700370701 024622 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
Item {
width: units.gu(40)
height: units.gu(71)
HintedButton {
objectName: "Button"
id: button
gradient: UbuntuColors.greyGradient
StyleHints {
gradientProxy.topColor: button.pressed ? "tan" : "blue"
}
}
}
./tests/unit_x11/tst_subtheming/SameNamedPaletteSettings.qml 0000644 0000156 0000165 00000002176 12700370701 024356 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
import Ubuntu.Components.Themes 1.3
Item {
StyledItem {
theme: ThemeSettings {
objectName: "firstTheme"
name: "Ubuntu.Components.Themes.SuruDark"
palette: Palette{
normal.background: UbuntuColors.red
}
}
}
StyledItem {
theme: ThemeSettings {
objectName: "secondTheme"
name: "Ubuntu.Components.Themes.SuruDark"
}
}
}
./tests/unit_x11/tst_subtheming/SimplePropertyHints.qml 0000644 0000156 0000165 00000001543 12700370701 023465 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
Item {
width: units.gu(40)
height: units.gu(71)
Button {
objectName: "Button"
StyleHints {
defaultColor: "blue"
}
}
}
./tests/unit_x11/tst_subtheming/StyledItemAppThemeVersioned.qml 0000644 0000156 0000165 00000001423 12700370701 025044 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
StyledItem {
id: item
theme.name: "themes.CustomTheme"
styleName: "TestStyle"
}
./tests/unit_x11/tst_subtheming/HintedButton.qml 0000644 0000156 0000165 00000001375 12700370701 022073 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
Button {
StyleHints {
minimumWidth: units.gu(20)
}
}
./tests/unit_x11/tst_subtheming/DynamicAssignment.qml 0000644 0000156 0000165 00000002032 12700370701 023070 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
StyledItem {
objectName: "main"
width: units.gu(40)
height: units.gu(71)
theme: ThemeSettings{ objectName: "top" }
ThemeSettings {
objectName: "testSet"
name: "Ubuntu.Components.Themes.SuruDark"
}
Item {
anchors.fill: parent
StyledItem {
objectName: "testItem"
}
}
}
./tests/unit_x11/tst_subtheming/InvalidPalette.qml 0000644 0000156 0000165 00000001362 12700370701 022365 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
StyledItem {
id: item
theme.palette: QtObject{}
}
./tests/unit_x11/tst_subtheming/DefaultTheme.qml 0000644 0000156 0000165 00000001442 12700370701 022026 0 ustar jenkins jenkins /*
* Copyright 2016 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
Label {
id: label
width: 400
height: width
text: "HOLA"
Label { }
Button { }
}
./tests/unit_x11/tst_subtheming/StyleHintsInvalidProperty.qml 0000644 0000156 0000165 00000001560 12700370701 024642 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
Item {
width: units.gu(40)
height: units.gu(71)
Button {
StyleHints {
ignoreUnknownProperties: false
invalidProperty: 10
}
}
}
./tests/unit_x11/tst_subtheming/DeprecatedTheme.qml 0000644 0000156 0000165 00000001541 12700370701 022502 0 ustar jenkins jenkins /*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import QtQuick 2.4
import Ubuntu.Components 1.3
StyledItem {
id: item
width: units.gu(40)
height: units.gu(40)
theme.name: "Ubuntu.Components.Themes.SuruGradient"
styleName: "OptionSelectorStyle"
}
./tests/unit_x11/tst_subtheming/tst_subtheming.cpp 0000644 0000156 0000165 00000114032 12700370714 022513 0 ustar jenkins jenkins /*
* Copyright 2016 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
*/
#include
#include
#include
#include
#include
#define private public
#define protected public
#include "uctheme.h"
#undef protected
#undef private
#include "quickutils.h"
#include "uctestcase.h"
#include "ucstyleditembase_p.h"
#include "ucnamespace.h"
#include "ucunits.h"
#include "uclabel.h"
#include "plugin.h"
class ThemeTestCase : public UbuntuTestCase
{
Q_OBJECT
public:
ThemeTestCase(const QString& file, bool assertOnFailure = true, QWindow* parent = 0)
: UbuntuTestCase(file, QQuickView::SizeViewToRootObject, assertOnFailure, parent)
{
}
~ThemeTestCase()
{
// restore theme before quitting
if (!rootContext()) {
return;
}
UCTheme *theme = globalTheme();
if (theme) {
theme->resetName();
} else {
qWarning() << "No theme instance found!";
}
}
void setGlobalTheme(const QString &theme)
{
UCTheme *rootTheme = globalTheme();
QVERIFY(rootTheme);
rootTheme->setName(theme);
}
void setTheme(const QString &theme, QQuickItem *watchedItem)
{
QSignalSpy spy(watchedItem, SIGNAL(themeChanged()));
rootObject()->setProperty("themeName", theme);
waitForSignal(&spy);
}
UCTheme *theme()
{
return rootObject()->property("theme").value();
}
UCTheme *globalTheme()
{
return rootContext()->contextProperty("theme").value();
}
};
class tst_Subtheming : public QObject
{
Q_OBJECT
private:
QString m_xdgDataPath;
QString m_themesPath;
private Q_SLOTS:
void initTestCase()
{
m_xdgDataPath = QLatin1String(getenv("XDG_DATA_DIRS"));
m_themesPath = QLatin1String(getenv("UBUNTU_UI_TOOLKIT_THEMES_PATH"));
qputenv("SUPPRESS_DEPRECATED_NOTE", "yes");
}
void cleanup()
{
qputenv("UBUNTU_UI_TOOLKIT_THEMES_PATH", m_themesPath.toLatin1());
qputenv("XDG_DATA_DIRS", m_xdgDataPath.toLocal8Bit());
UCTheme::previousVersion = 0;
}
void test_default_theme()
{
QQmlEngine engine;
UbuntuComponentsPlugin::initializeContextProperties(&engine);
UCTheme::defaultTheme(&engine);
}
void test_default_name()
{
UCTheme theme;
QCOMPARE(theme.name(), QString("Ubuntu.Components.Themes.Ambiance"));
}
void test_name_set()
{
QTest::ignoreMessage(QtWarningMsg, "Theme not found: \"MyBeautifulTheme\"");
UCTheme theme;
theme.setName("MyBeautifulTheme");
QCOMPARE(theme.name(), QString("MyBeautifulTheme"));
}
void test_name_reset()
{
UCTheme theme;
theme.setName("Ubuntu.Components.Themes.SuruDark");
QCOMPARE(theme.name(), QString("Ubuntu.Components.Themes.SuruDark"));
// reset
theme.resetName();
QCOMPARE(theme.name(), QString("Ubuntu.Components.Themes.Ambiance"));
}
void test_create_without_engine()
{
QTest::ignoreMessage(QtCriticalMsg, "The item UCLabel was created without a valid QML Engine. Styling will not be possible.");
QScopedPointer item(new UCLabel);
QVERIFY(!item->getTheme());
}
void test_default_theme_cleared_with_engine_bug1527546()
{
qputenv("QV4_FORCE_INTERPRETER", "1");
qputenv("QV4_MM_AGGRESSIVE_GC", "1");
for (int i = 0; i < 2; i++)
{
ThemeTestCase *view = new ThemeTestCase("DefaultTheme.qml");
QVERIFY(view->globalTheme());
QVERIFY(UCTheme::defaultTheme(view->engine()));
QObjectCleanupHandler themeCleanup;
themeCleanup.add(UCTheme::defaultTheme(view->engine()));
delete view;
QVERIFY(themeCleanup.isEmpty());
}
}
void test_multiple_view_instances_bug1527546()
{
qputenv("QV4_FORCE_INTERPRETER", "1");
qputenv("QV4_MM_AGGRESSIVE_GC", "1");
QScopedPointer view1(new ThemeTestCase("DefaultTheme.qml"));
QScopedPointer view2(new ThemeTestCase("DefaultTheme.qml"));
// the two views must have different default themes
QVERIFY(view1->globalTheme() != view2->globalTheme());
}
void test_multiple_themes_on_engine_bug1527546()
{
qputenv("QV4_FORCE_INTERPRETER", "1");
qputenv("QV4_MM_AGGRESSIVE_GC", "1");
QQmlEngine engine;
UbuntuComponentsPlugin::initializeContextProperties(&engine);
UCTheme *theme0 = UCTheme::defaultTheme(&engine);
UCTheme *theme1 = new UCTheme(&engine);
QVERIFY(theme0 != theme1);
}
void test_create_style_component_data() {
QTest::addColumn("styleName");
QTest::addColumn("parentName");
QTest::addColumn("success");
QTest::addColumn("warning");
QTest::newRow("Existing style") << "TestStyle" << "SimpleItem.qml" << true << QString();
QTest::newRow("Non existing style") << "NotExistingTestStyle" << "SimpleItem.qml" << false << "QML SimpleItem: Warning: Style NotExistingTestStyle.qml not found in theme TestModule.TestTheme";
}
void test_create_style_component()
{
QFETCH(QString, styleName);
QFETCH(QString, parentName);
QFETCH(bool, success);
QFETCH(QString, warning);
if (!warning.isEmpty()) {
ThemeTestCase::ignoreWarning(parentName, 20, 1, warning);
}
qputenv("UBUNTU_UI_TOOLKIT_THEMES_PATH", "./themes");
QScopedPointer view(new ThemeTestCase(parentName));
view->setTheme("TestModule.TestTheme", view->rootObject());
view->rootObject()->setProperty("styleName", styleName);
QQuickItem *testStyle = view->rootObject()->findChild("TestStyle");
QCOMPARE(testStyle != NULL, success);
}
void test_relative_theme_paths_environment_variables_data()
{
QTest::addColumn("themePath");
QTest::addColumn("xdgPath");
QTest::addColumn("theme");
QTest::addColumn("style");
QTest::addColumn("warning");
QTest::addColumn("success");
QTest::newRow("One toolkit theme path")
<< "./themes" << ""
<< "TestModule.TestTheme" << "TestStyle"
<< "" << true;
QTest::newRow("Two toolkit theme paths")
<< "./themes:./themes/TestModule" << ""
<< "CustomTheme" << "TestStyle"
<< "" << true;
QTest::newRow("One XDG path")
<< "" << "./themes"
<< "TestModule.TestTheme" << "TestStyle"
<< "" << true;
QTest::newRow("Two XDG paths")
<< "" << "./themes:./themes/TestModule"
<< "CustomTheme" << "TestStyle"
<< "" << true;
QTest::newRow("No variables")
<< "" << ""
<< QString() << "TestStyle"
<< "QML SimpleItem: Warning: Style TestStyle.qml not found in theme Ubuntu.Components.Themes.Ambiance" << false;
}
void test_relative_theme_paths_environment_variables()
{
QFETCH(QString, themePath);
QFETCH(QString, xdgPath);
QFETCH(QString, theme);
QFETCH(QString, style);
QFETCH(QString, warning);
QFETCH(bool, success);
if (!warning.isEmpty()) {
ThemeTestCase::ignoreWarning("SimpleItem.qml", 20, 1, warning);
}
qputenv("UBUNTU_UI_TOOLKIT_THEMES_PATH", themePath.toLocal8Bit());
qputenv("XDG_DATA_DIRS", xdgPath.toLocal8Bit());
QScopedPointer view(new ThemeTestCase("SimpleItem.qml"));
if (!theme.isEmpty()) {
view->setTheme(theme, view->rootObject());
}
view->rootObject()->setProperty("styleName", style);
QQuickItem *styleItem = view->rootObject()->findChild("TestStyle");
QCOMPARE(styleItem != NULL, success);
}
void test_import_path()
{
if (!QFile(QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath) + "/Ubuntu/Components").exists())
QSKIP("This can only be tested if the UITK is installed");
qputenv("UBUNTU_UI_TOOLKIT_THEMES_PATH", "");
qputenv("XDG_DATA_DIRS", "");
qputenv("QML2_IMPORT_PATH", "");
UCTheme theme;
QCOMPARE(theme.name(), QString("Ubuntu.Components.Themes.Ambiance"));
}
void test_bogus_import_path_set()
{
if (!QFile(QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath) + "/Ubuntu/Components").exists())
QSKIP("This can only be tested if the UITK is installed");
qputenv("UBUNTU_UI_TOOLKIT_THEMES_PATH", "");
qputenv("XDG_DATA_DIRS", "");
qputenv("QML2_IMPORT_PATH", "/no/plugins/here");
UCTheme theme;
QCOMPARE(theme.name(), QString("Ubuntu.Components.Themes.Ambiance"));
}
void test_multiple_import_paths_set()
{
if (!QFile(QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath) + "/Ubuntu/Components").exists())
QSKIP("This can only be tested if the UITK is installed");
qputenv("UBUNTU_UI_TOOLKIT_THEMES_PATH", "");
qputenv("XDG_DATA_DIRS", "");
qputenv("QML2_IMPORT_PATH", "/no/plugins/here");
QScopedPointer view(new ThemeTestCase("SimpleItem.qml"));
view->setTheme("CustomModule.TestTheme", view->rootObject());
}
void test_theme_not_root_theme()
{
qputenv("UBUNTU_UI_TOOLKIT_THEMES_PATH", ".");
QScopedPointer view(new ThemeTestCase("SimpleItem.qml"));
view->setTheme("CustomModule.TestTheme", view->rootObject());
UCTheme *theme = view->theme();
UCTheme *globalTheme = view->globalTheme();
QVERIFY(theme);
QVERIFY(globalTheme);
QVERIFY(theme != globalTheme);
}
void test_theme_reset_name()
{
qputenv("UBUNTU_UI_TOOLKIT_THEMES_PATH", "./themes");
QScopedPointer view(new ThemeTestCase("SimpleItem.qml"));
view->setTheme("TestModule.TestTheme", view->rootObject());
UCTheme *theme = view->theme();
QCOMPARE(theme->name(), QString("TestModule.TestTheme"));
// reset
theme->resetName();
QCOMPARE(theme->name(), QString("Ubuntu.Components.Themes.Ambiance"));
}
void test_parent_change_when_assinged()
{
QScopedPointer view(new ThemeTestCase("DynamicAssignment.qml"));
UCTheme *testSet = view->findItem("testSet");
UCStyledItemBase *testItem = view->findItem("testItem");
UCStyledItemBase *mainItem = qobject_cast(view->rootObject());
QSignalSpy parentChangeSpy(testSet, SIGNAL(parentThemeChanged()));
testItem->setTheme(testSet);
parentChangeSpy.wait(200);
QCOMPARE(parentChangeSpy.count(), 1);
// test if the parent is correct
QCOMPARE(testSet->parentTheme(), mainItem->getTheme());
}
void test_parent_set_reset_triggers_parent_change()
{
QScopedPointer view(new ThemeTestCase("ParentChanges.qml"));
UCTheme *testSet = view->findItem("testSet");
UCTheme *topTheme = view->findItem