Commit dd8df049 authored by chriadam's avatar chriadam

Merge branch 'jb52635' into 'master'

[nemo-qml-plugin-contacts] Fix unit tests. Contributes to JB#52635

See merge request !52
parents 70d7da9e 697e40bc
#!/bin/sh
export BASENAME=$1
export TESTCASE=$2
export DEVICEUSER=$(getent passwd $(grep '^UID_MIN' /etc/login.defs | tr -s ' ' | cut -d ' ' -f2) | sed 's/:.*//')
export LIBCONTACTS_TEST_MODE=1
/usr/sbin/run-blts-root /bin/su -g privileged -c "/opt/tests/$BASENAME/contacts/$TESTCASE" "$DEVICEUSER"
......@@ -9,6 +9,8 @@ SUBDIRS = \
tst_seasidefilteredmodel \
tst_seasidestringlistcompressor
OTHER_FILES += $$PWD/tests.xml.in $$PWD/run_test.sh
tests_xml.target = tests.xml
tests_xml.depends = $$PWD/tests.xml.in
tests_xml.commands = sed -e "s:@BASENAME@:$${BASENAME}:g" $< > $@
......@@ -19,7 +21,7 @@ QMAKE_CLEAN += $$tests_xml.target
PRE_TARGETDEPS += $$tests_xml.target
tests_install.path = /opt/tests/$${BASENAME}/contacts/
tests_install.files = $$tests_xml.target
tests_install.files = $$tests_xml.target $$PWD/run_test.sh
tests_install.depends = tests_xml
tests_install.CONFIG += no_check_exist
......
......@@ -5,13 +5,16 @@
<set name="contactcache-test0" feature="Contacts">
<description>Contact cache automatic tests</description>
<case manual="false" name="synchronizelists">
<step>LIBCONTACTS_TEST_MODE=1 /usr/sbin/run-blts-root /bin/su -g privileged -c '/opt/tests/@PACKAGENAME@/tst_synchronizelists' nemo</step>
<step>/opt/tests/@BASENAME@/contacts/run_test.sh @BASENAME@ tst_synchronizelists</step>
</case>
<case manual="false" name="seasideimport">
<step>LIBCONTACTS_TEST_MODE=1 /usr/sbin/run-blts-root /bin/su -g privileged -c '/opt/tests/@PACKAGENAME@/tst_seasideimport' nemo</step>
<step>/opt/tests/@BASENAME@/contacts/run_test.sh @BASENAME@ tst_seasideimport</step>
</case>
<case manual="false" name="resolve">
<step>LIBCONTACTS_TEST_MODE=1 /usr/sbin/run-blts-root /bin/su -g privileged -c '/opt/tests/@PACKAGENAME@/tst_resolve' nemo</step>
<step>/opt/tests/@BASENAME@/contacts/run_test.sh @BASENAME@ tst_resolve</step>
</case>
<case manual="false" name="seasidestringlistcompressor">
<step>/opt/tests/@BASENAME@/contacts/run_test.sh @BASENAME@ tst_seasidestringlistcompressor</step>
</case>
</set>
</suite>
......@@ -20,10 +23,10 @@
<set name="@BASENAME@-contacts-test0" feature="QML Contacts">
<description>Contacts QML plugin automatic tests</description>
<case manual="false" name="seasideperson" timeout="600">
<step>/opt/tests/@BASENAME@/contacts/tst_seasideperson</step>
<step>/opt/tests/@BASENAME@/contacts/run_test.sh @BASENAME@ tst_seasideperson</step>
</case>
<case manual="false" name="seasidefilteredmodel">
<step>/opt/tests/@BASENAME@/contacts/tst_seasidefilteredmodel</step>
<step>/opt/tests/@BASENAME@/contacts/run_test.sh @BASENAME@ tst_seasidefilteredmodel</step>
</case>
</set>
</suite>
......
......@@ -547,21 +547,23 @@ void tst_SeasideFilteredModel::filterCharacters()
QSKIP("Character matching is not testable with unknown locale");
}
// 1 2 3 4
// 1 2 3 4 5 - note that Ælvis will match due to NameDetails.Contains match rule with diacritic decomposition
model.setFilterPattern("Elvis");
QCOMPARE(model.rowCount(), 4);
QCOMPARE(model.rowCount(), 5);
QCOMPARE(model.index(QModelIndex(), 0, 0).data(SeasideFilteredModel::ContactIdRole).toInt(), 1);
QCOMPARE(model.index(QModelIndex(), 1, 0).data(SeasideFilteredModel::ContactIdRole).toInt(), 2);
QCOMPARE(model.index(QModelIndex(), 2, 0).data(SeasideFilteredModel::ContactIdRole).toInt(), 3);
QCOMPARE(model.index(QModelIndex(), 3, 0).data(SeasideFilteredModel::ContactIdRole).toInt(), 4);
QCOMPARE(model.index(QModelIndex(), 4, 0).data(SeasideFilteredModel::ContactIdRole).toInt(), 5);
// 1 2 3 4
// 1 2 3 4 5 - note that Ælvis will match due to NameDetails.Contains match rule with diacritic decomposition
model.setFilterPattern("elvis");
QCOMPARE(model.rowCount(), 4);
QCOMPARE(model.rowCount(), 5);
QCOMPARE(model.index(QModelIndex(), 0, 0).data(SeasideFilteredModel::ContactIdRole).toInt(), 1);
QCOMPARE(model.index(QModelIndex(), 1, 0).data(SeasideFilteredModel::ContactIdRole).toInt(), 2);
QCOMPARE(model.index(QModelIndex(), 2, 0).data(SeasideFilteredModel::ContactIdRole).toInt(), 3);
QCOMPARE(model.index(QModelIndex(), 3, 0).data(SeasideFilteredModel::ContactIdRole).toInt(), 4);
QCOMPARE(model.index(QModelIndex(), 4, 0).data(SeasideFilteredModel::ContactIdRole).toInt(), 5);
// 3
model.setFilterPattern(QString::fromUtf8(u8"\u00CBlvis")); // 'Ëlvis'
......
......@@ -160,7 +160,10 @@ void tst_SeasidePerson::sectionBucket()
QSignalSpy spy(person.data(), SIGNAL(displayLabelChanged()));
QCOMPARE(person->displayLabel(), SeasidePerson::placeholderDisplayLabel());
QCOMPARE(spy.count(), 0);
QCOMPARE(person->sectionBucket(), QString());
// ignore the placeholder id if necessary. unit tests don't load translation catalogues.
if (person->displayLabel() != QStringLiteral("nemo_contacts-la-placeholder_display_label")) {
QCOMPARE(person->sectionBucket(), QString());
}
// set first
person->setLastName("Test");
......
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