Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
KMailTransport
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PIM
KMailTransport
Commits
3c1f833f
Commit
3c1f833f
authored
Jul 29, 2014
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
astyle-kdelibs
parent
308e1a2c
Changes
82
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
82 changed files
with
4209 additions
and
4176 deletions
+4209
-4176
autotests/attributetest.cpp
autotests/attributetest.cpp
+120
-121
autotests/attributetest.h
autotests/attributetest.h
+2
-2
autotests/filteractiontest.cpp
autotests/filteractiontest.cpp
+127
-128
autotests/filteractiontest.h
autotests/filteractiontest.h
+5
-6
autotests/messagequeuejobtest.cpp
autotests/messagequeuejobtest.cpp
+117
-118
autotests/messagequeuejobtest.h
autotests/messagequeuejobtest.h
+4
-4
autotests/testattribute.h
autotests/testattribute.h
+18
-9
src/addtransportdialog.cpp
src/addtransportdialog.cpp
+92
-95
src/addtransportdialog.h
src/addtransportdialog.h
+8
-7
src/attributeregistrar.cpp
src/attributeregistrar.cpp
+18
-17
src/dispatcherinterface.cpp
src/dispatcherinterface.cpp
+37
-38
src/dispatcherinterface.h
src/dispatcherinterface.h
+4
-3
src/dispatcherinterface_p.h
src/dispatcherinterface_p.h
+6
-5
src/dispatchmodeattribute.cpp
src/dispatchmodeattribute.cpp
+39
-40
src/dispatchmodeattribute.h
src/dispatchmodeattribute.h
+11
-10
src/errorattribute.cpp
src/errorattribute.cpp
+14
-16
src/errorattribute.h
src/errorattribute.h
+7
-6
src/filteractionjob.cpp
src/filteractionjob.cpp
+54
-54
src/filteractionjob_p.h
src/filteractionjob_p.h
+14
-13
src/kcm/configmodule.cpp
src/kcm/configmodule.cpp
+8
-9
src/kcm/configmodule.h
src/kcm/configmodule.h
+5
-4
src/legacydecrypt.cpp
src/legacydecrypt.cpp
+12
-12
src/legacydecrypt.h
src/legacydecrypt.h
+5
-4
src/messagequeuejob.cpp
src/messagequeuejob.cpp
+120
-120
src/messagequeuejob.h
src/messagequeuejob.h
+10
-9
src/outboxactions.cpp
src/outboxactions.cpp
+63
-63
src/outboxactions_p.h
src/outboxactions_p.h
+18
-17
src/precommandjob.cpp
src/precommandjob.cpp
+40
-40
src/precommandjob.h
src/precommandjob.h
+10
-9
src/resourcesendjob.cpp
src/resourcesendjob.cpp
+23
-24
src/resourcesendjob_p.h
src/resourcesendjob_p.h
+8
-7
src/sendmailconfigwidget.cpp
src/sendmailconfigwidget.cpp
+29
-29
src/sendmailconfigwidget.h
src/sendmailconfigwidget.h
+12
-11
src/sendmailjob.cpp
src/sendmailjob.cpp
+39
-39
src/sendmailjob.h
src/sendmailjob.h
+9
-8
src/sentactionattribute.cpp
src/sentactionattribute.cpp
+57
-57
src/sentactionattribute.h
src/sentactionattribute.h
+15
-14
src/sentbehaviourattribute.cpp
src/sentbehaviourattribute.cpp
+33
-35
src/sentbehaviourattribute.h
src/sentbehaviourattribute.h
+12
-11
src/servertest.cpp
src/servertest.cpp
+372
-371
src/servertest.h
src/servertest.h
+29
-28
src/smtp/smtpsession.cpp
src/smtp/smtpsession.cpp
+454
-447
src/smtp/smtpsession.h
src/smtp/smtpsession.h
+18
-17
src/smtpconfigwidget.cpp
src/smtpconfigwidget.cpp
+221
-220
src/smtpconfigwidget.h
src/smtpconfigwidget.h
+12
-11
src/smtpjob.cpp
src/smtpjob.cpp
+253
-253
src/smtpjob.h
src/smtpjob.h
+18
-16
src/socket.cpp
src/socket.cpp
+94
-93
src/socket.h
src/socket.h
+19
-18
src/transport.cpp
src/transport.cpp
+228
-228
src/transport.h
src/transport.h
+14
-13
src/transport_p.h
src/transport_p.h
+1
-1
src/transportattribute.cpp
src/transportattribute.cpp
+15
-16
src/transportattribute.h
src/transportattribute.h
+7
-6
src/transportcombobox.cpp
src/transportcombobox.cpp
+37
-38
src/transportcombobox.h
src/transportcombobox.h
+8
-7
src/transportconfigdialog.cpp
src/transportconfigdialog.cpp
+57
-63
src/transportconfigdialog.h
src/transportconfigdialog.h
+9
-8
src/transportconfigwidget.cpp
src/transportconfigwidget.cpp
+23
-23
src/transportconfigwidget.h
src/transportconfigwidget.h
+12
-11
src/transportconfigwidget_p.h
src/transportconfigwidget_p.h
+3
-2
src/transportjob.cpp
src/transportjob.cpp
+38
-38
src/transportjob.h
src/transportjob.h
+29
-28
src/transportlistview.cpp
src/transportlistview.cpp
+72
-72
src/transportlistview.h
src/transportlistview.h
+9
-8
src/transportmanagementwidget.cpp
src/transportmanagementwidget.cpp
+83
-84
src/transportmanagementwidget.h
src/transportmanagementwidget.h
+14
-13
src/transportmanager.cpp
src/transportmanager.cpp
+483
-479
src/transportmanager.h
src/transportmanager.h
+37
-35
src/transporttype.cpp
src/transporttype.cpp
+27
-27
src/transporttype.h
src/transporttype.h
+12
-11
src/transporttype_p.h
src/transporttype_p.h
+10
-9
tests/abort.cpp
tests/abort.cpp
+17
-17
tests/abort.h
tests/abort.h
+3
-4
tests/clearerror.cpp
tests/clearerror.cpp
+11
-11
tests/clearerror.h
tests/clearerror.h
+3
-4
tests/queuer.cpp
tests/queuer.cpp
+110
-111
tests/queuer.h
tests/queuer.h
+10
-9
tests/sendqueued.cpp
tests/sendqueued.cpp
+11
-11
tests/sendqueued.h
tests/sendqueued.h
+3
-4
tests/transportmgr.cpp
tests/transportmgr.cpp
+91
-90
tests/transportmgr.h
tests/transportmgr.h
+7
-7
No files found.
autotests/attributetest.cpp
View file @
3c1f833f
...
...
@@ -19,7 +19,6 @@
#include "attributetest.h"
#include <attributefactory.h>
#include <qtest_akonadi.h>
#include <addressattribute.h>
...
...
@@ -39,130 +38,130 @@ void AttributeTest::initTestCase()
void
AttributeTest
::
testRegistrar
()
{
// The attributes should have been registered without any effort on our part.
{
Attribute
*
a
=
AttributeFactory
::
createAttribute
(
"AddressAttribute"
);
QVERIFY
(
dynamic_cast
<
AddressAttribute
*>
(
a
)
);
}
{
Attribute
*
a
=
AttributeFactory
::
createAttribute
(
"DispatchModeAttribute"
);
QVERIFY
(
dynamic_cast
<
DispatchModeAttribute
*>
(
a
)
);
}
{
Attribute
*
a
=
AttributeFactory
::
createAttribute
(
"ErrorAttribute"
);
QVERIFY
(
dynamic_cast
<
ErrorAttribute
*>
(
a
)
);
}
{
Attribute
*
a
=
AttributeFactory
::
createAttribute
(
"SentActionAttribute"
);
QVERIFY
(
dynamic_cast
<
SentActionAttribute
*>
(
a
)
);
}
{
Attribute
*
a
=
AttributeFactory
::
createAttribute
(
"SentBehaviourAttribute"
);
QVERIFY
(
dynamic_cast
<
SentBehaviourAttribute
*>
(
a
)
);
}
{
Attribute
*
a
=
AttributeFactory
::
createAttribute
(
"TransportAttribute"
);
QVERIFY
(
dynamic_cast
<
TransportAttribute
*>
(
a
)
);
}
// The attributes should have been registered without any effort on our part.
{
Attribute
*
a
=
AttributeFactory
::
createAttribute
(
"AddressAttribute"
);
QVERIFY
(
dynamic_cast
<
AddressAttribute
*>
(
a
)
);
}
{
Attribute
*
a
=
AttributeFactory
::
createAttribute
(
"DispatchModeAttribute"
);
QVERIFY
(
dynamic_cast
<
DispatchModeAttribute
*>
(
a
)
);
}
{
Attribute
*
a
=
AttributeFactory
::
createAttribute
(
"ErrorAttribute"
);
QVERIFY
(
dynamic_cast
<
ErrorAttribute
*>
(
a
)
);
}
{
Attribute
*
a
=
AttributeFactory
::
createAttribute
(
"SentActionAttribute"
);
QVERIFY
(
dynamic_cast
<
SentActionAttribute
*>
(
a
)
);
}
{
Attribute
*
a
=
AttributeFactory
::
createAttribute
(
"SentBehaviourAttribute"
);
QVERIFY
(
dynamic_cast
<
SentBehaviourAttribute
*>
(
a
)
);
}
{
Attribute
*
a
=
AttributeFactory
::
createAttribute
(
"TransportAttribute"
);
QVERIFY
(
dynamic_cast
<
TransportAttribute
*>
(
a
)
);
}
}
void
AttributeTest
::
testSerialization
()
{
{
QString
from
(
"from@me.org"
);
QStringList
to
(
"to1@me.org"
);
to
<<
"to2@me.org"
;
QStringList
cc
(
"cc1@me.org"
);
cc
<<
"cc2@me.org"
;
QStringList
bcc
(
"bcc1@me.org"
);
bcc
<<
"bcc2@me.org"
;
AddressAttribute
*
a
=
new
AddressAttribute
(
from
,
to
,
cc
,
bcc
);
QByteArray
data
=
a
->
serialized
();
delete
a
;
a
=
new
AddressAttribute
;
a
->
deserialize
(
data
);
QCOMPARE
(
from
,
a
->
from
()
);
QCOMPARE
(
to
,
a
->
to
()
);
QCOMPARE
(
cc
,
a
->
cc
()
);
QCOMPARE
(
bcc
,
a
->
bcc
()
);
}
{
DispatchModeAttribute
::
DispatchMode
mode
=
DispatchModeAttribute
::
Automatic
;
QDateTime
date
=
QDateTime
::
currentDateTime
();
// The serializer does not keep track of milliseconds, so forget them.
qDebug
()
<<
"ms"
<<
date
.
toString
(
"z"
);
int
ms
=
date
.
toString
(
"z"
).
toInt
();
date
=
date
.
addMSecs
(
-
ms
);
DispatchModeAttribute
*
a
=
new
DispatchModeAttribute
(
mode
);
a
->
setSendAfter
(
date
);
QByteArray
data
=
a
->
serialized
();
delete
a
;
a
=
new
DispatchModeAttribute
;
a
->
deserialize
(
data
);
QCOMPARE
(
mode
,
a
->
dispatchMode
()
);
QCOMPARE
(
date
,
a
->
sendAfter
()
);
}
{
QString
msg
(
"The #!@$ing thing failed!"
);
ErrorAttribute
*
a
=
new
ErrorAttribute
(
msg
);
QByteArray
data
=
a
->
serialized
();
delete
a
;
a
=
new
ErrorAttribute
;
a
->
deserialize
(
data
);
QCOMPARE
(
msg
,
a
->
message
()
);
}
{
SentActionAttribute
*
a
=
new
SentActionAttribute
();
const
qlonglong
id
=
123456789012345ll
;
a
->
addAction
(
SentActionAttribute
::
Action
::
MarkAsReplied
,
QVariant
(
id
)
);
a
->
addAction
(
SentActionAttribute
::
Action
::
MarkAsForwarded
,
QVariant
(
id
)
);
QByteArray
data
=
a
->
serialized
();
delete
a
;
a
=
new
SentActionAttribute
;
a
->
deserialize
(
data
);
const
SentActionAttribute
::
Action
::
List
actions
=
a
->
actions
();
QCOMPARE
(
actions
.
count
(),
2
);
QCOMPARE
(
SentActionAttribute
::
Action
::
MarkAsReplied
,
actions
[
0
].
type
()
);
QCOMPARE
(
id
,
actions
[
0
].
value
().
toLongLong
()
);
QCOMPARE
(
SentActionAttribute
::
Action
::
MarkAsForwarded
,
actions
[
1
].
type
()
);
QCOMPARE
(
id
,
actions
[
1
].
value
().
toLongLong
()
);
}
{
SentBehaviourAttribute
::
SentBehaviour
beh
=
SentBehaviourAttribute
::
MoveToCollection
;
Collection
::
Id
id
=
123456789012345ll
;
SentBehaviourAttribute
*
a
=
new
SentBehaviourAttribute
(
beh
,
Collection
(
id
)
);
QByteArray
data
=
a
->
serialized
();
delete
a
;
a
=
new
SentBehaviourAttribute
;
a
->
deserialize
(
data
);
QCOMPARE
(
beh
,
a
->
sentBehaviour
()
);
QCOMPARE
(
id
,
a
->
moveToCollection
().
id
()
);
}
{
int
id
=
3219
;
TransportAttribute
*
a
=
new
TransportAttribute
(
id
);
QByteArray
data
=
a
->
serialized
();
delete
a
;
a
=
new
TransportAttribute
;
a
->
deserialize
(
data
);
QCOMPARE
(
id
,
a
->
transportId
()
);
}
{
QString
from
(
"from@me.org"
);
QStringList
to
(
"to1@me.org"
);
to
<<
"to2@me.org"
;
QStringList
cc
(
"cc1@me.org"
);
cc
<<
"cc2@me.org"
;
QStringList
bcc
(
"bcc1@me.org"
);
bcc
<<
"bcc2@me.org"
;
AddressAttribute
*
a
=
new
AddressAttribute
(
from
,
to
,
cc
,
bcc
);
QByteArray
data
=
a
->
serialized
();
delete
a
;
a
=
new
AddressAttribute
;
a
->
deserialize
(
data
);
QCOMPARE
(
from
,
a
->
from
()
);
QCOMPARE
(
to
,
a
->
to
()
);
QCOMPARE
(
cc
,
a
->
cc
()
);
QCOMPARE
(
bcc
,
a
->
bcc
()
);
}
{
DispatchModeAttribute
::
DispatchMode
mode
=
DispatchModeAttribute
::
Automatic
;
QDateTime
date
=
QDateTime
::
currentDateTime
();
// The serializer does not keep track of milliseconds, so forget them.
qDebug
()
<<
"ms"
<<
date
.
toString
(
"z"
);
int
ms
=
date
.
toString
(
"z"
).
toInt
();
date
=
date
.
addMSecs
(
-
ms
);
DispatchModeAttribute
*
a
=
new
DispatchModeAttribute
(
mode
);
a
->
setSendAfter
(
date
);
QByteArray
data
=
a
->
serialized
();
delete
a
;
a
=
new
DispatchModeAttribute
;
a
->
deserialize
(
data
);
QCOMPARE
(
mode
,
a
->
dispatchMode
()
);
QCOMPARE
(
date
,
a
->
sendAfter
()
);
}
{
QString
msg
(
"The #!@$ing thing failed!"
);
ErrorAttribute
*
a
=
new
ErrorAttribute
(
msg
);
QByteArray
data
=
a
->
serialized
();
delete
a
;
a
=
new
ErrorAttribute
;
a
->
deserialize
(
data
);
QCOMPARE
(
msg
,
a
->
message
()
);
}
{
SentActionAttribute
*
a
=
new
SentActionAttribute
();
const
qlonglong
id
=
123456789012345ll
;
a
->
addAction
(
SentActionAttribute
::
Action
::
MarkAsReplied
,
QVariant
(
id
)
);
a
->
addAction
(
SentActionAttribute
::
Action
::
MarkAsForwarded
,
QVariant
(
id
)
);
QByteArray
data
=
a
->
serialized
();
delete
a
;
a
=
new
SentActionAttribute
;
a
->
deserialize
(
data
);
const
SentActionAttribute
::
Action
::
List
actions
=
a
->
actions
();
QCOMPARE
(
actions
.
count
(),
2
);
QCOMPARE
(
SentActionAttribute
::
Action
::
MarkAsReplied
,
actions
[
0
].
type
()
);
QCOMPARE
(
id
,
actions
[
0
].
value
().
toLongLong
()
);
QCOMPARE
(
SentActionAttribute
::
Action
::
MarkAsForwarded
,
actions
[
1
].
type
()
);
QCOMPARE
(
id
,
actions
[
1
].
value
().
toLongLong
()
);
}
{
SentBehaviourAttribute
::
SentBehaviour
beh
=
SentBehaviourAttribute
::
MoveToCollection
;
Collection
::
Id
id
=
123456789012345ll
;
SentBehaviourAttribute
*
a
=
new
SentBehaviourAttribute
(
beh
,
Collection
(
id
)
);
QByteArray
data
=
a
->
serialized
();
delete
a
;
a
=
new
SentBehaviourAttribute
;
a
->
deserialize
(
data
);
QCOMPARE
(
beh
,
a
->
sentBehaviour
()
);
QCOMPARE
(
id
,
a
->
moveToCollection
().
id
()
);
}
{
int
id
=
3219
;
TransportAttribute
*
a
=
new
TransportAttribute
(
id
);
QByteArray
data
=
a
->
serialized
();
delete
a
;
a
=
new
TransportAttribute
;
a
->
deserialize
(
data
);
QCOMPARE
(
id
,
a
->
transportId
()
);
}
}
QTEST_AKONADIMAIN
(
AttributeTest
,
NoGUI
)
QTEST_AKONADIMAIN
(
AttributeTest
,
NoGUI
)
autotests/attributetest.h
View file @
3c1f833f
...
...
@@ -27,9 +27,9 @@
*/
class
AttributeTest
:
public
QObject
{
Q_OBJECT
Q_OBJECT
private
Q_SLOTS
:
private
Q_SLOTS
:
void
initTestCase
();
void
testRegistrar
();
void
testSerialization
();
...
...
autotests/filteractiontest.cpp
View file @
3c1f833f
...
...
@@ -21,7 +21,6 @@
#include <collectionpathresolver_p.h>
#include <testattribute.h>
#include <attributefactory.h>
#include <collectioncreatejob.h>
#include <itemcreatejob.h>
...
...
@@ -33,7 +32,7 @@
using
namespace
Akonadi
;
QTEST_AKONADIMAIN
(
FilterActionTest
,
NoGUI
)
QTEST_AKONADIMAIN
(
FilterActionTest
,
NoGUI
)
static
const
QByteArray
acceptable
=
"acceptable"
;
static
const
QByteArray
unacceptable
=
"unacceptable"
;
...
...
@@ -44,163 +43,163 @@ class MyFunctor : public FilterAction
{
virtual
Akonadi
::
ItemFetchScope
fetchScope
()
const
{
ItemFetchScope
scope
;
scope
.
fetchAttribute
<
TestAttribute
>
();
return
scope
;
ItemFetchScope
scope
;
scope
.
fetchAttribute
<
TestAttribute
>
();
return
scope
;
}
virtual
bool
itemAccepted
(
const
Akonadi
::
Item
&
item
)
const
virtual
bool
itemAccepted
(
const
Akonadi
::
Item
&
item
)
const
{
if
(
!
item
.
hasAttribute
<
TestAttribute
>
()
)
{
return
false
;
}
return
(
item
.
attribute
<
TestAttribute
>
()
->
data
==
acceptable
);
if
(
!
item
.
hasAttribute
<
TestAttribute
>
()
)
{
return
false
;
}
return
(
item
.
attribute
<
TestAttribute
>
()
->
data
==
acceptable
);
}
virtual
Akonadi
::
Job
*
itemAction
(
const
Akonadi
::
Item
&
item
,
FilterActionJob
*
parent
)
const
virtual
Akonadi
::
Job
*
itemAction
(
const
Akonadi
::
Item
&
item
,
FilterActionJob
*
parent
)
const
{
Item
cp
(
item
);
TestAttribute
*
newa
=
new
TestAttribute
;
newa
->
data
=
modified
;
cp
.
addAttribute
(
newa
);
return
new
ItemModifyJob
(
cp
,
parent
);
Item
cp
(
item
);
TestAttribute
*
newa
=
new
TestAttribute
;
newa
->
data
=
modified
;
cp
.
addAttribute
(
newa
);
return
new
ItemModifyJob
(
cp
,
parent
);
}
};
void
FilterActionTest
::
initTestCase
()
{
AttributeFactory
::
registerAttribute
<
TestAttribute
>
();
AttributeFactory
::
registerAttribute
<
TestAttribute
>
();
CollectionPathResolver
*
resolver
=
new
CollectionPathResolver
(
"res1"
,
this
);
QVERIFY
(
resolver
->
exec
()
);
res1
=
Collection
(
resolver
->
collection
()
);
CollectionPathResolver
*
resolver
=
new
CollectionPathResolver
(
"res1"
,
this
);
QVERIFY
(
resolver
->
exec
()
);
res1
=
Collection
(
resolver
->
collection
()
);
}
void
FilterActionTest
::
testMassModifyItem
()
{
Collection
col
=
createCollection
(
"testMassModifyItem"
);
// Test acceptable item.
Item
item
=
createItem
(
col
,
true
);
FilterActionJob
*
mjob
=
new
FilterActionJob
(
item
,
new
MyFunctor
,
this
);
AKVERIFYEXEC
(
mjob
);
ItemFetchJob
*
fjob
=
new
ItemFetchJob
(
item
,
this
);
fjob
->
fetchScope
().
fetchAllAttributes
();
AKVERIFYEXEC
(
fjob
);
QCOMPARE
(
fjob
->
items
().
count
(),
1
);
item
=
fjob
->
items
().
first
();
QVERIFY
(
item
.
hasAttribute
<
TestAttribute
>
()
);
TestAttribute
*
attr
=
item
.
attribute
<
TestAttribute
>
();
QCOMPARE
(
attr
->
data
,
modified
);
// Test unacceptable item.
item
=
createItem
(
col
,
false
);
mjob
=
new
FilterActionJob
(
item
,
new
MyFunctor
,
this
);
AKVERIFYEXEC
(
mjob
);
fjob
=
new
ItemFetchJob
(
item
,
this
);
fjob
->
fetchScope
().
fetchAllAttributes
();
AKVERIFYEXEC
(
fjob
);
QCOMPARE
(
fjob
->
items
().
count
(),
1
);
item
=
fjob
->
items
().
first
();
QVERIFY
(
item
.
hasAttribute
<
TestAttribute
>
()
);
attr
=
item
.
attribute
<
TestAttribute
>
();
QCOMPARE
(
attr
->
data
,
unacceptable
);
Collection
col
=
createCollection
(
"testMassModifyItem"
);
// Test acceptable item.
Item
item
=
createItem
(
col
,
true
);
FilterActionJob
*
mjob
=
new
FilterActionJob
(
item
,
new
MyFunctor
,
this
);
AKVERIFYEXEC
(
mjob
);
ItemFetchJob
*
fjob
=
new
ItemFetchJob
(
item
,
this
);
fjob
->
fetchScope
().
fetchAllAttributes
();
AKVERIFYEXEC
(
fjob
);
QCOMPARE
(
fjob
->
items
().
count
(),
1
);
item
=
fjob
->
items
().
first
();
QVERIFY
(
item
.
hasAttribute
<
TestAttribute
>
()
);
TestAttribute
*
attr
=
item
.
attribute
<
TestAttribute
>
();
QCOMPARE
(
attr
->
data
,
modified
);
// Test unacceptable item.
item
=
createItem
(
col
,
false
);
mjob
=
new
FilterActionJob
(
item
,
new
MyFunctor
,
this
);
AKVERIFYEXEC
(
mjob
);
fjob
=
new
ItemFetchJob
(
item
,
this
);
fjob
->
fetchScope
().
fetchAllAttributes
();
AKVERIFYEXEC
(
fjob
);
QCOMPARE
(
fjob
->
items
().
count
(),
1
);
item
=
fjob
->
items
().
first
();
QVERIFY
(
item
.
hasAttribute
<
TestAttribute
>
()
);
attr
=
item
.
attribute
<
TestAttribute
>
();
QCOMPARE
(
attr
->
data
,
unacceptable
);
}
void
FilterActionTest
::
testMassModifyItems
()
{
Collection
col
=
createCollection
(
"testMassModifyItems"
);
// Test a bunch of acceptable and unacceptable items.
Item
::
List
acc
,
unacc
;
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
acc
.
append
(
createItem
(
col
,
true
)
);
unacc
.
append
(
createItem
(
col
,
false
)
);
}
Item
::
List
all
=
acc
+
unacc
;
QCOMPARE
(
all
.
count
(),
10
);
FilterActionJob
*
mjob
=
new
FilterActionJob
(
all
,
new
MyFunctor
,
this
);
AKVERIFYEXEC
(
mjob
);
ItemFetchJob
*
fjob
=
new
ItemFetchJob
(
col
,
this
);
fjob
->
fetchScope
().
fetchAllAttributes
();
AKVERIFYEXEC
(
fjob
);
QCOMPARE
(
fjob
->
items
().
count
(),
10
);
foreach
(
const
Item
&
item
,
fjob
->
items
()
)
{
QVERIFY
(
item
.
hasAttribute
<
TestAttribute
>
()
);
const
QByteArray
data
=
item
.
attribute
<
TestAttribute
>
()
->
data
;
if
(
data
==
unacceptable
)
{
QVERIFY
(
unacc
.
contains
(
item
)
);
unacc
.
removeAll
(
item
);
}
else
if
(
data
==
modified
)
{
QVERIFY
(
acc
.
contains
(
item
)
);
acc
.
removeAll
(
item
);
}
else
{
QVERIFY2
(
false
,
QByteArray
(
QByteArray
(
"Got bad data
\"
"
)
+
data
+
QByteArray
(
"
\"
"
))
);
Collection
col
=
createCollection
(
"testMassModifyItems"
);
// Test a bunch of acceptable and unacceptable items.
Item
::
List
acc
,
unacc
;
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
acc
.
append
(
createItem
(
col
,
true
));
unacc
.
append
(
createItem
(
col
,
false
));
}
}
QCOMPARE
(
acc
.
count
(),
0
);
QCOMPARE
(
unacc
.
count
(),
0
);
Item
::
List
all
=
acc
+
unacc
;
QCOMPARE
(
all
.
count
(),
10
);
FilterActionJob
*
mjob
=
new
FilterActionJob
(
all
,
new
MyFunctor
,
this
);
AKVERIFYEXEC
(
mjob
);
ItemFetchJob
*
fjob
=
new
ItemFetchJob
(
col
,
this
);
fjob
->
fetchScope
().
fetchAllAttributes
();
AKVERIFYEXEC
(
fjob
);
QCOMPARE
(
fjob
->
items
().
count
(),
10
);
foreach
(
const
Item
&
item
,
fjob
->
items
())
{
QVERIFY
(
item
.
hasAttribute
<
TestAttribute
>
());
const
QByteArray
data
=
item
.
attribute
<
TestAttribute
>
()
->
data
;
if
(
data
==
unacceptable
)
{
QVERIFY
(
unacc
.
contains
(
item
));
unacc
.
removeAll
(
item
);
}
else
if
(
data
==
modified
)
{
QVERIFY
(
acc
.
contains
(
item
));
acc
.
removeAll
(
item
);
}
else
{
QVERIFY2
(
false
,
QByteArray
(
QByteArray
(
"Got bad data
\"
"
)
+
data
+
QByteArray
(
"
\"
"
)));
}
}
QCOMPARE
(
acc
.
count
(),
0
);
QCOMPARE
(
unacc
.
count
(),
0
);
}
void
FilterActionTest
::
testMassModifyCollection
()
{
Collection
col
=
createCollection
(
"testMassModifyCollection"
);
// Test a bunch of acceptable and unacceptable items.
Item
::
List
acc
,
unacc
;
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
acc
.
append
(
createItem
(
col
,
true
)
);
unacc
.
append
(
createItem
(
col
,
false
)
);
}
FilterActionJob
*
mjob
=
new
FilterActionJob
(
col
,
new
MyFunctor
,
this
);
qDebug
()
<<
"Executing FilterActionJob."
;
AKVERIFYEXEC
(
mjob
);
ItemFetchJob
*
fjob
=
new
ItemFetchJob
(
col
,
this
);
fjob
->
fetchScope
().
fetchAllAttributes
();
AKVERIFYEXEC
(
fjob
);
QCOMPARE
(
fjob
->
items
().
count
(),
10
);
foreach
(
const
Item
&
item
,
fjob
->
items
()
)
{
QVERIFY
(
item
.
hasAttribute
<
TestAttribute
>
()
);
const
QByteArray
data
=
item
.
attribute
<
TestAttribute
>
()
->
data
;
if
(
data
==
unacceptable
)
{
QVERIFY
(
unacc
.
contains
(
item
)
);
unacc
.
removeAll
(
item
);
}
else
if
(
data
==
modified
)
{
QVERIFY
(
acc
.
contains
(
item
)
);
acc
.
removeAll
(
item
);
}
else
{
QVERIFY2
(
false
,
QByteArray
(
QByteArray
(
"Got bad data
\"
"
)
+
data
+
QByteArray
(
"
\"
"
))
);
Collection
col
=
createCollection
(
"testMassModifyCollection"
);
// Test a bunch of acceptable and unacceptable items.
Item
::
List
acc
,
unacc
;
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
acc
.
append
(
createItem
(
col
,
true
));
unacc
.
append
(
createItem
(
col
,
false
));
}
FilterActionJob
*
mjob
=
new
FilterActionJob
(
col
,
new
MyFunctor
,
this
);
qDebug
()
<<
"Executing FilterActionJob."
;
AKVERIFYEXEC
(
mjob
);
ItemFetchJob
*
fjob
=
new
ItemFetchJob
(
col
,
this
);
fjob
->
fetchScope
().
fetchAllAttributes
();
AKVERIFYEXEC
(
fjob
);
QCOMPARE
(
fjob
->
items
().
count
(),
10
);
foreach
(
const
Item
&
item
,
fjob
->
items
())
{
QVERIFY
(
item
.
hasAttribute
<
TestAttribute
>
());
const
QByteArray
data
=
item
.
attribute
<
TestAttribute
>
()
->
data
;
if
(
data
==
unacceptable
)
{
QVERIFY
(
unacc
.
contains
(
item
));
unacc
.
removeAll
(
item
);
}
else
if
(
data
==
modified
)
{
QVERIFY
(
acc
.
contains
(
item
));
acc
.
removeAll
(
item
);
}
else
{
QVERIFY2
(
false
,
QByteArray
(
QByteArray
(
"Got bad data
\"
"
)
+
data
+
QByteArray
(
"
\"
"
)));
}
}
}
QCOMPARE
(
acc
.
count
(),
0
);
QCOMPARE
(
unacc
.
count
(),
0
);
QCOMPARE
(
acc
.
count
(),
0
);
QCOMPARE
(
unacc
.
count
(),
0
);
}
Collection
FilterActionTest
::
createCollection
(
const
QString
&
name
)
Collection
FilterActionTest
::
createCollection
(
const
QString
&
name
)
{
Collection
col
;
col
.
setParentCollection
(
res1
);
col
.
setName
(
name
);
CollectionCreateJob
*
ccjob
=
new
CollectionCreateJob
(
col
,
this
);
Q_ASSERT
(
ccjob
->
exec
()
);
return
ccjob
->
collection
();
Collection
col
;
col
.
setParentCollection
(
res1
);
col
.
setName
(
name
);
CollectionCreateJob
*
ccjob
=
new
CollectionCreateJob
(
col
,
this
);
Q_ASSERT
(
ccjob
->
exec
()
);
return
ccjob
->
collection
();
}
Item
FilterActionTest
::
createItem
(
const
Collection
&
col
,
bool
accept
)
Item
FilterActionTest
::
createItem
(
const
Collection
&
col
,
bool
accept
)
{
Q_ASSERT
(
col
.
isValid
()
);
Item
item
;
item
.
setMimeType
(
"text/directory"
);
TestAttribute
*
attr
=
new
TestAttribute
;
if
(
accept
)
{
attr
->
data
=
acceptable
;
}
else
{
attr
->
data
=
unacceptable
;
}
item
.
addAttribute
(
attr
);