Allow qtdeclarative to compile with -no-widgets

We have no hard requirement for QtWidgets library, so we should
build without it.

Change-Id: I85c85cc1a52bf9daa7ab7916f19bf7cc3ad5845f
Reviewed-by: Damian Jansen <damian.jansen@nokia.com>
This commit is contained in:
Martin Jones 2012-06-01 14:53:26 +10:00 committed by Qt by Nokia
parent c734706c69
commit 805c30e809
14 changed files with 70 additions and 23 deletions

View File

@ -6,9 +6,10 @@ SUBDIRS += \
binding \ binding \
coercion \ coercion \
default \ default \
extended \
grouped \ grouped \
properties \ properties \
signal \ signal \
valuesource \ valuesource \
methods methods
!contains(QT_CONFIG, no-widgets): SUBDIRS += extended

View File

@ -13,7 +13,6 @@
); );
%mastercontent = ( %mastercontent = (
"gui" => "#include <QtGui/QtGui>\n", "gui" => "#include <QtGui/QtGui>\n",
"script" => "#include <QtScript/QtScript>\n",
"network" => "#include <QtNetwork/QtNetwork>\n", "network" => "#include <QtNetwork/QtNetwork>\n",
"testlib" => "#include <QtTest/QtTest>\n", "testlib" => "#include <QtTest/QtTest>\n",
"qml" => "#include <QtQml/QtQml>\n", "qml" => "#include <QtQml/QtQml>\n",

View File

@ -5,8 +5,6 @@ METATYPETESTS += \
PUBLICTESTS += \ PUBLICTESTS += \
parserstress \ parserstress \
qjsengine \
qjsvalue \
qjsvalueiterator \ qjsvalueiterator \
qjsonbinding \ qjsonbinding \
qmlmin \ qmlmin \
@ -50,6 +48,15 @@ PRIVATETESTS += \
qqmlbundle \ qqmlbundle \
v4 v4
!contains(QT_CONFIG, no-widgets) {
PUBLICTESTS += \
qjsengine \
qjsvalue
PRIVATETESTS += \
qqmlecmascript
}
SUBDIRS += $$PUBLICTESTS SUBDIRS += $$PUBLICTESTS
SUBDIRS += $$METATYPETESTS SUBDIRS += $$METATYPETESTS
SUBDIRS += debugger SUBDIRS += debugger

View File

@ -16,4 +16,6 @@ include (../../shared/util.pri)
TESTDATA = data/* TESTDATA = data/*
QT += core-private gui-private v8-private qml-private network widgets testlib QT += core-private gui-private v8-private qml-private network testlib
!contains(QT_CONFIG, no-widgets): QT += widgets

View File

@ -39,8 +39,10 @@
** **
****************************************************************************/ ****************************************************************************/
#include "testtypes.h" #include "testtypes.h"
#include <QWidget> #ifndef QT_NO_WIDGETS
#include <QPlainTextEdit> # include <QWidget>
# include <QPlainTextEdit>
#endif
#include <QQmlEngine> #include <QQmlEngine>
#include <QJSEngine> #include <QJSEngine>
#include <QThread> #include <QThread>
@ -201,8 +203,10 @@ void registerTypes()
// MyRevisionedSubclass 1.1 uses MyRevisionedClass revision 1 // MyRevisionedSubclass 1.1 uses MyRevisionedClass revision 1
qmlRegisterType<MyRevisionedSubclass,1>("Qt.test",1,1,"MyRevisionedSubclass"); qmlRegisterType<MyRevisionedSubclass,1>("Qt.test",1,1,"MyRevisionedSubclass");
#ifndef QT_NO_WIDGETS
qmlRegisterExtendedType<QWidget,QWidgetDeclarativeUI>("Qt.test",1,0,"QWidget"); qmlRegisterExtendedType<QWidget,QWidgetDeclarativeUI>("Qt.test",1,0,"QWidget");
qmlRegisterType<QPlainTextEdit>("Qt.test",1,0,"QPlainTextEdit"); qmlRegisterType<QPlainTextEdit>("Qt.test",1,0,"QPlainTextEdit");
#endif
qRegisterMetaType<MyQmlObject::MyType>("MyQmlObject::MyType"); qRegisterMetaType<MyQmlObject::MyType>("MyQmlObject::MyType");

View File

@ -190,7 +190,9 @@ private slots:
void qtbug_21580(); void qtbug_21580();
void singleV8BindingDestroyedDuringEvaluation(); void singleV8BindingDestroyedDuringEvaluation();
void bug1(); void bug1();
#ifndef QT_NO_WIDGETS
void bug2(); void bug2();
#endif
void dynamicCreationCrash(); void dynamicCreationCrash();
void dynamicCreationOwnership(); void dynamicCreationOwnership();
void regExpBug(); void regExpBug();
@ -2042,6 +2044,7 @@ void tst_qqmlecmascript::bug1()
delete object; delete object;
} }
#ifndef QT_NO_WIDGETS
void tst_qqmlecmascript::bug2() void tst_qqmlecmascript::bug2()
{ {
QQmlComponent component(&engine); QQmlComponent component(&engine);
@ -2052,6 +2055,7 @@ void tst_qqmlecmascript::bug2()
delete object; delete object;
} }
#endif
// Don't crash in createObject when the component has errors. // Don't crash in createObject when the component has errors.
void tst_qqmlecmascript::dynamicCreationCrash() void tst_qqmlecmascript::dynamicCreationCrash()

