@@ -20,6 +20,7 @@ import ".."
2020import "../../../qml/Greeter"
2121import Ubuntu.Components 1.3
2222import AccountsService 0.1
23+import Biometryd 0.0
2324import GSettings 1.0
2425import IntegratedLightDM 0.1 as LightDM
2526import Unity.Test 0.1 as UT
@@ -149,6 +150,8 @@ Item {
149150 teaseSpy.clear();
150151 sessionStartedSpy.clear();
151152 activeChangedSpy.clear();
153+ Biometryd.reset(false);
154+ AccountsService.enableFingerprintIdentification = false;
152155 viewShowMessageSpy.clear();
153156 viewShowPromptSpy.clear();
154157 viewShowLastChanceSpy.clear();
@@ -562,49 +565,129 @@ Item {
562565 }
563566
564567 function test_fingerprintSuccess() {
568+ Biometryd.reset(true);
569+ AccountsService.enableFingerprintIdentification = true;
570+ var index = selectUser("has-password");
571+
565572 var biometryd = findInvisibleChild(greeter, "biometryd");
566− selectUser("has-password");
567− biometryd.mockIdentification(0, "");
568− verify(greeter.forcedUnlock);
573+ verify(biometryd.operation);
574+ verify(biometryd.operation.running);
575+
576+ biometryd.operation.mockSuccess(LightDM.Users.data(index, LightDM.UserRoles.UidRole));
577+ verify(!greeter.active);
569578 }
570579
571580 function test_fingerprintFailureMessage() {
581+ Biometryd.reset(true);
582+ AccountsService.enableFingerprintIdentification = true;
583+ var index = selectUser("has-password");
584+
572585 var biometryd = findInvisibleChild(greeter, "biometryd");
573− selectUser("has-password");
574− biometryd.mockIdentification(0, "error");
586+ verify(biometryd.operation);
587+ verify(biometryd.operation.running);
588+
589+ biometryd.operation.mockFailure("error");
575590 compare(viewShowErrorMessageSpy.count, 1);
576591 compare(viewShowErrorMessageSpy.signalArguments[0][0], i18n.tr("Try again"));
577592 }
578593
579594 function test_fingerprintTooManyFailures() {
580− var biometryd = findInvisibleChild(greeter, "biometryd");
595+ Biometryd.reset(true);
596+ AccountsService.enableFingerprintIdentification = true;
581597 selectUser("has-password");
582− biometryd.mockIdentification(0, "error");
583− biometryd.mockIdentification(0, "error");
598+
599+ var biometryd = findInvisibleChild(greeter, "biometryd");
600+ biometryd.operation.mockFailure("error");
601+ biometryd.operation.mockFailure("error");
584602 compare(viewTryToUnlockSpy.count, 0);
585603
586− biometryd.mockIdentification(0, "error");
604+ biometryd.operation.mockFailure("error");
587605 compare(viewTryToUnlockSpy.count, 1);
588606
589607 compare(viewShowErrorMessageSpy.count, 3);
590608 }
591609
592610 function test_fingerprintFailureCountReset() {
593− var biometryd = findInvisibleChild(greeter, "biometryd");
611+ Biometryd.reset(true);
612+ AccountsService.enableFingerprintIdentification = true;
594613 selectUser("has-password");
595− biometryd.mockIdentification(0, "error");
596− biometryd.mockIdentification(0, "error");
614+
615+ var biometryd = findInvisibleChild(greeter, "biometryd");
616+ biometryd.operation.mockFailure("error");
617+ biometryd.operation.mockFailure("error");
597618 compare(viewTryToUnlockSpy.count, 0);
598619
599620 greeter.forceShow();
600− biometryd.mockIdentification(0, "error");
601− biometryd.mockIdentification(0, "error");
621+ biometryd.operation.mockFailure("error");
622+ biometryd.operation.mockFailure("error");
602623 compare(viewTryToUnlockSpy.count, 0);
603624
604− biometryd.mockIdentification(0, "error");
625+ biometryd.operation.mockFailure("error");
605626 compare(viewTryToUnlockSpy.count, 1);
606627
607628 compare(viewShowErrorMessageSpy.count, 5);
608629 }
630+
631+ function test_fingerprintWrongUid() {
632+ Biometryd.reset(true);
633+ AccountsService.enableFingerprintIdentification = true;
634+ selectUser("has-password");
635+
636+ var biometryd = findInvisibleChild(greeter, "biometryd");
637+ biometryd.operation.mockSuccess(0);
638+
639+ verify(greeter.active);
640+ compare(viewShowErrorMessageSpy.count, 1);
641+ compare(viewShowErrorMessageSpy.signalArguments[0][0], i18n.tr("Try again"));
642+ }
643+
644+ function test_fingerprintNotEnabled() {
645+ Biometryd.reset(true);
646+ selectUser("has-password");
647+
648+ var biometryd = findInvisibleChild(greeter, "biometryd");
649+ verify(!biometryd.operation);
650+
651+ AccountsService.enableFingerprintIdentification = true;
652+ verify(biometryd.operation);
653+ verify(biometryd.operation.running);
654+
655+ AccountsService.enableFingerprintIdentification = false;
656+ verify(!biometryd.operation);
657+ }
658+
659+ function test_fingerprintReaderNotPresent() {
660+ AccountsService.enableFingerprintIdentification = true;
661+ selectUser("has-password");
662+
663+ verify(!Biometryd.defaultDevice);
664+
665+ var biometryd = findInvisibleChild(greeter, "biometryd");
666+ verify(!biometryd.operation);
667+
668+ Biometryd.reset(true);
669+ verify(biometryd.operation);
670+ verify(biometryd.operation.running);
671+
672+ Biometryd.reset(false);
673+ verify(!biometryd.operation);
674+ }
675+
676+ function test_fingerprintGreeterNotActive() {
677+ Biometryd.reset(true);
678+ AccountsService.enableFingerprintIdentification = true;
679+ selectUser("has-password");
680+
681+ var biometryd = findInvisibleChild(greeter, "biometryd");
682+ verify(biometryd.operation);
683+ verify(biometryd.operation.running);
684+
685+ greeter.hideNow();
686+ verify(!biometryd.operation);
687+
688+ greeter.showNow();
689+ verify(biometryd.operation);
690+ verify(biometryd.operation.running);
691+ }
609692 }
610693}