Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
PIM Calendar Support
Commits
d313caf0
Commit
d313caf0
authored
Aug 13, 2020
by
Volker Krause
Browse files
Replace ancient ModelTest copy by QAbstractItemModelTester
parent
bfb6f6ad
Pipeline
#31065
passed with stage
in 22 minutes and 12 seconds
Changes
5
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
src/freebusymodel/autotests/CMakeLists.txt
View file @
d313caf0
macro
(
add_libkdepim_freebusymodel_unittest _name
)
ecm_add_test
(
${
_name
}
.cpp
modeltest.cpp
ecm_add_test
(
${
_name
}
.cpp
TEST_NAME
${
_name
}
NAME_PREFIX
"libkdepim-freebusymodel-"
LINK_LIBRARIES Qt5::Test KF5::AkonadiCore KF5::CalendarUtils KF5::CalendarCore KF5::CalendarSupport
...
...
src/freebusymodel/autotests/modeltest.cpp
deleted
100644 → 0
View file @
bfb6f6ad
This diff is collapsed.
Click to expand it.
src/freebusymodel/autotests/modeltest.h
deleted
100644 → 0
View file @
bfb6f6ad
/****************************************************************************
**
** SPDX-FileCopyrightText: 2007 Trolltech ASA. All rights reserved.
**
** 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
src/freebusymodel/autotests/testfreebusyitemmodel.cpp
View file @
d313caf0
...
...
@@ -6,12 +6,12 @@
*/
#include "testfreebusyitemmodel.h"
#include "modeltest.h"
#include "../freebusyitemmodel.h"
#include "../freebusyitem.h"
#include <KCalendarCore/Attendee>
#include <QAbstractItemModelTester>
#include <QTest>
using
namespace
CalendarSupport
;
...
...
@@ -23,7 +23,7 @@ QTEST_GUILESS_MAIN(FreeBusyItemModelTest)
void
FreeBusyItemModelTest
::
testModelValidity
()
{
FreeBusyItemModel
*
model
=
new
FreeBusyItemModel
(
this
);
new
ModelTest
(
model
,
this
);
new
QAbstractItem
ModelTest
er
(
model
,
this
);
QVERIFY
(
model
->
rowCount
()
==
0
);
...
...
@@ -76,7 +76,7 @@ void FreeBusyItemModelTest::testModelValidity()
void
FreeBusyItemModelTest
::
testModelValidity2
()
{
FreeBusyItemModel
*
model
=
new
FreeBusyItemModel
(
this
);
new
ModelTest
(
model
,
this
);
new
QAbstractItem
ModelTest
er
(
model
,
this
);
const
QDateTime
dt1
(
QDate
(
2010
,
7
,
24
),
QTime
(
7
,
0
,
0
),
Qt
::
UTC
);
const
QDateTime
dt2
(
QDate
(
2010
,
7
,
24
),
QTime
(
10
,
0
,
0
),
Qt
::
UTC
);
...
...
@@ -199,7 +199,7 @@ void FreeBusyItemModelTest::testModelValidity2()
void
FreeBusyItemModelTest
::
testInsertFreeBusy
()
{
FreeBusyItemModel
*
model
=
new
FreeBusyItemModel
(
this
);
new
ModelTest
(
model
,
this
);
new
QAbstractItem
ModelTest
er
(
model
,
this
);
const
QDateTime
dt1
(
QDate
(
2010
,
7
,
24
),
QTime
(
7
,
0
,
0
),
Qt
::
UTC
);
const
QDateTime
dt2
(
QDate
(
2010
,
7
,
24
),
QTime
(
10
,
0
,
0
),
Qt
::
UTC
);
...
...
src/freebusymodel/autotests/testfreeperiodmodel.cpp
View file @
d313caf0
...
...
@@ -6,12 +6,12 @@
*/
#include "testfreeperiodmodel.h"
#include "modeltest.h"
#include "../freeperiodmodel.h"
#include <KCalendarCore/Period>
#include <KCalendarCore/Duration>
#include <QAbstractItemModelTester>
#include <QTest>
using
namespace
CalendarSupport
;
...
...
@@ -23,7 +23,7 @@ QTEST_GUILESS_MAIN(FreePeriodModelTest)
void
FreePeriodModelTest
::
testModelValidity
()
{
FreePeriodModel
*
model
=
new
FreePeriodModel
(
this
);
new
ModelTest
(
model
,
this
);
new
QAbstractItem
ModelTest
er
(
model
,
this
);
const
QDateTime
dt1
(
QDate
(
2010
,
7
,
24
),
QTime
(
7
,
0
,
0
),
Qt
::
UTC
);
const
QDateTime
dt2
(
QDate
(
2010
,
7
,
24
),
QTime
(
10
,
0
,
0
),
Qt
::
UTC
);
...
...
@@ -41,7 +41,7 @@ void FreePeriodModelTest::testModelValidity()
void
FreePeriodModelTest
::
testSplitByDay
()
{
FreePeriodModel
*
model
=
new
FreePeriodModel
(
this
);
new
ModelTest
(
model
,
this
);
new
QAbstractItem
ModelTest
er
(
model
,
this
);
const
QDateTime
startDt
(
QDate
(
2010
,
7
,
24
),
QTime
(
8
,
0
,
0
),
Qt
::
UTC
);
const
QDateTime
endDt
(
QDate
(
2010
,
7
,
25
),
QTime
(
8
,
0
,
0
),
Qt
::
UTC
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment