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
Akonadi
Commits
0f667cad
Commit
0f667cad
authored
Jan 26, 2021
by
Laurent Montel
😁
Browse files
run git clang-format
parent
4b751018
Changes
815
Hide whitespace changes
Inline
Side-by-side
autotests/akonadicontrol/agenttypetest.cpp
View file @
0f667cad
...
...
@@ -26,14 +26,13 @@ void AgentTypeTest::testLoad_data()
{
AgentType
googleContactsResource
;
googleContactsResource
.
exec
=
QStringLiteral
(
"akonadi_googlecontacts_resource"
);
googleContactsResource
.
mimeTypes
=
QStringList
{
QStringLiteral
(
"text/directory"
),
QString
()};
googleContactsResource
.
capabilities
=
QStringList
{
AgentType
::
CapabilityResource
};
googleContactsResource
.
mimeTypes
=
QStringList
{
QStringLiteral
(
"text/directory"
),
QString
()};
googleContactsResource
.
capabilities
=
QStringList
{
AgentType
::
CapabilityResource
};
googleContactsResource
.
instanceCounter
=
0
;
googleContactsResource
.
identifier
=
QStringLiteral
(
"akonadi_googlecontacts_resource"
);
googleContactsResource
.
custom
=
QVariantMap
{
{
QStringLiteral
(
"KAccounts"
),
QStringList
{
QStringLiteral
(
"google-contacts"
),
QStringLiteral
(
"google-calendar"
)
}
},
{
QStringLiteral
(
"HasLocalStorage"
),
true
}
};
googleContactsResource
.
custom
=
QVariantMap
{{
QStringLiteral
(
"KAccounts"
),
QStringList
{
QStringLiteral
(
"google-contacts"
),
QStringLiteral
(
"google-calendar"
)}},
{
QStringLiteral
(
"HasLocalStorage"
),
true
}};
googleContactsResource
.
launchMethod
=
AgentType
::
Process
;
// We test an UTF-8 name within quotes.
googleContactsResource
.
name
=
QStringLiteral
(
"
\"
Контакти Google
\"
"
);
...
...
@@ -41,7 +40,6 @@ void AgentTypeTest::testLoad_data()
googleContactsResource
.
comment
=
QStringLiteral
(
"Доступ до ваших записів контактів, Google з KDE"
);
googleContactsResource
.
icon
=
QStringLiteral
(
"im-google"
);
QTest
::
addColumn
<
QString
>
(
"fileName"
);
QTest
::
addColumn
<
AgentType
>
(
"expectedAgentType"
);
...
...
autotests/libs/actionstatemanagertest.cpp
View file @
0f667cad
...
...
@@ -4,8 +4,8 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include <qtest_akonadi.h>
#include "collection.h"
#include <qtest_akonadi.h>
#include "../src/widgets/actionstatemanager_p.h"
#include "../src/widgets/standardactionmanager.h"
...
...
@@ -467,7 +467,7 @@ private Q_SLOTS:
collectionList
<<
folderCollectionThreeOne
;
StateMap
map
;
map
.
insert
(
StandardActionManager
::
CreateCollection
,
false
);
// content mimetype is missing
map
.
insert
(
StandardActionManager
::
CreateCollection
,
false
);
// content mimetype is missing
map
.
insert
(
StandardActionManager
::
CopyCollections
,
true
);
map
.
insert
(
StandardActionManager
::
DeleteCollections
,
true
);
map
.
insert
(
StandardActionManager
::
SynchronizeCollections
,
false
);
...
...
@@ -475,7 +475,7 @@ private Q_SLOTS:
map
.
insert
(
StandardActionManager
::
CopyItems
,
false
);
map
.
insert
(
StandardActionManager
::
Paste
,
false
);
map
.
insert
(
StandardActionManager
::
DeleteItems
,
false
);
map
.
insert
(
StandardActionManager
::
AddToFavoriteCollections
,
false
);
// content mimetype is missing
map
.
insert
(
StandardActionManager
::
AddToFavoriteCollections
,
false
);
// content mimetype is missing
map
.
insert
(
StandardActionManager
::
RemoveFromFavoriteCollections
,
false
);
map
.
insert
(
StandardActionManager
::
RenameFavoriteCollection
,
false
);
map
.
insert
(
StandardActionManager
::
CopyCollectionToMenu
,
true
);
...
...
@@ -566,7 +566,7 @@ private Q_SLOTS:
QHashIterator
<
StandardActionManager
::
Type
,
bool
>
it
(
stateMap
);
while
(
it
.
hasNext
())
{
it
.
next
();
//qDebug() << it.key();
//
qDebug() << it.key();
QVERIFY
(
mStateMap
.
contains
(
it
.
key
()));
const
bool
expected
=
mStateMap
.
value
(
it
.
key
());
if
(
it
.
value
()
!=
expected
)
{
...
...
autotests/libs/attributefactorytest.cpp
View file @
0f667cad
...
...
@@ -13,8 +13,8 @@
#include "itemcreatejob.h"
#include "itemfetchjob.h"
#include "itemfetchscope.h"
#include "resourceselectjob_p.h"
#include "qtest_akonadi.h"
#include "resourceselectjob_p.h"
using
namespace
Akonadi
;
...
...
@@ -54,9 +54,9 @@ void AttributeFactoryTest::testUnknownAttribute()
AKVERIFYEXEC
(
fjob
);
QCOMPARE
(
fjob
->
items
().
count
(),
1
);
item
=
fjob
->
items
().
first
();
QVERIFY
(
item
.
hasAttribute
<
TestAttribute
>
());
// has DefaultAttribute
QVERIFY
(
item
.
hasAttribute
<
TestAttribute
>
());
// has DefaultAttribute
ta
=
item
.
attribute
<
TestAttribute
>
();
QVERIFY
(
!
ta
);
// but can't cast it to TestAttribute
QVERIFY
(
!
ta
);
// but can't cast it to TestAttribute
}
void
AttributeFactoryTest
::
testRegisteredAttribute
()
...
...
autotests/libs/attributefactorytest.h
View file @
0f667cad
...
...
@@ -16,7 +16,6 @@ private Q_SLOTS:
void
initTestCase
();
void
testUnknownAttribute
();
void
testRegisteredAttribute
();
};
#endif
autotests/libs/cachepolicytest.cpp
View file @
0f667cad
...
...
@@ -11,12 +11,10 @@
CachePolicyTest
::
CachePolicyTest
(
QObject
*
parent
)
:
QObject
(
parent
)
{
}
CachePolicyTest
::~
CachePolicyTest
()
{
}
void
CachePolicyTest
::
shouldHaveDefaultValue
()
...
...
@@ -30,4 +28,3 @@ void CachePolicyTest::shouldHaveDefaultValue()
}
QTEST_MAIN
(
CachePolicyTest
)
autotests/libs/cachetest.cpp
View file @
0f667cad
...
...
@@ -4,15 +4,15 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "agentinstance.h"
#include "agentmanager.h"
#include "collection.h"
#include "collectionfetchjob.h"
#include "collectionmodifyjob.h"
#include "item.h"
#include "itemcopyjob.h"
#include "itemfetchjob.h"
#include "itemfetchscope.h"
#include "agentmanager.h"
#include "agentinstance.h"
#include "itemcopyjob.h"
#include "qtest_akonadi.h"
#include <QHash>
...
...
@@ -82,7 +82,7 @@ private Q_SLOTS:
item
=
fetch
->
items
().
first
();
QVERIFY
(
item
.
isValid
());
QVERIFY
(
item
.
hasPayload
());
QVERIFY
(
item
.
revision
()
>
0
);
// was changed by the resource delivering the payload
QVERIFY
(
item
.
revision
()
>
0
);
// was changed by the resource delivering the payload
}
fetch
=
new
ItemFetchJob
(
item
,
this
);
...
...
@@ -135,7 +135,6 @@ private Q_SLOTS:
QVERIFY
(
item
.
isValid
());
QCOMPARE
(
item
.
hasPayload
(),
resourceEnabled
);
}
};
QTEST_AKONADIMAIN
(
CacheTest
)
...
...
autotests/libs/changerecordertest.cpp
View file @
0f667cad
...
...
@@ -4,12 +4,12 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "testattribute.h"
#include "changerecorder.h"
#include "agentmanager.h"
#include "itemdeletejob.h"
#include "itemfetchscope.h"
#include "itemmodifyjob.h"
#include "itemdeletejob.h"
#include "agentmanager.h"
#include "testattribute.h"
#include "qtest_akonadi.h"
...
...
@@ -28,7 +28,7 @@ private Q_SLOTS:
void
initTestCase
()
{
qRegisterMetaType
<
Akonadi
::
Item
>
();
qRegisterMetaType
<
QSet
<
QByteArray
>
>
();
qRegisterMetaType
<
QSet
<
QByteArray
>>
();
AkonadiTest
::
checkTestIsIsolated
();
AkonadiTest
::
setAllResourcesOffline
();
...
...
@@ -48,10 +48,16 @@ private Q_SLOTS:
QTest
::
newRow
(
"nothingToReplay"
)
<<
(
QStringList
()
<<
QStringLiteral
(
"rn"
));
QTest
::
newRow
(
"nothingOneNothing"
)
<<
(
QStringList
()
<<
QStringLiteral
(
"rn"
)
<<
QStringLiteral
(
"c2"
)
<<
QStringLiteral
(
"r2"
)
<<
QStringLiteral
(
"rn"
));
QTest
::
newRow
(
"multipleItems"
)
<<
(
QStringList
()
<<
QStringLiteral
(
"c1"
)
<<
QStringLiteral
(
"c2"
)
<<
QStringLiteral
(
"c3"
)
<<
QStringLiteral
(
"r1"
)
<<
QStringLiteral
(
"c4"
)
<<
QStringLiteral
(
"r2"
)
<<
QStringLiteral
(
"r3"
)
<<
QStringLiteral
(
"r4"
)
<<
QStringLiteral
(
"rn"
));
QTest
::
newRow
(
"reload"
)
<<
(
QStringList
()
<<
QStringLiteral
(
"c1"
)
<<
QStringLiteral
(
"c1"
)
<<
QStringLiteral
(
"c3"
)
<<
QStringLiteral
(
"reload"
)
<<
QStringLiteral
(
"r1"
)
<<
QStringLiteral
(
"r1"
)
<<
QStringLiteral
(
"r3"
)
<<
QStringLiteral
(
"rn"
));
QTest
::
newRow
(
"more"
)
<<
(
QStringList
()
<<
QStringLiteral
(
"c1"
)
<<
QStringLiteral
(
"c2"
)
<<
QStringLiteral
(
"c3"
)
<<
QStringLiteral
(
"reload"
)
<<
QStringLiteral
(
"r1"
)
<<
QStringLiteral
(
"reload"
)
<<
QStringLiteral
(
"c4"
)
<<
QStringLiteral
(
"reload"
)
<<
QStringLiteral
(
"r2"
)
<<
QStringLiteral
(
"reload"
)
<<
QStringLiteral
(
"r3"
)
<<
QStringLiteral
(
"r4"
)
<<
QStringLiteral
(
"rn"
));
//FIXME: Due to the event compression in the server we simply expect a removal signal
QTest
::
newRow
(
"multipleItems"
)
<<
(
QStringList
()
<<
QStringLiteral
(
"c1"
)
<<
QStringLiteral
(
"c2"
)
<<
QStringLiteral
(
"c3"
)
<<
QStringLiteral
(
"r1"
)
<<
QStringLiteral
(
"c4"
)
<<
QStringLiteral
(
"r2"
)
<<
QStringLiteral
(
"r3"
)
<<
QStringLiteral
(
"r4"
)
<<
QStringLiteral
(
"rn"
));
QTest
::
newRow
(
"reload"
)
<<
(
QStringList
()
<<
QStringLiteral
(
"c1"
)
<<
QStringLiteral
(
"c1"
)
<<
QStringLiteral
(
"c3"
)
<<
QStringLiteral
(
"reload"
)
<<
QStringLiteral
(
"r1"
)
<<
QStringLiteral
(
"r1"
)
<<
QStringLiteral
(
"r3"
)
<<
QStringLiteral
(
"rn"
));
QTest
::
newRow
(
"more"
)
<<
(
QStringList
()
<<
QStringLiteral
(
"c1"
)
<<
QStringLiteral
(
"c2"
)
<<
QStringLiteral
(
"c3"
)
<<
QStringLiteral
(
"reload"
)
<<
QStringLiteral
(
"r1"
)
<<
QStringLiteral
(
"reload"
)
<<
QStringLiteral
(
"c4"
)
<<
QStringLiteral
(
"reload"
)
<<
QStringLiteral
(
"r2"
)
<<
QStringLiteral
(
"reload"
)
<<
QStringLiteral
(
"r3"
)
<<
QStringLiteral
(
"r4"
)
<<
QStringLiteral
(
"rn"
));
// FIXME: Due to the event compression in the server we simply expect a removal signal
// QTest::newRow("modifyThenDelete") << (QStringList() << "c1" << "d1" << "r1" << "rn");
}
...
...
@@ -171,7 +177,6 @@ private:
}
QSettings
*
settings
=
nullptr
;
};
QTEST_AKONADIMAIN
(
ChangeRecorderTest
)
...
...
autotests/libs/collectionattributetest.cpp
View file @
0f667cad
...
...
@@ -7,15 +7,15 @@
#include "collectionattributetest.h"
#include "collectionpathresolver.h"
#include "collection.h"
#include "attributefactory.h"
#include "collection.h"
#include "collectioncreatejob.h"
#include "collectiondeletejob.h"
#include "collectionfetchjob.h"
#include "collectionidentificationattribute.h"
#include "collectionmodifyjob.h"
#include "collectionrightsattribute_p.h"
#include "control.h"
#include "collectionidentificationattribute.h"
#include "qtest_akonadi.h"
...
...
@@ -44,9 +44,11 @@ public:
{
return
mData
;
}
void
deserialize
(
const
QByteArray
&
data
)
override
{
void
deserialize
(
const
QByteArray
&
data
)
override
{
mData
=
data
;
}
private:
QByteArray
mData
;
};
...
...
@@ -91,8 +93,12 @@ void CollectionAttributeTest::testAttributes()
QFETCH
(
QByteArray
,
attr2
);
struct
Cleanup
{
explicit
Cleanup
(
const
Collection
&
col
)
:
m_col
(
col
)
{}
~
Cleanup
()
{
explicit
Cleanup
(
const
Collection
&
col
)
:
m_col
(
col
)
{
}
~
Cleanup
()
{
// cleanup
auto
*
del
=
new
CollectionDeleteJob
(
m_col
);
AKVERIFYEXEC
(
del
);
...
...
autotests/libs/collectioncolorattributetest.cpp
View file @
0f667cad
...
...
@@ -54,4 +54,3 @@ private Q_SLOTS:
QTEST_MAIN
(
CollectionColorAttributeTest
)
#include "collectioncolorattributetest.moc"
autotests/libs/collectioncopytest.cpp
View file @
0f667cad
...
...
@@ -6,9 +6,9 @@
#include "agentinstance.h"
#include "agentmanager.h"
#include "control.h"
#include "collectioncopyjob.h"
#include "collectionfetchjob.h"
#include "control.h"
#include "item.h"
#include "itemfetchjob.h"
#include "itemfetchscope.h"
...
...
@@ -28,7 +28,7 @@ private Q_SLOTS:
Control
::
start
();
// switch target resources offline to reduce interference from them
foreach
(
Akonadi
::
AgentInstance
agent
,
Akonadi
::
AgentManager
::
self
()
->
instances
())
{
//krazy:exclude=foreach
foreach
(
Akonadi
::
AgentInstance
agent
,
Akonadi
::
AgentManager
::
self
()
->
instances
())
{
//
krazy:exclude=foreach
if
(
agent
.
identifier
()
==
QLatin1String
(
"akonadi_knut_resource_2"
))
{
agent
.
setIsOnline
(
false
);
}
...
...
@@ -112,7 +112,6 @@ private Q_SLOTS:
copy
=
new
CollectionCopyJob
(
Collection
(
1
),
Collection
(
INT_MAX
));
QVERIFY
(
!
copy
->
exec
());
}
};
QTEST_AKONADIMAIN
(
CollectionCopyTest
)
...
...
autotests/libs/collectioncreatetest.cpp
View file @
0f667cad
...
...
@@ -6,8 +6,8 @@
*/
#include "collectioncreatejob.h"
#include "collectionfetchjob.h"
#include "collectiondeletejob.h"
#include "collectionfetchjob.h"
#include "entitydisplayattribute.h"
#include "qtest_akonadi.h"
...
...
@@ -30,7 +30,7 @@ private Q_SLOTS:
Collection
col
;
col
.
setName
(
QLatin1String
(
"test_collection"
));
col
.
setContentMimeTypes
({
Collection
::
mimeType
()
});
col
.
setContentMimeTypes
({
Collection
::
mimeType
()});
col
.
setParentCollection
(
Collection
(
AkonadiTest
::
collectionIdFromPath
(
QLatin1String
(
"res1"
))));
col
.
setRights
(
Collection
::
AllRights
);
...
...
autotests/libs/collectioncreator.cpp
View file @
0f667cad
...
...
@@ -32,9 +32,10 @@ private Q_SLOTS:
QList
<
int
>
counts
=
QList
<
int
>
()
<<
1
<<
10
<<
100
<<
1000
;
QList
<
bool
>
transactions
=
QList
<
bool
>
()
<<
false
<<
true
;
foreach
(
int
count
,
counts
)
{
foreach
(
bool
transaction
,
transactions
)
{
//krazy:exclude=foreach
QTest
::
newRow
(
QString
::
fromLatin1
(
"%1-%2"
).
arg
(
count
).
arg
(
transaction
?
QLatin1String
(
"trans"
)
:
QLatin1String
(
"notrans"
)).
toLatin1
().
constData
())
<<
count
<<
transaction
;
foreach
(
bool
transaction
,
transactions
)
{
// krazy:exclude=foreach
QTest
::
newRow
(
QString
::
fromLatin1
(
"%1-%2"
).
arg
(
count
).
arg
(
transaction
?
QLatin1String
(
"trans"
)
:
QLatin1String
(
"notrans"
)).
toLatin1
().
constData
())
<<
count
<<
transaction
;
}
}
}
...
...
@@ -50,22 +51,19 @@ private Q_SLOTS:
static
int
index
=
0
;
Job
*
lastJob
=
0
;
QBENCHMARK
{
if
(
useTransaction
)
{
if
(
useTransaction
)
{
lastJob
=
new
TransactionBeginJob
(
this
);
}
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
Collection
col
;
col
.
setParentCollection
(
parent
);
col
.
setName
(
QLatin1String
(
"col"
)
+
QString
::
number
(
++
index
));
lastJob
=
new
CollectionCreateJob
(
col
,
this
);
}
if
(
useTransaction
)
{
if
(
useTransaction
)
{
lastJob
=
new
TransactionCommitJob
(
this
);
}
AkonadiTest
::
akWaitForSignal
(
lastJob
,
SIGNAL
(
result
(
KJob
*
)),
15000
);
AkonadiTest
::
akWaitForSignal
(
lastJob
,
SIGNAL
(
result
(
KJob
*
)),
15000
);
}
}
};
...
...
autotests/libs/collectionjobtest.cpp
View file @
0f667cad
...
...
@@ -8,17 +8,18 @@
#include <sys/types.h>
#include <qtest_akonadi.h>
#include "testattribute.h"
#include <qtest_akonadi.h>
#include "agentmanager.h"
#include "agentinstance.h"
#include "agentmanager.h"
#include "attributefactory.h"
#include "cachepolicy.h"
#include "collection.h"
#include "collectioncreatejob.h"
#include "collectiondeletejob.h"
#include "collectionfetchjob.h"
#include "collectionfetchscope.h"
#include "collectionmodifyjob.h"
#include "collectionstatistics.h"
#include "collectionstatisticsjob.h"
...
...
@@ -26,7 +27,6 @@
#include "control.h"
#include "item.h"
#include "resourceselectjob_p.h"
#include "collectionfetchscope.h"
using
namespace
Akonadi
;
...
...
@@ -51,7 +51,7 @@ static Collection findCol(const Collection::List &list, const QString &name)
}
// list compare which ignores the order
template
<
class
T
>
static
void
compareLists
(
const
QList
<
T
>
&
l1
,
const
QList
<
T
>
&
l2
)
template
<
class
T
>
static
void
compareLists
(
const
QList
<
T
>
&
l1
,
const
QList
<
T
>
&
l2
)
{
QCOMPARE
(
l1
.
count
(),
l2
.
count
());
foreach
(
const
T
&
entry
,
l1
)
{
...
...
@@ -59,7 +59,7 @@ template <class T> static void compareLists(const QList<T> &l1, const QList<T> &
}
}
template
<
class
T
>
static
void
compareLists
(
const
QVector
<
T
>
&
l1
,
const
QVector
<
T
>
&
l2
)
template
<
class
T
>
static
void
compareLists
(
const
QVector
<
T
>
&
l1
,
const
QVector
<
T
>
&
l2
)
{
QCOMPARE
(
l1
.
count
(),
l2
.
count
());
foreach
(
const
T
&
entry
,
l1
)
{
...
...
@@ -67,7 +67,7 @@ template <class T> static void compareLists(const QVector<T> &l1, const QVector<
}
}
template
<
typename
T
>
static
T
*
extractAttribute
(
QList
<
Attribute
*>
attrs
)
template
<
typename
T
>
static
T
*
extractAttribute
(
QList
<
Attribute
*>
attrs
)
{
T
dummy
;
foreach
(
Attribute
*
attr
,
attrs
)
{
...
...
@@ -311,7 +311,7 @@ void CollectionJobTest::testCreateDeleteFolder_data()
col
.
setName
(
QStringLiteral
(
"foo2"
));
QTest
::
newRow
(
"already existing"
)
<<
col
<<
false
;
col
.
parentCollection
().
setId
(
res2ColId
);
// Sibling of collection 'foo2'
col
.
parentCollection
().
setId
(
res2ColId
);
// Sibling of collection 'foo2'
col
.
setName
(
QStringLiteral
(
"foo2 "
));
QTest
::
newRow
(
"name of an sibling with an additional ending space"
)
<<
col
<<
true
;
...
...
@@ -331,7 +331,7 @@ void CollectionJobTest::testCreateDeleteFolder_data()
col
=
Collection
();
col
.
setName
(
QStringLiteral
(
"rid parent"
));
col
.
parentCollection
().
setRemoteId
(
QStringLiteral
(
"8"
));
QTest
::
newRow
(
"rid parent"
)
<<
col
<<
false
;
// missing resource context
QTest
::
newRow
(
"rid parent"
)
<<
col
<<
false
;
// missing resource context
}
void
CollectionJobTest
::
testCreateDeleteFolder
()
...
...
@@ -402,8 +402,7 @@ void CollectionJobTest::testIllegalDeleteFolder()
void
CollectionJobTest
::
testStatistics
()
{
// empty folder
CollectionStatisticsJob
*
statistics
=
new
CollectionStatisticsJob
(
Collection
(
res1ColId
),
this
);
CollectionStatisticsJob
*
statistics
=
new
CollectionStatisticsJob
(
Collection
(
res1ColId
),
this
);
AKVERIFYEXEC
(
statistics
);
CollectionStatistics
s
=
statistics
->
statistics
();
...
...
@@ -430,9 +429,10 @@ void CollectionJobTest::testModify_data()
QTest
::
newRow
(
"rid"
)
<<
-
1LL
<<
QStringLiteral
(
"10"
);
}
#define RESET_COLLECTION_ID \
col.setId( uid ); \
if ( !rid.isEmpty() ) col.setRemoteId( rid )
#define RESET_COLLECTION_ID \
col.setId(uid); \
if (!rid.isEmpty()) \
col.setRemoteId(rid)
void
CollectionJobTest
::
testModify
()
{
...
...
@@ -444,9 +444,11 @@ void CollectionJobTest::testModify()
AKVERIFYEXEC
(
rjob
);
}
const
QStringList
reference
=
{
QStringLiteral
(
"text/calendar"
),
QStringLiteral
(
"text/directory"
),
QStringLiteral
(
"message/rfc822"
),
QStringLiteral
(
"application/octet-stream"
),
QStringLiteral
(
"inode/directory"
)
};
const
QStringList
reference
=
{
QStringLiteral
(
"text/calendar"
),
QStringLiteral
(
"text/directory"
),
QStringLiteral
(
"message/rfc822"
),
QStringLiteral
(
"application/octet-stream"
),
QStringLiteral
(
"inode/directory"
)};
Collection
col
;
RESET_COLLECTION_ID
;
...
...
@@ -573,7 +575,7 @@ void CollectionJobTest::testUtf8CollectionName()
QCOMPARE
(
list
->
collections
().
first
().
name
(),
col
.
name
());
// modify collection
col
.
setContentMimeTypes
(
{
QStringLiteral
(
"message/rfc822"
)
}
);
col
.
setContentMimeTypes
(
{
QStringLiteral
(
"message/rfc822"
)
}
);
auto
*
modify
=
new
CollectionModifyJob
(
col
,
this
);
AKVERIFYEXEC
(
modify
);
...
...
@@ -646,7 +648,7 @@ void CollectionJobTest::testRecursiveMultiList()
QCOMPARE
(
list
.
count
(),
4
+
2
);
QVERIFY
(
findCol
(
list
,
QStringLiteral
(
"foo"
)).
isValid
());
QVERIFY
(
findCol
(
list
,
QStringLiteral
(
"bar"
)).
isValid
());
QVERIFY
(
findCol
(
list
,
QStringLiteral
(
"bla"
)).
isValid
());
//There are two bla folders, but we only check for one.
QVERIFY
(
findCol
(
list
,
QStringLiteral
(
"bla"
)).
isValid
());
//
There are two bla folders, but we only check for one.
QVERIFY
(
findCol
(
list
,
QStringLiteral
(
"foo2"
)).
isValid
());
QVERIFY
(
findCol
(
list
,
QStringLiteral
(
"space folder"
)).
isValid
());
}
...
...
@@ -754,7 +756,7 @@ void CollectionJobTest::testAncestorRetrieval()
ResourceSelectJob
*
select
=
new
ResourceSelectJob
(
QStringLiteral
(
"akonadi_knut_resource_0"
),
this
);
AKVERIFYEXEC
(
select
);
Collection
col2
(
col
);
col2
.
setId
(
-
1
);
// make it invalid but keep the ancestor chain
col2
.
setId
(
-
1
);
// make it invalid but keep the ancestor chain
job
=
new
CollectionFetchJob
(
col2
,
CollectionFetchJob
::
Base
,
this
);
AKVERIFYEXEC
(
job
);
QCOMPARE
(
job
->
collections
().
count
(),
1
);
...
...
@@ -790,7 +792,7 @@ void CollectionJobTest::testAncestorAttributeRetrieval()
QCOMPARE
(
result
.
parentCollection
().
hasAttribute
<
TestAttribute
>
(),
true
);
}
//Cleanup
//
Cleanup
auto
*
deleteJob
=
new
CollectionDeleteJob
(
baseCol
);
AKVERIFYEXEC
(
deleteJob
);
}
...
...
@@ -858,7 +860,7 @@ void CollectionJobTest::testListPreference()
QCOMPARE
(
result
.
localListPreference
(
Collection
::
ListIndex
),
Collection
::
ListEnabled
);
}
//Check list filter
//
Check list filter
{
auto
*
job
=
new
CollectionFetchJob
(
baseCol
,
CollectionFetchJob
::
FirstLevel
);
job
->
fetchScope
().
setListFilter
(
CollectionFetchScope
::
Display
);
...
...
@@ -884,7 +886,7 @@ void CollectionJobTest::testListPreference()
QCOMPARE
(
job
->
collections
().
size
(),
2
);
}
//Cleanup
//
Cleanup
auto
*
deleteJob
=
new
CollectionDeleteJob
(
baseCol
);
AKVERIFYEXEC
(
deleteJob
);
}
...
...
autotests/libs/collectionmodifytest.cpp
View file @
0f667cad
...
...
@@ -6,9 +6,9 @@
*/
#include "collectioncreatejob.h"
#include "collectiondeletejob.h"
#include "collectionfetchjob.h"
#include "collectionmodifyjob.h"
#include "collectiondeletejob.h"
#include "entitydisplayattribute.h"
#include "qtest_akonadi.h"
...
...
@@ -28,7 +28,7 @@ private Q_SLOTS:
{
Collection
col
;
col
.
setName
(
QLatin1String
(
"test_collection"
));
col
.
setContentMimeTypes
({
Collection
::
mimeType
()
});
col
.
setContentMimeTypes
({
Collection
::
mimeType
()});
col
.
setParentCollection
(
Collection
(
AkonadiTest
::
collectionIdFromPath
(
QLatin1String
(
"res1"
))));
col
.
setRights
(
Collection
::
AllRights
);
...
...
@@ -39,7 +39,7 @@ private Q_SLOTS:
auto
*
attr
=
col
.
attribute
<
EntityDisplayAttribute
>
(
Collection
::
AddIfMissing
);
attr
->
setDisplayName
(
QStringLiteral
(
"Test Collection"
));
col
.
setContentMimeTypes
({
Collection
::
mimeType
(),
QLatin1String
(
"application/octet-stream"
)
});
col
.
setContentMimeTypes
({
Collection
::
mimeType
(),
QLatin1String
(
"application/octet-stream"
)});
auto
*
mj
=
new
CollectionModifyJob
(
col
,
this
);
AKVERIFYEXEC
(
mj
);
...
...
@@ -64,4 +64,3 @@ private Q_SLOTS:
QTEST_AKONADIMAIN
(
CollectionModifyTest
)
#include "collectionmodifytest.moc"
autotests/libs/collectionmovetest.cpp
View file @
0f667cad
...
...
@@ -4,13 +4,13 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "qtest_akonadi.h"
#include "collection.h"
#include "collectionfetchjob.h"
#include "collectionmovejob.h"
#include "item.h"
#include "itemfetchjob.h"
#include "itemfetchscope.h"
#include "qtest_akonadi.h"
#include <QHash>
...
...
@@ -58,11 +58,9 @@ private Q_SLOTS:
QTest
::
addColumn
<
bool
>
(
"crossResource"
);
QTest
::
newRow
(
"inter-resource"
)
<<
Collection
(
AkonadiTest
::
collectionIdFromPath
(
QStringLiteral
(
"res1"
)))
<<
Collection
(
AkonadiTest
::
collectionIdFromPath
(
QStringLiteral
(
"res2"
)))
<<
true
;
<<
Collection
(
AkonadiTest
::
collectionIdFromPath
(
QStringLiteral
(
"res2"
)))
<<
true
;
QTest
::
newRow
(
"intra-resource"
)
<<
Collection
(
AkonadiTest
::
collectionIdFromPath
(
QStringLiteral
(
"res1/foo/bla"
)))
<<
Collection
(
AkonadiTest
::
collectionIdFromPath
(
QStringLiteral
(
"res1/foo/bar/bla"
)))
<<
false
;
<<
Collection
(
AkonadiTest
::
collectionIdFromPath
(
QStringLiteral
(
"res1/foo/bar/bla"
)))
<<
false
;
}
// TODO: test signals
...
...
autotests/libs/collectionsynctest.cpp
View file @
0f667cad
...
...
@@ -4,16 +4,16 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "agentmanager.h"
#include "agentinstance.h"
#include "
control
.h"
#include "
agentmanager
.h"
#include "collection.h"
#include "collectiondeletejob.h"
#include "collectionfetchjob.h"
#include "collectionfetchscope.h"
#include "collectiondeletejob.h"
#include "collectionmodifyjob.h"
#include "entitydisplayattribute.h"
#include "collectionsync_p.h"
#include "control.h"
#include "entitydisplayattribute.h"
#include "qtest_akonadi.h"
#include "resourceselectjob_p.h"
...
...
@@ -105,7 +105,7 @@ private:
CollectionSync
*
prepareBenchmarkSyncer
(
const
Collection
::
List
&
collections
)
{
CollectionSync
*
syncer
=
new
CollectionSync
(
QStringLiteral
(
"akonadi_knut_resource_0"
));
connect
(
syncer
,
SIGNAL
(
percent
(
KJob
*
,
ulong
)),
this
,
SLOT
(
syncBenchmarkProgress
(
KJob
*
,
ulong
)));
connect
(
syncer
,
SIGNAL
(
percent
(
KJob
*
,
ulong
)),
this
,
SLOT
(
syncBenchmarkProgress
(
KJob
*
,
ulong
)));
syncer
->
setHierarchicalRemoteIds
(
false
);
syncer
->
setRemoteCollections
(
collections
);
return
syncer
;
...
...
@@ -129,7 +129,7 @@ public Q_SLOTS:
void
syncBenchmarkProgress
(
KJob
*
job
,
ulong
percent
)
{
Q_UNUSED
(
job
)
qDebug
()
<<
"CollectionSync progress:"
<<
percent
<<
"%"
;
qDebug
()
<<
"CollectionSync progress:"
<<
percent
<<
"%"
;
}
private
Q_SLOTS
:
...
...
@@ -190,7 +190,7 @@ private Q_SLOTS:
l
<<
origCols
[
i
];
syncer
->
setRemoteCollections
(
l
);
if
(
i
<
origCols
.
count
()
-
1
)
{
QTest
::
qWait
(
10
);
// enter the event loop so itemsync actually can do something
QTest
::
qWait
(
10
);
// enter the event loop so itemsync actually can do something