Commit 08f1d0ec authored by Laurent Montel's avatar Laurent Montel 😁

isolate akonadi

parent c61aadb9
......@@ -11,7 +11,11 @@ macro(add_kmail_automaticaddscontacts_unittest _source _additional)
target_link_libraries( ${_name} Qt5::Test KF5::IconThemes KF5::MessageComposer KF5::I18n KF5::PimCommon KF5::AkonadiWidgets)
endmacro ()
add_kmail_automaticaddscontacts_unittest(automaticaddcontactsplugintest.cpp "../automaticaddcontactsjob.cpp;../automaticaddcontactsplugin.cpp;../automaticaddcontactsinterface.cpp;../automaticaddcontactsconfigurewidget.cpp")
add_kmail_automaticaddscontacts_unittest(automaticaddcontactsinterfacetest.cpp "../automaticaddcontactsinterface.cpp")
add_kmail_automaticaddscontacts_unittest(automaticaddcontactswidgettest.cpp "../automaticaddcontactsconfigurewidget.cpp")
add_kmail_automaticaddscontacts_unittest(automaticaddcontactsjobtest.cpp "../automaticaddcontactsjob.cpp")
set(KDEPIMLIBS_RUN_ISOLATED_TESTS TRUE)
set(KDEPIMLIBS_RUN_SQLITE_ISOLATED_TESTS TRUE)
add_akonadi_isolated_test_advanced(automaticaddcontactsplugintest.cpp "${automaticaddcontacts_common_SRCS};../automaticaddcontactsjob.cpp;../automaticaddcontactsplugin.cpp;../automaticaddcontactsinterface.cpp;../automaticaddcontactsconfigurewidget.cpp" "KF5::IconThemes;KF5::MessageComposer;KF5::I18n;KF5::PimCommon;KF5::AkonadiWidgets")
add_akonadi_isolated_test_advanced(automaticaddcontactsinterfacetest.cpp "${automaticaddcontacts_common_SRCS};../automaticaddcontactsinterface.cpp" "KF5::IconThemes;KF5::MessageComposer;KF5::I18n;KF5::PimCommon;KF5::AkonadiWidgets")
add_akonadi_isolated_test_advanced(automaticaddcontactswidgettest.cpp "${automaticaddcontacts_common_SRCS};../automaticaddcontactsconfigurewidget.cpp" "KF5::IconThemes;KF5::MessageComposer;KF5::I18n;KF5::PimCommon;KF5::AkonadiWidgets")
add_kmail_automaticaddscontacts_unittest(automaticaddcontactsjobtest.cpp "../automaticaddcontactsjob.cpp" "KF5::IconThemes;KF5::MessageComposer;KF5::I18n;KF5::PimCommon;KF5::AkonadiWidgets")
......@@ -25,12 +25,31 @@
#include <QVBoxLayout>
#include <QStandardPaths>
#include <QLabel>
#include <QStandardItemModel>
#include <AkonadiWidgets/CollectionComboBox>
#include <AkonadiCore/EntityTreeModel>
#include <KContacts/Addressee>
AutomaticAddContactsWidgetTest::AutomaticAddContactsWidgetTest(QObject *parent)
: QObject(parent)
{
QStandardPaths::setTestModeEnabled(true);
mComboboxModel = new QStandardItemModel;
for (int id = 42; id < 51; ++id) {
Akonadi::Collection collection(id);
collection.setRights(Akonadi::Collection::AllRights);
collection.setName(QString::number(id));
collection.setContentMimeTypes(QStringList() << KContacts::Addressee::mimeType());
QStandardItem *item = new QStandardItem(collection.name());
item->setData(QVariant::fromValue(collection),
Akonadi::EntityTreeModel::CollectionRole);
item->setData(QVariant::fromValue(collection.id()),
Akonadi::EntityTreeModel::CollectionIdRole);
mComboboxModel->appendRow(item);
}
}
AutomaticAddContactsWidgetTest::~AutomaticAddContactsWidgetTest()
......@@ -38,40 +57,48 @@ AutomaticAddContactsWidgetTest::~AutomaticAddContactsWidgetTest()
}
AutomaticAddContactsWidget *AutomaticAddContactsWidgetTest::createContactWidget()
{
AutomaticAddContactsWidget *w = new AutomaticAddContactsWidget(0, mComboboxModel);
return w;
}
void AutomaticAddContactsWidgetTest::shouldHaveDefaultValue()
{
AutomaticAddContactsWidget w;
QVBoxLayout *vboxlayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainlayout"));
AutomaticAddContactsWidget *w = new AutomaticAddContactsWidget(createContactWidget());
QVBoxLayout *vboxlayout = w->findChild<QVBoxLayout *>(QStringLiteral("mainlayout"));
QVERIFY(vboxlayout);
QCheckBox *mEnabled = w.findChild<QCheckBox *>(QStringLiteral("enabled"));
QCheckBox *mEnabled = w->findChild<QCheckBox *>(QStringLiteral("enabled"));
QVERIFY(mEnabled);
QVERIFY(!mEnabled->text().isEmpty());
QVERIFY(!mEnabled->isChecked());
QHBoxLayout *hlay = w.findChild<QHBoxLayout *>(QStringLiteral("folderlayout"));
QHBoxLayout *hlay = w->findChild<QHBoxLayout *>(QStringLiteral("folderlayout"));
QVERIFY(hlay);
QCOMPARE(hlay->margin(), 0);
QLabel *lab = w.findChild<QLabel *>(QStringLiteral("labelfolder"));
QLabel *lab = w->findChild<QLabel *>(QStringLiteral("labelfolder"));
QVERIFY(lab);
QVERIFY(!lab->text().isEmpty());
Akonadi::CollectionComboBox *mCollectionCombobox = w.findChild<Akonadi::CollectionComboBox *>(QStringLiteral("akonadicombobox"));
Akonadi::CollectionComboBox *mCollectionCombobox = w->findChild<Akonadi::CollectionComboBox *>(QStringLiteral("akonadicombobox"));
QVERIFY(mCollectionCombobox);
delete w;
}
void AutomaticAddContactsWidgetTest::shouldResetValue()
{
AutomaticAddContactsWidget w;
QCheckBox *mEnabled = w.findChild<QCheckBox *>(QStringLiteral("enabled"));
AutomaticAddContactsWidget *w = new AutomaticAddContactsWidget(createContactWidget());
QCheckBox *mEnabled = w->findChild<QCheckBox *>(QStringLiteral("enabled"));
QVERIFY(!mEnabled->isChecked());
mEnabled->setChecked(true);
QVERIFY(mEnabled->isChecked());
w.resetSettings();
w->resetSettings();
QVERIFY(!mEnabled->isChecked());
delete w;
}
QTEST_MAIN(AutomaticAddContactsWidgetTest)
......@@ -21,7 +21,8 @@
#define AUTOMATICADDCONTACTSWIDGETTEST_H
#include <QObject>
class QStandardItemModel;
class AutomaticAddContactsWidget;
class AutomaticAddContactsWidgetTest : public QObject
{
Q_OBJECT
......@@ -31,6 +32,9 @@ public:
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldResetValue();
private:
AutomaticAddContactsWidget *createContactWidget();
QStandardItemModel *mComboboxModel;
};
#endif // AUTOMATICADDCONTACTSWIDGETTEST_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment