@@ -19,6 +19,7 @@ import QtTest 1.0
1919import ".."
2020import "../../../qml/Greeter"
2121import Ubuntu.Components 1.3
22+import Ubuntu.Fingerprints 0.1
2223import AccountsService 0.1
2324import GSettings 1.0
2425import IntegratedLightDM 0.1 as LightDM
@@ -125,6 +126,12 @@ Item {
125126 signalName: "_notifyAuthenticationFailedCalled"
126127 }
127128
129+ SignalSpy {
130+ id: viewShowErrorMessageSpy
131+ target: testCase.view
132+ signalName: "_showErrorMessageCalled"
133+ }
134+
128135 SignalSpy {
129136 id: viewResetSpy
130137 target: testCase.view
@@ -149,6 +156,7 @@ Item {
149156 viewHideSpy.clear();
150157 viewAuthenticationSucceededSpy.clear();
151158 viewAuthenticationFailedSpy.clear();
159+ viewShowErrorMessageSpy.clear();
152160 viewResetSpy.clear();
153161 viewTryToUnlockSpy.clear();
154162 tryCompare(greeter, "waiting", false);
@@ -552,5 +560,47 @@ Item {
552560 LightDM.Greeter.showGreeter();
553561 compare(viewResetSpy.count, 1);
554562 }
563+
564+ function test_fingerprintSuccess() {
565+ selectUser("has-password");
566+ Fingerprints.mockIdentification(0, Fingerprints.None);
567+ verify(greeter.forcedUnlock);
568+ }
569+
570+ function test_fingerprintFailureMessage() {
571+ selectUser("has-password");
572+ Fingerprints.mockIdentification(0, Fingerprints.Error);
573+ compare(viewShowErrorMessageSpy.count, 1);
574+ compare(viewShowErrorMessageSpy.signalArguments[0][0], i18n.tr("Try again"));
575+ }
576+
577+ function test_fingerprintTooManyFailures() {
578+ selectUser("has-password");
579+ Fingerprints.mockIdentification(0, Fingerprints.Error);
580+ Fingerprints.mockIdentification(0, Fingerprints.Error);
581+ compare(viewTryToUnlockSpy.count, 0);
582+
583+ Fingerprints.mockIdentification(0, Fingerprints.Error);
584+ compare(viewTryToUnlockSpy.count, 1);
585+
586+ compare(viewShowErrorMessageSpy.count, 3);
587+ }
588+
589+ function test_fingerprintFailureCountReset() {
590+ selectUser("has-password");
591+ Fingerprints.mockIdentification(0, Fingerprints.Error);
592+ Fingerprints.mockIdentification(0, Fingerprints.Error);
593+ compare(viewTryToUnlockSpy.count, 0);
594+
595+ greeter.forceShow();
596+ Fingerprints.mockIdentification(0, Fingerprints.Error);
597+ Fingerprints.mockIdentification(0, Fingerprints.Error);
598+ compare(viewTryToUnlockSpy.count, 0);
599+
600+ Fingerprints.mockIdentification(0, Fingerprints.Error);
601+ compare(viewTryToUnlockSpy.count, 1);
602+
603+ compare(viewShowErrorMessageSpy.count, 5);
604+ }
555605 }
556606}