View File

@ -10,7 +10,7 @@ TESTDATA = data/*
CONFIG += parallel_test CONFIG += parallel_test
QT += core-private gui-private v8-private qml-private quick-private testlib widgets QT += core-private gui-private v8-private qml-private quick-private testlib
# QTBUG-23385 - color mixing tests failing on Ubuntu 11.10 x64 # QTBUG-23385 - color mixing tests failing on Ubuntu 11.10 x64
linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):DEFINES+=UBUNTU_ONEIRIC linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):DEFINES+=UBUNTU_ONEIRIC

View File

@ -9,4 +9,5 @@ include (../shared/util.pri)
TESTDATA = data/* TESTDATA = data/*
QT += core-private gui-private v8-private qml-private quick-private widgets testlib QT += core-private gui-private v8-private qml-private quick-private testlib
!contains(QT_CONFIG, no-widgets): QT += widgets

View File

@ -53,7 +53,6 @@
#include <QtQml/private/qquicklistmodel_p.h> #include <QtQml/private/qquicklistmodel_p.h>
#include <QtQml/private/qqmlvaluetype_p.h> #include <QtQml/private/qqmlvaluetype_p.h>
#include <QStringListModel> #include <QStringListModel>
#include <QStandardItemModel>
#include <QFile> #include <QFile>
#include "../../shared/util.h" #include "../../shared/util.h"
@ -65,6 +64,8 @@ using namespace QQuickVisualTestUtil;
Q_DECLARE_METATYPE(QQuickPathView::HighlightRangeMode) Q_DECLARE_METATYPE(QQuickPathView::HighlightRangeMode)
#ifndef QT_NO_WIDGETS
#include <QStandardItemModel>
static void initStandardTreeModel(QStandardItemModel *model) static void initStandardTreeModel(QStandardItemModel *model)
{ {
QStandardItem *item; QStandardItem *item;
@ -82,6 +83,7 @@ static void initStandardTreeModel(QStandardItemModel *model)
item->setIcon(QIcon()); item->setIcon(QIcon());
model->insertRow(2, item); model->insertRow(2, item);
} }
#endif
class tst_QQuickPathView : public QQmlDataTest class tst_QQuickPathView : public QQmlDataTest
@ -120,7 +122,9 @@ private slots:
void visualDataModel(); void visualDataModel();
void undefinedPath(); void undefinedPath();
void mouseDrag(); void mouseDrag();
#ifndef QT_NO_WIDGETS
void treeModel(); void treeModel();
#endif
void changePreferredHighlight(); void changePreferredHighlight();
void missingPercent(); void missingPercent();
void creationContext(); void creationContext();
@ -1415,6 +1419,7 @@ void tst_QQuickPathView::mouseDrag()
delete canvas; delete canvas;
} }
#ifndef QT_NO_WIDGETS
void tst_QQuickPathView::treeModel() void tst_QQuickPathView::treeModel()
{ {
QQuickView *canvas = createView(); QQuickView *canvas = createView();
@ -1442,6 +1447,7 @@ void tst_QQuickPathView::treeModel()
delete canvas; delete canvas;
} }
#endif
void tst_QQuickPathView::changePreferredHighlight() void tst_QQuickPathView::changePreferredHighlight()
{ {

View File

@ -5,4 +5,5 @@ macx:CONFIG -= app_bundle
SOURCES += tst_qquicksystempalette.cpp SOURCES += tst_qquicksystempalette.cpp
CONFIG += parallel_test CONFIG += parallel_test
QT += core-private gui-private qml-private quick-private widgets testlib QT += core-private gui-private qml-private quick-private testlib
!contains(QT_CONFIG, no-widgets): QT += widgets

View File

@ -56,7 +56,9 @@ private slots:
void activePalette(); void activePalette();
void inactivePalette(); void inactivePalette();
void disabledPalette(); void disabledPalette();
#ifndef QT_NO_WIDGETS
void paletteChanged(); void paletteChanged();
#endif
private: private:
QQmlEngine engine; QQmlEngine engine;
@ -155,6 +157,7 @@ void tst_qquicksystempalette::disabledPalette()
delete object; delete object;
} }
#ifndef QT_NO_WIDGETS
void tst_qquicksystempalette::paletteChanged() void tst_qquicksystempalette::paletteChanged()
{ {
QString componentStr = "import QtQuick 2.0\nSystemPalette { }"; QString componentStr = "import QtQuick 2.0\nSystemPalette { }";
@ -179,6 +182,7 @@ void tst_qquicksystempalette::paletteChanged()
delete object; delete object;
} }
#endif
QTEST_MAIN(tst_qquicksystempalette) QTEST_MAIN(tst_qquicksystempalette)

View File

@ -11,4 +11,5 @@ TESTDATA = data/*
CONFIG += parallel_test CONFIG += parallel_test
QT += core-private gui-private v8-private qml-private quick-private widgets testlib QT += core-private gui-private v8-private qml-private quick-private testlib
!contains(QT_CONFIG, no-widgets): QT += widgets

View File

@ -43,7 +43,6 @@
#include <qtest.h> #include <qtest.h>
#include <QtTest/QSignalSpy> #include <QtTest/QSignalSpy>
#include <QStandardItemModel>
#include <QtQml/qqmlengine.h> #include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h> #include <QtQml/qqmlcomponent.h>
#include <QtQml/qqmlcontext.h> #include <QtQml/qqmlcontext.h>
@ -61,6 +60,8 @@ using namespace QQuickVisualTestUtil;
template <typename T, int N> int lengthOf(const T (&)[N]) { return N; } template <typename T, int N> int lengthOf(const T (&)[N]) { return N; }
#ifndef QT_NO_WIDGETS
#include <QStandardItemModel>
static void initStandardTreeModel(QStandardItemModel *model) static void initStandardTreeModel(QStandardItemModel *model)
{ {
QStandardItem *item; QStandardItem *item;
@ -78,6 +79,7 @@ static void initStandardTreeModel(QStandardItemModel *model)
item->setIcon(QIcon()); item->setIcon(QIcon());
model->insertRow(2, item); model->insertRow(2, item);
} }
#endif
class SingleRoleModel : public QAbstractListModel class SingleRoleModel : public QAbstractListModel
{ {
@ -120,6 +122,7 @@ protected:
} }
}; };
#ifndef QT_NO_WIDGETS
class StandardItem : public QObject, public QStandardItem class StandardItem : public QObject, public QStandardItem
{ {
Q_OBJECT Q_OBJECT
@ -143,6 +146,7 @@ public:
static_cast<QStandardItemModel *>(property->object)->appendRow(item); static_cast<QStandardItemModel *>(property->object)->appendRow(item);
} }
}; };
#endif
class DataObject : public QObject class DataObject : public QObject
{ {
@ -183,9 +187,11 @@ private:
}; };
QML_DECLARE_TYPE(SingleRoleModel) QML_DECLARE_TYPE(SingleRoleModel)
QML_DECLARE_TYPE(DataObject)
#ifndef QT_NO_WIDGETS
QML_DECLARE_TYPE(StandardItem) QML_DECLARE_TYPE(StandardItem)
QML_DECLARE_TYPE(StandardItemModel) QML_DECLARE_TYPE(StandardItemModel)
QML_DECLARE_TYPE(DataObject) #endif
class tst_qquickvisualdatamodel : public QQmlDataTest class tst_qquickvisualdatamodel : public QQmlDataTest
{ {
@ -196,18 +202,20 @@ public:
private slots: private slots:
void initTestCase(); void initTestCase();
void cleanupTestCase(); void cleanupTestCase();
#ifndef QT_NO_WIDGETS
void rootIndex(); void rootIndex();
void updateLayout_data(); void updateLayout_data();
void updateLayout(); void updateLayout();
void childChanged_data(); void childChanged_data();
void childChanged(); void childChanged();
void objectListModel();
void singleRole();
void modelProperties();
void noDelegate_data(); void noDelegate_data();
void noDelegate(); void noDelegate();
void itemsDestroyed_data(); void itemsDestroyed_data();
void itemsDestroyed(); void itemsDestroyed();
#endif
void objectListModel();
void singleRole();
void modelProperties();
void packagesDestroyed(); void packagesDestroyed();
void qaimRowsMoved(); void qaimRowsMoved();
void qaimRowsMoved_data(); void qaimRowsMoved_data();
@ -283,9 +291,11 @@ void tst_qquickvisualdatamodel::initTestCase()
qRegisterMetaType<QQuickChangeSet>(); qRegisterMetaType<QQuickChangeSet>();
qmlRegisterType<SingleRoleModel>("tst_qquickvisualdatamodel", 1, 0, "SingleRoleModel"); qmlRegisterType<SingleRoleModel>("tst_qquickvisualdatamodel", 1, 0, "SingleRoleModel");
qmlRegisterType<DataObject>("tst_qquickvisualdatamodel", 1, 0, "DataObject");
#ifndef QT_NO_WIDGETS
qmlRegisterType<StandardItem>("tst_qquickvisualdatamodel", 1, 0, "StandardItem"); qmlRegisterType<StandardItem>("tst_qquickvisualdatamodel", 1, 0, "StandardItem");
qmlRegisterType<StandardItemModel>("tst_qquickvisualdatamodel", 1, 0, "StandardItemModel"); qmlRegisterType<StandardItemModel>("tst_qquickvisualdatamodel", 1, 0, "StandardItemModel");
qmlRegisterType<DataObject>("tst_qquickvisualdatamodel", 1, 0, "DataObject"); #endif
} }
void tst_qquickvisualdatamodel::cleanupTestCase() void tst_qquickvisualdatamodel::cleanupTestCase()
@ -296,6 +306,7 @@ tst_qquickvisualdatamodel::tst_qquickvisualdatamodel()
{ {
} }
#ifndef QT_NO_WIDGETS
void tst_qquickvisualdatamodel::rootIndex() void tst_qquickvisualdatamodel::rootIndex()
{ {
QQmlEngine engine; QQmlEngine engine;
@ -437,6 +448,7 @@ void tst_qquickvisualdatamodel::childChanged()
QVERIFY(name); QVERIFY(name);
QCOMPARE(name->text(), QString("Row 3 Item")); QCOMPARE(name->text(), QString("Row 3 Item"));
} }
#endif
void tst_qquickvisualdatamodel::objectListModel() void tst_qquickvisualdatamodel::objectListModel()
{ {
@ -603,6 +615,7 @@ void tst_qquickvisualdatamodel::modelProperties()
QCOMPARE(delegate->property("test8").toInt(),1); QCOMPARE(delegate->property("test8").toInt(),1);
} }
#ifndef QT_NO_WIDGETS
{ {
QQuickView view; QQuickView view;
@ -644,10 +657,11 @@ void tst_qquickvisualdatamodel::modelProperties()
QCOMPARE(delegate->property("test7").toInt(),1); QCOMPARE(delegate->property("test7").toInt(),1);
QCOMPARE(delegate->property("test8").toInt(),1); QCOMPARE(delegate->property("test8").toInt(),1);
} }
#endif
//### should also test QStringList and QVariantList //### should also test QStringList and QVariantList
} }
#ifndef QT_NO_WIDGETS
void tst_qquickvisualdatamodel::noDelegate_data() void tst_qquickvisualdatamodel::noDelegate_data()
{ {
QTest::addColumn<QUrl>("source"); QTest::addColumn<QUrl>("source");
@ -711,6 +725,7 @@ void tst_qquickvisualdatamodel::itemsDestroyed()
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
QVERIFY(!delegate); QVERIFY(!delegate);
} }
#endif
void tst_qquickvisualdatamodel::packagesDestroyed() void tst_qquickvisualdatamodel::packagesDestroyed()
{ {
@ -2368,7 +2383,7 @@ void tst_qquickvisualdatamodel::insert_data()
<< 4 << 5 << 0 << true << true << false << false << true << 4 << 5 << 0 << true << true << false << false << true
<< QString("name") << QString("name")
<< (QStringList() << "seven" << "one" << "two" << "three" << "four"); << (QStringList() << "seven" << "one" << "two" << "three" << "four");
#ifndef QT_NO_WIDGETS
// AbstractItemModel (Multiple Roles). // AbstractItemModel (Multiple Roles).
QTest::newRow("StandardItemModel.items prepend") QTest::newRow("StandardItemModel.items prepend")
<< multipleRoleSource[i] << multipleRoleSource[i]
@ -2449,7 +2464,7 @@ void tst_qquickvisualdatamodel::insert_data()
<< 4 << 5 << 0 << true << true << false << false << false << 4 << 5 << 0 << true << true << false << false << false
<< QString("display") << QString("display")
<< (QStringList() << "Row 7 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); << (QStringList() << "Row 7 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
#endif
// StringList. // StringList.
QTest::newRow("StringList.items prepend") QTest::newRow("StringList.items prepend")
<< stringListSource[i] << stringListSource[i]
@ -2949,6 +2964,7 @@ void tst_qquickvisualdatamodel::resolve_data()
<< QString("name") << QString("name")
<< (QStringList() << "one" << "two" << "three" << "four"); << (QStringList() << "one" << "two" << "three" << "four");
#ifndef QT_NO_WIDGETS
// AbstractItemModel (Multiple Roles) // AbstractItemModel (Multiple Roles)
QTest::newRow("StandardItemModel.items prepend, resolve prepended") QTest::newRow("StandardItemModel.items prepend, resolve prepended")
<< multipleRoleSource[i] << multipleRoleSource[i]
@ -2973,7 +2989,7 @@ void tst_qquickvisualdatamodel::resolve_data()
<< 5 << 4 << 4 << 2 << true << false << true << false << false << 5 << 4 << 4 << 2 << true << false << true << false << false
<< QString("display") << QString("display")
<< (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
#endif
// StringList // StringList
QTest::newRow("StringList.items prepend, resolve prepended") QTest::newRow("StringList.items prepend, resolve prepended")
<< stringListSource[i] << stringListSource[i]

View File

@ -2,10 +2,11 @@ TEMPLATE = subdirs
PUBLICTESTS += \ PUBLICTESTS += \
geometry \ geometry \
nodes \
rendernode \ rendernode \
qquickpixmapcache qquickpixmapcache
!contains(QT_CONFIG, no-widgets): PUBLICTESTS += nodes
!cross_compile: PUBLICTESTS += examples !cross_compile: PUBLICTESTS += examples
# This test requires the qtconcurrent module # This test requires the qtconcurrent module