Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Unmaintained
KDE Pim
Commits
15f15662
Commit
15f15662
authored
Dec 04, 2014
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't add same files
parent
b1f555ab
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
136 additions
and
2 deletions
+136
-2
messageviewer/tests/CMakeLists.txt
messageviewer/tests/CMakeLists.txt
+6
-0
messageviewer/tests/attachmenttemporaryfilesdirstest.cpp
messageviewer/tests/attachmenttemporaryfilesdirstest.cpp
+79
-0
messageviewer/tests/attachmenttemporaryfilesdirstest.h
messageviewer/tests/attachmenttemporaryfilesdirstest.h
+40
-0
messageviewer/viewer/attachmenttemporaryfilesdirs.cpp
messageviewer/viewer/attachmenttemporaryfilesdirs.cpp
+10
-2
messageviewer/viewer/attachmenttemporaryfilesdirs.h
messageviewer/viewer/attachmenttemporaryfilesdirs.h
+1
-0
No files found.
messageviewer/tests/CMakeLists.txt
View file @
15f15662
...
...
@@ -42,6 +42,12 @@ add_messageviewer_unittest( todoedittest.cpp )
add_messageviewer_unittest( eventedittest.cpp )
add_messageviewer_unittest( eventdatetimewidgettest.cpp )
add_messageviewer_unittest( messagedisplayformatattributetest.cpp )
set( messageviewer_attachmentdirs_SRCS attachmenttemporaryfilesdirstest.cpp ../viewer/attachmenttemporaryfilesdirs.cpp)
kde4_add_unit_test( messageviewer_attachmentdirstest
${
messageviewer_attachmentdirs_SRCS
}
)
target_link_libraries( messageviewer_attachmentdirstest
${
QT_QTTEST_LIBRARY
}
${
KDE4_KDEUI_LIBS
}
)
########### viewertest_gui ###############
...
...
messageviewer/tests/attachmenttemporaryfilesdirstest.cpp
0 → 100644
View file @
15f15662
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "attachmenttemporaryfilesdirstest.h"
#include "../viewer/attachmenttemporaryfilesdirs.h"
#include <qtest_kde.h>
AttachmentTemporaryFilesDirsTest
::
AttachmentTemporaryFilesDirsTest
(
QObject
*
parent
)
:
QObject
(
parent
)
{
}
AttachmentTemporaryFilesDirsTest
::~
AttachmentTemporaryFilesDirsTest
()
{
}
void
AttachmentTemporaryFilesDirsTest
::
shouldHaveDefaultValue
()
{
MessageViewer
::
AttachmentTemporaryFilesDirs
attachmentDir
;
QVERIFY
(
attachmentDir
.
temporaryFiles
().
isEmpty
());
QVERIFY
(
attachmentDir
.
temporaryDirs
().
isEmpty
());
}
void
AttachmentTemporaryFilesDirsTest
::
shouldAddTemporaryFiles
()
{
MessageViewer
::
AttachmentTemporaryFilesDirs
attachmentDir
;
attachmentDir
.
addTempFile
(
QLatin1String
(
"foo"
));
QCOMPARE
(
attachmentDir
.
temporaryFiles
().
count
(),
1
);
attachmentDir
.
addTempFile
(
QLatin1String
(
"foo1"
));
QCOMPARE
(
attachmentDir
.
temporaryFiles
().
count
(),
2
);
}
void
AttachmentTemporaryFilesDirsTest
::
shouldAddTemporaryDirs
()
{
MessageViewer
::
AttachmentTemporaryFilesDirs
attachmentDir
;
attachmentDir
.
addTempDir
(
QLatin1String
(
"foo"
));
QCOMPARE
(
attachmentDir
.
temporaryDirs
().
count
(),
1
);
attachmentDir
.
addTempDir
(
QLatin1String
(
"foo1"
));
QCOMPARE
(
attachmentDir
.
temporaryDirs
().
count
(),
2
);
}
void
AttachmentTemporaryFilesDirsTest
::
shouldNotAddSameFiles
()
{
MessageViewer
::
AttachmentTemporaryFilesDirs
attachmentDir
;
attachmentDir
.
addTempFile
(
QLatin1String
(
"foo"
));
QCOMPARE
(
attachmentDir
.
temporaryFiles
().
count
(),
1
);
attachmentDir
.
addTempFile
(
QLatin1String
(
"foo"
));
QCOMPARE
(
attachmentDir
.
temporaryFiles
().
count
(),
1
);
}
void
AttachmentTemporaryFilesDirsTest
::
shouldNotAddSameDirs
()
{
MessageViewer
::
AttachmentTemporaryFilesDirs
attachmentDir
;
attachmentDir
.
addTempDir
(
QLatin1String
(
"foo"
));
QCOMPARE
(
attachmentDir
.
temporaryDirs
().
count
(),
1
);
attachmentDir
.
addTempDir
(
QLatin1String
(
"foo"
));
QCOMPARE
(
attachmentDir
.
temporaryDirs
().
count
(),
1
);
}
QTEST_KDEMAIN
(
AttachmentTemporaryFilesDirsTest
,
NoGUI
)
messageviewer/tests/attachmenttemporaryfilesdirstest.h
0 → 100644
View file @
15f15662
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef ATTACHMENTTEMPORARYFILESDIRSTEST_H
#define ATTACHMENTTEMPORARYFILESDIRSTEST_H
#include <QObject>
class
AttachmentTemporaryFilesDirsTest
:
public
QObject
{
Q_OBJECT
public:
explicit
AttachmentTemporaryFilesDirsTest
(
QObject
*
parent
=
0
);
~
AttachmentTemporaryFilesDirsTest
();
private
Q_SLOTS
:
void
shouldHaveDefaultValue
();
void
shouldAddTemporaryFiles
();
void
shouldAddTemporaryDirs
();
void
shouldNotAddSameFiles
();
void
shouldNotAddSameDirs
();
};
#endif // ATTACHMENTTEMPORARYFILESDIRSTEST_H
messageviewer/viewer/attachmenttemporaryfilesdirs.cpp
View file @
15f15662
...
...
@@ -68,12 +68,16 @@ void AttachmentTemporaryFilesDirs::slotRemoveTempFiles()
void
AttachmentTemporaryFilesDirs
::
addTempFile
(
const
QString
&
file
)
{
mTempFiles
.
append
(
file
);
if
(
!
mTempFiles
.
contains
(
file
))
{
mTempFiles
.
append
(
file
);
}
}
void
AttachmentTemporaryFilesDirs
::
addTempDir
(
const
QString
&
dir
)
{
mTempDirs
.
append
(
dir
);
if
(
!
mTempDirs
.
contains
(
dir
))
{
mTempDirs
.
append
(
dir
);
}
}
QStringList
AttachmentTemporaryFilesDirs
::
temporaryFiles
()
const
...
...
@@ -81,4 +85,8 @@ QStringList AttachmentTemporaryFilesDirs::temporaryFiles() const
return
mTempFiles
;
}
QStringList
AttachmentTemporaryFilesDirs
::
temporaryDirs
()
const
{
return
mTempDirs
;
}
messageviewer/viewer/attachmenttemporaryfilesdirs.h
View file @
15f15662
...
...
@@ -39,6 +39,7 @@ public:
void
removeTempFiles
();
void
forceCleanTempFiles
();
QStringList
temporaryDirs
()
const
;
private
Q_SLOTS
:
void
slotRemoveTempFiles
();
...
...
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