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
KDE PIM Runtime
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
KDE PIM Runtime
Commits
a9fb7c00
Commit
a9fb7c00
authored
Jan 05, 2015
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unittest
parent
4c631470
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
138 additions
and
4 deletions
+138
-4
resources/mbox/CMakeLists.txt
resources/mbox/CMakeLists.txt
+1
-0
resources/mbox/autotests/CMakeLists.txt
resources/mbox/autotests/CMakeLists.txt
+5
-0
resources/mbox/autotests/deleteitemsattributetest.cpp
resources/mbox/autotests/deleteitemsattributetest.cpp
+84
-0
resources/mbox/autotests/deleteitemsattributetest.h
resources/mbox/autotests/deleteitemsattributetest.h
+38
-0
resources/mbox/deleteditemsattribute.cpp
resources/mbox/deleteditemsattribute.cpp
+6
-1
resources/mbox/deleteditemsattribute.h
resources/mbox/deleteditemsattribute.h
+4
-3
No files found.
resources/mbox/CMakeLists.txt
View file @
a9fb7c00
...
...
@@ -42,3 +42,4 @@ endif ()
target_link_libraries
(
akonadi_mbox_resource
${
KDEPIMLIBS_KMBOX_LIBS
}
${
KDEPIMLIBS_AKONADI_LIBS
}
${
KDEPIMLIBS_AKONADI_KMIME_LIBS
}
${
QT_QTDBUS_LIBRARY
}
${
KDE4_KIO_LIBS
}
${
KDEPIMLIBS_KMIME_LIBS
}
)
install
(
TARGETS akonadi_mbox_resource DESTINATION
${
PLUGIN_INSTALL_DIR
}
)
add_subdirectory
(
autotests
)
resources/mbox/autotests/CMakeLists.txt
0 → 100644
View file @
a9fb7c00
set
(
mbox_deleteitemsattributetest_source deleteitemsattributetest.cpp ../deleteditemsattribute.cpp
)
kde4_add_unit_test
(
deleteitemsattributetest
${
mbox_deleteitemsattributetest_source
}
)
target_link_libraries
(
deleteitemsattributetest
${
QT_QTTEST_LIBRARY
}
${
KDE4_KDECORE_LIBS
}
${
QT_QTGUI_LIBRARY
}
${
KDEPIMLIBS_AKONADI_LIBS
}
${
KDEPIMLIBS_KMBOX_LIBS
}
)
resources/mbox/autotests/deleteitemsattributetest.cpp
0 → 100644
View file @
a9fb7c00
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "deleteitemsattributetest.h"
#include "../deleteditemsattribute.h"
#include <qtest_kde.h>
DeleteItemsAttributeTest
::
DeleteItemsAttributeTest
(
QObject
*
parent
)
:
QObject
(
parent
)
{
}
DeleteItemsAttributeTest
::~
DeleteItemsAttributeTest
()
{
}
void
DeleteItemsAttributeTest
::
shouldHaveDefaultValue
()
{
DeletedItemsAttribute
attr
;
QVERIFY
(
attr
.
deletedItemOffsets
().
isEmpty
());
QCOMPARE
(
attr
.
offsetCount
(),
0
);
}
void
DeleteItemsAttributeTest
::
shouldAssignValue
()
{
DeletedItemsAttribute
attr
;
QSet
<
quint64
>
lst
;
lst
.
insert
(
15
);
attr
.
addDeletedItemOffset
(
15
);
lst
.
insert
(
154
);
attr
.
addDeletedItemOffset
(
154
);
lst
.
insert
(
225
);
attr
.
addDeletedItemOffset
(
225
);
QVERIFY
(
!
attr
.
deletedItemOffsets
().
isEmpty
());
QCOMPARE
(
attr
.
offsetCount
(),
3
);
QCOMPARE
(
lst
,
attr
.
deletedItemOffsets
());
}
void
DeleteItemsAttributeTest
::
shouldDeserializeValue
()
{
DeletedItemsAttribute
attr
;
attr
.
addDeletedItemOffset
(
15
);
attr
.
addDeletedItemOffset
(
154
);
attr
.
addDeletedItemOffset
(
225
);
const
QByteArray
ba
=
attr
.
serialized
();
DeletedItemsAttribute
result
;
result
.
deserialize
(
ba
);
QVERIFY
(
result
==
attr
);
}
void
DeleteItemsAttributeTest
::
shouldCloneAttribute
()
{
DeletedItemsAttribute
attr
;
attr
.
addDeletedItemOffset
(
15
);
attr
.
addDeletedItemOffset
(
154
);
attr
.
addDeletedItemOffset
(
225
);
DeletedItemsAttribute
*
result
=
attr
.
clone
();
QVERIFY
(
*
result
==
attr
);
}
void
DeleteItemsAttributeTest
::
shouldHaveTypeName
()
{
DeletedItemsAttribute
attr
;
QCOMPARE
(
attr
.
type
(),
QByteArray
(
"DeletedMboxItems"
));
}
QTEST_KDEMAIN
(
DeleteItemsAttributeTest
,
NoGUI
)
resources/mbox/autotests/deleteitemsattributetest.h
0 → 100644
View file @
a9fb7c00
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef DELETEITEMSATTRIBUTETEST_H
#define DELETEITEMSATTRIBUTETEST_H
#include <QObject>
class
DeleteItemsAttributeTest
:
public
QObject
{
Q_OBJECT
public:
explicit
DeleteItemsAttributeTest
(
QObject
*
parent
=
0
);
~
DeleteItemsAttributeTest
();
private
Q_SLOTS
:
void
shouldHaveDefaultValue
();
void
shouldDeserializeValue
();
void
shouldAssignValue
();
void
shouldCloneAttribute
();
void
shouldHaveTypeName
();
};
#endif // DELETEITEMSATTRIBUTETEST_H
resources/mbox/deleteditemsattribute.cpp
View file @
a9fb7c00
...
...
@@ -41,7 +41,7 @@ void DeletedItemsAttribute::addDeletedItemOffset( quint64 offset )
mDeletedItemOffsets
.
insert
(
offset
);
}
Akonadi
::
Attribute
*
DeletedItemsAttribute
::
clone
()
const
DeletedItems
Attribute
*
DeletedItemsAttribute
::
clone
()
const
{
return
new
DeletedItemsAttribute
(
*
this
);
}
...
...
@@ -95,3 +95,8 @@ QByteArray DeletedItemsAttribute::type() const
static
const
QByteArray
sType
(
"DeletedMboxItems"
);
return
sType
;
}
bool
DeletedItemsAttribute
::
operator
==
(
const
DeletedItemsAttribute
&
other
)
const
{
return
mDeletedItemOffsets
==
other
.
deletedItemOffsets
();
}
resources/mbox/deleteditemsattribute.h
View file @
a9fb7c00
...
...
@@ -26,7 +26,7 @@
#include <QtCore/QSet>
/**
* This attribute stores a list of off
d
ets in the mbox file of mails which are
* This attribute stores a list of off
s
ets in the mbox file of mails which are
* deleted but not yet actually removed from the file yet.
*/
class
DeletedItemsAttribute
:
public
Akonadi
::
Attribute
...
...
@@ -40,7 +40,7 @@ class DeletedItemsAttribute : public Akonadi::Attribute
void
addDeletedItemOffset
(
quint64
);
virtual
Attribute
*
clone
()
const
;
virtual
DeletedItems
Attribute
*
clone
()
const
;
QSet
<
quint64
>
deletedItemOffsets
()
const
;
KMBox
::
MBoxEntry
::
List
deletedItemEntries
()
const
;
...
...
@@ -56,7 +56,8 @@ class DeletedItemsAttribute : public Akonadi::Attribute
virtual
QByteArray
type
()
const
;
private:
bool
operator
==
(
const
DeletedItemsAttribute
&
other
)
const
;
private:
QSet
<
quint64
>
mDeletedItemOffsets
;
};
...
...
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