Merge branch 'master' of git://scm.dev.nokia.troll.no/qt/qtbase-staging
* 'master' of git://scm.dev.nokia.troll.no/qt/qtbase-staging: (84 commits) Reduce usage of Q_ASSERT in autotests. Fixed license header. Remove Q_ASSERT's from qsharedmemory autotest Remove Q_ASSERT's from QNetworkReply autotest Remove Q_ASSERT from QXmlStream autotest Remove Q_ASSERT's from QXmlStream autotest Remove Q_ASSERT from QItemModel autotest Remove Q_ASSERT's from QXmlStream autotest Remove Q_ASSERT from QVariant autotest Remove Q_ASSERT's from QTreeView autotest Remove Q_ASSERT from qtesselator autotest Remove unused function from qtessellator autotest Remove Q_ASSERT's from qreadwritelock autotest Remove Q_ASSERT's from QObject autotest Remove Q_ASSERT's from QObject autotest Remove Q_ASSERT's from QNetworkReply autotest Remove Q_ASSERT from qitemmodel autotest Remove Q_ASSERT's from QMutex autotest Remove Q_ASSERT from QMetaType autotest Remove Q_ASSERT's in qitemview autotest ...
This commit is contained in:
commit
aabda9f5c6
@ -60,7 +60,7 @@ QT_USE_NAMESPACE
|
||||
#include "3rdparty/memcheck.h"
|
||||
#endif
|
||||
|
||||
class tst_ExceptionSafetyObjects: public QObject
|
||||
class tst_ExceptionSafety_Objects: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -156,7 +156,7 @@ struct DirCreator : public AbstractTester
|
||||
}
|
||||
};
|
||||
|
||||
void tst_ExceptionSafetyObjects::objects_data()
|
||||
void tst_ExceptionSafety_Objects::objects_data()
|
||||
{
|
||||
QTest::addColumn<AbstractTester *>("objectCreator");
|
||||
|
||||
@ -164,12 +164,12 @@ void tst_ExceptionSafetyObjects::objects_data()
|
||||
NEWROW(QObject);
|
||||
NEWROW(QBuffer);
|
||||
NEWROW(QFile);
|
||||
NEWROW(QFSFileEngine);
|
||||
NEWROW(QProcess);
|
||||
NEWROW(QSettings);
|
||||
NEWROW(QThread);
|
||||
NEWROW(QThreadPool);
|
||||
NEWROW(QTranslator);
|
||||
NEWROW(QFSFileEngine);
|
||||
|
||||
#define NEWROW2(T, CREATOR) QTest::newRow(#T) << static_cast<AbstractTester *>(new CREATOR)
|
||||
NEWROW2(QBitArray, BitArrayCreator);
|
||||
@ -177,7 +177,6 @@ void tst_ExceptionSafetyObjects::objects_data()
|
||||
NEWROW2(QCryptographicHash, CryptographicHashCreator);
|
||||
NEWROW2(QDataStream, DataStreamCreator);
|
||||
NEWROW2(QDir, DirCreator);
|
||||
|
||||
}
|
||||
|
||||
// create and destructs an object, and lets each and every allocation
|
||||
@ -274,9 +273,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
QtMsgHandler tst_ExceptionSafetyObjects::testMessageHandler;
|
||||
QtMsgHandler tst_ExceptionSafety_Objects::testMessageHandler;
|
||||
|
||||
void tst_ExceptionSafetyObjects::safeMessageHandler(QtMsgType type, const char *msg)
|
||||
void tst_ExceptionSafety_Objects::safeMessageHandler(QtMsgType type, const char *msg)
|
||||
{
|
||||
// this temporarily suspends OOM testing while handling a message
|
||||
int currentIndex = mallocFailIndex;
|
||||
@ -301,7 +300,7 @@ void debugUnexpected()
|
||||
(*defaultUnexpected)();
|
||||
}
|
||||
|
||||
void tst_ExceptionSafetyObjects::initTestCase()
|
||||
void tst_ExceptionSafety_Objects::initTestCase()
|
||||
{
|
||||
// set handlers for bad exception cases, you might want to step in and breakpoint the default handlers too
|
||||
defaultTerminate = std::set_terminate(&debugTerminate);
|
||||
@ -345,17 +344,25 @@ void tst_ExceptionSafetyObjects::initTestCase()
|
||||
QCOMPARE(malloc2Failed, 1);
|
||||
}
|
||||
|
||||
void tst_ExceptionSafetyObjects::cleanupTestCase()
|
||||
void tst_ExceptionSafety_Objects::cleanupTestCase()
|
||||
{
|
||||
qInstallMsgHandler(testMessageHandler);
|
||||
}
|
||||
|
||||
void tst_ExceptionSafetyObjects::objects()
|
||||
void tst_ExceptionSafety_Objects::objects()
|
||||
{
|
||||
QLatin1String tag = QLatin1String(QTest::currentDataTag());
|
||||
if (tag == QLatin1String("QFile")
|
||||
|| tag == QLatin1String("QProcess")
|
||||
|| tag == QLatin1String("QSettings")
|
||||
|| tag == QLatin1String("QThread")
|
||||
|| tag == QLatin1String("QThreadPool"))
|
||||
QSKIP("This type of object is not currently strongly exception safe", SkipSingle);
|
||||
|
||||
QFETCH(AbstractTester *, objectCreator);
|
||||
|
||||
doOOMTest(*objectCreator, 0);
|
||||
|
||||
|
||||
delete objectCreator;
|
||||
}
|
||||
|
||||
@ -364,7 +371,8 @@ struct WidgetCreator : public AbstractTester
|
||||
{
|
||||
void operator()(QObject *parent)
|
||||
{
|
||||
Q_ASSERT(!parent || parent->isWidgetType());
|
||||
if (parent && !parent->isWidgetType())
|
||||
qFatal("%s: parent must be either null or a widget type", Q_FUNC_INFO);
|
||||
QScopedPointer<T> ptr(parent ? new T(static_cast<QWidget *>(parent)) : new T);
|
||||
}
|
||||
};
|
||||
@ -374,7 +382,8 @@ template <> struct WidgetCreator<QSizeGrip> : public AbstractTester
|
||||
{
|
||||
void operator()(QObject *parent)
|
||||
{
|
||||
Q_ASSERT(!parent || parent->isWidgetType());
|
||||
if (parent && !parent->isWidgetType())
|
||||
qFatal("%s: parent must be either null or a widget type", Q_FUNC_INFO);
|
||||
QScopedPointer<QSizeGrip> ptr(new QSizeGrip(static_cast<QWidget *>(parent)));
|
||||
}
|
||||
};
|
||||
@ -384,17 +393,18 @@ template <> struct WidgetCreator<QDesktopWidget> : public AbstractTester
|
||||
{
|
||||
void operator()(QObject *parent)
|
||||
{
|
||||
Q_ASSERT(!parent || parent->isWidgetType());
|
||||
if (parent && !parent->isWidgetType())
|
||||
qFatal("%s: parent must be either null or a widget type", Q_FUNC_INFO);
|
||||
QScopedPointer<QDesktopWidget> ptr(new QDesktopWidget());
|
||||
}
|
||||
};
|
||||
void tst_ExceptionSafetyObjects::widgets_data()
|
||||
void tst_ExceptionSafety_Objects::widgets_data()
|
||||
{
|
||||
#ifdef Q_OS_SYMBIAN
|
||||
// Initialise the S60 rasteriser, which crashes if started while out of memory
|
||||
QImage image(20, 20, QImage::Format_RGB32);
|
||||
QPainter p(&image);
|
||||
p.drawText(0, 15, "foo");
|
||||
QImage image(20, 20, QImage::Format_RGB32);
|
||||
QPainter p(&image);
|
||||
p.drawText(0, 15, "foo");
|
||||
#endif
|
||||
|
||||
QTest::addColumn<AbstractTester *>("widgetCreator");
|
||||
@ -405,23 +415,27 @@ void tst_ExceptionSafetyObjects::widgets_data()
|
||||
NEWROW(QWidget);
|
||||
|
||||
NEWROW(QButtonGroup);
|
||||
NEWROW(QDesktopWidget);
|
||||
NEWROW(QCheckBox);
|
||||
NEWROW(QColumnView);
|
||||
NEWROW(QComboBox);
|
||||
NEWROW(QCommandLinkButton);
|
||||
NEWROW(QDateEdit);
|
||||
NEWROW(QDateTimeEdit);
|
||||
NEWROW(QDesktopWidget);
|
||||
NEWROW(QDial);
|
||||
NEWROW(QDoubleSpinBox);
|
||||
NEWROW(QFocusFrame);
|
||||
NEWROW(QFontComboBox);
|
||||
NEWROW(QFrame);
|
||||
NEWROW(QGroupBox);
|
||||
NEWROW(QLCDNumber);
|
||||
NEWROW(QLabel);
|
||||
NEWROW(QLCDNumber);
|
||||
NEWROW(QLineEdit);
|
||||
NEWROW(QListView);
|
||||
NEWROW(QListWidget);
|
||||
NEWROW(QMainWindow);
|
||||
NEWROW(QMenu);
|
||||
NEWROW(QMenuBar);
|
||||
NEWROW(QPlainTextEdit);
|
||||
NEWROW(QProgressBar);
|
||||
NEWROW(QPushButton);
|
||||
@ -435,28 +449,58 @@ void tst_ExceptionSafetyObjects::widgets_data()
|
||||
NEWROW(QStackedWidget);
|
||||
NEWROW(QStatusBar);
|
||||
NEWROW(QTabBar);
|
||||
NEWROW(QTableView);
|
||||
NEWROW(QTableWidget);
|
||||
NEWROW(QTabWidget);
|
||||
NEWROW(QTextBrowser);
|
||||
NEWROW(QTextEdit);
|
||||
NEWROW(QTimeEdit);
|
||||
NEWROW(QToolBar);
|
||||
NEWROW(QToolBox);
|
||||
NEWROW(QToolButton);
|
||||
NEWROW(QStatusBar);
|
||||
NEWROW(QToolBar);
|
||||
NEWROW(QMenuBar);
|
||||
NEWROW(QMainWindow);
|
||||
NEWROW(QWorkspace);
|
||||
NEWROW(QColumnView);
|
||||
NEWROW(QListView);
|
||||
NEWROW(QListWidget);
|
||||
NEWROW(QTableView);
|
||||
NEWROW(QTableWidget);
|
||||
NEWROW(QTreeView);
|
||||
NEWROW(QTreeWidget);
|
||||
NEWROW(QWorkspace);
|
||||
}
|
||||
|
||||
void tst_ExceptionSafetyObjects::widgets()
|
||||
void tst_ExceptionSafety_Objects::widgets()
|
||||
{
|
||||
QLatin1String tag = QLatin1String(QTest::currentDataTag());
|
||||
if (tag == QLatin1String("QColumnView")
|
||||
|| tag == QLatin1String("QComboBox")
|
||||
|| tag == QLatin1String("QCommandLinkButton")
|
||||
|| tag == QLatin1String("QDateEdit")
|
||||
|| tag == QLatin1String("QDateTimeEdit")
|
||||
|| tag == QLatin1String("QDesktopWidget")
|
||||
|| tag == QLatin1String("QDoubleSpinBox")
|
||||
|| tag == QLatin1String("QFontComboBox")
|
||||
|| tag == QLatin1String("QGroupBox")
|
||||
|| tag == QLatin1String("QLineEdit")
|
||||
|| tag == QLatin1String("QListView")
|
||||
|| tag == QLatin1String("QListWidget")
|
||||
|| tag == QLatin1String("QMainWindow")
|
||||
|| tag == QLatin1String("QMenu")
|
||||
|| tag == QLatin1String("QMenuBar")
|
||||
|| tag == QLatin1String("QPlainTextEdit")
|
||||
|| tag == QLatin1String("QProgressBar")
|
||||
|| tag == QLatin1String("QPushButton")
|
||||
|| tag == QLatin1String("QScrollArea")
|
||||
|| tag == QLatin1String("QSpinBox")
|
||||
|| tag == QLatin1String("QStackedWidget")
|
||||
|| tag == QLatin1String("QStatusBar")
|
||||
|| tag == QLatin1String("QTableView")
|
||||
|| tag == QLatin1String("QTableWidget")
|
||||
|| tag == QLatin1String("QTabWidget")
|
||||
|| tag == QLatin1String("QTextBrowser")
|
||||
|| tag == QLatin1String("QTextEdit")
|
||||
|| tag == QLatin1String("QTimeEdit")
|
||||
|| tag == QLatin1String("QToolBar")
|
||||
|| tag == QLatin1String("QToolBox")
|
||||
|| tag == QLatin1String("QTreeView")
|
||||
|| tag == QLatin1String("QTreeWidget")
|
||||
|| tag == QLatin1String("QWorkspace"))
|
||||
QSKIP("This type of widget is not currently strongly exception safe", SkipSingle);
|
||||
|
||||
QFETCH(AbstractTester *, widgetCreator);
|
||||
|
||||
doOOMTest(*widgetCreator, 0, 00000);
|
||||
@ -547,7 +591,9 @@ struct IntegerMoveable
|
||||
};
|
||||
|
||||
int IntegerMoveable::instanceCount = 0;
|
||||
QT_BEGIN_NAMESPACE
|
||||
Q_DECLARE_TYPEINFO(IntegerMoveable, Q_MOVABLE_TYPE);
|
||||
QT_END_NAMESPACE
|
||||
|
||||
template <typename T, template<typename> class Container>
|
||||
void containerInsertTest(QObject*)
|
||||
@ -720,12 +766,12 @@ static void containerData()
|
||||
QTest::newRow("erase moveable") << static_cast<TestFunction>(containerEraseTest<IntegerMoveable, Container>);
|
||||
}
|
||||
|
||||
void tst_ExceptionSafetyObjects::vector_data()
|
||||
void tst_ExceptionSafety_Objects::vector_data()
|
||||
{
|
||||
containerData<QVector>();
|
||||
}
|
||||
|
||||
void tst_ExceptionSafetyObjects::vector()
|
||||
void tst_ExceptionSafety_Objects::vector()
|
||||
{
|
||||
QFETCH(TestFunction, testFunction);
|
||||
|
||||
@ -736,30 +782,30 @@ void tst_ExceptionSafetyObjects::vector()
|
||||
doOOMTest(testFunction, 0);
|
||||
}
|
||||
|
||||
void tst_ExceptionSafetyObjects::list_data()
|
||||
void tst_ExceptionSafety_Objects::list_data()
|
||||
{
|
||||
containerData<QList>();
|
||||
}
|
||||
|
||||
void tst_ExceptionSafetyObjects::list()
|
||||
void tst_ExceptionSafety_Objects::list()
|
||||
{
|
||||
QFETCH(TestFunction, testFunction);
|
||||
|
||||
doOOMTest(testFunction, 0);
|
||||
}
|
||||
|
||||
void tst_ExceptionSafetyObjects::linkedList_data()
|
||||
void tst_ExceptionSafety_Objects::linkedList_data()
|
||||
{
|
||||
containerData<QLinkedList>();
|
||||
}
|
||||
|
||||
void tst_ExceptionSafetyObjects::linkedList()
|
||||
void tst_ExceptionSafety_Objects::linkedList()
|
||||
{
|
||||
QFETCH(TestFunction, testFunction);
|
||||
|
||||
doOOMTest(testFunction, 0);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_ExceptionSafetyObjects)
|
||||
QTEST_MAIN(tst_ExceptionSafety_Objects)
|
||||
#include "tst_exceptionsafety_objects.moc"
|
||||
#endif // QT_NO_EXCEPTIONS
|
||||
|
@ -280,7 +280,7 @@ protected:
|
||||
eventsPtr->canceled << g->gestureType();
|
||||
break;
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
qWarning() << "Unknown GestureState enum value:" << static_cast<int>(g->state());
|
||||
}
|
||||
}
|
||||
} else if (event->type() == CustomEvent::EventType) {
|
||||
@ -823,7 +823,7 @@ public:
|
||||
emit gestureCanceled(e->type(), g);
|
||||
break;
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
qWarning() << "Unknown GestureState enum value:" << static_cast<int>(g->state());
|
||||
}
|
||||
}
|
||||
} else if (event->type() == CustomEvent::EventType) {
|
||||
@ -1518,17 +1518,20 @@ void tst_Gestures::autoCancelGestures()
|
||||
{
|
||||
class MockWidget : public GestureWidget {
|
||||
public:
|
||||
MockWidget(const char *name) : GestureWidget(name) { }
|
||||
MockWidget(const char *name) : GestureWidget(name), badGestureEvents(0) { }
|
||||
|
||||
bool event(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::Gesture) {
|
||||
QGestureEvent *ge = static_cast<QGestureEvent*>(event);
|
||||
Q_ASSERT(ge->gestures().count() == 1); // can't use QCOMPARE here...
|
||||
if (ge->gestures().count() != 1)
|
||||
++badGestureEvents; // event should contain exactly one gesture
|
||||
ge->gestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext);
|
||||
}
|
||||
return GestureWidget::event(event);
|
||||
}
|
||||
|
||||
int badGestureEvents;
|
||||
};
|
||||
|
||||
const Qt::GestureType secondGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
|
||||
@ -1563,22 +1566,26 @@ void tst_Gestures::autoCancelGestures()
|
||||
event.serial = CustomGesture::SerialFinishedThreshold;
|
||||
QApplication::sendEvent(child, &event);
|
||||
QCOMPARE(parent.events.all.count(), 2);
|
||||
QCOMPARE(parent.badGestureEvents, 0);
|
||||
}
|
||||
|
||||
void tst_Gestures::autoCancelGestures2()
|
||||
{
|
||||
class MockItem : public GestureItem {
|
||||
public:
|
||||
MockItem(const char *name) : GestureItem(name) { }
|
||||
MockItem(const char *name) : GestureItem(name), badGestureEvents(0) { }
|
||||
|
||||
bool event(QEvent *event) {
|
||||
if (event->type() == QEvent::Gesture) {
|
||||
QGestureEvent *ge = static_cast<QGestureEvent*>(event);
|
||||
Q_ASSERT(ge->gestures().count() == 1); // can't use QCOMPARE here...
|
||||
if (ge->gestures().count() != 1)
|
||||
++badGestureEvents; // event should contain exactly one gesture
|
||||
ge->gestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext);
|
||||
}
|
||||
return GestureItem::event(event);
|
||||
}
|
||||
|
||||
int badGestureEvents;
|
||||
};
|
||||
|
||||
const Qt::GestureType secondGesture = QGestureRecognizer ::registerRecognizer(new CustomGestureRecognizer);
|
||||
@ -1614,6 +1621,7 @@ void tst_Gestures::autoCancelGestures2()
|
||||
event.serial = CustomGesture::SerialFinishedThreshold;
|
||||
scene.sendEvent(child, &event);
|
||||
QCOMPARE(parent->events.all.count(), 2);
|
||||
QCOMPARE(parent->badGestureEvents, 0);
|
||||
}
|
||||
|
||||
void tst_Gestures::graphicsViewParentPropagation()
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
|
||||
DynamicTreeModel::DynamicTreeModel(QObject *parent)
|
||||
@ -66,9 +67,11 @@ QModelIndex DynamicTreeModel::index(int row, int column, const QModelIndex &pare
|
||||
const qint64 grandParent = findParentId(parent.internalId());
|
||||
if (grandParent >= 0) {
|
||||
QList<QList<qint64> > parentTable = m_childItems.value(grandParent);
|
||||
Q_ASSERT(parent.column() < parentTable.size());
|
||||
if (parent.column() >= parentTable.size())
|
||||
qFatal("%s: parent.column() must be less than parentTable.size()", Q_FUNC_INFO);
|
||||
QList<qint64> parentSiblings = parentTable.at(parent.column());
|
||||
Q_ASSERT(parent.row() < parentSiblings.size());
|
||||
if (parent.row() >= parentSiblings.size())
|
||||
qFatal("%s: parent.row() must be less than parentSiblings.size()", Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
if (childIdColumns.size() == 0)
|
||||
@ -189,7 +192,8 @@ QModelIndex ModelChangeCommand::findIndex(QList<int> rows)
|
||||
while (i.hasNext())
|
||||
{
|
||||
parent = m_model->index(i.next(), col, parent);
|
||||
Q_ASSERT(parent.isValid());
|
||||
if (!parent.isValid())
|
||||
qFatal("%s: parent must be valid", Q_FUNC_INFO);
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
@ -45,8 +45,6 @@
|
||||
#include "modeltest.h"
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#undef Q_ASSERT
|
||||
#define Q_ASSERT QVERIFY
|
||||
|
||||
Q_DECLARE_METATYPE ( QModelIndex )
|
||||
|
||||
@ -55,7 +53,8 @@ Q_DECLARE_METATYPE ( QModelIndex )
|
||||
*/
|
||||
ModelTest::ModelTest ( QAbstractItemModel *_model, QObject *parent ) : QObject ( parent ), model ( _model ), fetchingMore ( false )
|
||||
{
|
||||
Q_ASSERT ( model );
|
||||
if (!model)
|
||||
qFatal("%s: model must not be null", Q_FUNC_INFO);
|
||||
|
||||
connect ( model, SIGNAL ( columnsAboutToBeInserted ( const QModelIndex &, int, int ) ),
|
||||
this, SLOT ( runAllTests() ) );
|
||||
@ -118,15 +117,15 @@ void ModelTest::runAllTests()
|
||||
*/
|
||||
void ModelTest::nonDestructiveBasicTest()
|
||||
{
|
||||
Q_ASSERT ( model->buddy ( QModelIndex() ) == QModelIndex() );
|
||||
QVERIFY( model->buddy ( QModelIndex() ) == QModelIndex() );
|
||||
model->canFetchMore ( QModelIndex() );
|
||||
Q_ASSERT ( model->columnCount ( QModelIndex() ) >= 0 );
|
||||
Q_ASSERT ( model->data ( QModelIndex() ) == QVariant() );
|
||||
QVERIFY( model->columnCount ( QModelIndex() ) >= 0 );
|
||||
QVERIFY( model->data ( QModelIndex() ) == QVariant() );
|
||||
fetchingMore = true;
|
||||
model->fetchMore ( QModelIndex() );
|
||||
fetchingMore = false;
|
||||
Qt::ItemFlags flags = model->flags ( QModelIndex() );
|
||||
Q_ASSERT ( flags == Qt::ItemIsDropEnabled || flags == 0 );
|
||||
QVERIFY( flags == Qt::ItemIsDropEnabled || flags == 0 );
|
||||
model->hasChildren ( QModelIndex() );
|
||||
model->hasIndex ( 0, 0 );
|
||||
model->headerData ( 0, Qt::Horizontal );
|
||||
@ -135,8 +134,8 @@ void ModelTest::nonDestructiveBasicTest()
|
||||
QVariant cache;
|
||||
model->match ( QModelIndex(), -1, cache );
|
||||
model->mimeTypes();
|
||||
Q_ASSERT ( model->parent ( QModelIndex() ) == QModelIndex() );
|
||||
Q_ASSERT ( model->rowCount() >= 0 );
|
||||
QVERIFY( model->parent ( QModelIndex() ) == QModelIndex() );
|
||||
QVERIFY( model->rowCount() >= 0 );
|
||||
QVariant variant;
|
||||
model->setData ( QModelIndex(), variant, -1 );
|
||||
model->setHeaderData ( -1, Qt::Horizontal, QVariant() );
|
||||
@ -158,17 +157,17 @@ void ModelTest::rowCount()
|
||||
// check top row
|
||||
QModelIndex topIndex = model->index ( 0, 0, QModelIndex() );
|
||||
int rows = model->rowCount ( topIndex );
|
||||
Q_ASSERT ( rows >= 0 );
|
||||
QVERIFY( rows >= 0 );
|
||||
if ( rows > 0 )
|
||||
Q_ASSERT ( model->hasChildren ( topIndex ) == true );
|
||||
QVERIFY( model->hasChildren ( topIndex ) );
|
||||
|
||||
QModelIndex secondLevelIndex = model->index ( 0, 0, topIndex );
|
||||
if ( secondLevelIndex.isValid() ) { // not the top level
|
||||
// check a row count where parent is valid
|
||||
rows = model->rowCount ( secondLevelIndex );
|
||||
Q_ASSERT ( rows >= 0 );
|
||||
QVERIFY( rows >= 0 );
|
||||
if ( rows > 0 )
|
||||
Q_ASSERT ( model->hasChildren ( secondLevelIndex ) == true );
|
||||
QVERIFY( model->hasChildren ( secondLevelIndex ) );
|
||||
}
|
||||
|
||||
// The models rowCount() is tested more extensively in checkChildren(),
|
||||
@ -182,12 +181,12 @@ void ModelTest::columnCount()
|
||||
{
|
||||
// check top row
|
||||
QModelIndex topIndex = model->index ( 0, 0, QModelIndex() );
|
||||
Q_ASSERT ( model->columnCount ( topIndex ) >= 0 );
|
||||
QVERIFY( model->columnCount ( topIndex ) >= 0 );
|
||||
|
||||
// check a column count where parent is valid
|
||||
QModelIndex childIndex = model->index ( 0, 0, topIndex );
|
||||
if ( childIndex.isValid() )
|
||||
Q_ASSERT ( model->columnCount ( childIndex ) >= 0 );
|
||||
QVERIFY( model->columnCount ( childIndex ) >= 0 );
|
||||
|
||||
// columnCount() is tested more extensively in checkChildren(),
|
||||
// but this catches the big mistakes
|
||||
@ -200,19 +199,19 @@ void ModelTest::hasIndex()
|
||||
{
|
||||
// qDebug() << "hi";
|
||||
// Make sure that invalid values returns an invalid index
|
||||
Q_ASSERT ( model->hasIndex ( -2, -2 ) == false );
|
||||
Q_ASSERT ( model->hasIndex ( -2, 0 ) == false );
|
||||
Q_ASSERT ( model->hasIndex ( 0, -2 ) == false );
|
||||
QVERIFY( !model->hasIndex ( -2, -2 ) );
|
||||
QVERIFY( !model->hasIndex ( -2, 0 ) );
|
||||
QVERIFY( !model->hasIndex ( 0, -2 ) );
|
||||
|
||||
int rows = model->rowCount();
|
||||
int columns = model->columnCount();
|
||||
|
||||
// check out of bounds
|
||||
Q_ASSERT ( model->hasIndex ( rows, columns ) == false );
|
||||
Q_ASSERT ( model->hasIndex ( rows + 1, columns + 1 ) == false );
|
||||
QVERIFY( !model->hasIndex ( rows, columns ) );
|
||||
QVERIFY( !model->hasIndex ( rows + 1, columns + 1 ) );
|
||||
|
||||
if ( rows > 0 )
|
||||
Q_ASSERT ( model->hasIndex ( 0, 0 ) == true );
|
||||
QVERIFY( model->hasIndex ( 0, 0 ) );
|
||||
|
||||
// hasIndex() is tested more extensively in checkChildren(),
|
||||
// but this catches the big mistakes
|
||||
@ -225,9 +224,9 @@ void ModelTest::index()
|
||||
{
|
||||
// qDebug() << "i";
|
||||
// Make sure that invalid values returns an invalid index
|
||||
Q_ASSERT ( model->index ( -2, -2 ) == QModelIndex() );
|
||||
Q_ASSERT ( model->index ( -2, 0 ) == QModelIndex() );
|
||||
Q_ASSERT ( model->index ( 0, -2 ) == QModelIndex() );
|
||||
QVERIFY( model->index ( -2, -2 ) == QModelIndex() );
|
||||
QVERIFY( model->index ( -2, 0 ) == QModelIndex() );
|
||||
QVERIFY( model->index ( 0, -2 ) == QModelIndex() );
|
||||
|
||||
int rows = model->rowCount();
|
||||
int columns = model->columnCount();
|
||||
@ -236,13 +235,13 @@ void ModelTest::index()
|
||||
return;
|
||||
|
||||
// Catch off by one errors
|
||||
Q_ASSERT ( model->index ( rows, columns ) == QModelIndex() );
|
||||
Q_ASSERT ( model->index ( 0, 0 ).isValid() == true );
|
||||
QVERIFY( model->index ( rows, columns ) == QModelIndex() );
|
||||
QVERIFY( model->index ( 0, 0 ).isValid() );
|
||||
|
||||
// Make sure that the same index is *always* returned
|
||||
QModelIndex a = model->index ( 0, 0 );
|
||||
QModelIndex b = model->index ( 0, 0 );
|
||||
Q_ASSERT ( a == b );
|
||||
QVERIFY( a == b );
|
||||
|
||||
// index() is tested more extensively in checkChildren(),
|
||||
// but this catches the big mistakes
|
||||
@ -256,7 +255,7 @@ void ModelTest::parent()
|
||||
// qDebug() << "p";
|
||||
// Make sure the model wont crash and will return an invalid QModelIndex
|
||||
// when asked for the parent of an invalid index.
|
||||
Q_ASSERT ( model->parent ( QModelIndex() ) == QModelIndex() );
|
||||
QVERIFY( model->parent ( QModelIndex() ) == QModelIndex() );
|
||||
|
||||
if ( model->rowCount() == 0 )
|
||||
return;
|
||||
@ -269,13 +268,13 @@ void ModelTest::parent()
|
||||
// Common error test #1, make sure that a top level index has a parent
|
||||
// that is a invalid QModelIndex.
|
||||
QModelIndex topIndex = model->index ( 0, 0, QModelIndex() );
|
||||
Q_ASSERT ( model->parent ( topIndex ) == QModelIndex() );
|
||||
QVERIFY( model->parent ( topIndex ) == QModelIndex() );
|
||||
|
||||
// Common error test #2, make sure that a second level index has a parent
|
||||
// that is the first level index.
|
||||
if ( model->rowCount ( topIndex ) > 0 ) {
|
||||
QModelIndex childIndex = model->index ( 0, 0, topIndex );
|
||||
Q_ASSERT ( model->parent ( childIndex ) == topIndex );
|
||||
QVERIFY( model->parent ( childIndex ) == topIndex );
|
||||
}
|
||||
|
||||
// Common error test #3, the second column should NOT have the same children
|
||||
@ -285,7 +284,7 @@ void ModelTest::parent()
|
||||
if ( model->rowCount ( topIndex1 ) > 0 ) {
|
||||
QModelIndex childIndex = model->index ( 0, 0, topIndex );
|
||||
QModelIndex childIndex1 = model->index ( 0, 0, topIndex1 );
|
||||
Q_ASSERT ( childIndex != childIndex1 );
|
||||
QVERIFY( childIndex != childIndex1 );
|
||||
}
|
||||
|
||||
// Full test, walk n levels deep through the model making sure that all
|
||||
@ -325,47 +324,47 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth )
|
||||
int columns = model->columnCount ( parent );
|
||||
|
||||
if ( rows > 0 )
|
||||
Q_ASSERT ( model->hasChildren ( parent ) );
|
||||
QVERIFY( model->hasChildren ( parent ) );
|
||||
|
||||
// Some further testing against rows(), columns(), and hasChildren()
|
||||
Q_ASSERT ( rows >= 0 );
|
||||
Q_ASSERT ( columns >= 0 );
|
||||
QVERIFY( rows >= 0 );
|
||||
QVERIFY( columns >= 0 );
|
||||
if ( rows > 0 )
|
||||
Q_ASSERT ( model->hasChildren ( parent ) == true );
|
||||
QVERIFY( model->hasChildren ( parent ) );
|
||||
|
||||
//qDebug() << "parent:" << model->data(parent).toString() << "rows:" << rows
|
||||
// << "columns:" << columns << "parent column:" << parent.column();
|
||||
|
||||
Q_ASSERT ( model->hasIndex ( rows + 1, 0, parent ) == false );
|
||||
QVERIFY( !model->hasIndex ( rows + 1, 0, parent ) );
|
||||
for ( int r = 0; r < rows; ++r ) {
|
||||
if ( model->canFetchMore ( parent ) ) {
|
||||
fetchingMore = true;
|
||||
model->fetchMore ( parent );
|
||||
fetchingMore = false;
|
||||
}
|
||||
Q_ASSERT ( model->hasIndex ( r, columns + 1, parent ) == false );
|
||||
QVERIFY( !model->hasIndex ( r, columns + 1, parent ) );
|
||||
for ( int c = 0; c < columns; ++c ) {
|
||||
Q_ASSERT ( model->hasIndex ( r, c, parent ) == true );
|
||||
QVERIFY( model->hasIndex ( r, c, parent ) );
|
||||
QModelIndex index = model->index ( r, c, parent );
|
||||
// rowCount() and columnCount() said that it existed...
|
||||
Q_ASSERT ( index.isValid() == true );
|
||||
QVERIFY( index.isValid() );
|
||||
|
||||
// index() should always return the same index when called twice in a row
|
||||
QModelIndex modifiedIndex = model->index ( r, c, parent );
|
||||
Q_ASSERT ( index == modifiedIndex );
|
||||
QVERIFY( index == modifiedIndex );
|
||||
|
||||
// Make sure we get the same index if we request it twice in a row
|
||||
QModelIndex a = model->index ( r, c, parent );
|
||||
QModelIndex b = model->index ( r, c, parent );
|
||||
Q_ASSERT ( a == b );
|
||||
QVERIFY( a == b );
|
||||
|
||||
// Some basic checking on the index that is returned
|
||||
Q_ASSERT ( index.model() == model );
|
||||
Q_ASSERT ( index.row() == r );
|
||||
Q_ASSERT ( index.column() == c );
|
||||
QVERIFY( index.model() == model );
|
||||
QCOMPARE( index.row(), r );
|
||||
QCOMPARE( index.column(), c );
|
||||
// While you can technically return a QVariant usually this is a sign
|
||||
// of an bug in data() Disable if this really is ok in your model.
|
||||
// Q_ASSERT ( model->data ( index, Qt::DisplayRole ).isValid() == true );
|
||||
// of a bug in data(). Disable if this really is ok in your model.
|
||||
// QVERIFY( model->data ( index, Qt::DisplayRole ).isValid() );
|
||||
|
||||
// If the next test fails here is some somewhat useful debug you play with.
|
||||
|
||||
@ -380,8 +379,7 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth )
|
||||
}
|
||||
|
||||
// Check that we can get back our real parent.
|
||||
// qDebug() << model->parent ( index ) << parent ;
|
||||
Q_ASSERT ( model->parent ( index ) == parent );
|
||||
QCOMPARE( model->parent ( index ), parent );
|
||||
|
||||
// recursively go down the children
|
||||
if ( model->hasChildren ( index ) && currentDepth < 10 ) {
|
||||
@ -391,7 +389,7 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth )
|
||||
|
||||
// make sure that after testing the children that the index doesn't change.
|
||||
QModelIndex newerIndex = model->index ( r, c, parent );
|
||||
Q_ASSERT ( index == newerIndex );
|
||||
QVERIFY( index == newerIndex );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -402,68 +400,68 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth )
|
||||
void ModelTest::data()
|
||||
{
|
||||
// Invalid index should return an invalid qvariant
|
||||
Q_ASSERT ( !model->data ( QModelIndex() ).isValid() );
|
||||
QVERIFY( !model->data ( QModelIndex() ).isValid() );
|
||||
|
||||
if ( model->rowCount() == 0 )
|
||||
return;
|
||||
|
||||
// A valid index should have a valid QVariant data
|
||||
Q_ASSERT ( model->index ( 0, 0 ).isValid() );
|
||||
QVERIFY( model->index ( 0, 0 ).isValid() );
|
||||
|
||||
// shouldn't be able to set data on an invalid index
|
||||
Q_ASSERT ( model->setData ( QModelIndex(), QLatin1String ( "foo" ), Qt::DisplayRole ) == false );
|
||||
QVERIFY( !model->setData ( QModelIndex(), QLatin1String ( "foo" ), Qt::DisplayRole ) );
|
||||
|
||||
// General Purpose roles that should return a QString
|
||||
QVariant variant = model->data ( model->index ( 0, 0 ), Qt::ToolTipRole );
|
||||
if ( variant.isValid() ) {
|
||||
Q_ASSERT ( qVariantCanConvert<QString> ( variant ) );
|
||||
QVERIFY( qVariantCanConvert<QString> ( variant ) );
|
||||
}
|
||||
variant = model->data ( model->index ( 0, 0 ), Qt::StatusTipRole );
|
||||
if ( variant.isValid() ) {
|
||||
Q_ASSERT ( qVariantCanConvert<QString> ( variant ) );
|
||||
QVERIFY( qVariantCanConvert<QString> ( variant ) );
|
||||
}
|
||||
variant = model->data ( model->index ( 0, 0 ), Qt::WhatsThisRole );
|
||||
if ( variant.isValid() ) {
|
||||
Q_ASSERT ( qVariantCanConvert<QString> ( variant ) );
|
||||
QVERIFY( qVariantCanConvert<QString> ( variant ) );
|
||||
}
|
||||
|
||||
// General Purpose roles that should return a QSize
|
||||
variant = model->data ( model->index ( 0, 0 ), Qt::SizeHintRole );
|
||||
if ( variant.isValid() ) {
|
||||
Q_ASSERT ( qVariantCanConvert<QSize> ( variant ) );
|
||||
QVERIFY( qVariantCanConvert<QSize> ( variant ) );
|
||||
}
|
||||
|
||||
// General Purpose roles that should return a QFont
|
||||
QVariant fontVariant = model->data ( model->index ( 0, 0 ), Qt::FontRole );
|
||||
if ( fontVariant.isValid() ) {
|
||||
Q_ASSERT ( qVariantCanConvert<QFont> ( fontVariant ) );
|
||||
QVERIFY( qVariantCanConvert<QFont> ( fontVariant ) );
|
||||
}
|
||||
|
||||
// Check that the alignment is one we know about
|
||||
QVariant textAlignmentVariant = model->data ( model->index ( 0, 0 ), Qt::TextAlignmentRole );
|
||||
if ( textAlignmentVariant.isValid() ) {
|
||||
int alignment = textAlignmentVariant.toInt();
|
||||
Q_ASSERT ( alignment == ( alignment & ( Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask ) ) );
|
||||
QCOMPARE( alignment, ( alignment & ( Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask ) ) );
|
||||
}
|
||||
|
||||
// General Purpose roles that should return a QColor
|
||||
QVariant colorVariant = model->data ( model->index ( 0, 0 ), Qt::BackgroundColorRole );
|
||||
if ( colorVariant.isValid() ) {
|
||||
Q_ASSERT ( qVariantCanConvert<QColor> ( colorVariant ) );
|
||||
QVERIFY( qVariantCanConvert<QColor> ( colorVariant ) );
|
||||
}
|
||||
|
||||
colorVariant = model->data ( model->index ( 0, 0 ), Qt::TextColorRole );
|
||||
if ( colorVariant.isValid() ) {
|
||||
Q_ASSERT ( qVariantCanConvert<QColor> ( colorVariant ) );
|
||||
QVERIFY( qVariantCanConvert<QColor> ( colorVariant ) );
|
||||
}
|
||||
|
||||
// Check that the "check state" is one we know about.
|
||||
QVariant checkStateVariant = model->data ( model->index ( 0, 0 ), Qt::CheckStateRole );
|
||||
if ( checkStateVariant.isValid() ) {
|
||||
int state = checkStateVariant.toInt();
|
||||
Q_ASSERT ( state == Qt::Unchecked ||
|
||||
state == Qt::PartiallyChecked ||
|
||||
state == Qt::Checked );
|
||||
QVERIFY( state == Qt::Unchecked ||
|
||||
state == Qt::PartiallyChecked ||
|
||||
state == Qt::Checked );
|
||||
}
|
||||
}
|
||||
|
||||
@ -494,7 +492,7 @@ void ModelTest::rowsAboutToBeInserted ( const QModelIndex &parent, int start, in
|
||||
void ModelTest::rowsInserted ( const QModelIndex & parent, int start, int end )
|
||||
{
|
||||
Changing c = insert.pop();
|
||||
Q_ASSERT ( c.parent == parent );
|
||||
QVERIFY( c.parent == parent );
|
||||
// qDebug() << "rowsInserted" << "start=" << start << "end=" << end << "oldsize=" << c.oldSize
|
||||
// << "parent=" << model->data ( parent ).toString() << "current rowcount of parent=" << model->rowCount ( parent );
|
||||
|
||||
@ -504,8 +502,8 @@ void ModelTest::rowsInserted ( const QModelIndex & parent, int start, int end )
|
||||
// }
|
||||
// qDebug();
|
||||
|
||||
Q_ASSERT ( c.oldSize + ( end - start + 1 ) == model->rowCount ( parent ) );
|
||||
Q_ASSERT ( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) );
|
||||
QVERIFY( c.oldSize + ( end - start + 1 ) == model->rowCount ( parent ) );
|
||||
QVERIFY( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) );
|
||||
|
||||
if (c.next != model->data(model->index(end + 1, 0, c.parent))) {
|
||||
qDebug() << start << end;
|
||||
@ -514,7 +512,7 @@ void ModelTest::rowsInserted ( const QModelIndex & parent, int start, int end )
|
||||
qDebug() << c.next << model->data(model->index(end + 1, 0, c.parent));
|
||||
}
|
||||
|
||||
Q_ASSERT ( c.next == model->data ( model->index ( end + 1, 0, c.parent ) ) );
|
||||
QVERIFY( c.next == model->data ( model->index ( end + 1, 0, c.parent ) ) );
|
||||
}
|
||||
|
||||
void ModelTest::layoutAboutToBeChanged()
|
||||
@ -527,7 +525,7 @@ void ModelTest::layoutChanged()
|
||||
{
|
||||
for ( int i = 0; i < changing.count(); ++i ) {
|
||||
QPersistentModelIndex p = changing[i];
|
||||
Q_ASSERT ( p == model->index ( p.row(), p.column(), p.parent() ) );
|
||||
QVERIFY( p == model->index ( p.row(), p.column(), p.parent() ) );
|
||||
}
|
||||
changing.clear();
|
||||
}
|
||||
@ -557,10 +555,10 @@ void ModelTest::rowsRemoved ( const QModelIndex & parent, int start, int end )
|
||||
{
|
||||
qDebug() << "rr" << parent << start << end;
|
||||
Changing c = remove.pop();
|
||||
Q_ASSERT ( c.parent == parent );
|
||||
Q_ASSERT ( c.oldSize - ( end - start + 1 ) == model->rowCount ( parent ) );
|
||||
Q_ASSERT ( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) );
|
||||
Q_ASSERT ( c.next == model->data ( model->index ( start, 0, c.parent ) ) );
|
||||
QVERIFY( c.parent == parent );
|
||||
QVERIFY( c.oldSize - ( end - start + 1 ) == model->rowCount ( parent ) );
|
||||
QVERIFY( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) );
|
||||
QVERIFY( c.next == model->data ( model->index ( start, 0, c.parent ) ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -201,8 +201,10 @@ class ObservingObject : public QObject
|
||||
Q_OBJECT
|
||||
public:
|
||||
ObservingObject(AccessibleProxyModel *proxy, QObject *parent = 0)
|
||||
: QObject(parent),
|
||||
m_proxy(proxy)
|
||||
: QObject(parent)
|
||||
, m_proxy(proxy)
|
||||
, storePersistentFailureCount(0)
|
||||
, checkPersistentFailureCount(0)
|
||||
{
|
||||
connect(m_proxy, SIGNAL(layoutAboutToBeChanged()), SLOT(storePersistent()));
|
||||
connect(m_proxy, SIGNAL(layoutChanged()), SLOT(checkPersistent()));
|
||||
@ -215,8 +217,14 @@ public slots:
|
||||
for (int row = 0; row < m_proxy->rowCount(parent); ++row) {
|
||||
QModelIndex proxyIndex = m_proxy->index(row, 0, parent);
|
||||
QModelIndex sourceIndex = m_proxy->mapToSource(proxyIndex);
|
||||
Q_ASSERT(proxyIndex.isValid());
|
||||
Q_ASSERT(sourceIndex.isValid());
|
||||
if (!proxyIndex.isValid()) {
|
||||
qWarning("%s: Invalid proxy index", Q_FUNC_INFO);
|
||||
++storePersistentFailureCount;
|
||||
}
|
||||
if (!sourceIndex.isValid()) {
|
||||
qWarning("%s: invalid source index", Q_FUNC_INFO);
|
||||
++storePersistentFailureCount;
|
||||
}
|
||||
m_persistentSourceIndexes.append(sourceIndex);
|
||||
m_persistentProxyIndexes.append(proxyIndex);
|
||||
if (m_proxy->hasChildren(proxyIndex))
|
||||
@ -226,12 +234,24 @@ public slots:
|
||||
|
||||
void storePersistent()
|
||||
{
|
||||
foreach(const QModelIndex &idx, m_persistentProxyIndexes)
|
||||
Q_ASSERT(idx.isValid()); // This is called from layoutAboutToBeChanged. Persistent indexes should be valid
|
||||
// This method is called from layoutAboutToBeChanged. Persistent indexes should be valid
|
||||
foreach(const QModelIndex &idx, m_persistentProxyIndexes)
|
||||
if (!idx.isValid()) {
|
||||
qWarning("%s: persistentProxyIndexes contains invalid index", Q_FUNC_INFO);
|
||||
++storePersistentFailureCount;
|
||||
}
|
||||
|
||||
Q_ASSERT(m_proxy->persistent().isEmpty());
|
||||
if (!m_proxy->persistent().isEmpty()) {
|
||||
qWarning("%s: proxy should have no persistent indexes when storePersistent called",
|
||||
Q_FUNC_INFO);
|
||||
++storePersistentFailureCount;
|
||||
}
|
||||
storePersistent(QModelIndex());
|
||||
Q_ASSERT(!m_proxy->persistent().isEmpty());
|
||||
if (m_proxy->persistent().isEmpty()) {
|
||||
qWarning("%s: proxy should have persistent index after storePersistent called",
|
||||
Q_FUNC_INFO);
|
||||
++storePersistentFailureCount;
|
||||
}
|
||||
}
|
||||
|
||||
void checkPersistent()
|
||||
@ -243,7 +263,10 @@ public slots:
|
||||
for (int row = 0; row < m_persistentProxyIndexes.size(); ++row) {
|
||||
QModelIndex updatedProxy = m_persistentProxyIndexes.at(row);
|
||||
QModelIndex updatedSource = m_persistentSourceIndexes.at(row);
|
||||
QCOMPARE(m_proxy->mapToSource(updatedProxy), updatedSource);
|
||||
if (m_proxy->mapToSource(updatedProxy) != updatedSource) {
|
||||
qWarning("%s: check failed at row %d", Q_FUNC_INFO, row);
|
||||
++checkPersistentFailureCount;
|
||||
}
|
||||
}
|
||||
m_persistentSourceIndexes.clear();
|
||||
m_persistentProxyIndexes.clear();
|
||||
@ -253,6 +276,9 @@ private:
|
||||
AccessibleProxyModel *m_proxy;
|
||||
QList<QPersistentModelIndex> m_persistentSourceIndexes;
|
||||
QList<QPersistentModelIndex> m_persistentProxyIndexes;
|
||||
public:
|
||||
int storePersistentFailureCount;
|
||||
int checkPersistentFailureCount;
|
||||
};
|
||||
|
||||
void tst_ModelTest::moveSourceItems()
|
||||
@ -280,6 +306,9 @@ void tst_ModelTest::moveSourceItems()
|
||||
moveCommand->setDestAncestors(QList<int>() << 1);
|
||||
moveCommand->setDestRow(0);
|
||||
moveCommand->doCommand();
|
||||
|
||||
QCOMPARE(observer.storePersistentFailureCount, 0);
|
||||
QCOMPARE(observer.checkPersistentFailureCount, 0);
|
||||
}
|
||||
|
||||
void tst_ModelTest::testResetThroughProxy()
|
||||
@ -302,6 +331,9 @@ void tst_ModelTest::testResetThroughProxy()
|
||||
ModelResetCommand *resetCommand = new ModelResetCommand(model, this);
|
||||
resetCommand->setNumCols(0);
|
||||
resetCommand->doCommand();
|
||||
|
||||
QCOMPARE(observer.storePersistentFailureCount, 0);
|
||||
QCOMPARE(observer.checkPersistentFailureCount, 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,10 +3,8 @@
|
||||
|
||||
TEMPLATE=subdirs
|
||||
SUBDIRS=\
|
||||
# exceptionsafety_objects \ shouldn't enable it
|
||||
# baselineexample \ Just an example demonstrating qbaselinetest usage
|
||||
lancelot \
|
||||
qaccessibility \
|
||||
qalgorithms \
|
||||
qcombobox \
|
||||
qcssparser \
|
||||
@ -37,6 +35,8 @@ SUBDIRS=\
|
||||
windowsmobile \
|
||||
nativeimagehandleprovider
|
||||
|
||||
contains(QT_CONFIG, accessibility):SUBDIRS += qaccessibility
|
||||
|
||||
contains(QT_CONFIG, OdfWriter):SUBDIRS += qzip qtextodfwriter
|
||||
mac: {
|
||||
SUBDIRS += macgui \
|
||||
@ -56,6 +56,8 @@ symbian {
|
||||
qs60mainapplication
|
||||
}
|
||||
|
||||
!win32-msvc*:!wince*:SUBDIRS += exceptionsafety_objects
|
||||
|
||||
# Following tests depends on private API
|
||||
!contains(QT_CONFIG, private_tests): SUBDIRS -= \
|
||||
qcombobox \
|
||||
|
@ -83,8 +83,12 @@ public:
|
||||
|
||||
bool open(QIODevice::OpenMode openMode)
|
||||
{
|
||||
Q_ASSERT(!openForRead_);
|
||||
Q_ASSERT(!openForWrite_);
|
||||
if (openForRead_ || openForWrite_) {
|
||||
qWarning("%s: file is already open for %s",
|
||||
Q_FUNC_INFO,
|
||||
(openForRead_ ? "reading" : "writing"));
|
||||
return false;
|
||||
}
|
||||
|
||||
openFile_ = resolveFile(openMode & QIODevice::WriteOnly);
|
||||
if (!openFile_)
|
||||
@ -132,13 +136,19 @@ public:
|
||||
|
||||
qint64 pos() const
|
||||
{
|
||||
Q_ASSERT(openForRead_ || openForWrite_);
|
||||
if (!openForRead_ && !openForWrite_) {
|
||||
qWarning("%s: file is not open", Q_FUNC_INFO);
|
||||
return -1;
|
||||
}
|
||||
return position_;
|
||||
}
|
||||
|
||||
bool seek(qint64 pos)
|
||||
{
|
||||
Q_ASSERT(openForRead_ || openForWrite_);
|
||||
if (!openForRead_ && !openForWrite_) {
|
||||
qWarning("%s: file is not open", Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pos >= 0) {
|
||||
position_ = pos;
|
||||
@ -150,7 +160,11 @@ public:
|
||||
|
||||
bool flush()
|
||||
{
|
||||
Q_ASSERT(openForRead_ || openForWrite_);
|
||||
if (!openForRead_ && !openForWrite_) {
|
||||
qWarning("%s: file is not open", Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -346,10 +360,10 @@ public:
|
||||
|
||||
void setFileName(const QString &file)
|
||||
{
|
||||
Q_ASSERT(!openForRead_);
|
||||
Q_ASSERT(!openForWrite_);
|
||||
|
||||
fileName_ = file;
|
||||
if (openForRead_ || openForWrite_)
|
||||
qWarning("%s: Can't set file name while file is open", Q_FUNC_INFO);
|
||||
else
|
||||
fileName_ = file;
|
||||
}
|
||||
|
||||
// typedef QAbstractFileEngineIterator Iterator;
|
||||
@ -368,9 +382,16 @@ public:
|
||||
|
||||
qint64 read(char *data, qint64 maxLen)
|
||||
{
|
||||
Q_ASSERT(openForRead_);
|
||||
if (!openForRead_) {
|
||||
qWarning("%s: file must be open for reading", Q_FUNC_INFO);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (openFile_.isNull()) {
|
||||
qWarning("%s: file must not be null", Q_FUNC_INFO);
|
||||
return -1;
|
||||
}
|
||||
|
||||
Q_ASSERT(!openFile_.isNull());
|
||||
QMutexLocker lock(&openFile_->mutex);
|
||||
qint64 readSize = qMin(openFile_->content.size() - position_, maxLen);
|
||||
if (readSize < 0)
|
||||
@ -384,12 +405,19 @@ public:
|
||||
|
||||
qint64 write(const char *data, qint64 length)
|
||||
{
|
||||
Q_ASSERT(openForWrite_);
|
||||
if (!openForWrite_) {
|
||||
qWarning("%s: file must be open for writing", Q_FUNC_INFO);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (openFile_.isNull()) {
|
||||
qWarning("%s: file must not be null", Q_FUNC_INFO);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (length < 0)
|
||||
return -1;
|
||||
|
||||
Q_ASSERT(!openFile_.isNull());
|
||||
QMutexLocker lock(&openFile_->mutex);
|
||||
if (openFile_->content.size() == position_)
|
||||
openFile_->content.append(data, length);
|
||||
@ -434,7 +462,8 @@ protected:
|
||||
QSharedPointer<File> resolveFile(bool create) const
|
||||
{
|
||||
if (openForRead_ || openForWrite_) {
|
||||
Q_ASSERT(openFile_);
|
||||
if (!openFile_)
|
||||
qWarning("%s: file should not be null", Q_FUNC_INFO);
|
||||
return openFile_;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
load(qttest_p4)
|
||||
requires(contains(QT_CONFIG,accessibility))
|
||||
SOURCES += tst_qaccessibility.cpp
|
||||
|
||||
unix:!mac:LIBS+=-lm
|
||||
|
@ -326,69 +326,16 @@ QString eventName(const int ev)
|
||||
}
|
||||
}
|
||||
|
||||
static QString stateNames(int state)
|
||||
{
|
||||
QString stateString;
|
||||
if (state == 0x00000000) stateString += " Normal";
|
||||
if (state & 0x00000001) stateString += " Unavailable";
|
||||
if (state & 0x00000002) stateString += " Selected";
|
||||
if (state & 0x00000004) stateString += " Focused";
|
||||
if (state & 0x00000008) stateString += " Pressed";
|
||||
if (state & 0x00000010) stateString += " Checked";
|
||||
if (state & 0x00000020) stateString += " Mixed";
|
||||
if (state & 0x00000040) stateString += " ReadOnly";
|
||||
if (state & 0x00000080) stateString += " HotTracked";
|
||||
if (state & 0x00000100) stateString += " DefaultButton";
|
||||
if (state & 0x00000200) stateString += " Expanded";
|
||||
if (state & 0x00000400) stateString += " Collapsed";
|
||||
if (state & 0x00000800) stateString += " Busy";
|
||||
if (state & 0x00001000) stateString += " Floating";
|
||||
if (state & 0x00002000) stateString += " Marqueed";
|
||||
if (state & 0x00004000) stateString += " Animated";
|
||||
if (state & 0x00008000) stateString += " Invisible";
|
||||
if (state & 0x00010000) stateString += " Offscreen";
|
||||
if (state & 0x00020000) stateString += " Sizeable";
|
||||
if (state & 0x00040000) stateString += " Moveable";
|
||||
if (state & 0x00080000) stateString += " SelfVoicing";
|
||||
if (state & 0x00100000) stateString += " Focusable";
|
||||
if (state & 0x00200000) stateString += " Selectable";
|
||||
if (state & 0x00400000) stateString += " Linked";
|
||||
if (state & 0x00800000) stateString += " Traversed";
|
||||
if (state & 0x01000000) stateString += " MultiSelectable";
|
||||
if (state & 0x02000000) stateString += " ExtSelectable";
|
||||
if (state & 0x04000000) stateString += " AlertLow";
|
||||
if (state & 0x08000000) stateString += " AlertMedium";
|
||||
if (state & 0x10000000) stateString += " AlertHigh";
|
||||
if (state & 0x20000000) stateString += " Protected";
|
||||
if (state & 0x3fffffff) stateString += " Valid";
|
||||
|
||||
if (stateString.isEmpty())
|
||||
stateString = "Unknown state " + QString::number(state);
|
||||
|
||||
return stateString;
|
||||
}
|
||||
|
||||
QAccessible::State state(QWidget * const widget)
|
||||
{
|
||||
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(widget);
|
||||
Q_ASSERT(iface);
|
||||
QAccessible::State state = iface->state(0);
|
||||
if (!iface)
|
||||
qWarning() << "Cannot get QAccessibleInterface for widget";
|
||||
QAccessible::State state = (iface ? iface->state(0) : static_cast<QAccessible::State>(0));
|
||||
delete iface;
|
||||
return state;
|
||||
}
|
||||
|
||||
void printState(QWidget * const widget)
|
||||
{
|
||||
qDebug() << "State for" << widget->metaObject()->className() << stateNames(state(widget));
|
||||
}
|
||||
|
||||
void printState(QAccessibleInterface * const iface, const int child = 0)
|
||||
{
|
||||
qDebug() << "State for" << iface->object()->metaObject()->className() << "child" << child
|
||||
<< iface->text(QAccessible::Name, child) << stateNames(iface->state(child));
|
||||
}
|
||||
|
||||
|
||||
class QtTestAccessibleWidget: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -403,7 +350,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
class QtTestAccessibleWidgetIface: public QAccessibleWidget
|
||||
{
|
||||
public:
|
||||
@ -421,7 +367,6 @@ public:
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
tst_QAccessibility::tst_QAccessibility()
|
||||
{
|
||||
@ -433,17 +378,13 @@ tst_QAccessibility::~tst_QAccessibility()
|
||||
|
||||
void tst_QAccessibility::initTestCase()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QTestAccessibility::initialize();
|
||||
QAccessible::installFactory(QtTestAccessibleWidgetIface::ifaceFactory);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::cleanupTestCase()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QTestAccessibility::cleanup();
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::init()
|
||||
@ -453,7 +394,6 @@ void tst_QAccessibility::init()
|
||||
|
||||
void tst_QAccessibility::cleanup()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
const EventList list = QTestAccessibility::events();
|
||||
if (!list.isEmpty()) {
|
||||
qWarning("%d accessibility event(s) were not handled in testfunction '%s':", list.count(),
|
||||
@ -463,14 +403,10 @@ void tst_QAccessibility::cleanup()
|
||||
eventName(list.at(i).event).toAscii().constData(), list.at(i).event, list.at(i).child);
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::eventTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QPushButton* button = new QPushButton(0);
|
||||
button->setObjectName(QString("Olaf"));
|
||||
|
||||
@ -491,14 +427,10 @@ void tst_QAccessibility::eventTest()
|
||||
QVERIFY_EVENT(button, 0, QAccessible::ObjectHide);
|
||||
|
||||
delete button;
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::customWidget()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QtTestAccessibleWidget* widget = new QtTestAccessibleWidget(0, "Heinz");
|
||||
|
||||
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(widget);
|
||||
@ -510,14 +442,10 @@ void tst_QAccessibility::customWidget()
|
||||
|
||||
delete iface;
|
||||
delete widget;
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::deletedWidget()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QtTestAccessibleWidget *widget = new QtTestAccessibleWidget(0, "Ralf");
|
||||
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(widget);
|
||||
QVERIFY(iface != 0);
|
||||
@ -528,9 +456,6 @@ void tst_QAccessibility::deletedWidget()
|
||||
widget = 0;
|
||||
QVERIFY(!iface->isValid());
|
||||
delete iface;
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
QWidget *tst_QAccessibility::createGUI()
|
||||
@ -539,7 +464,6 @@ QWidget *tst_QAccessibility::createGUI()
|
||||
qWarning( "Should never get here without Qt3Support");
|
||||
return 0;
|
||||
#else
|
||||
# ifdef QTEST_ACCESSIBILITY
|
||||
QWidget *toplevel = new QWidget(0, Qt::X11BypassWindowManagerHint);
|
||||
QGridLayout *grid = new QGridLayout(toplevel, 2, 2);
|
||||
|
||||
@ -611,10 +535,6 @@ QWidget *tst_QAccessibility::createGUI()
|
||||
radioAM->setFocus();
|
||||
QTestAccessibility::clearEvents();
|
||||
return toplevel;
|
||||
# else
|
||||
Q_ASSERT(0); // this function cannot be called without accessibility support
|
||||
return 0;
|
||||
# endif
|
||||
#endif // !QT3_SUPPORT
|
||||
}
|
||||
|
||||
@ -623,7 +543,6 @@ void tst_QAccessibility::childAt()
|
||||
#if !defined(QT3_SUPPORT)
|
||||
QSKIP("This test needs Qt3Support", SkipAll);
|
||||
#else
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QWidget *toplevel = createGUI();
|
||||
QAccessibleInterface *acc_toplevel = QAccessible::queryAccessibleInterface(toplevel);
|
||||
QVERIFY(acc_toplevel);
|
||||
@ -655,9 +574,6 @@ void tst_QAccessibility::childAt()
|
||||
delete acc_toplevel;
|
||||
delete toplevel;
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
#endif // !QT3_SUPPORT
|
||||
}
|
||||
|
||||
@ -666,7 +582,6 @@ void tst_QAccessibility::childCount()
|
||||
#if !defined(QT3_SUPPORT)
|
||||
QSKIP("This test needs Qt3Support", SkipAll);
|
||||
#else
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QWidget *toplevel = createGUI();
|
||||
QObject *topLeft = toplevel->child("topLeft");
|
||||
QObject *topRight = toplevel->child("topRight");
|
||||
@ -699,9 +614,6 @@ void tst_QAccessibility::childCount()
|
||||
delete acc_bottomRight;
|
||||
delete toplevel;
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
#endif // !QT3_SUPPORT
|
||||
}
|
||||
|
||||
@ -710,7 +622,6 @@ void tst_QAccessibility::relationTo()
|
||||
#if !defined(QT3_SUPPORT)
|
||||
QSKIP("This test needs Qt3Support", SkipAll);
|
||||
#else
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QWidget *toplevel = createGUI();
|
||||
toplevel->resize(400,300);
|
||||
QObject *topLeft = toplevel->child("topLeft");
|
||||
@ -916,15 +827,11 @@ void tst_QAccessibility::relationTo()
|
||||
delete toplevel;
|
||||
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
#endif // !QT3_SUPPORT
|
||||
}
|
||||
|
||||
void tst_QAccessibility::navigateGeometric()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
{
|
||||
static const int skip = 20; //speed the test up significantly
|
||||
static const double step = Q_PI / 180;
|
||||
@ -1020,14 +927,10 @@ void tst_QAccessibility::navigateGeometric()
|
||||
delete w;
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::navigateSlider()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
{
|
||||
QSlider *slider = new QSlider(0);
|
||||
slider->setObjectName(QString("Slidy"));
|
||||
@ -1054,14 +957,10 @@ void tst_QAccessibility::navigateSlider()
|
||||
delete slider;
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::navigateCovered()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
{
|
||||
QWidget *w = new QWidget(0);
|
||||
w->setObjectName(QString("Harry"));
|
||||
@ -1164,14 +1063,10 @@ void tst_QAccessibility::navigateCovered()
|
||||
delete w;
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::navigateHierarchy()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
{
|
||||
QWidget *w = new QWidget(0);
|
||||
w->setObjectName(QString("Hans"));
|
||||
@ -1267,9 +1162,6 @@ void tst_QAccessibility::navigateHierarchy()
|
||||
delete w;
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
#define QSETCOMPARE(thetypename, elements, otherelements) \
|
||||
@ -1280,7 +1172,6 @@ void tst_QAccessibility::navigateControllers()
|
||||
#if !defined(QT3_SUPPORT)
|
||||
QSKIP("This test needs Qt3Support", SkipAll);
|
||||
#else
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
{
|
||||
Q3VBox vbox;
|
||||
QSlider slider(&vbox);
|
||||
@ -1363,9 +1254,6 @@ void tst_QAccessibility::navigateControllers()
|
||||
delete acc_slider;
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
#endif // !QT3_SUPPORT
|
||||
}
|
||||
|
||||
@ -1374,7 +1262,6 @@ void tst_QAccessibility::navigateLabels()
|
||||
#if !defined(QT3_SUPPORT)
|
||||
QSKIP("This test needs Qt3Support", SkipAll);
|
||||
#else
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
{
|
||||
Q3VBox vbox;
|
||||
Q3HBox hbox(&vbox);
|
||||
@ -1496,9 +1383,6 @@ void tst_QAccessibility::navigateLabels()
|
||||
delete acc_lineedit3;
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
#endif // !QT3_SUPPORT
|
||||
}
|
||||
|
||||
@ -1550,7 +1434,6 @@ static QWidget *createWidgets()
|
||||
|
||||
void tst_QAccessibility::accessibleName()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QWidget *toplevel = createWidgets();
|
||||
toplevel->show();
|
||||
#if defined(Q_WS_X11)
|
||||
@ -1575,9 +1458,6 @@ void tst_QAccessibility::accessibleName()
|
||||
|
||||
delete toplevel;
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::text()
|
||||
@ -1585,7 +1465,6 @@ void tst_QAccessibility::text()
|
||||
#if !defined(QT3_SUPPORT)
|
||||
QSKIP("This test needs Qt3Support", SkipAll);
|
||||
#else
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QWidget *toplevel = createGUI();
|
||||
toplevel->show();
|
||||
#if defined(Q_WS_X11)
|
||||
@ -1681,10 +1560,6 @@ void tst_QAccessibility::text()
|
||||
|
||||
delete toplevel;
|
||||
QTestAccessibility::clearEvents();
|
||||
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
#endif // !QT3_SUPPORT
|
||||
}
|
||||
|
||||
@ -1693,7 +1568,6 @@ void tst_QAccessibility::setText()
|
||||
#if !defined(QT3_SUPPORT)
|
||||
QSKIP("This test needs Qt3Support", SkipAll);
|
||||
#else
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QWidget *toplevel = createGUI();
|
||||
toplevel->show();
|
||||
QObject *bottomLeft = toplevel->findChild<QObject *>("bottomLeft");
|
||||
@ -1717,16 +1591,11 @@ void tst_QAccessibility::setText()
|
||||
delete acc_lineedit;
|
||||
delete toplevel;
|
||||
QTestAccessibility::clearEvents();
|
||||
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
#endif //QT3_SUPPORT
|
||||
}
|
||||
|
||||
void tst_QAccessibility::hideShowTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QWidget * const window = new QWidget();
|
||||
QWidget * const child = new QWidget(window);
|
||||
|
||||
@ -1753,14 +1622,10 @@ void tst_QAccessibility::hideShowTest()
|
||||
|
||||
delete window;
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::userActionCount()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QWidget widget;
|
||||
|
||||
QAccessibleInterface *test = QAccessible::queryAccessibleInterface(&widget);
|
||||
@ -1790,18 +1655,14 @@ void tst_QAccessibility::userActionCount()
|
||||
QCOMPARE(test->userActionCount(1), 0);
|
||||
QCOMPARE(test->userActionCount(-1), 0);
|
||||
delete test; test = 0;
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::actionText()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QWidget widget;
|
||||
widget.show();
|
||||
QWidget *widget = new QWidget;
|
||||
widget->show();
|
||||
|
||||
QAccessibleInterface *test = QAccessible::queryAccessibleInterface(&widget);
|
||||
QAccessibleInterface *test = QAccessible::queryAccessibleInterface(widget);
|
||||
QVERIFY(test);
|
||||
QVERIFY(test->isValid());
|
||||
|
||||
@ -1813,20 +1674,15 @@ void tst_QAccessibility::actionText()
|
||||
QCOMPARE(test->actionText(QAccessible::DefaultAction, QAccessible::Name, 0), QString("SetFocus"));
|
||||
QCOMPARE(test->actionText(QAccessible::SetFocus, QAccessible::Name, 0), QString("SetFocus"));
|
||||
|
||||
delete test; test = 0;
|
||||
delete test;
|
||||
delete widget;
|
||||
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
QTestAccessibility::clearEvents();
|
||||
}
|
||||
|
||||
void tst_QAccessibility::doAction()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QSKIP("TODO: Implement me", SkipAll);
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::applicationTest()
|
||||
@ -1881,7 +1737,6 @@ public Q_SLOTS:
|
||||
|
||||
void tst_QAccessibility::buttonTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QWidget window;
|
||||
window.setLayout(new QVBoxLayout);
|
||||
|
||||
@ -2070,10 +1925,6 @@ void tst_QAccessibility::buttonTest()
|
||||
// test->release();
|
||||
|
||||
QTestAccessibility::clearEvents();
|
||||
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::sliderTest()
|
||||
@ -2081,20 +1932,19 @@ void tst_QAccessibility::sliderTest()
|
||||
#if !defined(QT3_SUPPORT)
|
||||
QSKIP("This test needs Qt3Support", SkipAll);
|
||||
#else
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QAccessibleInterface *test = 0;
|
||||
Q3VBox vbox;
|
||||
QLabel labelHorizontal("Horizontal", &vbox);
|
||||
QSlider sliderHorizontal(Qt::Horizontal, &vbox);
|
||||
labelHorizontal.setBuddy(&sliderHorizontal);
|
||||
Q3VBox *vbox = new Q3VBox;
|
||||
QLabel *labelHorizontal = new QLabel("Horizontal", vbox);
|
||||
QSlider *sliderHorizontal = new QSlider(Qt::Horizontal, vbox);
|
||||
labelHorizontal->setBuddy(sliderHorizontal);
|
||||
|
||||
QLabel labelVertical("Vertical", &vbox);
|
||||
QSlider sliderVertical(Qt::Vertical, &vbox);
|
||||
labelVertical.setBuddy(&sliderVertical);
|
||||
vbox.show();
|
||||
QLabel *labelVertical = new QLabel("Vertical", vbox);
|
||||
QSlider *sliderVertical = new QSlider(Qt::Vertical, vbox);
|
||||
labelVertical->setBuddy(sliderVertical);
|
||||
vbox->show();
|
||||
|
||||
// test horizontal slider
|
||||
test = QAccessible::queryAccessibleInterface(&sliderHorizontal);
|
||||
test = QAccessible::queryAccessibleInterface(sliderHorizontal);
|
||||
QVERIFY(test);
|
||||
QCOMPARE(test->childCount(), 3);
|
||||
QCOMPARE(test->role(0), QAccessible::Slider);
|
||||
@ -2102,15 +1952,15 @@ void tst_QAccessibility::sliderTest()
|
||||
QCOMPARE(test->role(2), QAccessible::Indicator);
|
||||
QCOMPARE(test->role(3), QAccessible::PushButton);
|
||||
|
||||
QCOMPARE(test->text(QAccessible::Name, 0), labelHorizontal.text());
|
||||
QCOMPARE(test->text(QAccessible::Name, 0), labelHorizontal->text());
|
||||
QCOMPARE(test->text(QAccessible::Name, 1), QSlider::tr("Page left"));
|
||||
QCOMPARE(test->text(QAccessible::Name, 2), QSlider::tr("Position"));
|
||||
QCOMPARE(test->text(QAccessible::Name, 3), QSlider::tr("Page right"));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal.value()));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal->value()));
|
||||
QCOMPARE(test->text(QAccessible::Value, 1), QString());
|
||||
QCOMPARE(test->text(QAccessible::Value, 2), QString::number(sliderHorizontal.value()));
|
||||
QCOMPARE(test->text(QAccessible::Value, 2), QString::number(sliderHorizontal->value()));
|
||||
QCOMPARE(test->text(QAccessible::Value, 3), QString());
|
||||
// Skip acton tests.
|
||||
// Skip action tests.
|
||||
#if 0
|
||||
QCOMPARE(test->defaultAction(0), QAccessible::SetFocus);
|
||||
QCOMPARE(test->defaultAction(1), QAccessible::Press);
|
||||
@ -2122,26 +1972,26 @@ void tst_QAccessibility::sliderTest()
|
||||
QCOMPARE(test->actionText(QAccessible::Decrease, QAccessible::Name, 2), QSlider::tr("Decrease"));
|
||||
QCOMPARE(test->actionText(QAccessible::Press, QAccessible::Name, 3), QSlider::tr("Press"));
|
||||
QVERIFY(test->doAction(QAccessible::Press, 3));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal.pageStep()));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal->pageStep()));
|
||||
QVERIFY(test->doAction(QAccessible::Press, 3));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderHorizontal.pageStep()));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderHorizontal->pageStep()));
|
||||
QVERIFY(test->doAction(QAccessible::Press, 1));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal.pageStep()));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal->pageStep()));
|
||||
QVERIFY(test->doAction(QAccessible::Press, 1));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(0));
|
||||
QVERIFY(test->doAction(QAccessible::Increase, 2));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal.lineStep()));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal->lineStep()));
|
||||
QVERIFY(test->doAction(QAccessible::Increase, 2));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderHorizontal.lineStep()));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderHorizontal->lineStep()));
|
||||
QVERIFY(test->doAction(QAccessible::Decrease, 2));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal.lineStep()));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal->lineStep()));
|
||||
QVERIFY(test->doAction(QAccessible::Decrease, 2));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(0));
|
||||
#endif
|
||||
delete test;
|
||||
|
||||
// test vertical slider
|
||||
test = QAccessible::queryAccessibleInterface(&sliderVertical);
|
||||
test = QAccessible::queryAccessibleInterface(sliderVertical);
|
||||
QVERIFY(test);
|
||||
QCOMPARE(test->childCount(), 3);
|
||||
QCOMPARE(test->role(0), QAccessible::Slider);
|
||||
@ -2149,15 +1999,15 @@ void tst_QAccessibility::sliderTest()
|
||||
QCOMPARE(test->role(2), QAccessible::Indicator);
|
||||
QCOMPARE(test->role(3), QAccessible::PushButton);
|
||||
|
||||
QCOMPARE(test->text(QAccessible::Name, 0), labelVertical.text());
|
||||
QCOMPARE(test->text(QAccessible::Name, 0), labelVertical->text());
|
||||
QCOMPARE(test->text(QAccessible::Name, 1), QSlider::tr("Page up"));
|
||||
QCOMPARE(test->text(QAccessible::Name, 2), QSlider::tr("Position"));
|
||||
QCOMPARE(test->text(QAccessible::Name, 3), QSlider::tr("Page down"));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical.value()));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical->value()));
|
||||
QCOMPARE(test->text(QAccessible::Value, 1), QString());
|
||||
QCOMPARE(test->text(QAccessible::Value, 2), QString::number(sliderVertical.value()));
|
||||
QCOMPARE(test->text(QAccessible::Value, 2), QString::number(sliderVertical->value()));
|
||||
QCOMPARE(test->text(QAccessible::Value, 3), QString());
|
||||
// Skip acton tests.
|
||||
// Skip action tests.
|
||||
#if 0
|
||||
QCOMPARE(test->defaultAction(0), QAccessible::SetFocus);
|
||||
QCOMPARE(test->defaultAction(1), QAccessible::Press);
|
||||
@ -2169,23 +2019,28 @@ void tst_QAccessibility::sliderTest()
|
||||
QCOMPARE(test->actionText(QAccessible::Decrease, QAccessible::Name, 2), QSlider::tr("Decrease"));
|
||||
QCOMPARE(test->actionText(QAccessible::Press, QAccessible::Name, 3), QSlider::tr("Press"));
|
||||
QVERIFY(test->doAction(QAccessible::Press, 3));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical.pageStep()));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical->pageStep()));
|
||||
QVERIFY(test->doAction(QAccessible::Press, 3));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderVertical.pageStep()));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderVertical->pageStep()));
|
||||
QVERIFY(test->doAction(QAccessible::Press, 1));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical.pageStep()));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical->pageStep()));
|
||||
QVERIFY(test->doAction(QAccessible::Press, 1));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(0));
|
||||
QVERIFY(test->doAction(QAccessible::Increase, 2));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical.lineStep()));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical->lineStep()));
|
||||
QVERIFY(test->doAction(QAccessible::Increase, 2));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderVertical.lineStep()));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderVertical->lineStep()));
|
||||
QVERIFY(test->doAction(QAccessible::Decrease, 2));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical.lineStep()));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical->lineStep()));
|
||||
QVERIFY(test->doAction(QAccessible::Decrease, 2));
|
||||
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(0));
|
||||
#endif
|
||||
delete test;
|
||||
delete sliderHorizontal;
|
||||
delete sliderVertical;
|
||||
delete labelHorizontal;
|
||||
delete labelVertical;
|
||||
delete vbox;
|
||||
|
||||
// Test that when we hide() a slider, the PageLeft, Indicator, and PageRight also gets the
|
||||
// Invisible state bit set.
|
||||
@ -2268,17 +2123,12 @@ void tst_QAccessibility::sliderTest()
|
||||
delete sliderInterface;
|
||||
}
|
||||
|
||||
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
#endif //!QT3_SUPPORT
|
||||
}
|
||||
|
||||
void tst_QAccessibility::scrollBarTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
// Test that when we hide() a slider, the PageLeft, Indicator, and PageRight also gets the
|
||||
// Invisible state bit set.
|
||||
enum SubControls { LineUp = 1,
|
||||
@ -2286,7 +2136,7 @@ void tst_QAccessibility::scrollBarTest()
|
||||
Position = 3,
|
||||
PageDown = 4,
|
||||
LineDown = 5
|
||||
};
|
||||
};
|
||||
|
||||
QScrollBar *scrollBar = new QScrollBar();
|
||||
QAccessibleInterface * const scrollBarInterface = QAccessible::queryAccessibleInterface(scrollBar);
|
||||
@ -2368,15 +2218,10 @@ void tst_QAccessibility::scrollBarTest()
|
||||
}
|
||||
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void tst_QAccessibility::tabTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QTabBar *tabBar = new QTabBar();
|
||||
tabBar->show();
|
||||
|
||||
@ -2412,9 +2257,6 @@ void tst_QAccessibility::tabTest()
|
||||
delete tabBar;
|
||||
delete interface;
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::tabWidgetTest()
|
||||
@ -2512,7 +2354,6 @@ void tst_QAccessibility::tabWidgetTest()
|
||||
|
||||
void tst_QAccessibility::menuTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
{
|
||||
QMainWindow mw;
|
||||
mw.resize(300, 200);
|
||||
@ -2758,14 +2599,10 @@ void tst_QAccessibility::menuTest()
|
||||
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::spinBoxTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QSpinBox * const spinBox = new QSpinBox();
|
||||
spinBox->show();
|
||||
|
||||
@ -2792,14 +2629,10 @@ void tst_QAccessibility::spinBoxTest()
|
||||
QVERIFY(events.contains(expectedEvent));
|
||||
delete spinBox;
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::doubleSpinBoxTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QDoubleSpinBox *doubleSpinBox = new QDoubleSpinBox;
|
||||
doubleSpinBox->show();
|
||||
|
||||
@ -2819,14 +2652,10 @@ void tst_QAccessibility::doubleSpinBoxTest()
|
||||
|
||||
delete doubleSpinBox;
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::textEditTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
{
|
||||
QTextEdit edit;
|
||||
QString text = "hello world\nhow are you today?\n";
|
||||
@ -2846,14 +2675,10 @@ void tst_QAccessibility::textEditTest()
|
||||
QCOMPARE(iface->textInterface()->characterRect(6, QAccessible2::RelativeToParent).size(), QSize(fm.width("w"), fm.height()));
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::textBrowserTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
{
|
||||
QTextBrowser textBrowser;
|
||||
QString text = QLatin1String("Hello world\nhow are you today?\n");
|
||||
@ -2870,14 +2695,10 @@ void tst_QAccessibility::textBrowserTest()
|
||||
QCOMPARE(interface->text(QAccessible::Value, 6), QString());
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::listViewTest()
|
||||
{
|
||||
#if 1 //def QTEST_ACCESSIBILITY
|
||||
{
|
||||
QListView listView;
|
||||
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(&listView);
|
||||
@ -2943,15 +2764,11 @@ void tst_QAccessibility::listViewTest()
|
||||
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void tst_QAccessibility::mdiAreaTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
{
|
||||
QMdiArea mdiArea;
|
||||
mdiArea.resize(400,300);
|
||||
@ -3000,14 +2817,10 @@ void tst_QAccessibility::mdiAreaTest()
|
||||
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::mdiSubWindowTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
{
|
||||
QMdiArea mdiArea;
|
||||
mdiArea.show();
|
||||
@ -3130,14 +2943,10 @@ void tst_QAccessibility::mdiSubWindowTest()
|
||||
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::lineEditTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QLineEdit *le = new QLineEdit;
|
||||
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(le);
|
||||
QVERIFY(iface);
|
||||
@ -3195,14 +3004,10 @@ void tst_QAccessibility::lineEditTest()
|
||||
delete le2;
|
||||
delete toplevel;
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::workspaceTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
{
|
||||
QWorkspace workspace;
|
||||
workspace.resize(400,300);
|
||||
@ -3256,14 +3061,10 @@ void tst_QAccessibility::workspaceTest()
|
||||
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::dialogButtonBoxTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
{
|
||||
QDialogButtonBox box(QDialogButtonBox::Reset |
|
||||
QDialogButtonBox::Help |
|
||||
@ -3376,14 +3177,10 @@ void tst_QAccessibility::dialogButtonBoxTest()
|
||||
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::dialTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
{
|
||||
QDial dial;
|
||||
dial.setValue(20);
|
||||
@ -3425,28 +3222,20 @@ void tst_QAccessibility::dialTest()
|
||||
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::rubberBandTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QRubberBand rubberBand(QRubberBand::Rectangle);
|
||||
QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&rubberBand);
|
||||
QVERIFY(interface);
|
||||
QCOMPARE(interface->role(0), QAccessible::Border);
|
||||
delete interface;
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::abstractScrollAreaTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
{
|
||||
QAbstractScrollArea abstractScrollArea;
|
||||
|
||||
@ -3604,14 +3393,10 @@ void tst_QAccessibility::abstractScrollAreaTest()
|
||||
}
|
||||
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::scrollAreaTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
{
|
||||
QScrollArea scrollArea;
|
||||
scrollArea.show();
|
||||
@ -3625,14 +3410,10 @@ void tst_QAccessibility::scrollAreaTest()
|
||||
delete interface;
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::tableWidgetTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
{
|
||||
QWidget *topLevel = new QWidget;
|
||||
QTableWidget *w = new QTableWidget(8,4,topLevel);
|
||||
@ -3672,10 +3453,6 @@ void tst_QAccessibility::tableWidgetTest()
|
||||
delete topLevel;
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
class QtTestTableModel: public QAbstractTableModel
|
||||
@ -3758,7 +3535,6 @@ public:
|
||||
|
||||
void tst_QAccessibility::tableViewTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
{
|
||||
QtTestTableModel *model = new QtTestTableModel(3, 4);
|
||||
QTableView *w = new QTableView();
|
||||
@ -3838,15 +3614,11 @@ void tst_QAccessibility::tableViewTest()
|
||||
delete model;
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::calendarWidgetTest()
|
||||
{
|
||||
#ifndef QT_NO_CALENDARWIDGET
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
{
|
||||
QCalendarWidget calendarWidget;
|
||||
|
||||
@ -3939,17 +3711,12 @@ void tst_QAccessibility::calendarWidgetTest()
|
||||
|
||||
}
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
#endif // QT_NO_CALENDARWIDGET
|
||||
}
|
||||
|
||||
void tst_QAccessibility::dockWidgetTest()
|
||||
{
|
||||
#ifndef QT_NO_DOCKWIDGET
|
||||
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
// Set up a proper main window with two dock widgets
|
||||
QMainWindow *mw = new QMainWindow();
|
||||
QFrame *central = new QFrame(mw);
|
||||
@ -4017,19 +3784,14 @@ void tst_QAccessibility::dockWidgetTest()
|
||||
delete dock2;
|
||||
delete mw;
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
#endif // QT_NO_DOCKWIDGET
|
||||
}
|
||||
|
||||
void tst_QAccessibility::pushButtonTest()
|
||||
{
|
||||
#if !defined(QT3_SUPPORT)
|
||||
qWarning( "Should never get here without Qt3Support");
|
||||
return ;
|
||||
QSKIP( "Should never get here without Qt3Support", SkipAll);
|
||||
#else
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
// Set up a proper main window with two dock widgets
|
||||
QWidget *toplevel = createGUI();
|
||||
QObject *topRight = toplevel->findChild<QObject *>("topRight");
|
||||
@ -4063,15 +3825,11 @@ void tst_QAccessibility::pushButtonTest()
|
||||
delete accToplevel;
|
||||
delete toplevel;
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
#endif //QT3_SUPPORT
|
||||
}
|
||||
|
||||
void tst_QAccessibility::comboBoxTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
#if defined(Q_OS_WINCE)
|
||||
if (!IsValidCEPlatform()) {
|
||||
QSKIP("Test skipped on Windows Mobile test hardware", SkipAll);
|
||||
@ -4109,15 +3867,10 @@ void tst_QAccessibility::comboBoxTest()
|
||||
delete w;
|
||||
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void tst_QAccessibility::treeWidgetTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QWidget *w = new QWidget;
|
||||
QTreeWidget *tree = new QTreeWidget(w);
|
||||
QHBoxLayout *l = new QHBoxLayout(w);
|
||||
@ -4175,14 +3928,10 @@ void tst_QAccessibility::treeWidgetTest()
|
||||
delete w;
|
||||
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::labelTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QString text = "Hello World";
|
||||
QLabel *label = new QLabel(text);
|
||||
label->show();
|
||||
@ -4221,14 +3970,10 @@ void tst_QAccessibility::labelTest()
|
||||
delete acc_label;
|
||||
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::accelerators()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QWidget *window = new QWidget;
|
||||
QHBoxLayout *lay = new QHBoxLayout(window);
|
||||
QLabel *label = new QLabel(tr("&Line edit"), window);
|
||||
@ -4252,6 +3997,10 @@ void tst_QAccessibility::accelerators()
|
||||
QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + QLatin1String("A"));
|
||||
label->setText(tr("Q &&A"));
|
||||
QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QString());
|
||||
|
||||
#if !defined(QT_NO_DEBUG) && !defined(Q_WS_MAC)
|
||||
QTest::ignoreMessage(QtWarningMsg, "QKeySequence::mnemonic: \"Q &A&B\" contains multiple occurrences of '&'");
|
||||
#endif
|
||||
label->setText(tr("Q &A&B"));
|
||||
QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + QLatin1String("A"));
|
||||
|
||||
@ -4261,9 +4010,6 @@ void tst_QAccessibility::accelerators()
|
||||
QTest::qWait(100);
|
||||
delete window;
|
||||
QTestAccessibility::clearEvents();
|
||||
#else
|
||||
QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -241,7 +241,8 @@ QList<ResultSet> testAlgorithm(Algorithm &algorithm, QStringList dataSetTypes,
|
||||
foreach(QString dataSetType, dataSetTypes) {
|
||||
QVector<DataType> container = generateData<DataType>(dataSetType, size);
|
||||
results.append(testRun(container, algorithm, time));
|
||||
Q_ASSERT(isSorted(container));
|
||||
if (!isSorted(container))
|
||||
qWarning("%s: container is not sorted after test", Q_FUNC_INFO);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
@ -116,8 +116,7 @@ tst_QAtomicInt::~tst_QAtomicInt()
|
||||
|
||||
void tst_QAtomicInt::warningFreeHelper()
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
// The code below is bogus, and shouldn't be run. We're looking for warnings, only.
|
||||
qFatal("This code is bogus, and shouldn't be run. We're looking for compiler warnings only.");
|
||||
|
||||
QBasicAtomicInt i = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
|
||||
|
@ -98,8 +98,7 @@ struct WFHC
|
||||
|
||||
void tst_QAtomicPointer::warningFreeHelper()
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
// The code below is bogus, and shouldn't be run. We're looking for warnings, only.
|
||||
qFatal("This code is bogus, and shouldn't be run. We're looking for compiler warnings only.");
|
||||
|
||||
QBasicAtomicPointer<WFHC> p = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
|
||||
|
@ -309,8 +309,7 @@ void tst_QBuffer::seekTest()
|
||||
// (see Task 184730)
|
||||
{
|
||||
char c;
|
||||
const int offset = 1;
|
||||
Q_ASSERT(offset > 0); // any positive integer will do
|
||||
const int offset = 1; // any positive integer will do
|
||||
const qint64 pos = buf.size() + offset;
|
||||
QVERIFY(buf.seek(pos));
|
||||
QCOMPARE(buf.pos(), pos);
|
||||
|
@ -548,14 +548,14 @@ void tst_QChar::normalization_data()
|
||||
|
||||
QList<QByteArray> l = line.split(';');
|
||||
|
||||
Q_ASSERT(l.size() == 5);
|
||||
QCOMPARE(l.size(), 5);
|
||||
|
||||
QStringList columns;
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
columns.append(QString());
|
||||
|
||||
QList<QByteArray> c = l.at(i).split(' ');
|
||||
Q_ASSERT(!c.isEmpty());
|
||||
QVERIFY(!c.isEmpty());
|
||||
|
||||
for (int j = 0; j < c.size(); ++j) {
|
||||
bool ok;
|
||||
|
@ -277,7 +277,9 @@ retry:
|
||||
case 'L': row = completer->completionCount() - 1; break;
|
||||
case 'F': row = 0; break;
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
QFAIL(qPrintable(QString(
|
||||
"Problem with 'step' value in test data: %1 (only P, N, L and F are allowed)."
|
||||
).arg(step[i])));
|
||||
}
|
||||
completer->setCurrentRow(row);
|
||||
}
|
||||
@ -1248,9 +1250,7 @@ public:
|
||||
void tst_QCompleter::task189564_omitNonSelectableItems()
|
||||
{
|
||||
const QString prefix("a");
|
||||
Q_ASSERT(!prefix.isEmpty());
|
||||
const int n = 5;
|
||||
Q_ASSERT(n > 0);
|
||||
|
||||
QStringList strings;
|
||||
for (int i = 0; i < n; ++i)
|
||||
@ -1278,10 +1278,11 @@ public:
|
||||
{
|
||||
setEditable(true);
|
||||
setInsertPolicy(NoInsert);
|
||||
Q_ASSERT(completer());
|
||||
completer()->setCompletionMode(QCompleter::PopupCompletion);
|
||||
completer()->setCompletionRole(Qt::DisplayRole);
|
||||
connect(lineEdit(), SIGNAL(editingFinished()), SLOT(setCompletionPrefix()));
|
||||
if (completer()) {
|
||||
completer()->setCompletionMode(QCompleter::PopupCompletion);
|
||||
completer()->setCompletionRole(Qt::DisplayRole);
|
||||
connect(lineEdit(), SIGNAL(editingFinished()), SLOT(setCompletionPrefix()));
|
||||
}
|
||||
}
|
||||
private slots:
|
||||
void setCompletionPrefix() { completer()->setCompletionPrefix(lineEdit()->text()); }
|
||||
@ -1290,6 +1291,7 @@ private slots:
|
||||
void tst_QCompleter::task246056_setCompletionPrefix()
|
||||
{
|
||||
task246056_ComboBox *comboBox = new task246056_ComboBox;
|
||||
QVERIFY(comboBox->completer());
|
||||
comboBox->addItem("");
|
||||
comboBox->addItem("a1");
|
||||
comboBox->addItem("a2");
|
||||
|
@ -49,7 +49,11 @@ int main(int argc, char** argv)
|
||||
#ifdef Q_WS_QWS
|
||||
QApplication app(argc, argv);
|
||||
QStringList args = app.arguments();
|
||||
Q_ASSERT(args.count() == 3 || args.count() == 4);
|
||||
if (args.count() != 3 && args.count() != 4) {
|
||||
fprintf(stdout,qPrintable(QString("Usage: %1 channel message [data]").arg(args.at(0))));
|
||||
fflush(stdout);
|
||||
return 1;
|
||||
}
|
||||
QString channelName = args.at(1);
|
||||
QString msg = args.at(2);
|
||||
QByteArray data;
|
||||
|
@ -2701,17 +2701,10 @@ void tst_QDateTimeEdit::task98554()
|
||||
QCOMPARE(testWidget->time(), QTime(0, 0, 10, 0));
|
||||
}
|
||||
|
||||
static QList<int> makeList(int val1, int val2 = -1, int val3 = -1, int val4 = -1, int val5 = -1, int val6 = -1, int val7 = -1)
|
||||
static QList<int> makeList(int val1, int val2, int val3)
|
||||
{
|
||||
QList<int> ret;
|
||||
Q_ASSERT(val1 >= 0);
|
||||
ret << val1;
|
||||
if (val2 < 0) {return ret;} else {ret << val2;}
|
||||
if (val3 < 0) {return ret;} else {ret << val3;}
|
||||
if (val4 < 0) {return ret;} else {ret << val4;}
|
||||
if (val5 < 0) {return ret;} else {ret << val5;}
|
||||
if (val6 < 0) {return ret;} else {ret << val6;}
|
||||
if (val7 >= 0) {ret << val2;}
|
||||
ret << val1 << val2 << val3;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2753,7 +2746,7 @@ void tst_QDateTimeEdit::setCurrentSection()
|
||||
QFETCH(QList<int>, setCurrentSections);
|
||||
QFETCH(QList<int>, expectedCursorPositions);
|
||||
|
||||
Q_ASSERT(setCurrentSections.size() == expectedCursorPositions.size());
|
||||
QCOMPARE(setCurrentSections.size(), expectedCursorPositions.size());
|
||||
testWidget->setDisplayFormat(format);
|
||||
testWidget->setDateTime(dateTime);
|
||||
#ifdef Q_WS_MAC
|
||||
|
@ -592,7 +592,7 @@ void tst_QDBusThreading::callbackInAnotherAuxThread()
|
||||
// wait for the event loop
|
||||
sem1.release();
|
||||
sem2.acquire();
|
||||
Q_ASSERT(loop);
|
||||
QVERIFY(loop);
|
||||
|
||||
// create the second thread
|
||||
new Thread;
|
||||
|
@ -641,10 +641,10 @@ void tst_QDirModel::filter()
|
||||
QDirModel model;
|
||||
model.setNameFilters(QStringList() << "*.nada");
|
||||
QModelIndex index = model.index(SRCDIR "test");
|
||||
Q_ASSERT(model.rowCount(index) == 0);
|
||||
QCOMPARE(model.rowCount(index), 0);
|
||||
QModelIndex index2 = model.index(SRCDIR "test/file01.tst");
|
||||
Q_ASSERT(!index2.isValid());
|
||||
Q_ASSERT(model.rowCount(index) == 0);
|
||||
QVERIFY(!index2.isValid());
|
||||
QCOMPARE(model.rowCount(index), 0);
|
||||
}
|
||||
|
||||
void tst_QDirModel::task244669_remove()
|
||||
|
@ -137,7 +137,6 @@ private slots:
|
||||
|
||||
private:
|
||||
static QDomDocument generateRequest();
|
||||
static QDomDocument doc(const QString &title, const QByteArray &ba);
|
||||
static int hasAttributesHelper( const QDomNode& node );
|
||||
static bool compareDocuments( const QDomDocument &doc1, const QDomDocument &doc2 );
|
||||
static bool compareNodes( const QDomNode &node1, const QDomNode &node2, bool deep );
|
||||
@ -1591,14 +1590,6 @@ void tst_QDom::reportDuplicateAttributes() const
|
||||
QVERIFY2(!isSuccess, "Duplicate attributes are well-formedness errors, and should be reported as such.");
|
||||
}
|
||||
|
||||
QDomDocument tst_QDom::doc(const QString &title, const QByteArray &ba)
|
||||
{
|
||||
QDomDocument doc(title);
|
||||
const bool ret = doc.setContent(ba, true);
|
||||
Q_ASSERT(ret);
|
||||
return doc;
|
||||
}
|
||||
|
||||
void tst_QDom::namespacedAttributes() const
|
||||
{
|
||||
static const char *const xml =
|
||||
@ -1611,8 +1602,13 @@ void tst_QDom::namespacedAttributes() const
|
||||
" <Title displayLabel='Title' >>>> SIMPLE BASIC OP - SEND - DUT AS SINK</Title>\n"
|
||||
"</xan:td>\n";
|
||||
|
||||
QDomDocument one = doc("document", xml);
|
||||
QDomDocument two = doc("document2", one.toByteArray(2));
|
||||
QDomDocument one("document");
|
||||
QString error;
|
||||
bool docParsed = one.setContent(QByteArray(xml), true, &error);
|
||||
QVERIFY2(docParsed, qPrintable(error));
|
||||
QDomDocument two("document2");
|
||||
docParsed = two.setContent(one.toByteArray(2), true, &error);
|
||||
QVERIFY2(docParsed, qPrintable(error));
|
||||
|
||||
QVERIFY(isDeepEqual(one, two));
|
||||
}
|
||||
|
@ -160,13 +160,10 @@ static inline void appendRaw(QByteArray &array, T data)
|
||||
*/
|
||||
static inline void topUpWith(QByteArray &array, QByteArray filler, int size)
|
||||
{
|
||||
Q_ASSERT(filler.size() > 0);
|
||||
|
||||
for (int i = (size - array.size()) / filler.size(); i > 0; --i)
|
||||
array.append(filler);
|
||||
|
||||
if (array.size() < size) {
|
||||
Q_ASSERT(size - array.size() < filler.size());
|
||||
array.append(filler.left(size - array.size()));
|
||||
}
|
||||
}
|
||||
@ -206,15 +203,12 @@ static inline QByteArray generateDataBlock(int blockSize, QString text, qint64 u
|
||||
|
||||
QByteArray filler("0123456789");
|
||||
block.append(filler.right(10 - block.size() % 10));
|
||||
topUpWith(block, filler, blockSize - 2 * sizeof(qint64));
|
||||
topUpWith(block, filler, blockSize - 3 * sizeof(qint64));
|
||||
|
||||
appendRaw(block, counter);
|
||||
appendRaw(block, userBits);
|
||||
appendRaw(block, randomBits);
|
||||
|
||||
Q_ASSERT( block.size() >= blockSize );
|
||||
block.resize(blockSize);
|
||||
|
||||
++counter;
|
||||
return block;
|
||||
}
|
||||
|
@ -812,7 +812,7 @@ void tst_QFileDialog2::task239706_editableFilterCombo()
|
||||
break;
|
||||
}
|
||||
}
|
||||
Q_ASSERT(filterCombo);
|
||||
QVERIFY(filterCombo);
|
||||
filterCombo->setEditable(true);
|
||||
QTest::mouseClick(filterCombo, Qt::LeftButton);
|
||||
QTest::keyPress(filterCombo, Qt::Key_X);
|
||||
|
@ -132,33 +132,32 @@ static void setAnchor(QGraphicsAnchorLayout *l,
|
||||
anchor->setSpacing(spacing);
|
||||
}
|
||||
|
||||
static bool checkReverseDirection(QGraphicsWidget *w)
|
||||
static bool checkReverseDirection(QGraphicsWidget *widget)
|
||||
{
|
||||
QGraphicsLayout *l = w->layout();
|
||||
Q_ASSERT(l);
|
||||
QGraphicsLayout *layout = widget->layout();
|
||||
qreal left, top, right, bottom;
|
||||
l->getContentsMargins(&left, &top, &right, &bottom);
|
||||
w->setLayoutDirection(Qt::LeftToRight);
|
||||
layout->getContentsMargins(&left, &top, &right, &bottom);
|
||||
widget->setLayoutDirection(Qt::LeftToRight);
|
||||
QApplication::processEvents();
|
||||
const QRectF lg = l->geometry();
|
||||
const QRectF layoutGeometry = layout->geometry();
|
||||
QMap<QGraphicsLayoutItem *, QRectF> geometries;
|
||||
for (int i = 0; i < l->count(); ++i) {
|
||||
QGraphicsLayoutItem *w = l->itemAt(i);
|
||||
geometries.insert(w, w->geometry());
|
||||
for (int i = 0; i < layout->count(); ++i) {
|
||||
QGraphicsLayoutItem *item = layout->itemAt(i);
|
||||
geometries.insert(item, item->geometry());
|
||||
}
|
||||
w->setLayoutDirection(Qt::RightToLeft);
|
||||
widget->setLayoutDirection(Qt::RightToLeft);
|
||||
QApplication::processEvents();
|
||||
lg.adjusted(+right, +top, -left, -bottom);
|
||||
for (int i = 0; i < l->count(); ++i) {
|
||||
QGraphicsLayoutItem *w = l->itemAt(i);
|
||||
const QRectF rtlGeom = w->geometry();
|
||||
const QRectF ltrGeom = geometries.value(w);
|
||||
QRectF expectedGeom = ltrGeom;
|
||||
expectedGeom.moveRight(lg.right() - (0 + ltrGeom.left()));
|
||||
if (expectedGeom != rtlGeom) {
|
||||
qDebug() << "layout->geometry():" << lg
|
||||
<< "expected:" << expectedGeom
|
||||
<< "actual:" << rtlGeom;
|
||||
layoutGeometry.adjusted(+right, +top, -left, -bottom);
|
||||
for (int i = 0; i < layout->count(); ++i) {
|
||||
QGraphicsLayoutItem *item = layout->itemAt(i);
|
||||
const QRectF rightToLeftGeometry = item->geometry();
|
||||
const QRectF leftToRightGeometry = geometries.value(item);
|
||||
QRectF expectedGeometry = leftToRightGeometry;
|
||||
expectedGeometry.moveRight(layoutGeometry.right() - leftToRightGeometry.left());
|
||||
if (expectedGeometry != rightToLeftGeometry) {
|
||||
qDebug() << "layout->geometry():" << layoutGeometry
|
||||
<< "expected:" << expectedGeometry
|
||||
<< "actual:" << rightToLeftGeometry;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -345,6 +344,7 @@ void tst_QGraphicsAnchorLayout::layoutDirection()
|
||||
p->show();
|
||||
view->show();
|
||||
|
||||
QVERIFY(p->layout());
|
||||
QCOMPARE(checkReverseDirection(p), true);
|
||||
|
||||
if (hasSimplification) {
|
||||
@ -445,6 +445,7 @@ void tst_QGraphicsAnchorLayout::diagonal()
|
||||
QVERIFY(!usedSimplex(l, Qt::Vertical));
|
||||
}
|
||||
|
||||
QVERIFY(p.layout());
|
||||
QCOMPARE(checkReverseDirection(&p), true);
|
||||
|
||||
c->setMinimumWidth(300);
|
||||
@ -735,6 +736,7 @@ void tst_QGraphicsAnchorLayout::snakeOppositeDirections()
|
||||
QCOMPARE(c->geometry(), QRectF(90.0, 200.0, 100.0, 100.0));
|
||||
QCOMPARE(p.size(), layoutMaximumSize);
|
||||
|
||||
QVERIFY(p.layout());
|
||||
QCOMPARE(checkReverseDirection(&p), true);
|
||||
}
|
||||
|
||||
|
@ -2585,15 +2585,11 @@ void tst_QGraphicsAnchorLayout1::testSizeDistribution_data()
|
||||
sizeHints1.insert( Qt::MinimumSize, 30 );
|
||||
sizeHints1.insert( Qt::PreferredSize, 35 );
|
||||
sizeHints1.insert( Qt::MaximumSize, 40 );
|
||||
Q_ASSERT( sizeHints1.value( Qt::MinimumSize ) <= sizeHints1.value( Qt::PreferredSize ) );
|
||||
Q_ASSERT( sizeHints1.value( Qt::PreferredSize ) <= sizeHints1.value( Qt::MaximumSize ) );
|
||||
|
||||
SizeHintArray sizeHints2;
|
||||
sizeHints2.insert( Qt::MinimumSize, 5 );
|
||||
sizeHints2.insert( Qt::PreferredSize, 35 );
|
||||
sizeHints2.insert( Qt::MaximumSize, 300 );
|
||||
Q_ASSERT( sizeHints2.value( Qt::MinimumSize ) <= sizeHints2.value( Qt::PreferredSize ) );
|
||||
Q_ASSERT( sizeHints2.value( Qt::PreferredSize ) <= sizeHints2.value( Qt::MaximumSize ) );
|
||||
|
||||
const qreal width1 = 35;
|
||||
const qreal width2 = 100-10-10-10-width1;
|
||||
@ -2605,15 +2601,11 @@ void tst_QGraphicsAnchorLayout1::testSizeDistribution_data()
|
||||
sizeHints1.insert( Qt::MinimumSize, 0 );
|
||||
sizeHints1.insert( Qt::PreferredSize, 20 );
|
||||
sizeHints1.insert( Qt::MaximumSize, 100 );
|
||||
Q_ASSERT( sizeHints1.value( Qt::MinimumSize ) <= sizeHints1.value( Qt::PreferredSize ) );
|
||||
Q_ASSERT( sizeHints1.value( Qt::PreferredSize ) <= sizeHints1.value( Qt::MaximumSize ) );
|
||||
|
||||
SizeHintArray sizeHints2;
|
||||
sizeHints2.insert( Qt::MinimumSize, 0 );
|
||||
sizeHints2.insert( Qt::PreferredSize, 50 );
|
||||
sizeHints2.insert( Qt::MaximumSize, 100 );
|
||||
Q_ASSERT( sizeHints2.value( Qt::MinimumSize ) <= sizeHints2.value( Qt::PreferredSize ) );
|
||||
Q_ASSERT( sizeHints2.value( Qt::PreferredSize ) <= sizeHints2.value( Qt::MaximumSize ) );
|
||||
|
||||
const qreal width1 = 20;
|
||||
const qreal width2 = 100-10-10-10-width1;
|
||||
@ -2625,15 +2617,11 @@ void tst_QGraphicsAnchorLayout1::testSizeDistribution_data()
|
||||
sizeHints1.insert( Qt::MinimumSize, 0 );
|
||||
sizeHints1.insert( Qt::PreferredSize, 40 );
|
||||
sizeHints1.insert( Qt::MaximumSize, 100 );
|
||||
Q_ASSERT( sizeHints1.value( Qt::MinimumSize ) <= sizeHints1.value( Qt::PreferredSize ) );
|
||||
Q_ASSERT( sizeHints1.value( Qt::PreferredSize ) <= sizeHints1.value( Qt::MaximumSize ) );
|
||||
|
||||
SizeHintArray sizeHints2;
|
||||
sizeHints2.insert( Qt::MinimumSize, 0 );
|
||||
sizeHints2.insert( Qt::PreferredSize, 60 );
|
||||
sizeHints2.insert( Qt::MaximumSize, 100 );
|
||||
Q_ASSERT( sizeHints2.value( Qt::MinimumSize ) <= sizeHints2.value( Qt::PreferredSize ) );
|
||||
Q_ASSERT( sizeHints2.value( Qt::PreferredSize ) <= sizeHints2.value( Qt::MaximumSize ) );
|
||||
|
||||
const qreal width1 = 28; // got from manual calculation
|
||||
const qreal width2 = 100-10-10-10-width1;
|
||||
@ -2645,15 +2633,11 @@ void tst_QGraphicsAnchorLayout1::testSizeDistribution_data()
|
||||
sizeHints1.insert( Qt::MinimumSize, 0 );
|
||||
sizeHints1.insert( Qt::PreferredSize, 10 );
|
||||
sizeHints1.insert( Qt::MaximumSize, 100 );
|
||||
Q_ASSERT( sizeHints1.value( Qt::MinimumSize ) <= sizeHints1.value( Qt::PreferredSize ) );
|
||||
Q_ASSERT( sizeHints1.value( Qt::PreferredSize ) <= sizeHints1.value( Qt::MaximumSize ) );
|
||||
|
||||
SizeHintArray sizeHints2;
|
||||
sizeHints2.insert( Qt::MinimumSize, 0 );
|
||||
sizeHints2.insert( Qt::PreferredSize, 40 );
|
||||
sizeHints2.insert( Qt::MaximumSize, 100 );
|
||||
Q_ASSERT( sizeHints2.value( Qt::MinimumSize ) <= sizeHints2.value( Qt::PreferredSize ) );
|
||||
Q_ASSERT( sizeHints2.value( Qt::PreferredSize ) <= sizeHints2.value( Qt::MaximumSize ) );
|
||||
|
||||
const qreal width1 = 22; // got from manual calculation
|
||||
const qreal width2 = 100-10-10-10-width1;
|
||||
@ -2669,6 +2653,12 @@ void tst_QGraphicsAnchorLayout1::testSizeDistribution()
|
||||
QFETCH(qreal, width1);
|
||||
QFETCH(qreal, width2);
|
||||
|
||||
// sanity-check the test data - MinimumSize <= PreferredSize <= MaximumSize
|
||||
QVERIFY( sizeHints1.value( Qt::MinimumSize ) <= sizeHints1.value( Qt::PreferredSize ) );
|
||||
QVERIFY( sizeHints1.value( Qt::PreferredSize ) <= sizeHints1.value( Qt::MaximumSize ) );
|
||||
QVERIFY( sizeHints2.value( Qt::MinimumSize ) <= sizeHints2.value( Qt::PreferredSize ) );
|
||||
QVERIFY( sizeHints2.value( Qt::PreferredSize ) <= sizeHints2.value( Qt::MaximumSize ) );
|
||||
|
||||
// create objects
|
||||
QGraphicsWidget widget;
|
||||
TheAnchorLayout *layout = new TheAnchorLayout;
|
||||
|
@ -3018,39 +3018,6 @@ static QSizeF wfh(Qt::SizeHint /*which*/, const QSizeF &constraint)
|
||||
return result;
|
||||
}
|
||||
|
||||
static qreal growthFactorBelowPreferredSize(qreal desired, qreal sumAvailable, qreal sumDesired)
|
||||
{
|
||||
Q_ASSERT(sumDesired != 0.0);
|
||||
return desired * qPow(sumAvailable / sumDesired, desired / sumDesired);
|
||||
}
|
||||
|
||||
static void expectedWidth(qreal minSize1, qreal prefSize1,
|
||||
qreal minSize2, qreal prefSize2,
|
||||
qreal targetSize, qreal *width1, qreal *width2)
|
||||
{
|
||||
qreal sumAvail,factor1,factor2;
|
||||
// stretch behaviour is different below and above preferred size...
|
||||
if (targetSize < prefSize1 + prefSize2) {
|
||||
sumAvail = targetSize - minSize1 - minSize2;
|
||||
const qreal desired1 = prefSize1 - minSize1;
|
||||
const qreal desired2 = prefSize2 - minSize2;
|
||||
const qreal sumDesired = desired1 + desired2;
|
||||
factor1 = growthFactorBelowPreferredSize(desired1, sumAvail, sumDesired);
|
||||
factor2 = growthFactorBelowPreferredSize(desired2, sumAvail, sumDesired);
|
||||
const qreal sumFactors = factor1 + factor2;
|
||||
*width1 = sumAvail*factor1/sumFactors + minSize1;
|
||||
*width2 = sumAvail*factor2/sumFactors + minSize2;
|
||||
} else {
|
||||
sumAvail = targetSize - prefSize1 - prefSize2;
|
||||
factor1 = prefSize1;
|
||||
factor2 = prefSize2;
|
||||
const qreal sumFactors = factor1 + factor2;
|
||||
*width1 = sumAvail*factor1/sumFactors + prefSize1;
|
||||
*width2 = sumAvail*factor2/sumFactors + prefSize2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool qFuzzyCompare(const QSizeF &a, const QSizeF &b)
|
||||
{
|
||||
return qFuzzyCompare(a.width(), b.width()) && qFuzzyCompare(a.height(), b.height());
|
||||
|
@ -10732,7 +10732,7 @@ void tst_QGraphicsItem::deviceCoordinateCache_simpleRotations()
|
||||
QTRY_VERIFY(view.repaints > 0);
|
||||
|
||||
QGraphicsItemCache *itemCache = QGraphicsItemPrivate::get(item)->extraItemCache();
|
||||
Q_ASSERT(itemCache);
|
||||
QVERIFY(itemCache);
|
||||
QPixmapCache::Key currentKey = itemCache->deviceData.value(view.viewport()).key;
|
||||
|
||||
// Trigger an update and verify that the cache is unchanged.
|
||||
|
@ -3594,7 +3594,7 @@ void tst_QGraphicsScene::task160653_selectionChanged()
|
||||
item->flags() | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable);
|
||||
item->setSelected(true);
|
||||
}
|
||||
Q_ASSERT(scene.items().size() > 1);
|
||||
QVERIFY(scene.items().size() > 1);
|
||||
QCOMPARE(scene.items().size(), scene.selectedItems().size());
|
||||
|
||||
QSignalSpy spy(&scene, SIGNAL(selectionChanged()));
|
||||
|
@ -1106,7 +1106,7 @@ void tst_QHeaderView::moveAndInsertSection()
|
||||
|
||||
void tst_QHeaderView::resizeMode()
|
||||
{
|
||||
// Q_ASSERT's when resizeMode is called with an invalid index
|
||||
// resizeMode must not be called with an invalid index
|
||||
int last = view->count() - 1;
|
||||
view->setResizeMode(QHeaderView::Interactive);
|
||||
QCOMPARE(view->resizeMode(last), QHeaderView::Interactive);
|
||||
|
@ -193,12 +193,12 @@ void testGetNumeric(QInputDialog *dialog, SpinBoxType * = 0, ValueType * = 0)
|
||||
void testGetText(QInputDialog *dialog)
|
||||
{
|
||||
QLineEdit *ledit = qFindChild<QLineEdit *>(dialog);
|
||||
Q_ASSERT(ledit);
|
||||
QVERIFY(ledit);
|
||||
|
||||
QDialogButtonBox *bbox = qFindChild<QDialogButtonBox *>(dialog);
|
||||
Q_ASSERT(bbox);
|
||||
QVERIFY(bbox);
|
||||
QPushButton *okButton = bbox->button(QDialogButtonBox::Ok);
|
||||
Q_ASSERT(okButton);
|
||||
QVERIFY(okButton);
|
||||
|
||||
QVERIFY(ledit->hasAcceptableInput());
|
||||
QCOMPARE(ledit->selectedText(), ledit->text());
|
||||
@ -211,12 +211,12 @@ void testGetText(QInputDialog *dialog)
|
||||
void testGetItem(QInputDialog *dialog)
|
||||
{
|
||||
QComboBox *cbox = qFindChild<QComboBox *>(dialog);
|
||||
Q_ASSERT(cbox);
|
||||
QVERIFY(cbox);
|
||||
|
||||
QDialogButtonBox *bbox = qFindChild<QDialogButtonBox *>(dialog);
|
||||
Q_ASSERT(bbox);
|
||||
QVERIFY(bbox);
|
||||
QPushButton *okButton = bbox->button(QDialogButtonBox::Ok);
|
||||
Q_ASSERT(okButton);
|
||||
QVERIFY(okButton);
|
||||
|
||||
QVERIFY(okButton->isEnabled());
|
||||
const int origIndex = cbox->currentIndex();
|
||||
@ -249,7 +249,7 @@ void tst_QInputDialog::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
killTimer(event->timerId());
|
||||
QInputDialog *dialog = qFindChild<QInputDialog *>(parent);
|
||||
Q_ASSERT(dialog);
|
||||
QVERIFY(dialog);
|
||||
if (testFunc)
|
||||
testFunc(dialog);
|
||||
dialog->done(doneCode); // cause static function call to return
|
||||
@ -270,7 +270,7 @@ void tst_QInputDialog::getInteger()
|
||||
{
|
||||
QFETCH(int, min);
|
||||
QFETCH(int, max);
|
||||
Q_ASSERT(min < max);
|
||||
QVERIFY(min < max);
|
||||
parent = new QWidget;
|
||||
doneCode = QDialog::Accepted;
|
||||
testFunc = &tst_QInputDialog::testFuncGetInteger;
|
||||
@ -310,7 +310,7 @@ void tst_QInputDialog::getDouble()
|
||||
QFETCH(double, min);
|
||||
QFETCH(double, max);
|
||||
QFETCH(int, decimals);
|
||||
Q_ASSERT(min < max && decimals >= 0 && decimals <= 13);
|
||||
QVERIFY(min < max && decimals >= 0 && decimals <= 13);
|
||||
parent = new QWidget;
|
||||
doneCode = QDialog::Accepted;
|
||||
testFunc = &tst_QInputDialog::testFuncGetDouble;
|
||||
|
@ -227,7 +227,6 @@ QAbstractItemModel *ModelsToTest::createModel(const QString &modelType)
|
||||
return widget->model();
|
||||
}
|
||||
|
||||
Q_ASSERT(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -309,15 +308,23 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model)
|
||||
*/
|
||||
}
|
||||
QModelIndex returnIndex = model->index(0,0);
|
||||
Q_ASSERT(returnIndex.isValid());
|
||||
if (!returnIndex.isValid())
|
||||
qFatal("%s: model index to be returned is invalid", Q_FUNC_INFO);
|
||||
return returnIndex;
|
||||
}
|
||||
|
||||
if (QDirModel *dirModel = qobject_cast<QDirModel *>(model)) {
|
||||
// Don't risk somthing bad happening, assert if this fails
|
||||
Q_ASSERT(QDir(QDir::currentPath()).mkdir("test"));
|
||||
for (int i = 0; i < 26; ++i)
|
||||
Q_ASSERT(QDir(QDir::currentPath()).mkdir(QString("test/foo_%1").arg(i)));
|
||||
if (!QDir::current().mkdir("test"))
|
||||
qFatal("%s: cannot create directory %s",
|
||||
Q_FUNC_INFO,
|
||||
qPrintable(QDir::toNativeSeparators(QDir::currentPath()+"/test")));
|
||||
for (int i = 0; i < 26; ++i) {
|
||||
QString subdir = QString("test/foo_%1").arg(i);
|
||||
if (!QDir::current().mkdir(subdir))
|
||||
qFatal("%s: cannot create directory %s",
|
||||
Q_FUNC_INFO,
|
||||
qPrintable(QDir::toNativeSeparators(QDir::currentPath()+"/"+subdir)));
|
||||
}
|
||||
return dirModel->index(QDir::currentPath()+"/test");
|
||||
}
|
||||
|
||||
@ -373,7 +380,7 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model)
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
Q_ASSERT(false);
|
||||
qFatal("%s: unknown type of model", Q_FUNC_INFO);
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
@ -387,9 +394,17 @@ void ModelsToTest::cleanupTestArea(QAbstractItemModel *model)
|
||||
{
|
||||
if (QDir(QDir::currentPath()+"/test").exists())
|
||||
{
|
||||
for (int i = 0; i < 26; ++i)
|
||||
QDir::current().rmdir(QString("test/foo_%1").arg(i));
|
||||
Q_ASSERT(QDir::current().rmdir("test"));
|
||||
for (int i = 0; i < 26; ++i) {
|
||||
QString subdir(QString("test/foo_%1").arg(i));
|
||||
if (!QDir::current().rmdir(subdir))
|
||||
qFatal("%s: cannot remove directory %s",
|
||||
Q_FUNC_INFO,
|
||||
qPrintable(QDir::toNativeSeparators(QDir::currentPath()+"/"+subdir)));
|
||||
}
|
||||
if (!QDir::current().rmdir("test"))
|
||||
qFatal("%s: cannot remove directory %s",
|
||||
Q_FUNC_INFO,
|
||||
qPrintable(QDir::toNativeSeparators(QDir::currentPath()+"/test")));
|
||||
}
|
||||
} else if (qobject_cast<QSqlQueryModel *>(model)) {
|
||||
QSqlQuery q("DROP TABLE test");
|
||||
|
@ -199,6 +199,7 @@ void tst_QItemModel::nonDestructiveBasicTest()
|
||||
{
|
||||
QFETCH(QString, modelType);
|
||||
currentModel = testModels->createModel(modelType);
|
||||
QVERIFY(currentModel);
|
||||
|
||||
QCOMPARE(currentModel->buddy(QModelIndex()), QModelIndex());
|
||||
currentModel->canFetchMore(QModelIndex());
|
||||
@ -244,6 +245,7 @@ void tst_QItemModel::rowCount()
|
||||
{
|
||||
QFETCH(QString, modelType);
|
||||
currentModel = testModels->createModel(modelType);
|
||||
QVERIFY(currentModel);
|
||||
|
||||
QFETCH(bool, isEmpty);
|
||||
if (isEmpty) {
|
||||
@ -291,6 +293,7 @@ void tst_QItemModel::columnCount()
|
||||
{
|
||||
QFETCH(QString, modelType);
|
||||
currentModel = testModels->createModel(modelType);
|
||||
QVERIFY(currentModel);
|
||||
|
||||
QFETCH(bool, isEmpty);
|
||||
if (isEmpty) {
|
||||
@ -325,6 +328,7 @@ void tst_QItemModel::hasIndex()
|
||||
{
|
||||
QFETCH(QString, modelType);
|
||||
currentModel = testModels->createModel(modelType);
|
||||
QVERIFY(currentModel);
|
||||
|
||||
// Make sure that invalid values returns an invalid index
|
||||
QCOMPARE(currentModel->hasIndex(-2, -2), false);
|
||||
@ -359,6 +363,7 @@ void tst_QItemModel::index()
|
||||
{
|
||||
QFETCH(QString, modelType);
|
||||
currentModel = testModels->createModel(modelType);
|
||||
QVERIFY(currentModel);
|
||||
|
||||
// Make sure that invalid values returns an invalid index
|
||||
QCOMPARE(currentModel->index(-2, -2), QModelIndex());
|
||||
@ -489,6 +494,7 @@ void tst_QItemModel::parent()
|
||||
{
|
||||
QFETCH(QString, modelType);
|
||||
currentModel = testModels->createModel(modelType);
|
||||
QVERIFY(currentModel);
|
||||
|
||||
// Make sure the model wont crash and will return an invalid QModelIndex
|
||||
// when asked for the parent of an invalid index.
|
||||
@ -538,6 +544,7 @@ void tst_QItemModel::data()
|
||||
{
|
||||
QFETCH(QString, modelType);
|
||||
currentModel = testModels->createModel(modelType);
|
||||
QVERIFY(currentModel);
|
||||
|
||||
// Invalid index should return an invalid qvariant
|
||||
QVERIFY(!currentModel->data(QModelIndex()).isValid());
|
||||
@ -618,6 +625,7 @@ void tst_QItemModel::setData()
|
||||
{
|
||||
QFETCH(QString, modelType);
|
||||
currentModel = testModels->createModel(modelType);
|
||||
QVERIFY(currentModel);
|
||||
qRegisterMetaType<QModelIndex>("QModelIndex");
|
||||
QSignalSpy spy(currentModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)));
|
||||
QCOMPARE(currentModel->setData(QModelIndex(), QVariant()), false);
|
||||
@ -660,6 +668,7 @@ void tst_QItemModel::setHeaderData()
|
||||
{
|
||||
QFETCH(QString, modelType);
|
||||
currentModel = testModels->createModel(modelType);
|
||||
QVERIFY(currentModel);
|
||||
|
||||
QCOMPARE(currentModel->setHeaderData(-1, Qt::Horizontal, QVariant()), false);
|
||||
QCOMPARE(currentModel->setHeaderData(-1, Qt::Vertical, QVariant()), false);
|
||||
@ -708,6 +717,7 @@ void tst_QItemModel::sort()
|
||||
{
|
||||
QFETCH(QString, modelType);
|
||||
currentModel = testModels->createModel(modelType);
|
||||
QVERIFY(currentModel);
|
||||
|
||||
QFETCH(bool, isEmpty);
|
||||
if (isEmpty)
|
||||
@ -819,6 +829,7 @@ void tst_QItemModel::remove()
|
||||
QFETCH(QString, modelType);
|
||||
|
||||
currentModel = testModels->createModel(modelType);
|
||||
QVERIFY(currentModel);
|
||||
|
||||
QFETCH(bool, readOnly);
|
||||
if (readOnly)
|
||||
@ -1160,6 +1171,7 @@ void tst_QItemModel::insert()
|
||||
{
|
||||
QFETCH(QString, modelType);
|
||||
currentModel = testModels->createModel(modelType);
|
||||
QVERIFY(currentModel);
|
||||
|
||||
QFETCH(bool, readOnly);
|
||||
if (readOnly)
|
||||
|
@ -148,12 +148,18 @@ public:
|
||||
CheckerModel() : QStandardItemModel() {};
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole ) const {
|
||||
Q_ASSERT(index.isValid());
|
||||
if (!index.isValid()) {
|
||||
qWarning("%s: index is not valid", Q_FUNC_INFO);
|
||||
return QVariant();
|
||||
}
|
||||
return QStandardItemModel::data(index, role);
|
||||
};
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex & index) const {
|
||||
Q_ASSERT(index.isValid());
|
||||
if (!index.isValid()) {
|
||||
qWarning("%s: index is not valid", Q_FUNC_INFO);
|
||||
return Qt::ItemFlags();
|
||||
}
|
||||
if (index.row() == 2 || index.row() == rowCount() - 3
|
||||
|| index.column() == 2 || index.column() == columnCount() - 3) {
|
||||
Qt::ItemFlags f = QStandardItemModel::flags(index);
|
||||
@ -164,14 +170,26 @@ public:
|
||||
};
|
||||
|
||||
QModelIndex parent ( const QModelIndex & child ) const {
|
||||
Q_ASSERT(child.isValid());
|
||||
if (!child.isValid()) {
|
||||
qWarning("%s: child index is not valid", Q_FUNC_INFO);
|
||||
return QModelIndex();
|
||||
}
|
||||
return QStandardItemModel::parent(child);
|
||||
};
|
||||
|
||||
QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const {
|
||||
Q_ASSERT(section >= 0);
|
||||
if (orientation == Qt::Horizontal) { Q_ASSERT(section <= columnCount());};
|
||||
if (orientation == Qt::Vertical) { Q_ASSERT(section <= rowCount());};
|
||||
if (orientation == Qt::Horizontal
|
||||
&& (section < 0 || section > columnCount())) {
|
||||
qWarning("%s: invalid section %d, must be in range 0..%d",
|
||||
Q_FUNC_INFO, section, columnCount());
|
||||
return QVariant();
|
||||
}
|
||||
if (orientation == Qt::Vertical
|
||||
&& (section < 0 || section > rowCount())) {
|
||||
qWarning("%s: invalid section %d, must be in range 0..%d",
|
||||
Q_FUNC_INFO, section, rowCount());
|
||||
return QVariant();
|
||||
}
|
||||
return QStandardItemModel::headerData(section, orientation, role);
|
||||
}
|
||||
|
||||
@ -180,23 +198,46 @@ public:
|
||||
};
|
||||
|
||||
bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ) {
|
||||
Q_ASSERT(index.isValid());
|
||||
if (!index.isValid()) {
|
||||
qWarning("%s: index is not valid", Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
return QStandardItemModel::setData(index, value, role);
|
||||
}
|
||||
|
||||
void sort( int column, Qt::SortOrder order = Qt::AscendingOrder ) {
|
||||
Q_ASSERT(column >= 0 && column <= columnCount());
|
||||
QStandardItemModel::sort(column, order);
|
||||
if (column < 0 || column > columnCount())
|
||||
qWarning("%s: invalid column %d, must be in range 0..%d",
|
||||
Q_FUNC_INFO, column, columnCount());
|
||||
else
|
||||
QStandardItemModel::sort(column, order);
|
||||
};
|
||||
|
||||
QModelIndexList match ( const QModelIndex & start, int role, const QVariant & value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap ) ) const {
|
||||
Q_ASSERT(hits > 0);
|
||||
Q_ASSERT(value.isValid());
|
||||
if (hits <= 0) {
|
||||
qWarning("%s: hits must be greater than zero", Q_FUNC_INFO);
|
||||
return QModelIndexList();
|
||||
}
|
||||
if (!value.isValid()) {
|
||||
qWarning("%s: value is not valid", Q_FUNC_INFO);
|
||||
return QModelIndexList();
|
||||
}
|
||||
return QAbstractItemModel::match(start, role, value, hits, flags);
|
||||
};
|
||||
|
||||
bool setHeaderData ( int section, Qt::Orientation orientation, const QVariant & value, int role = Qt::EditRole ) {
|
||||
Q_ASSERT(section >= 0);
|
||||
if (orientation == Qt::Horizontal
|
||||
&& (section < 0 || section > columnCount())) {
|
||||
qWarning("%s: invalid section %d, must be in range 0..%d",
|
||||
Q_FUNC_INFO, section, columnCount());
|
||||
return false;
|
||||
}
|
||||
if (orientation == Qt::Vertical
|
||||
&& (section < 0 || section > rowCount())) {
|
||||
qWarning("%s: invalid section %d, must be in range 0..%d",
|
||||
Q_FUNC_INFO, section, rowCount());
|
||||
return false;
|
||||
}
|
||||
return QAbstractItemModel::setHeaderData(section, orientation, value, role);
|
||||
};
|
||||
};
|
||||
@ -297,9 +338,11 @@ void tst_QItemView::nonDestructiveBasicTest()
|
||||
#endif
|
||||
|
||||
QFETCH(QString, viewType);
|
||||
view = testViews->createView(viewType);
|
||||
QFETCH(int, vscroll);
|
||||
QFETCH(int, hscroll);
|
||||
|
||||
view = testViews->createView(viewType);
|
||||
QVERIFY(view);
|
||||
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
|
||||
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
|
||||
|
||||
@ -454,9 +497,11 @@ void tst_QItemView::spider()
|
||||
QSKIP("This test takes too long to execute on IRIX", SkipAll);
|
||||
#endif
|
||||
QFETCH(QString, viewType);
|
||||
view = testViews->createView(viewType);
|
||||
QFETCH(int, vscroll);
|
||||
QFETCH(int, hscroll);
|
||||
|
||||
view = testViews->createView(viewType);
|
||||
QVERIFY(view);
|
||||
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
|
||||
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
|
||||
view->setModel(treeModel);
|
||||
@ -489,9 +534,11 @@ void tst_QItemView::resize()
|
||||
// This test needs to be re-thought out, it takes too long and
|
||||
// doesn't really catch theproblem.
|
||||
QFETCH(QString, viewType);
|
||||
view = testViews->createView(viewType);
|
||||
QFETCH(int, vscroll);
|
||||
QFETCH(int, hscroll);
|
||||
|
||||
view = testViews->createView(viewType);
|
||||
QVERIFY(view);
|
||||
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
|
||||
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
|
||||
view->setModel(treeModel);
|
||||
@ -517,9 +564,11 @@ void tst_QItemView::visualRect()
|
||||
QSKIP("This test takes too long to execute on IRIX", SkipAll);
|
||||
#endif
|
||||
QFETCH(QString, viewType);
|
||||
view = testViews->createView(viewType);
|
||||
QFETCH(int, vscroll);
|
||||
QFETCH(int, hscroll);
|
||||
|
||||
view = testViews->createView(viewType);
|
||||
QVERIFY(view);
|
||||
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
|
||||
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
|
||||
QCOMPARE(view->visualRect(QModelIndex()), QRect());
|
||||
@ -651,9 +700,11 @@ void tst_QItemView::indexAt()
|
||||
QSKIP("This test takes too long to execute on IRIX", SkipAll);
|
||||
#endif
|
||||
QFETCH(QString, viewType);
|
||||
view = testViews->createView(viewType);
|
||||
QFETCH(int, vscroll);
|
||||
QFETCH(int, hscroll);
|
||||
|
||||
view = testViews->createView(viewType);
|
||||
QVERIFY(view);
|
||||
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
|
||||
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
|
||||
view->show();
|
||||
@ -685,9 +736,11 @@ void tst_QItemView::scrollTo()
|
||||
QSKIP("This test takes too long to execute on IRIX", SkipAll);
|
||||
#endif
|
||||
QFETCH(QString, viewType);
|
||||
view = testViews->createView(viewType);
|
||||
QFETCH(int, vscroll);
|
||||
QFETCH(int, hscroll);
|
||||
|
||||
view = testViews->createView(viewType);
|
||||
QVERIFY(view);
|
||||
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
|
||||
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
|
||||
view->setModel(treeModel);
|
||||
@ -735,6 +788,7 @@ void tst_QItemView::moveCursor()
|
||||
#endif
|
||||
QFETCH(QString, viewType);
|
||||
view = testViews->createView(viewType);
|
||||
QVERIFY(view);
|
||||
if (view->objectName() == "QHeaderView")
|
||||
return;
|
||||
|
||||
|
@ -141,7 +141,6 @@ QAbstractItemView *ViewsToTest::createView(const QString &viewType)
|
||||
view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
view->setSelectionBehavior(QAbstractItemView::SelectItems);
|
||||
}
|
||||
Q_ASSERT(view);
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -468,7 +468,7 @@ void tst_QLibrary::errorString()
|
||||
}
|
||||
break;}
|
||||
default:
|
||||
Q_ASSERT(0);
|
||||
QFAIL(qPrintable(QString("Unknown operation: %1").arg(operation)));
|
||||
break;
|
||||
}
|
||||
QRegExp re(errorString);
|
||||
|
@ -326,7 +326,7 @@ void tst_QLocale::ctor()
|
||||
TEST_CTOR("en-GB", English, UnitedKingdom)
|
||||
TEST_CTOR("en-GB@bla", English, UnitedKingdom)
|
||||
|
||||
Q_ASSERT(QLocale::Norwegian == QLocale::NorwegianBokmal);
|
||||
QVERIFY(QLocale::Norwegian == QLocale::NorwegianBokmal);
|
||||
TEST_CTOR("no", Norwegian, Norway)
|
||||
TEST_CTOR("nb", Norwegian, Norway)
|
||||
TEST_CTOR("nn", NorwegianNynorsk, Norway)
|
||||
@ -431,7 +431,7 @@ void tst_QLocale::emptyCtor()
|
||||
TEST_CTOR("en_GB@bla", "en_GB")
|
||||
TEST_CTOR("de", "de_DE")
|
||||
|
||||
Q_ASSERT(QLocale::Norwegian == QLocale::NorwegianBokmal);
|
||||
QVERIFY(QLocale::Norwegian == QLocale::NorwegianBokmal);
|
||||
TEST_CTOR("no", "nb_NO")
|
||||
TEST_CTOR("nb", "nb_NO")
|
||||
TEST_CTOR("nn", "nn_NO")
|
||||
|
@ -1,3 +1,45 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
int main(int,char**)
|
||||
{
|
||||
}
|
||||
|
@ -789,7 +789,7 @@ void tst_QMenu::task250673_activeMultiColumnSubMenuPosition()
|
||||
while (main.columnCount() < 2) {
|
||||
main.addAction(QString("Item %1").arg(i));
|
||||
++i;
|
||||
Q_ASSERT(i<1000);
|
||||
QVERIFY(i<1000);
|
||||
}
|
||||
main.setActiveAction(menuAction);
|
||||
sub.setActiveAction(subAction);
|
||||
|
@ -609,48 +609,43 @@ void tst_QMessageBox::testSymbols()
|
||||
button = QMessageBox::FlagMask;
|
||||
|
||||
mb1.setText("Foo");
|
||||
QString text = mb1.text();
|
||||
Q_ASSERT(text == "Foo");
|
||||
QCOMPARE(mb1.text(), "Foo");
|
||||
|
||||
icon = mb1.icon();
|
||||
Q_ASSERT(icon == QMessageBox::NoIcon);
|
||||
QVERIFY(icon == QMessageBox::NoIcon);
|
||||
mb1.setIcon(QMessageBox::Question);
|
||||
Q_ASSERT(mb1.icon() == QMessageBox::Question);
|
||||
QVERIFY(mb1.icon() == QMessageBox::Question);
|
||||
|
||||
QPixmap iconPixmap = mb1.iconPixmap();
|
||||
mb1.setIconPixmap(iconPixmap);
|
||||
Q_ASSERT(mb1.icon() == QMessageBox::NoIcon);
|
||||
QVERIFY(mb1.icon() == QMessageBox::NoIcon);
|
||||
|
||||
QString bt0 = mb1.buttonText(QMessageBox::Ok);
|
||||
QString bt1 = mb1.buttonText(QMessageBox::Cancel);
|
||||
QString bt2 = mb1.buttonText(QMessageBox::Ok | QMessageBox::Default);
|
||||
|
||||
Q_ASSERT(bt0 == "OK");
|
||||
Q_ASSERT(bt1.isEmpty());
|
||||
Q_ASSERT(bt2.isEmpty());
|
||||
QCOMPARE(mb1.buttonText(QMessageBox::Ok), "OK");
|
||||
QCOMPARE(mb1.buttonText(QMessageBox::Cancel), QString());
|
||||
QCOMPARE(mb1.buttonText(QMessageBox::Ok | QMessageBox::Default), QString());
|
||||
|
||||
mb2.setButtonText(QMessageBox::Cancel, "Foo");
|
||||
mb2.setButtonText(QMessageBox::Ok, "Bar");
|
||||
mb2.setButtonText(QMessageBox::Ok | QMessageBox::Default, "Baz");
|
||||
|
||||
Q_ASSERT(mb2.buttonText(QMessageBox::Cancel).isEmpty());
|
||||
Q_ASSERT(mb2.buttonText(QMessageBox::Ok) == "Bar");
|
||||
QCOMPARE(mb2.buttonText(QMessageBox::Cancel), QString());
|
||||
QCOMPARE(mb2.buttonText(QMessageBox::Ok), "Bar");
|
||||
|
||||
Q_ASSERT(mb3b.buttonText(QMessageBox::Yes).endsWith("Yes"));
|
||||
Q_ASSERT(mb3b.buttonText(QMessageBox::YesAll).isEmpty());
|
||||
Q_ASSERT(mb3b.buttonText(QMessageBox::Ok).isEmpty());
|
||||
QVERIFY(mb3b.buttonText(QMessageBox::Yes).endsWith("Yes"));
|
||||
QCOMPARE(mb3b.buttonText(QMessageBox::YesAll), QString());
|
||||
QCOMPARE(mb3b.buttonText(QMessageBox::Ok), QString());
|
||||
|
||||
mb3b.setButtonText(QMessageBox::Yes, "Blah");
|
||||
mb3b.setButtonText(QMessageBox::YesAll, "Zoo");
|
||||
mb3b.setButtonText(QMessageBox::Ok, "Zoo");
|
||||
|
||||
Q_ASSERT(mb3b.buttonText(QMessageBox::Yes) == "Blah");
|
||||
Q_ASSERT(mb3b.buttonText(QMessageBox::YesAll).isEmpty());
|
||||
Q_ASSERT(mb3b.buttonText(QMessageBox::Ok).isEmpty());
|
||||
QCOMPARE(mb3b.buttonText(QMessageBox::Yes), "Blah");
|
||||
QCOMPARE(mb3b.buttonText(QMessageBox::YesAll), QString());
|
||||
QCOMPARE(mb3b.buttonText(QMessageBox::Ok), QString());
|
||||
|
||||
Q_ASSERT(mb1.textFormat() == Qt::AutoText);
|
||||
QCOMPARE(mb1.textFormat(), Qt::AutoText);
|
||||
mb1.setTextFormat(Qt::PlainText);
|
||||
Q_ASSERT(mb1.textFormat() == Qt::PlainText);
|
||||
QCOMPARE(mb1.textFormat(), Qt::PlainText);
|
||||
|
||||
CONVENIENCE_FUNC_SYMS(information);
|
||||
CONVENIENCE_FUNC_SYMS_EXTRA(information);
|
||||
@ -660,7 +655,7 @@ void tst_QMessageBox::testSymbols()
|
||||
CONVENIENCE_FUNC_SYMS(critical);
|
||||
|
||||
QSize sizeHint = mb1.sizeHint();
|
||||
Q_ASSERT(sizeHint.width() > 20 && sizeHint.height() > 20);
|
||||
QVERIFY(sizeHint.width() > 20 && sizeHint.height() > 20);
|
||||
|
||||
#ifdef QT3_SUPPORT
|
||||
//test QT3_SUPPORT stuff
|
||||
@ -672,8 +667,8 @@ void tst_QMessageBox::testSymbols()
|
||||
QPixmap pm = QMessageBox::standardIcon(QMessageBox::Question, Qt::GUIStyle(1));
|
||||
QPixmap pm2 = QMessageBox::standardIcon(QMessageBox::Question);
|
||||
|
||||
Q_ASSERT(pm.toImage() == iconPixmap.toImage());
|
||||
Q_ASSERT(pm2.toImage() == iconPixmap.toImage());
|
||||
QVERIFY(pm.toImage() == iconPixmap.toImage());
|
||||
QVERIFY(pm2.toImage() == iconPixmap.toImage());
|
||||
|
||||
int ret1 = QMessageBox::message("title", "text");
|
||||
int ret2 = QMessageBox::message("title", "text", "OK");
|
||||
@ -692,10 +687,10 @@ void tst_QMessageBox::testSymbols()
|
||||
Q_UNUSED(ret5);
|
||||
|
||||
QPixmap pm3 = QMessageBox::standardIcon(QMessageBox::NoIcon);
|
||||
Q_ASSERT(pm3.isNull());
|
||||
QVERIFY(pm3.isNull());
|
||||
|
||||
pm3 = QMessageBox::standardIcon(QMessageBox::Information);
|
||||
Q_ASSERT(!pm3.isNull());
|
||||
QVERIFY(!pm3.isNull());
|
||||
#endif //QT3_SUPPORT
|
||||
|
||||
QMessageBox::about(&mb1, "title", "text");
|
||||
|
@ -244,7 +244,12 @@ public:
|
||||
QObject *child;
|
||||
|
||||
public slots:
|
||||
void on_child1_destroyed(QObject *obj = 0) { ++invokeCount1; Q_ASSERT(obj && obj == child); }
|
||||
void on_child1_destroyed(QObject *obj = 0)
|
||||
{
|
||||
++invokeCount1;
|
||||
if (!obj || obj != child)
|
||||
qWarning() << "on_child1_destroyed invoked with wrong child object";
|
||||
}
|
||||
void on_child2_destroyed() { ++invokeCount2; }
|
||||
};
|
||||
|
||||
@ -268,7 +273,12 @@ public:
|
||||
}
|
||||
|
||||
private slots:
|
||||
void on_child1_destroyed(QObject *obj) { ++invokeCount1; Q_ASSERT(obj && obj == child); }
|
||||
void on_child1_destroyed(QObject *obj)
|
||||
{
|
||||
++invokeCount1;
|
||||
if (!obj || obj != child)
|
||||
qWarning() << "on_child1_destroyed invoked with wrong child object";
|
||||
}
|
||||
void on_child1_destroyed() { ++invokeCount2; }
|
||||
};
|
||||
|
||||
|
@ -96,10 +96,18 @@ struct Bar
|
||||
Bar()
|
||||
{
|
||||
// check re-entrancy
|
||||
Q_ASSERT(QMetaType::isRegistered(qRegisterMetaType<Foo>("Foo")));
|
||||
if (!QMetaType::isRegistered(qRegisterMetaType<Foo>("Foo"))) {
|
||||
qWarning("%s: re-entrancy test failed", Q_FUNC_INFO);
|
||||
++failureCount;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
static int failureCount;
|
||||
};
|
||||
|
||||
int Bar::failureCount = 0;
|
||||
|
||||
class MetaTypeTorturer: public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -113,17 +121,35 @@ protected:
|
||||
#ifdef Q_OS_LINUX
|
||||
pthread_yield();
|
||||
#endif
|
||||
Q_ASSERT(QMetaType::isRegistered(tp));
|
||||
Q_ASSERT(QMetaType::type(nm) == tp);
|
||||
Q_ASSERT(QMetaType::typeName(tp) == name);
|
||||
if (!QMetaType::isRegistered(tp)) {
|
||||
++failureCount;
|
||||
qWarning() << name << "is not a registered metatype";
|
||||
}
|
||||
if (QMetaType::type(nm) != tp) {
|
||||
++failureCount;
|
||||
qWarning() << "Wrong metatype returned for" << name;
|
||||
}
|
||||
if (QMetaType::typeName(tp) != name) {
|
||||
++failureCount;
|
||||
qWarning() << "Wrong typeName returned for" << tp;
|
||||
}
|
||||
void *buf = QMetaType::construct(tp, 0);
|
||||
void *buf2 = QMetaType::construct(tp, buf);
|
||||
Q_ASSERT(buf);
|
||||
Q_ASSERT(buf2);
|
||||
if (!buf) {
|
||||
++failureCount;
|
||||
qWarning() << "Null buffer returned by QMetaType::construct(tp, 0)";
|
||||
}
|
||||
if (!buf2) {
|
||||
++failureCount;
|
||||
qWarning() << "Null buffer returned by QMetaType::construct(tp, buf)";
|
||||
}
|
||||
QMetaType::destroy(tp, buf);
|
||||
QMetaType::destroy(tp, buf2);
|
||||
}
|
||||
}
|
||||
public:
|
||||
MetaTypeTorturer() : failureCount(0) { }
|
||||
int failureCount;
|
||||
};
|
||||
|
||||
void tst_QMetaType::threadSafety()
|
||||
@ -139,6 +165,11 @@ void tst_QMetaType::threadSafety()
|
||||
QVERIFY(t1.wait());
|
||||
QVERIFY(t2.wait());
|
||||
QVERIFY(t3.wait());
|
||||
|
||||
QCOMPARE(t1.failureCount, 0);
|
||||
QCOMPARE(t2.failureCount, 0);
|
||||
QCOMPARE(t3.failureCount, 0);
|
||||
QCOMPARE(Bar::failureCount, 0);
|
||||
}
|
||||
|
||||
namespace TestSpace
|
||||
|
@ -462,6 +462,7 @@ public:
|
||||
static QBasicAtomicInt lockCount;
|
||||
static QBasicAtomicInt sentinel;
|
||||
static QMutex mutex;
|
||||
static int errorCount;
|
||||
void start()
|
||||
{
|
||||
t.start();
|
||||
@ -471,13 +472,13 @@ public:
|
||||
{
|
||||
while (t.elapsed() < one_minute) {
|
||||
mutex.lock();
|
||||
Q_ASSERT(!sentinel.ref());
|
||||
Q_ASSERT(sentinel.deref());
|
||||
if (sentinel.ref()) ++errorCount;
|
||||
if (!sentinel.deref()) ++errorCount;
|
||||
lockCount.ref();
|
||||
mutex.unlock();
|
||||
if (mutex.tryLock()) {
|
||||
Q_ASSERT(!sentinel.ref());
|
||||
Q_ASSERT(sentinel.deref());
|
||||
if (sentinel.ref()) ++errorCount;
|
||||
if (!sentinel.deref()) ++errorCount;
|
||||
lockCount.ref();
|
||||
mutex.unlock();
|
||||
}
|
||||
@ -487,6 +488,7 @@ public:
|
||||
QMutex StressTestThread::mutex;
|
||||
QBasicAtomicInt StressTestThread::lockCount = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
QBasicAtomicInt StressTestThread::sentinel = Q_BASIC_ATOMIC_INITIALIZER(-1);
|
||||
int StressTestThread::errorCount = 0;
|
||||
|
||||
void tst_QMutex::stressTest()
|
||||
{
|
||||
@ -496,6 +498,7 @@ void tst_QMutex::stressTest()
|
||||
QVERIFY(threads[0].wait(one_minute + 10000));
|
||||
for (int i = 1; i < threadCount; ++i)
|
||||
QVERIFY(threads[i].wait(10000));
|
||||
QCOMPARE(StressTestThread::errorCount, 0);
|
||||
qDebug("locked %d times", int(StressTestThread::lockCount));
|
||||
}
|
||||
|
||||
@ -534,7 +537,12 @@ void tst_QMutex::tryLockRace()
|
||||
TryLockRaceThread::mutex.unlock();
|
||||
}
|
||||
|
||||
// Variable that will be protected by the mutex. Volatile so that the
|
||||
// the optimiser doesn't mess with it based on the increment-then-decrement
|
||||
// usage pattern.
|
||||
static volatile int qtbug16115_trylock_counter;
|
||||
// Counter for how many times the protected variable has an incorrect value.
|
||||
static int qtbug16115_failure_count = 0;
|
||||
|
||||
void tst_QMutex::qtbug16115_trylock()
|
||||
{
|
||||
@ -545,8 +553,10 @@ void tst_QMutex::qtbug16115_trylock()
|
||||
void run() {
|
||||
for (int i = 0; i < 1000000; ++i) {
|
||||
if (mut.tryLock(0)) {
|
||||
Q_ASSERT((++qtbug16115_trylock_counter) == 1);
|
||||
Q_ASSERT((--qtbug16115_trylock_counter) == 0);
|
||||
if ((++qtbug16115_trylock_counter) != 1)
|
||||
++qtbug16115_failure_count;
|
||||
if ((--qtbug16115_trylock_counter) != 0)
|
||||
++qtbug16115_failure_count;
|
||||
mut.unlock();
|
||||
}
|
||||
}
|
||||
@ -562,13 +572,16 @@ void tst_QMutex::qtbug16115_trylock()
|
||||
|
||||
for (int i = 0; i < 1000000; ++i) {
|
||||
mut.lock();
|
||||
Q_ASSERT((++qtbug16115_trylock_counter) == 1);
|
||||
Q_ASSERT((--qtbug16115_trylock_counter) == 0);
|
||||
if ((++qtbug16115_trylock_counter) != 1)
|
||||
++qtbug16115_failure_count;
|
||||
if ((--qtbug16115_trylock_counter) != 0)
|
||||
++qtbug16115_failure_count;
|
||||
mut.unlock();
|
||||
}
|
||||
t1.wait();
|
||||
t2.wait();
|
||||
t3.wait();
|
||||
QCOMPARE(qtbug16115_failure_count, 0);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QMutex)
|
||||
|
@ -622,9 +622,14 @@ public:
|
||||
}
|
||||
|
||||
QIODevice *prepare(const QNetworkCacheMetaData &)
|
||||
{ Q_ASSERT(0 && "Should not have tried to add to the cache"); return 0; }
|
||||
{
|
||||
qFatal("%s: Should not have tried to add to the cache", Q_FUNC_INFO);
|
||||
return 0;
|
||||
}
|
||||
void insert(QIODevice *)
|
||||
{ Q_ASSERT(0 && "Should not have tried to add to the cache"); }
|
||||
{
|
||||
qFatal("%s: Should not have tried to add to the cache", Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
void clear() { cache.clear(); }
|
||||
};
|
||||
@ -774,7 +779,9 @@ public:
|
||||
QTcpSocket* waitForNextConnectionSocket() {
|
||||
waitForNewConnection(-1);
|
||||
if (doSsl) {
|
||||
Q_ASSERT(sslSocket);
|
||||
if (!sslSocket)
|
||||
qFatal("%s: sslSocket should not be null after calling waitForNewConnection()",
|
||||
Q_FUNC_INFO);
|
||||
return sslSocket;
|
||||
} else {
|
||||
//qDebug() << "returning nextPendingConnection";
|
||||
@ -946,7 +953,8 @@ protected:
|
||||
while (dataIndex < wantedSize) {
|
||||
const int remainingBytes = wantedSize - measuredSentBytes;
|
||||
const int bytesToWrite = qMin(remainingBytes, static_cast<int>(BlockSize));
|
||||
Q_ASSERT(bytesToWrite);
|
||||
if (bytesToWrite <= 0)
|
||||
qFatal("%s: attempt to write %d bytes", Q_FUNC_INFO, bytesToWrite);
|
||||
measuredSentBytes += writeNextData(client, bytesToWrite);
|
||||
|
||||
while (client->bytesToWrite() > 0) {
|
||||
@ -1005,7 +1013,8 @@ public:
|
||||
|
||||
// Wait for data to be readyRead
|
||||
bool ok = connect(&senderObj, SIGNAL(dataReady()), this, SLOT(slotDataReady()));
|
||||
Q_ASSERT(ok);
|
||||
if (!ok)
|
||||
qFatal("%s: Cannot connect dataReady signal", Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
void wrapUp()
|
||||
@ -1028,9 +1037,9 @@ protected:
|
||||
void timerEvent(QTimerEvent *)
|
||||
{
|
||||
//qDebug() << "RateControlledReader: timerEvent bytesAvailable=" << device->bytesAvailable();
|
||||
if (readBufferSize > 0) {
|
||||
// This asserts passes all the time, except in the final flush.
|
||||
//Q_ASSERT(device->bytesAvailable() <= readBufferSize);
|
||||
if (readBufferSize > 0 && device->bytesAvailable() > readBufferSize) {
|
||||
// This passes all the time, except in the final flush.
|
||||
//qFatal("%s: Too many bytes available", Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
qint64 bytesRead = 0;
|
||||
@ -1189,7 +1198,7 @@ QString tst_QNetworkReply::runSimpleRequest(QNetworkAccessManager::Operation op,
|
||||
break;
|
||||
|
||||
default:
|
||||
Q_ASSERT_X(false, "tst_QNetworkReply", "Invalid/unknown operation requested");
|
||||
qFatal("%s: Invalid/unknown operation requested", Q_FUNC_INFO);
|
||||
}
|
||||
reply->setParent(this);
|
||||
|
||||
|
@ -69,7 +69,8 @@ void Receiver::received ()
|
||||
::Step++;
|
||||
const int stepCopy = ::Step;
|
||||
TRACE (stepCopy, "Receiver::received()");
|
||||
Q_ASSERT (::Step == 2 || ::Step == 4);
|
||||
if (::Step != 2 && ::Step != 4)
|
||||
qFatal("%s: Incorrect Step: %d (should be 2 or 4)", Q_FUNC_INFO, ::Step);
|
||||
|
||||
if (::Step == 2)
|
||||
s->fire ();
|
||||
@ -91,7 +92,8 @@ void Disconnector::received ()
|
||||
::Step++;
|
||||
const int stepCopy = ::Step;
|
||||
TRACE (stepCopy, "Disconnector::received()");
|
||||
Q_ASSERT (::Step == 5 || ::Step == 6);
|
||||
if (::Step != 5 && ::Step != 6)
|
||||
qFatal("%s: Incorrect Step: %d (should be 5 or 6)", Q_FUNC_INFO, ::Step);
|
||||
|
||||
fprintf (stderr, "Disconnector<%s>::received() sender=%s\n",
|
||||
(const char *) objectName ().toAscii (), sender ()->metaObject()->className());
|
||||
@ -124,7 +126,8 @@ void Sender::fire ()
|
||||
::Step++;
|
||||
const int stepCopy = ::Step;
|
||||
TRACE (stepCopy, "Sender::fire()");
|
||||
Q_ASSERT (::Step == 1 || ::Step == 3);
|
||||
if (::Step != 1 && ::Step != 3)
|
||||
qFatal("%s: Incorrect Step: %d (should be 1 or 3)", Q_FUNC_INFO, ::Step);
|
||||
|
||||
emit fired ();
|
||||
TRACE (stepCopy, "ends Sender::fire()");
|
||||
|
@ -403,6 +403,8 @@ public:
|
||||
}
|
||||
|
||||
void reset() {
|
||||
called_slot10 = 0;
|
||||
called_slot9 = 0;
|
||||
called_slot8 = 0;
|
||||
called_slot7 = 0;
|
||||
called_slot6 = 0;
|
||||
@ -421,6 +423,8 @@ public:
|
||||
int called_slot6;
|
||||
int called_slot7;
|
||||
int called_slot8;
|
||||
int called_slot9;
|
||||
int called_slot10;
|
||||
|
||||
bool called(int slot) {
|
||||
switch (slot) {
|
||||
@ -432,6 +436,8 @@ public:
|
||||
case 6: return called_slot6;
|
||||
case 7: return called_slot7;
|
||||
case 8: return called_slot8;
|
||||
case 9: return called_slot9;
|
||||
case 10: return called_slot10;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
@ -449,8 +455,8 @@ public slots:
|
||||
void slotLoopBack() { ++called_slot8; }
|
||||
|
||||
protected slots:
|
||||
void o() { Q_ASSERT(0); }
|
||||
void on() { Q_ASSERT(0); }
|
||||
void o() { ++called_slot9; }
|
||||
void on() { ++called_slot10; }
|
||||
|
||||
signals:
|
||||
void on_Sender_signalLoopBack();
|
||||
@ -473,6 +479,8 @@ void tst_QObject::connectByName()
|
||||
QCOMPARE(receiver.called(6), false);
|
||||
QCOMPARE(receiver.called(7), false);
|
||||
QCOMPARE(receiver.called(8), false);
|
||||
QCOMPARE(receiver.called(9), false);
|
||||
QCOMPARE(receiver.called(10), false);
|
||||
receiver.reset();
|
||||
|
||||
sender.emitSignalWithParams(0);
|
||||
@ -484,6 +492,8 @@ void tst_QObject::connectByName()
|
||||
QCOMPARE(receiver.called(6), false);
|
||||
QCOMPARE(receiver.called(7), false);
|
||||
QCOMPARE(receiver.called(8), false);
|
||||
QCOMPARE(receiver.called(9), false);
|
||||
QCOMPARE(receiver.called(10), false);
|
||||
receiver.reset();
|
||||
|
||||
sender.emitSignalWithParams(0, "string");
|
||||
@ -495,6 +505,8 @@ void tst_QObject::connectByName()
|
||||
QCOMPARE(receiver.called(6), false);
|
||||
QCOMPARE(receiver.called(7), false);
|
||||
QCOMPARE(receiver.called(8), false);
|
||||
QCOMPARE(receiver.called(9), false);
|
||||
QCOMPARE(receiver.called(10), false);
|
||||
receiver.reset();
|
||||
|
||||
sender.emitSignalManyParams(1, 2, 3, "string", true);
|
||||
@ -506,6 +518,8 @@ void tst_QObject::connectByName()
|
||||
QCOMPARE(receiver.called(6), false);
|
||||
QCOMPARE(receiver.called(7), false);
|
||||
QCOMPARE(receiver.called(8), false);
|
||||
QCOMPARE(receiver.called(9), false);
|
||||
QCOMPARE(receiver.called(10), false);
|
||||
receiver.reset();
|
||||
|
||||
sender.emitSignalManyParams2(1, 2, 3, "string", true);
|
||||
@ -517,6 +531,8 @@ void tst_QObject::connectByName()
|
||||
QCOMPARE(receiver.called(6), false);
|
||||
QCOMPARE(receiver.called(7), true);
|
||||
QCOMPARE(receiver.called(8), false);
|
||||
QCOMPARE(receiver.called(9), false);
|
||||
QCOMPARE(receiver.called(10), false);
|
||||
receiver.reset();
|
||||
|
||||
sender.emitSignalLoopBack();
|
||||
@ -528,6 +544,8 @@ void tst_QObject::connectByName()
|
||||
QCOMPARE(receiver.called(6), false);
|
||||
QCOMPARE(receiver.called(7), false);
|
||||
QCOMPARE(receiver.called(8), true);
|
||||
QCOMPARE(receiver.called(9), false);
|
||||
QCOMPARE(receiver.called(10), false);
|
||||
receiver.reset();
|
||||
}
|
||||
|
||||
@ -1312,14 +1330,16 @@ public:
|
||||
|
||||
void customEvent(QEvent *)
|
||||
{
|
||||
Q_ASSERT(customEventThread == 0);
|
||||
if (customEventThread)
|
||||
qFatal("%s: customEventThread should be null", Q_FUNC_INFO);
|
||||
customEventThread = QThread::currentThread();
|
||||
emit theSignal();
|
||||
}
|
||||
|
||||
void timerEvent(QTimerEvent *)
|
||||
{
|
||||
Q_ASSERT(timerEventThread == 0);
|
||||
if (timerEventThread)
|
||||
qFatal("%s: timerEventThread should be null", Q_FUNC_INFO);
|
||||
timerEventThread = QThread::currentThread();
|
||||
emit theSignal();
|
||||
}
|
||||
@ -1327,7 +1347,8 @@ public:
|
||||
public slots:
|
||||
void theSlot()
|
||||
{
|
||||
Q_ASSERT(slotThread == 0);
|
||||
if (slotThread)
|
||||
qFatal("%s: slotThread should be null", Q_FUNC_INFO);
|
||||
slotThread = QThread::currentThread();
|
||||
emit theSignal();
|
||||
}
|
||||
|
@ -1697,8 +1697,8 @@ void tst_QPixmap::fromImageReaderAnimatedGif()
|
||||
QImageReader referenceReader(path);
|
||||
QImageReader pixmapReader(path);
|
||||
|
||||
Q_ASSERT(referenceReader.canRead());
|
||||
Q_ASSERT(referenceReader.imageCount() > 1);
|
||||
QVERIFY(referenceReader.canRead());
|
||||
QVERIFY(referenceReader.imageCount() > 1);
|
||||
|
||||
for (int i = 0; i < referenceReader.imageCount(); ++i) {
|
||||
QImage refImage = referenceReader.read();
|
||||
|
@ -668,7 +668,7 @@ void tst_QProcess::exitStatus()
|
||||
QSKIP("This test opens a crash dialog on Windows", SkipSingle);
|
||||
#endif
|
||||
|
||||
Q_ASSERT(processList.count() == exitStatus.count());
|
||||
QCOMPARE(exitStatus.count(), processList.count());
|
||||
for (int i = 0; i < processList.count(); ++i) {
|
||||
process->start(processList.at(i));
|
||||
QVERIFY(process->waitForStarted(5000));
|
||||
|
@ -362,34 +362,45 @@ void tst_QReadWriteLock::tryWriteLock()
|
||||
class Thread : public QThread
|
||||
{
|
||||
public:
|
||||
Thread() : failureCount(0) { }
|
||||
void run()
|
||||
{
|
||||
testsTurn.release();
|
||||
|
||||
threadsTurn.acquire();
|
||||
Q_ASSERT(!readWriteLock.tryLockForWrite());
|
||||
if (readWriteLock.tryLockForWrite())
|
||||
failureCount++;
|
||||
testsTurn.release();
|
||||
|
||||
threadsTurn.acquire();
|
||||
Q_ASSERT(readWriteLock.tryLockForWrite());
|
||||
Q_ASSERT(lockCount.testAndSetRelaxed(0, 1));
|
||||
Q_ASSERT(lockCount.testAndSetRelaxed(1, 0));
|
||||
if (!readWriteLock.tryLockForWrite())
|
||||
failureCount++;
|
||||
if (!lockCount.testAndSetRelaxed(0, 1))
|
||||
failureCount++;
|
||||
if (!lockCount.testAndSetRelaxed(1, 0))
|
||||
failureCount++;
|
||||
readWriteLock.unlock();
|
||||
testsTurn.release();
|
||||
|
||||
threadsTurn.acquire();
|
||||
Q_ASSERT(!readWriteLock.tryLockForWrite(1000));
|
||||
if (readWriteLock.tryLockForWrite(1000))
|
||||
failureCount++;
|
||||
testsTurn.release();
|
||||
|
||||
threadsTurn.acquire();
|
||||
Q_ASSERT(readWriteLock.tryLockForWrite(1000));
|
||||
Q_ASSERT(lockCount.testAndSetRelaxed(0, 1));
|
||||
Q_ASSERT(lockCount.testAndSetRelaxed(1, 0));
|
||||
if (!readWriteLock.tryLockForWrite(1000))
|
||||
failureCount++;
|
||||
if (!lockCount.testAndSetRelaxed(0, 1))
|
||||
failureCount++;
|
||||
if (!lockCount.testAndSetRelaxed(1, 0))
|
||||
failureCount++;
|
||||
readWriteLock.unlock();
|
||||
testsTurn.release();
|
||||
|
||||
threadsTurn.acquire();
|
||||
}
|
||||
|
||||
int failureCount;
|
||||
};
|
||||
|
||||
Thread thread;
|
||||
@ -419,6 +430,8 @@ void tst_QReadWriteLock::tryWriteLock()
|
||||
testsTurn.acquire();
|
||||
threadsTurn.release();
|
||||
thread.wait();
|
||||
|
||||
QCOMPARE(thread.failureCount, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QDirIterator>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#ifdef Q_OS_SYMBIAN
|
||||
#define DEFAULT_MAKESPEC "X:/STLsupport/mkspecs/symbian-abld/"
|
||||
@ -342,7 +343,8 @@ namespace QTest {
|
||||
|
||||
void QExternalTestPrivate::removeTemporaryDirectory()
|
||||
{
|
||||
Q_ASSERT(!temporaryDir.isEmpty());
|
||||
if (temporaryDir.isEmpty())
|
||||
qWarning() << "Temporary directory is expected to be non-empty";
|
||||
removeRecursive(temporaryDir);
|
||||
temporaryDir.clear();
|
||||
}
|
||||
@ -487,7 +489,8 @@ namespace QTest {
|
||||
|
||||
bool QExternalTestPrivate::createProjectFile()
|
||||
{
|
||||
Q_ASSERT(!temporaryDir.isEmpty());
|
||||
if (temporaryDir.isEmpty())
|
||||
qWarning() << "Temporary directory is expected to be non-empty";
|
||||
|
||||
QFile projectFile(temporaryDir + QLatin1String("/project.pro"));
|
||||
if (!projectFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
|
||||
@ -599,7 +602,9 @@ namespace QTest {
|
||||
|
||||
bool QExternalTestPrivate::runQmake()
|
||||
{
|
||||
Q_ASSERT(!temporaryDir.isEmpty());
|
||||
if (temporaryDir.isEmpty())
|
||||
qWarning() << "Temporary directory is expected to be non-empty";
|
||||
|
||||
if (!createProjectFile())
|
||||
return false;
|
||||
|
||||
@ -633,7 +638,8 @@ namespace QTest {
|
||||
|
||||
bool QExternalTestPrivate::runMake(Target target)
|
||||
{
|
||||
Q_ASSERT(!temporaryDir.isEmpty());
|
||||
if (temporaryDir.isEmpty())
|
||||
qWarning() << "Temporary directory is expected to be non-empty";
|
||||
|
||||
QExternalProcess make;
|
||||
make.setWorkingDirectory(temporaryDir);
|
||||
|
@ -139,7 +139,8 @@ public:
|
||||
|
||||
virtual ~Data()
|
||||
{
|
||||
Q_ASSERT_X(generation > 0, "tst_QSharedPointer", "Double deletion!");
|
||||
if (generation <= 0)
|
||||
qFatal("tst_qsharedpointer: Double deletion!");
|
||||
generation = 0;
|
||||
++destructorCounter;
|
||||
}
|
||||
@ -283,8 +284,8 @@ void tst_QSharedPointer::operators()
|
||||
QSharedPointer<char> p1;
|
||||
QSharedPointer<char> p2(new char);
|
||||
qptrdiff diff = p2.data() - p1.data();
|
||||
Q_ASSERT(p1.data() != p2.data());
|
||||
Q_ASSERT(diff != 0);
|
||||
QVERIFY(p1.data() != p2.data());
|
||||
QVERIFY(diff != 0);
|
||||
|
||||
// operator-
|
||||
QCOMPARE(p2 - p1.data(), diff);
|
||||
@ -867,8 +868,8 @@ void tst_QSharedPointer::differentPointers()
|
||||
{
|
||||
DiffPtrDerivedData *aData = new DiffPtrDerivedData;
|
||||
Data *aBase = aData;
|
||||
Q_ASSERT(aData == aBase);
|
||||
Q_ASSERT(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
|
||||
QVERIFY(aData == aBase);
|
||||
QVERIFY(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
|
||||
|
||||
QSharedPointer<Data> baseptr = QSharedPointer<Data>(aData);
|
||||
QSharedPointer<DiffPtrDerivedData> ptr = qSharedPointerCast<DiffPtrDerivedData>(baseptr);
|
||||
@ -885,8 +886,8 @@ void tst_QSharedPointer::differentPointers()
|
||||
{
|
||||
DiffPtrDerivedData *aData = new DiffPtrDerivedData;
|
||||
Data *aBase = aData;
|
||||
Q_ASSERT(aData == aBase);
|
||||
Q_ASSERT(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
|
||||
QVERIFY(aData == aBase);
|
||||
QVERIFY(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
|
||||
|
||||
QSharedPointer<DiffPtrDerivedData> ptr = QSharedPointer<DiffPtrDerivedData>(aData);
|
||||
QSharedPointer<Data> baseptr = ptr;
|
||||
@ -908,8 +909,8 @@ void tst_QSharedPointer::virtualBaseDifferentPointers()
|
||||
{
|
||||
VirtualDerived *aData = new VirtualDerived;
|
||||
Data *aBase = aData;
|
||||
Q_ASSERT(aData == aBase);
|
||||
Q_ASSERT(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
|
||||
QVERIFY(aData == aBase);
|
||||
QVERIFY(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
|
||||
|
||||
QSharedPointer<VirtualDerived> ptr = QSharedPointer<VirtualDerived>(aData);
|
||||
QSharedPointer<Data> baseptr = qSharedPointerCast<Data>(ptr);
|
||||
@ -928,8 +929,8 @@ void tst_QSharedPointer::virtualBaseDifferentPointers()
|
||||
{
|
||||
VirtualDerived *aData = new VirtualDerived;
|
||||
Data *aBase = aData;
|
||||
Q_ASSERT(aData == aBase);
|
||||
Q_ASSERT(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
|
||||
QVERIFY(aData == aBase);
|
||||
QVERIFY(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
|
||||
|
||||
QSharedPointer<VirtualDerived> ptr = QSharedPointer<VirtualDerived>(aData);
|
||||
QSharedPointer<Data> baseptr = ptr;
|
||||
@ -1605,7 +1606,7 @@ void hashAndMapTest()
|
||||
QVERIFY(it != c.find(Key()));
|
||||
|
||||
if (Ordered) {
|
||||
Q_ASSERT(k0 < k1);
|
||||
QVERIFY(k0 < k1);
|
||||
|
||||
it = c.begin();
|
||||
QCOMPARE(it.key(), k0);
|
||||
|
@ -1340,14 +1340,14 @@ void tst_QSplitter::task187373_addAbstractScrollAreas()
|
||||
QFETCH(QString, className);
|
||||
QFETCH(bool, addInConstructor);
|
||||
QFETCH(bool, addOutsideConstructor);
|
||||
Q_ASSERT(addInConstructor || addOutsideConstructor);
|
||||
QVERIFY(addInConstructor || addOutsideConstructor);
|
||||
|
||||
QSplitter *splitter = new QSplitter;
|
||||
splitter->show();
|
||||
Q_ASSERT(splitter->isVisible());
|
||||
QVERIFY(splitter->isVisible());
|
||||
|
||||
QAbstractScrollArea *w = task187373_createScrollArea(splitter, className, addInConstructor);
|
||||
Q_ASSERT(w);
|
||||
QVERIFY(w);
|
||||
if (addOutsideConstructor)
|
||||
splitter->addWidget(w);
|
||||
|
||||
|
@ -767,7 +767,7 @@ void tst_QSqlDatabase::checkValues(const FieldDef fieldDefs[], QSqlDatabase db)
|
||||
Q3SqlCursor cur(qTableName("qtestfields", __FILE__), true, db);
|
||||
QVERIFY_SQL(cur, select());
|
||||
QSqlRecord* rec = cur.primeInsert();
|
||||
Q_ASSERT(rec);
|
||||
QVERIFY(rec);
|
||||
rec->setValue("id", pkey++);
|
||||
int i = 0;
|
||||
for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) {
|
||||
@ -828,7 +828,7 @@ void tst_QSqlDatabase::checkNullValues(const FieldDef fieldDefs[], QSqlDatabase
|
||||
Q3SqlCursor cur(qTableName("qtestfields", __FILE__), true, db);
|
||||
QVERIFY_SQL(cur, select());
|
||||
QSqlRecord* rec = cur.primeInsert();
|
||||
Q_ASSERT(rec);
|
||||
QVERIFY(rec);
|
||||
rec->setValue("id", pkey++);
|
||||
int i = 0;
|
||||
for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) {
|
||||
|
@ -1565,8 +1565,8 @@ protected:
|
||||
// delayed start of encryption
|
||||
QTest::qSleep(100);
|
||||
QSslSocket *socket = server.socket;
|
||||
QVERIFY(socket);
|
||||
QVERIFY(socket->isValid());
|
||||
if (!socket || !socket->isValid())
|
||||
return; // error
|
||||
socket->ignoreSslErrors();
|
||||
socket->startServerEncryption();
|
||||
if (!socket->waitForEncrypted(2000))
|
||||
|
@ -3429,9 +3429,9 @@ void tst_QString::fromLatin1Roundtrip()
|
||||
QFETCH(QString, unicode);
|
||||
|
||||
// QtTest safety check:
|
||||
Q_ASSERT(latin1.isNull() == unicode.isNull());
|
||||
Q_ASSERT(latin1.isEmpty() == unicode.isEmpty());
|
||||
Q_ASSERT(latin1.length() == unicode.length());
|
||||
QCOMPARE(latin1.isNull(), unicode.isNull());
|
||||
QCOMPARE(latin1.isEmpty(), unicode.isEmpty());
|
||||
QCOMPARE(latin1.length(), unicode.length());
|
||||
|
||||
if (!latin1.isEmpty())
|
||||
while (latin1.length() < 128) {
|
||||
@ -3484,12 +3484,12 @@ void tst_QString::toLatin1Roundtrip()
|
||||
QFETCH(QString, unicodedst);
|
||||
|
||||
// QtTest safety check:
|
||||
Q_ASSERT(latin1.isNull() == unicodesrc.isNull());
|
||||
Q_ASSERT(latin1.isEmpty() == unicodesrc.isEmpty());
|
||||
Q_ASSERT(latin1.length() == unicodesrc.length());
|
||||
Q_ASSERT(latin1.isNull() == unicodedst.isNull());
|
||||
Q_ASSERT(latin1.isEmpty() == unicodedst.isEmpty());
|
||||
Q_ASSERT(latin1.length() == unicodedst.length());
|
||||
QCOMPARE(latin1.isNull(), unicodesrc.isNull());
|
||||
QCOMPARE(latin1.isEmpty(), unicodesrc.isEmpty());
|
||||
QCOMPARE(latin1.length(), unicodesrc.length());
|
||||
QCOMPARE(latin1.isNull(), unicodedst.isNull());
|
||||
QCOMPARE(latin1.isEmpty(), unicodedst.isEmpty());
|
||||
QCOMPARE(latin1.length(), unicodedst.length());
|
||||
|
||||
if (!latin1.isEmpty())
|
||||
while (latin1.length() < 128) {
|
||||
@ -3519,12 +3519,12 @@ void tst_QString::stringRef_toLatin1Roundtrip()
|
||||
QFETCH(QString, unicodedst);
|
||||
|
||||
// QtTest safety check:
|
||||
Q_ASSERT(latin1.isNull() == unicodesrc.isNull());
|
||||
Q_ASSERT(latin1.isEmpty() == unicodesrc.isEmpty());
|
||||
Q_ASSERT(latin1.length() == unicodesrc.length());
|
||||
Q_ASSERT(latin1.isNull() == unicodedst.isNull());
|
||||
Q_ASSERT(latin1.isEmpty() == unicodedst.isEmpty());
|
||||
Q_ASSERT(latin1.length() == unicodedst.length());
|
||||
QCOMPARE(latin1.isNull(), unicodesrc.isNull());
|
||||
QCOMPARE(latin1.isEmpty(), unicodesrc.isEmpty());
|
||||
QCOMPARE(latin1.length(), unicodesrc.length());
|
||||
QCOMPARE(latin1.isNull(), unicodedst.isNull());
|
||||
QCOMPARE(latin1.isEmpty(), unicodedst.isEmpty());
|
||||
QCOMPARE(latin1.length(), unicodedst.length());
|
||||
|
||||
if (!latin1.isEmpty())
|
||||
while (latin1.length() < 128) {
|
||||
|
@ -3028,7 +3028,7 @@ void tst_QTableView::spans_data()
|
||||
<< 1
|
||||
<< 2;
|
||||
|
||||
QTest::newRow("QTBUG-6004: No failing Q_ASSERT, then it passes.")
|
||||
QTest::newRow("QTBUG-6004: No failing assertion, then it passes.")
|
||||
<< 5 << 5
|
||||
<< (SpanList() << QRect(0, 0, 2, 2) << QRect(0, 0, 1, 1))
|
||||
<< false
|
||||
@ -3036,7 +3036,7 @@ void tst_QTableView::spans_data()
|
||||
<< 1
|
||||
<< 1;
|
||||
|
||||
QTest::newRow("QTBUG-6004 (follow-up): No failing Q_ASSERT, then it passes.")
|
||||
QTest::newRow("QTBUG-6004 (follow-up): No failing assertion, then it passes.")
|
||||
<< 10 << 10
|
||||
<< (SpanList() << QRect(2, 2, 1, 3) << QRect(2, 2, 1, 1))
|
||||
<< false
|
||||
|
@ -98,8 +98,12 @@ static QList<QPointF> parsePoints(const QByteArray &line)
|
||||
QList<qreal> nums = parseNumbersList(it);
|
||||
QList<qreal>::const_iterator nitr;
|
||||
for (nitr = nums.begin(); nitr != nums.end(); ++nitr) {
|
||||
qreal x = *nitr; ++nitr;
|
||||
Q_ASSERT(nitr != nums.end());
|
||||
qreal x = *nitr;
|
||||
++nitr;
|
||||
if (nitr == nums.end()) {
|
||||
qWarning() << "parsePoints: Even number of co-ordinates required, odd number found: skipping last point";
|
||||
break;
|
||||
}
|
||||
qreal y = *nitr;
|
||||
res.append(QPointF(x, y));
|
||||
}
|
||||
|
@ -80,19 +80,6 @@ struct QEdge {
|
||||
horizontal = p1.y == p2.y;
|
||||
}
|
||||
|
||||
inline qreal xAt(const qreal &y) const
|
||||
{
|
||||
Q_ASSERT(p1.y != p2.y);
|
||||
XFixed yf = XDoubleToFixed(y);
|
||||
|
||||
if (yf == p1.y)
|
||||
return XFixedToDouble(p1.x);
|
||||
else if (yf == p2.y)
|
||||
return XFixedToDouble(p2.x);
|
||||
|
||||
return (!vertical) ? (((y - b)*im)) : pf1.x();
|
||||
}
|
||||
|
||||
QPointF pf1, pf2;
|
||||
XPointFixed p1, p2;
|
||||
qreal m;
|
||||
@ -218,7 +205,8 @@ void old_tesselate_polygon(QVector<XTrapezoid> *traps, const QPointF *pg, int pg
|
||||
qreal ymax(INT_MIN/256);
|
||||
|
||||
//painter.begin(pg, pgSize);
|
||||
Q_ASSERT(pg[0] == pg[pgSize-1]);
|
||||
if (pg[0] != pg[pgSize-1])
|
||||
qWarning() << Q_FUNC_INFO << "Malformed polygon (first and last points must be identical)";
|
||||
// generate edge table
|
||||
// qDebug() << "POINTS:";
|
||||
for (int x = 0; x < pgSize-1; ++x) {
|
||||
@ -383,7 +371,8 @@ void old_tesselate_polygon(QVector<XTrapezoid> *traps, const QPointF *pg, int pg
|
||||
isects[i].edge = edge;
|
||||
}
|
||||
|
||||
Q_ASSERT(isects.size()%2 == 1);
|
||||
if (isects.size()%2 != 1)
|
||||
qFatal("%s: number of intersection points must be odd", Q_FUNC_INFO);
|
||||
|
||||
// sort intersection points
|
||||
qSort(&isects[0], &isects[isects.size()-1], compareIntersections);
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include <private/qtessellator_p.h>
|
||||
|
||||
#include "math.h"
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
class TestTessellator : public QTessellator
|
||||
{
|
||||
@ -91,7 +92,8 @@ void test_tessellate_polygon_rect(QVector<XTrapezoid> *traps, const QPointF *poi
|
||||
bool winding)
|
||||
{
|
||||
// 5 points per rect
|
||||
Q_ASSERT(nPoints % 5 == 0);
|
||||
if (nPoints % 5 != 0)
|
||||
qWarning() << Q_FUNC_INFO << "multiples of 5 points expected";
|
||||
|
||||
TestTessellator t;
|
||||
t.traps = traps;
|
||||
|
@ -123,14 +123,14 @@ void tst_QTextBoundaryFinder::graphemeBoundaries()
|
||||
if (test.at(pos).unicode() == 0xf7)
|
||||
breakPositions.append(strPos);
|
||||
else
|
||||
Q_ASSERT(test.at(pos).unicode() == 0xd7);
|
||||
QVERIFY(test.at(pos).unicode() == 0xd7);
|
||||
++pos;
|
||||
if (pos < test.length()) {
|
||||
Q_ASSERT(pos < test.length() - 4);
|
||||
QVERIFY(pos < test.length() - 4);
|
||||
QString hex = test.mid(pos, 4);
|
||||
bool ok = true;
|
||||
testString.append(QChar(hex.toInt(&ok, 16)));
|
||||
Q_ASSERT(ok);
|
||||
QVERIFY(ok);
|
||||
pos += 4;
|
||||
}
|
||||
++strPos;
|
||||
@ -176,14 +176,14 @@ void tst_QTextBoundaryFinder::wordBoundaries()
|
||||
if (test.at(pos).unicode() == 0xf7)
|
||||
breakPositions.append(strPos);
|
||||
else
|
||||
Q_ASSERT(test.at(pos).unicode() == 0xd7);
|
||||
QVERIFY(test.at(pos).unicode() == 0xd7);
|
||||
++pos;
|
||||
if (pos < test.length()) {
|
||||
Q_ASSERT(pos < test.length() - 4);
|
||||
QVERIFY(pos < test.length() - 4);
|
||||
QString hex = test.mid(pos, 4);
|
||||
bool ok = true;
|
||||
testString.append(QChar(hex.toInt(&ok, 16)));
|
||||
Q_ASSERT(ok);
|
||||
QVERIFY(ok);
|
||||
pos += 4;
|
||||
}
|
||||
++strPos;
|
||||
@ -228,14 +228,14 @@ void tst_QTextBoundaryFinder::sentenceBoundaries()
|
||||
if (test.at(pos).unicode() == 0xf7)
|
||||
breakPositions.append(strPos);
|
||||
else
|
||||
Q_ASSERT(test.at(pos).unicode() == 0xd7);
|
||||
QVERIFY(test.at(pos).unicode() == 0xd7);
|
||||
++pos;
|
||||
if (pos < test.length()) {
|
||||
Q_ASSERT(pos < test.length() - 4);
|
||||
QVERIFY(pos < test.length() - 4);
|
||||
QString hex = test.mid(pos, 4);
|
||||
bool ok = true;
|
||||
testString.append(QChar(hex.toInt(&ok, 16)));
|
||||
Q_ASSERT(ok);
|
||||
QVERIFY(ok);
|
||||
pos += 4;
|
||||
}
|
||||
++strPos;
|
||||
|
@ -428,7 +428,7 @@ void tst_QTextCodec::flagCodepointFFFF() const
|
||||
QString input(ch);
|
||||
|
||||
QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
|
||||
Q_ASSERT(codec);
|
||||
QVERIFY(codec);
|
||||
|
||||
const QByteArray asDecoded(codec->fromUnicode(input));
|
||||
QCOMPARE(asDecoded, QByteArray("?"));
|
||||
@ -465,7 +465,7 @@ void tst_QTextCodec::flagF7808080() const
|
||||
|
||||
|
||||
QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
|
||||
Q_ASSERT(codec);
|
||||
QVERIFY(codec);
|
||||
|
||||
//QVERIFY(!codec->canEncode(QChar(0x1C0000)));
|
||||
|
||||
@ -482,7 +482,7 @@ void tst_QTextCodec::flagEFBFBF() const
|
||||
invalidInput[2] = char(0xBF);
|
||||
|
||||
const QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
|
||||
Q_ASSERT(codec);
|
||||
QVERIFY(codec);
|
||||
|
||||
{
|
||||
//QVERIFY(!codec->canEncode(QChar(0xFFFF)));
|
||||
@ -1627,7 +1627,7 @@ void tst_QTextCodec::utf8bom()
|
||||
QFETCH(QString, result);
|
||||
|
||||
QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
|
||||
Q_ASSERT(codec);
|
||||
QVERIFY(codec);
|
||||
|
||||
QCOMPARE(codec->toUnicode(data.constData(), data.length(), 0), result);
|
||||
|
||||
|
@ -317,7 +317,7 @@ void tst_QTextEdit::getSetCheck()
|
||||
// void QTextEdit::setFontPointSize(qreal)
|
||||
obj1.setFontPointSize(qreal(1.1));
|
||||
QCOMPARE(qreal(1.1), obj1.fontPointSize());
|
||||
// we currently Q_ASSERT_X in QFont::setPointSizeF for that
|
||||
// we currently assert in QFont::setPointSizeF for that
|
||||
//obj1.setFontPointSize(0.0);
|
||||
//QCOMPARE(1.1, obj1.fontPointSize()); // Should not accept 0.0 => keep old
|
||||
|
||||
@ -327,7 +327,7 @@ void tst_QTextEdit::getSetCheck()
|
||||
QCOMPARE(1, obj1.fontWeight()); // Range<1, 99>
|
||||
obj1.setFontWeight(99);
|
||||
QCOMPARE(99, obj1.fontWeight()); // Range<1, 99>
|
||||
/* Q_ASSERT_X in qfont.cpp
|
||||
/* assertion in qfont.cpp
|
||||
obj1.setFontWeight(INT_MIN);
|
||||
QCOMPARE(1, obj1.fontWeight()); // Range<1, 99>
|
||||
obj1.setFontWeight(INT_MAX);
|
||||
@ -2064,7 +2064,7 @@ void tst_QTextEdit::compareWidgetAndImage(QTextEdit &widget, const QString &imag
|
||||
|
||||
QCOMPARE(original.isNull(), false);
|
||||
QCOMPARE(original.size(), image.size());
|
||||
Q_ASSERT(image.depth() == 32);
|
||||
QCOMPARE(image.depth(), 32);
|
||||
QCOMPARE(original.depth(), image.depth());
|
||||
|
||||
const int bytesPerLine = image.bytesPerLine();
|
||||
|
@ -114,11 +114,14 @@ QString tst_QTextOdfWriter::getContentFromXml()
|
||||
xmlWriter->writeEndDocument();
|
||||
buffer->close();
|
||||
QString stringContent = QString::fromUtf8(buffer->data());
|
||||
QString ret;
|
||||
int index = stringContent.indexOf("<dummy");
|
||||
Q_ASSERT(index);
|
||||
index = stringContent.indexOf('>', index);
|
||||
stringContent = stringContent.mid(index+1, stringContent.length() - index - 10);
|
||||
return stringContent;
|
||||
if (index > 0) {
|
||||
index = stringContent.indexOf('>', index);
|
||||
if (index > 0)
|
||||
ret = stringContent.mid(index+1, stringContent.length() - index - 10);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void tst_QTextOdfWriter::testWriteParagraph_data()
|
||||
|
@ -209,7 +209,7 @@ public:
|
||||
cond.wait(&mutex, five_minutes);
|
||||
}
|
||||
setTerminationEnabled(true);
|
||||
Q_ASSERT_X(false, "tst_QThread", "test case hung");
|
||||
qFatal("tst_QThread: test case hung");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -207,7 +207,8 @@ bool QSystemLockPrivate::modifySemaphore(QSystemLockPrivate::Operation op,
|
||||
if ((lockCount == 0 && op == Lock) || (lockCount > 0 && op == Unlock)) {
|
||||
if (op == Unlock) {
|
||||
--lockCount;
|
||||
Q_ASSERT(lockCount >= 0);
|
||||
if (lockCount < 0)
|
||||
qFatal("%s: lockCount must not be negative", Q_FUNC_INFO);
|
||||
if (lockCount > 0)
|
||||
return true;
|
||||
}
|
||||
|
@ -157,7 +157,8 @@ bool QSystemLockPrivate::modifySemaphore(QSystemLockPrivate::Operation op,
|
||||
if ((lockCount == 0 && op == Lock) || (lockCount > 0 && op == Unlock)) {
|
||||
if (op == Unlock) {
|
||||
--lockCount;
|
||||
Q_ASSERT(lockCount >= 0);
|
||||
if (lockCount < 0)
|
||||
qFatal("%s: lockCount must not be negative", Q_FUNC_INFO);
|
||||
if (lockCount > 0)
|
||||
return true;
|
||||
}
|
||||
|
@ -277,7 +277,8 @@ public:
|
||||
}
|
||||
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const {
|
||||
Q_ASSERT(fetched);
|
||||
if (!fetched)
|
||||
qFatal("%s: rowCount should not be called before fetching", Q_FUNC_INFO);
|
||||
if ((parent.column() > 0) || (level(parent) > levels))
|
||||
return 0;
|
||||
return rows;
|
||||
@ -2536,7 +2537,7 @@ void tst_QTreeView::sortByColumn()
|
||||
|
||||
/*
|
||||
This is a model that every time kill() is called it will completely change
|
||||
all of its nodes for new nodes. It then asserts if you later use a dead node.
|
||||
all of its nodes for new nodes. It then qFatal's if you later use a dead node.
|
||||
*/
|
||||
class EvilModel: public QAbstractItemModel
|
||||
{
|
||||
@ -2567,7 +2568,8 @@ public:
|
||||
}
|
||||
}
|
||||
if (parent == 0) {
|
||||
Q_ASSERT(children.isEmpty());
|
||||
if (!children.isEmpty())
|
||||
qFatal("%s: children should be empty when parent is null", Q_FUNC_INFO);
|
||||
populate();
|
||||
} else {
|
||||
isDead = true;
|
||||
@ -2624,7 +2626,8 @@ public:
|
||||
Node *parentNode = root;
|
||||
if (parent.isValid()) {
|
||||
parentNode = static_cast<Node*>(parent.internalPointer());
|
||||
Q_ASSERT(!parentNode->isDead);
|
||||
if (parentNode->isDead)
|
||||
qFatal("%s: parentNode is dead!", Q_FUNC_INFO);
|
||||
}
|
||||
return parentNode->children.count();
|
||||
}
|
||||
@ -2639,9 +2642,11 @@ public:
|
||||
Node *grandparentNode = static_cast<Node*>(parent.internalPointer());
|
||||
Node *parentNode = root;
|
||||
if (parent.isValid()) {
|
||||
Q_ASSERT(!grandparentNode->isDead);
|
||||
if (grandparentNode->isDead)
|
||||
qFatal("%s: grandparentNode is dead!", Q_FUNC_INFO);
|
||||
parentNode = grandparentNode->children[parent.row()];
|
||||
Q_ASSERT(!parentNode->isDead);
|
||||
if (parentNode->isDead)
|
||||
qFatal("%s: grandparentNode is dead!", Q_FUNC_INFO);
|
||||
}
|
||||
return createIndex(row, column, parentNode);
|
||||
}
|
||||
@ -2661,7 +2666,8 @@ public:
|
||||
Node *parentNode = root;
|
||||
if (idx.isValid()) {
|
||||
parentNode = static_cast<Node*>(idx.internalPointer());
|
||||
Q_ASSERT(!parentNode->isDead);
|
||||
if (parentNode->isDead)
|
||||
qFatal("%s: grandparentNode is dead!", Q_FUNC_INFO);
|
||||
}
|
||||
return QString("[%1,%2,%3]").arg(idx.row()).arg(idx.column())
|
||||
.arg(parentNode->isDead ? "dead" : "alive");
|
||||
|
@ -3239,18 +3239,24 @@ struct MyData
|
||||
{
|
||||
void *ptr;
|
||||
MyData() : ptr(this) {}
|
||||
~MyData() { Q_ASSERT(ptr == this); }
|
||||
MyData(const MyData& o) : ptr(this) { Q_ASSERT(o.ptr == &o); }
|
||||
~MyData()
|
||||
{
|
||||
if (ptr != this) qWarning("%s: object has moved", Q_FUNC_INFO);
|
||||
}
|
||||
MyData(const MyData& o) : ptr(this)
|
||||
{
|
||||
if (o.ptr != &o) qWarning("%s: other object has moved", Q_FUNC_INFO);
|
||||
}
|
||||
MyData &operator=(const MyData &o)
|
||||
{
|
||||
Q_ASSERT(ptr == this);
|
||||
Q_ASSERT(o.ptr == &o);
|
||||
if (ptr != this) qWarning("%s: object has moved", Q_FUNC_INFO);
|
||||
if (o.ptr != &o) qWarning("%s: other object has moved", Q_FUNC_INFO);
|
||||
return *this;
|
||||
}
|
||||
bool operator==(const MyData &o) const
|
||||
{
|
||||
Q_ASSERT(ptr == this);
|
||||
Q_ASSERT(o.ptr == &o);
|
||||
if (ptr != this) qWarning("%s: object has moved", Q_FUNC_INFO);
|
||||
if (o.ptr != &o) qWarning("%s: other object has moved", Q_FUNC_INFO);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -7234,8 +7234,7 @@ void tst_QWidget::render_systemClip2()
|
||||
QFETCH(bool, usePaintEvent);
|
||||
QFETCH(QColor, expectedColor);
|
||||
|
||||
Q_ASSERT_X(expectedColor != QColor(Qt::red), Q_FUNC_INFO,
|
||||
"Qt::red is the reference color for the image, pick another color");
|
||||
QVERIFY2(expectedColor != QColor(Qt::red), "Qt::red is the reference color for the image, pick another color");
|
||||
|
||||
class MyWidget : public QWidget
|
||||
{
|
||||
@ -10422,7 +10421,7 @@ void tst_QWidget::taskQTBUG_7532_tabOrderWithFocusProxy()
|
||||
w.setFocusProxy(fp);
|
||||
QWidget::setTabOrder(&w, fp);
|
||||
|
||||
// No Q_ASSERT, then it's allright.
|
||||
// In debug mode, no assertion failure means it's alright.
|
||||
}
|
||||
|
||||
void tst_QWidget::movedAndResizedAttributes()
|
||||
|
@ -854,25 +854,26 @@ struct MyPage2 : public QWizardPage
|
||||
public:
|
||||
MyPage2() : init(0), cleanup(0), validate(0) {}
|
||||
|
||||
void initializePage() { ++init; QWizardPage::initializePage(); checkInvariant(); }
|
||||
void cleanupPage() { ++cleanup; QWizardPage::cleanupPage(); checkInvariant(); }
|
||||
void initializePage() { ++init; QWizardPage::initializePage(); }
|
||||
void cleanupPage() { ++cleanup; QWizardPage::cleanupPage(); }
|
||||
bool validatePage() { ++validate; return QWizardPage::validatePage(); }
|
||||
|
||||
void check(int init, int cleanup)
|
||||
{ Q_ASSERT(init == this->init && cleanup == this->cleanup); Q_UNUSED(init); Q_UNUSED(cleanup); }
|
||||
bool check(int init, int cleanup)
|
||||
{
|
||||
return init == this->init
|
||||
&& cleanup == this->cleanup
|
||||
&& (this->init == this->cleanup || this->init - 1 == this->cleanup);
|
||||
}
|
||||
|
||||
int init;
|
||||
int cleanup;
|
||||
int validate;
|
||||
|
||||
private:
|
||||
void checkInvariant() { Q_ASSERT(init == cleanup || init - 1 == cleanup); }
|
||||
};
|
||||
|
||||
#define CHECK_PAGE_INIT(i0, c0, i1, c1, i2, c2) \
|
||||
page0->check((i0), (c0)); \
|
||||
page1->check((i1), (c1)); \
|
||||
page2->check((i2), (c2));
|
||||
QVERIFY(page0->check((i0), (c0))); \
|
||||
QVERIFY(page1->check((i1), (c1))); \
|
||||
QVERIFY(page2->check((i2), (c2)));
|
||||
|
||||
void tst_QWizard::setOption_IndependentPages()
|
||||
{
|
||||
|
@ -181,9 +181,7 @@ private slots:
|
||||
{
|
||||
if(bodyLength == -1)
|
||||
{
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO,
|
||||
"No length was specified in the header.");
|
||||
return;
|
||||
qFatal("No length was specified in the header.");
|
||||
}
|
||||
|
||||
QDomDocument domDoc;
|
||||
|
@ -165,7 +165,7 @@ class tst_QXmlSimpleReader : public QObject
|
||||
void roundtripWithNamespaces() const;
|
||||
|
||||
private:
|
||||
static QDomDocument fromByteArray(const QString &title, const QByteArray &ba);
|
||||
static QDomDocument fromByteArray(const QString &title, const QByteArray &ba, bool *ok);
|
||||
XmlServer *server;
|
||||
};
|
||||
|
||||
@ -730,25 +730,27 @@ void tst_QXmlSimpleReader::reportNamespace_data() const
|
||||
<< QString("http://example.com/");
|
||||
}
|
||||
|
||||
QDomDocument tst_QXmlSimpleReader::fromByteArray(const QString &title, const QByteArray &ba)
|
||||
QDomDocument tst_QXmlSimpleReader::fromByteArray(const QString &title, const QByteArray &ba, bool *ok)
|
||||
{
|
||||
QDomDocument doc(title);
|
||||
const bool ret = doc.setContent(ba, true);
|
||||
Q_ASSERT(ret);
|
||||
*ok = doc.setContent(ba, true);
|
||||
return doc;
|
||||
}
|
||||
|
||||
void tst_QXmlSimpleReader::roundtripWithNamespaces() const
|
||||
{
|
||||
QEXPECT_FAIL("", "Known problem, see 154573. The fix happens to break uic.", Abort);
|
||||
|
||||
const char *const expected = "<element b:attr=\"value\" xmlns:a=\"http://www.example.com/A\" xmlns:b=\"http://www.example.com/B\" />\n";
|
||||
bool ok;
|
||||
|
||||
{
|
||||
const char *const xml = "<element xmlns:b=\"http://www.example.com/B\" b:attr=\"value\" xmlns:a=\"http://www.example.com/A\"/>";
|
||||
|
||||
const QDomDocument one(fromByteArray("document", xml));
|
||||
const QDomDocument two(fromByteArray("document2", one.toByteArray(2)));
|
||||
const QDomDocument one(fromByteArray("document", xml, &ok));
|
||||
QVERIFY(ok);
|
||||
const QDomDocument two(fromByteArray("document2", one.toByteArray(2), &ok));
|
||||
QVERIFY(ok);
|
||||
|
||||
QEXPECT_FAIL("", "Known problem, see 154573. The fix happens to break uic.", Abort);
|
||||
|
||||
QCOMPARE(expected, one.toByteArray().constData());
|
||||
QCOMPARE(one.toByteArray(2).constData(), two.toByteArray(2).constData());
|
||||
@ -758,8 +760,10 @@ void tst_QXmlSimpleReader::roundtripWithNamespaces() const
|
||||
{
|
||||
const char *const xml = "<element b:attr=\"value\" xmlns:b=\"http://www.example.com/B\" xmlns:a=\"http://www.example.com/A\"/>";
|
||||
|
||||
const QDomDocument one(fromByteArray("document", xml));
|
||||
const QDomDocument two(fromByteArray("document2", one.toByteArray(2)));
|
||||
const QDomDocument one(fromByteArray("document", xml, &ok));
|
||||
QVERIFY(ok);
|
||||
const QDomDocument two(fromByteArray("document2", one.toByteArray(2), &ok));
|
||||
QVERIFY(ok);
|
||||
|
||||
QCOMPARE(expected, one.toByteArray().constData());
|
||||
QCOMPARE(one.toByteArray(2).constData(), two.toByteArray(2).constData());
|
||||
|
@ -47,17 +47,9 @@ QT_FORWARD_DECLARE_CLASS(QString)
|
||||
class QC14N
|
||||
{
|
||||
public:
|
||||
enum Option
|
||||
{
|
||||
IgnoreProcessingInstruction,
|
||||
IgnoreComments
|
||||
};
|
||||
typedef QFlags<Option> Options;
|
||||
|
||||
static bool isEqual(QIODevice *const firstDocument,
|
||||
QIODevice *const secondDocument,
|
||||
QString *const message = 0,
|
||||
const Options options = Options());
|
||||
QString *const message = 0);
|
||||
|
||||
private:
|
||||
static bool isDifferent(const QXmlStreamReader &r1,
|
||||
@ -76,20 +68,17 @@ private:
|
||||
*/
|
||||
bool QC14N::isEqual(QIODevice *const firstDocument,
|
||||
QIODevice *const secondDocument,
|
||||
QString *const message,
|
||||
const Options options)
|
||||
QString *const message)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
Q_ASSERT_X(firstDocument, Q_FUNC_INFO,
|
||||
"A valid QIODevice pointer must be supplied");
|
||||
Q_ASSERT_X(secondDocument, Q_FUNC_INFO,
|
||||
"A valid QIODevice pointer must be supplied");
|
||||
Q_ASSERT_X(firstDocument->isReadable(), Q_FUNC_INFO, "The device must be readable.");
|
||||
Q_ASSERT_X(secondDocument->isReadable(), Q_FUNC_INFO, "The device must be readable.");
|
||||
|
||||
Q_ASSERT_X(options == Options(), Q_FUNC_INFO,
|
||||
"Not yet implemented.");
|
||||
Q_UNUSED(options);
|
||||
if (!firstDocument)
|
||||
qFatal("%s: A valid firstDocument QIODevice pointer must be supplied", Q_FUNC_INFO);
|
||||
if (!secondDocument)
|
||||
qFatal("%s: A valid secondDocument QIODevice pointer must be supplied", Q_FUNC_INFO);
|
||||
if (!firstDocument->isReadable())
|
||||
qFatal("%s: The firstDocument device must be readable.", Q_FUNC_INFO);
|
||||
if (!secondDocument->isReadable())
|
||||
qFatal("%s: The secondDocument device must be readable.", Q_FUNC_INFO);
|
||||
|
||||
QXmlStreamReader r1(firstDocument);
|
||||
QXmlStreamReader r2(secondDocument);
|
||||
@ -202,9 +191,9 @@ bool QC14N::isDifferent(const QXmlStreamReader &r1,
|
||||
r2.processingInstructionData() == r2.processingInstructionData();
|
||||
|
||||
}
|
||||
default:
|
||||
qFatal("%s: Unknown tokenType: %d", Q_FUNC_INFO, static_cast<int>(r1.tokenType()));
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "This line should never be reached");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -221,8 +221,7 @@ static QString documentElement(const QByteArray &document)
|
||||
reader.readNext();
|
||||
}
|
||||
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO,
|
||||
qPrintable(QString::fromLatin1("The input %1 didn't contain an element.").arg(QString::fromUtf8(document.constData()))));
|
||||
qFatal("The input %s didn't contain an element", document.constData());
|
||||
return QString();
|
||||
}
|
||||
|
||||
@ -265,7 +264,8 @@ public:
|
||||
expected(aExpected),
|
||||
output(aOutput)
|
||||
{
|
||||
Q_ASSERT(!aId.isEmpty());
|
||||
if (aId.isEmpty())
|
||||
qFatal("%s: aId must not be an empty string", Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
QString id;
|
||||
@ -289,7 +289,8 @@ public:
|
||||
TestSuiteHandler(const QUrl &baseURI) : runCount(0),
|
||||
skipCount(0)
|
||||
{
|
||||
Q_ASSERT(baseURI.isValid());
|
||||
if (!baseURI.isValid())
|
||||
qFatal("%s: baseURI must be valid", Q_FUNC_INFO);
|
||||
m_baseURI.push(baseURI);
|
||||
}
|
||||
|
||||
@ -461,7 +462,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "The input catalog is invalid.");
|
||||
qFatal("The input catalog is invalid.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -481,9 +482,12 @@ public:
|
||||
|
||||
static bool isWellformed(QIODevice *const inputFile, const ParseMode mode)
|
||||
{
|
||||
Q_ASSERT(inputFile);
|
||||
Q_ASSERT_X(inputFile->isOpen(), Q_FUNC_INFO, "The caller is responsible for opening the device.");
|
||||
Q_ASSERT(mode == ParseIncrementally || mode == ParseSinglePass);
|
||||
if (!inputFile)
|
||||
qFatal("%s: inputFile must be a valid QIODevice pointer", Q_FUNC_INFO);
|
||||
if (!inputFile->isOpen())
|
||||
qFatal("%s: inputFile must be opened by the caller", Q_FUNC_INFO);
|
||||
if (mode != ParseIncrementally && mode != ParseSinglePass)
|
||||
qFatal("%s: mode must be either ParseIncrementally or ParseSinglePass", Q_FUNC_INFO);
|
||||
|
||||
if(mode == ParseIncrementally)
|
||||
{
|
||||
|
@ -78,7 +78,8 @@ private:
|
||||
QTestAlivePinger::QTestAlivePinger(QObject *receiver, QObject *parent)
|
||||
: QObject(parent), rec(receiver), currentSequenceId(0), lastSequenceId(0)
|
||||
{
|
||||
Q_ASSERT(rec);
|
||||
if (!rec)
|
||||
qFatal("Null receiver object passed to QTestAlivePinger::QTestAlivePinger()");
|
||||
timerId = startTimer(850);
|
||||
}
|
||||
|
||||
@ -147,8 +148,8 @@ bool QTestAlive::event(QEvent *e)
|
||||
|
||||
void QTestAlive::run()
|
||||
{
|
||||
Q_ASSERT_X(QCoreApplication::instance(), "QTestAlive::run()",
|
||||
"Cannot start QTestAlive without a QCoreApplication instance.");
|
||||
if (!QCoreApplication::instance())
|
||||
qFatal("QTestAlive::run(): Cannot start QTestAlive without a QCoreApplication instance.");
|
||||
|
||||
QTestAlivePinger p(this);
|
||||
pinger = &p;
|
||||
|
Loading…
Reference in New Issue
Block a user