on xenial help sign in
Support Biometryd.valid
ec51140Michael Terry
qml/Greeter/Greeter.qml+1−1
@@ -488,7 +488,7 @@ Showable {
488
488
489 property var operation: null
489 property var operation: null
490 readonly property bool idEnabled: root.active &&
490 readonly property bool idEnabled: root.active &&
491− Biometryd.defaultDevice &&
491+ Biometryd.valid &&
492 AccountsService.enableFingerprintIdentification
492 AccountsService.enableFingerprintIdentification
493
493
494 function cancelOperation() {
494 function cancelOperation() {
tests/mocks/Biometryd/MockBiometryd.cpp+11−10
@@ -19,7 +19,8 @@
19
19
20MockBiometryd::MockBiometryd(QObject *parent)
20MockBiometryd::MockBiometryd(QObject *parent)
21 : QObject(parent)
21 : QObject(parent)
22− , m_device(nullptr)
22+ , m_device(new MockDevice(this))
23+ , m_valid(false)
23{
24{
24}
25}
25
26
@@ -28,15 +29,15 @@ MockDevice *MockBiometryd::defaultDevice() const
28 return m_device;
29 return m_device;
29}
30}
30
31
31−void MockBiometryd::reset(bool devicePresent)
32+bool MockBiometryd::valid() const
32{
33{
33− if (m_device) {
34+ return m_valid;
34− delete m_device;
35− m_device = nullptr;
36− }
35+}
37−
38− if (devicePresent)
39− m_device = new MockDevice(this);
40
36
41− Q_EMIT defaultDeviceChanged();
37+void MockBiometryd::setValid(bool valid)
38+{
39+ if (m_valid != valid) {
40+ m_valid = valid;
41+ Q_EMIT validChanged();
42+ }
42}
43}
tests/mocks/Biometryd/MockBiometryd.h+9−3
@@ -25,20 +25,26 @@ class MockBiometryd : public QObject
25{
25{
26 Q_OBJECT
26 Q_OBJECT
27 Q_DISABLE_COPY(MockBiometryd)
27 Q_DISABLE_COPY(MockBiometryd)
28− Q_PROPERTY(MockDevice *defaultDevice READ defaultDevice NOTIFY defaultDeviceChanged)
28+ Q_PROPERTY(MockDevice *defaultDevice READ defaultDevice CONSTANT)
29+ Q_PROPERTY(bool valid
30+ READ valid
31+ WRITE setValid // only in mock
32+ NOTIFY validChanged)
29
33
30public:
34public:
31 explicit MockBiometryd(QObject *parent = 0);
35 explicit MockBiometryd(QObject *parent = 0);
32
36
33 MockDevice *defaultDevice() const;
37 MockDevice *defaultDevice() const;
34
38
35− Q_INVOKABLE void reset(bool devicePresent); // only in mock
39+ bool valid() const;
40+ void setValid(bool valid);
36
41
37Q_SIGNALS:
42Q_SIGNALS:
38− void defaultDeviceChanged();
43+ void validChanged();
39
44
40private:
45private:
41 MockDevice *m_device;
46 MockDevice *m_device;
47+ bool m_valid;
42};
48};
43
49
44#endif // MOCK_BIOMETRYD_H
50#endif // MOCK_BIOMETRYD_H
tests/qmltests/Greeter/tst_Greeter.qml+11−11
@@ -150,7 +150,7 @@ Item {
150 teaseSpy.clear();
150 teaseSpy.clear();
151 sessionStartedSpy.clear();
151 sessionStartedSpy.clear();
152 activeChangedSpy.clear();
152 activeChangedSpy.clear();
153− Biometryd.reset(false);
153+ Biometryd.valid = false;
154 AccountsService.enableFingerprintIdentification = false;
154 AccountsService.enableFingerprintIdentification = false;
155 viewShowMessageSpy.clear();
155 viewShowMessageSpy.clear();
156 viewShowPromptSpy.clear();
156 viewShowPromptSpy.clear();
@@ -565,7 +565,7 @@ Item {
565 }
565 }
566
566
567 function test_fingerprintSuccess() {
567 function test_fingerprintSuccess() {
568− Biometryd.reset(true);
568+ Biometryd.valid = true;
569 AccountsService.enableFingerprintIdentification = true;
569 AccountsService.enableFingerprintIdentification = true;
570 var index = selectUser("has-password");
570 var index = selectUser("has-password");
571
571
@@ -578,7 +578,7 @@ Item {
578 }
578 }
579
579
580 function test_fingerprintFailureMessage() {
580 function test_fingerprintFailureMessage() {
581− Biometryd.reset(true);
581+ Biometryd.valid = true;
582 AccountsService.enableFingerprintIdentification = true;
582 AccountsService.enableFingerprintIdentification = true;
583 var index = selectUser("has-password");
583 var index = selectUser("has-password");
584
584
@@ -592,7 +592,7 @@ Item {
592 }
592 }
593
593
594 function test_fingerprintTooManyFailures() {
594 function test_fingerprintTooManyFailures() {
595− Biometryd.reset(true);
595+ Biometryd.valid = true;
596 AccountsService.enableFingerprintIdentification = true;
596 AccountsService.enableFingerprintIdentification = true;
597 selectUser("has-password");
597 selectUser("has-password");
598
598
@@ -608,7 +608,7 @@ Item {
608 }
608 }
609
609
610 function test_fingerprintFailureCountReset() {
610 function test_fingerprintFailureCountReset() {
611− Biometryd.reset(true);
611+ Biometryd.valid = true;
612 AccountsService.enableFingerprintIdentification = true;
612 AccountsService.enableFingerprintIdentification = true;
613 selectUser("has-password");
613 selectUser("has-password");
614
614
@@ -629,7 +629,7 @@ Item {
629 }
629 }
630
630
631 function test_fingerprintWrongUid() {
631 function test_fingerprintWrongUid() {
632− Biometryd.reset(true);
632+ Biometryd.valid = true;
633 AccountsService.enableFingerprintIdentification = true;
633 AccountsService.enableFingerprintIdentification = true;
634 selectUser("has-password");
634 selectUser("has-password");
635
635
@@ -642,7 +642,7 @@ Item {
642 }
642 }
643
643
644 function test_fingerprintNotEnabled() {
644 function test_fingerprintNotEnabled() {
645− Biometryd.reset(true);
645+ Biometryd.valid = true;
646 selectUser("has-password");
646 selectUser("has-password");
647
647
648 var biometryd = findInvisibleChild(greeter, "biometryd");
648 var biometryd = findInvisibleChild(greeter, "biometryd");
@@ -660,21 +660,21 @@ Item {
660 AccountsService.enableFingerprintIdentification = true;
660 AccountsService.enableFingerprintIdentification = true;
661 selectUser("has-password");
661 selectUser("has-password");
662
662
663− verify(!Biometryd.defaultDevice);
663+ verify(!Biometryd.valid);
664
664
665 var biometryd = findInvisibleChild(greeter, "biometryd");
665 var biometryd = findInvisibleChild(greeter, "biometryd");
666 verify(!biometryd.operation);
666 verify(!biometryd.operation);
667
667
668− Biometryd.reset(true);
668+ Biometryd.valid = true;
669 verify(biometryd.operation);
669 verify(biometryd.operation);
670 verify(biometryd.operation.running);
670 verify(biometryd.operation.running);
671
671
672− Biometryd.reset(false);
672+ Biometryd.valid = false;
673 verify(!biometryd.operation);
673 verify(!biometryd.operation);
674 }
674 }
675
675
676 function test_fingerprintGreeterNotActive() {
676 function test_fingerprintGreeterNotActive() {
677− Biometryd.reset(true);
677+ Biometryd.valid = true;
678 AccountsService.enableFingerprintIdentification = true;
678 AccountsService.enableFingerprintIdentification = true;
679 selectUser("has-password");
679 selectUser("has-password");
680
680