Commit 1e43248a authored by Volker Krause's avatar Volker Krause
Browse files

Replace ancient ModelTest copy by QAbstractItemModelTester

parent 000cceed
Pipeline #31064 passed with stage
in 25 minutes and 46 seconds
......@@ -6,7 +6,7 @@ set(grant_lib KGantt)
macro(IE_UNIT_TESTS)
foreach(_testname ${ARGN})
add_executable(${_testname} ${_testname}.cpp modeltest.cpp)
add_executable(${_testname} ${_testname}.cpp)
add_test(NAME ${_testname} COMMAND ${_testname})
ecm_mark_as_test(${_testname})
target_link_libraries(${_testname}
......@@ -23,7 +23,7 @@ endmacro()
macro(IE_EXECUTABLE_TESTS)
foreach(_testname ${ARGN})
add_executable(${_testname} NOGUI TEST ${_testname}.cpp modeltest.cpp)
add_executable(${_testname} NOGUI TEST ${_testname}.cpp)
target_link_libraries(${_testname} KF5::CalendarCore Qt5::Test KF5::IncidenceEditor Qt5::Widgets)
endforeach()
endmacro()
......
This diff is collapsed.
/****************************************************************************
**
** SPDX-FileCopyrightText: 2007 Trolltech ASA. All rights reserved.
**
** This file is part of the Qt Concurrent project on Trolltech Labs.
**
** SPDX-License-Identifier: GPL-2.0-only
**
****************************************************************************/
//krazy:excludeall=style
#ifndef MODELTEST_H
#define MODELTEST_H
#include <QObject>
#include <QAbstractItemModel>
#include <QStack>
class ModelTest : public QObject
{
Q_OBJECT
public:
explicit ModelTest(QAbstractItemModel *model, QObject *parent = nullptr);
private Q_SLOTS:
void nonDestructiveBasicTest();
void rowCount();
void columnCount();
void hasIndex();
void index();
void parent();
void data();
protected Q_SLOTS:
void runAllTests();
void layoutAboutToBeChanged();
void layoutChanged();
void modelAboutToBeReset();
void modelReset();
void rowsAboutToBeInserted(const QModelIndex &parent, int start, int end);
void rowsInserted(const QModelIndex &parent, int start, int end);
void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
void rowsRemoved(const QModelIndex &parent, int start, int end);
void rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int);
void rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
private:
void checkChildren(const QModelIndex &parent, int currentDepth = 0);
QAbstractItemModel *model = nullptr;
struct Changing {
QModelIndex parent;
int oldSize;
QVariant last;
QVariant next;
};
QStack<Changing> insert;
QStack<Changing> remove;
bool fetchingMore = false;
QList<QPersistentModelIndex> changing;
};
#endif
......@@ -7,7 +7,6 @@
#include "testfreebusyganttproxymodel.h"
#include "freebusyganttproxymodel.h"
#include "modeltest.h"
#include <CalendarSupport/FreeBusyItem>
#include <CalendarSupport/FreeBusyItemModel>
......@@ -15,6 +14,7 @@
#include <KGantt/KGanttGraphicsView>
#include <KCalendarCore/Attendee>
#include <QAbstractItemModelTester>
#include <QTest>
#include <QStandardPaths>
QTEST_MAIN(FreeBusyGanttProxyModelTest)
......@@ -32,7 +32,7 @@ void FreeBusyGanttProxyModelTest::testModelValidity()
CalendarSupport::FreeBusyItemModel *fbModel = new CalendarSupport::FreeBusyItemModel();
FreeBusyGanttProxyModel *ganttModel = new FreeBusyGanttProxyModel();
ganttModel->setSourceModel(fbModel);
ModelTest *modelTest = new ModelTest(ganttModel);
auto *modelTest = new QAbstractItemModelTester(ganttModel);
Q_UNUSED(modelTest);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment