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
KDE PIM Add-ons
Commits
bd7dbb03
Commit
bd7dbb03
authored
Aug 05, 2020
by
Laurent Montel
😁
Browse files
Prepare autotest
parent
1bad745a
Pipeline
#29700
failed with stage
in 7 minutes and 44 seconds
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
kaddressbook/importexportplugins/windows-contacts/autotests/CMakeLists.txt
View file @
bd7dbb03
...
...
@@ -2,7 +2,7 @@ ecm_qt_declare_logging_category(kaddressbook_importexport_windowscontact_debugfi
DESCRIPTION
"kdepim-addons (Import/Export Windows Contact plugin)"
EXPORT KDEPIMADDONS
)
add_definitions
(
-DWINDOWSCONTACT_DATADIR=\"
${
CMAKE_CURRENT_SOURCE_DIR
}
\"
)
macro
(
add_windowscontact_unittest _source _additional
)
set
(
_test
${
_source
}
${
_additional
}
${
kaddressbook_importexport_windowscontact_debugfile_autotest_SRCS
}
)
get_filename_component
(
_name
${
_source
}
NAME_WE
)
...
...
kaddressbook/importexportplugins/windows-contacts/
example
/sample1.contact
→
kaddressbook/importexportplugins/windows-contacts/
autotests/data
/sample1.contact
View file @
bd7dbb03
File moved
kaddressbook/importexportplugins/windows-contacts/
example
/sample2.contact
→
kaddressbook/importexportplugins/windows-contacts/
autotests/data
/sample2.contact
View file @
bd7dbb03
File moved
kaddressbook/importexportplugins/windows-contacts/
example
/sample3.contact
→
kaddressbook/importexportplugins/windows-contacts/
autotests/data
/sample3.contact
View file @
bd7dbb03
File moved
kaddressbook/importexportplugins/windows-contacts/
example
/sample4.contact
→
kaddressbook/importexportplugins/windows-contacts/
autotests/data
/sample4.contact
View file @
bd7dbb03
File moved
kaddressbook/importexportplugins/windows-contacts/
example
/test1.contact
→
kaddressbook/importexportplugins/windows-contacts/
autotests/data
/test1.contact
View file @
bd7dbb03
File moved
kaddressbook/importexportplugins/windows-contacts/autotests/importwindowcontacttest.cpp
View file @
bd7dbb03
...
...
@@ -24,5 +24,21 @@ QTEST_MAIN(ImportWindowContactTest)
ImportWindowContactTest
::
ImportWindowContactTest
(
QObject
*
parent
)
:
QObject
(
parent
)
{
}
void
ImportWindowContactTest
::
shouldImportWindowContact_data
()
{
QTest
::
addColumn
<
QString
>
(
"filename"
);
QTest
::
addColumn
<
KContacts
::
Addressee
::
List
>
(
"result"
);
QTest
::
newRow
(
"empty"
)
<<
QString
()
<<
KContacts
::
Addressee
::
List
();
}
void
ImportWindowContactTest
::
shouldImportWindowContact
()
{
QFETCH
(
QString
,
filename
);
QFETCH
(
KContacts
::
Addressee
::
List
,
result
);
ImportWindowContact
contact
;
contact
.
setShowMessageBox
(
false
);
const
QString
fullPath
=
QStringLiteral
(
WINDOWSCONTACT_DATADIR
"/data/"
)
+
filename
;
QCOMPARE
(
contact
.
importFile
(
fullPath
),
result
);
}
kaddressbook/importexportplugins/windows-contacts/autotests/importwindowcontacttest.h
View file @
bd7dbb03
...
...
@@ -28,6 +28,9 @@ class ImportWindowContactTest : public QObject
public:
explicit
ImportWindowContactTest
(
QObject
*
parent
=
nullptr
);
~
ImportWindowContactTest
()
=
default
;
private
Q_SLOTS
:
void
shouldImportWindowContact_data
();
void
shouldImportWindowContact
();
};
#endif // IMPORTWINDOWCONTACTTEST_H
kaddressbook/importexportplugins/windows-contacts/importwindowcontact.cpp
View file @
bd7dbb03
...
...
@@ -39,8 +39,12 @@ KContacts::Addressee::List ImportWindowContact::importFile(const QString &fileNa
KContacts
::
Addressee
::
List
lst
;
QFile
file
(
fileName
);
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
))
{
const
QString
msg
=
i18n
(
"<qt>Unable to open <b>%1</b> for reading.</qt>"
,
fileName
);
KMessageBox
::
error
(
mParentWidget
,
msg
);
if
(
mShowMessageBox
)
{
const
QString
msg
=
i18n
(
"<qt>Unable to open <b>%1</b> for reading.</qt>"
,
fileName
);
KMessageBox
::
error
(
mParentWidget
,
msg
);
}
else
{
qCWarning
(
IMPORTEXPORTWINDOWSCONTACTPLUGIN_LOG
)
<<
"Impossible to open file: "
<<
fileName
;
}
return
lst
;
}
QDomDocument
doc
;
...
...
@@ -75,3 +79,8 @@ void ImportWindowContact::setParentWidget(QWidget *parentWidget)
{
mParentWidget
=
parentWidget
;
}
void
ImportWindowContact
::
setShowMessageBox
(
bool
b
)
{
mShowMessageBox
=
b
;
}
kaddressbook/importexportplugins/windows-contacts/importwindowcontact.h
View file @
bd7dbb03
...
...
@@ -33,9 +33,11 @@ public:
Q_REQUIRED_RESULT
KContacts
::
Addressee
::
List
importFile
(
const
QString
&
fileName
);
void
setParentWidget
(
QWidget
*
parentWidget
);
void
setShowMessageBox
(
bool
b
);
//Only for autotest
private:
Q_REQUIRED_RESULT
bool
loadDomElement
(
QDomDocument
&
doc
,
QFile
*
file
);
bool
mShowMessageBox
=
true
;
QWidget
*
mParentWidget
=
nullptr
;
};
...
...
Write
Preview
Supports
Markdown
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