on xenial help sign in
Support Biometryd.valid
commitec51140ee6424e76f1316bde9b9d266ae549f9d1 authorMichael Terry <michael.terry@canonical.com> dateFri 27 May 2016, 09:31 (10 years ago) parentbeb293c
4 files changed+32−25
qml/Greeter/Greeter.qml+1−1 tests/mocks/Biometryd/MockBiometryd.cpp+11−10 tests/mocks/Biometryd/MockBiometryd.h+9−3 tests/qmltests/Greeter/tst_Greeter.qml+11−11
qml/Greeter/Greeter.qml+1−1
@@ -488,7 +488,7 @@ Showable {
488488
489489 property var operation: null
490490 readonly property bool idEnabled: root.active &&
491− Biometryd.defaultDevice &&
491+ Biometryd.valid &&
492492 AccountsService.enableFingerprintIdentification
493493
494494 function cancelOperation() {
tests/mocks/Biometryd/MockBiometryd.cpp+11−10
@@ -19,7 +19,8 @@
1919
2020MockBiometryd::MockBiometryd(QObject *parent)
2121 : QObject(parent)
22− , m_device(nullptr)
22+ , m_device(new MockDevice(this))
23+ , m_valid(false)
2324{
2425}
2526
@@ -28,15 +29,15 @@ MockDevice *MockBiometryd::defaultDevice() const
2829 return m_device;
2930}
3031
31−void MockBiometryd::reset(bool devicePresent)
32+bool MockBiometryd::valid() const
3233{
33− if (m_device) {
34− delete m_device;
35− m_device = nullptr;
36− }
37−
38− if (devicePresent)
39− m_device = new MockDevice(this);
34+ return m_valid;
35+}
4036
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+ }
4243}
tests/mocks/Biometryd/MockBiometryd.h+9−3
@@ -25,20 +25,26 @@ class MockBiometryd : public QObject
2525{
2626 Q_OBJECT
2727 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)
2933
3034public:
3135 explicit MockBiometryd(QObject *parent = 0);
3236
3337 MockDevice *defaultDevice() const;
3438
35− Q_INVOKABLE void reset(bool devicePresent); // only in mock
39+ bool valid() const;
40+ void setValid(bool valid);
3641
3742Q_SIGNALS:
38− void defaultDeviceChanged();
43+ void validChanged();
3944
4045private:
4146 MockDevice *m_device;
47+ bool m_valid;
4248};
4349
4450#endif // MOCK_BIOMETRYD_H
tests/qmltests/Greeter/tst_Greeter.qml+11−11
@@ -150,7 +150,7 @@ Item {
150150 teaseSpy.clear();
151151 sessionStartedSpy.clear();
152152 activeChangedSpy.clear();
153− Biometryd.reset(false);
153+ Biometryd.valid = false;
154154 AccountsService.enableFingerprintIdentification = false;
155155 viewShowMessageSpy.clear();
156156 viewShowPromptSpy.clear();
@@ -565,7 +565,7 @@ Item {
565565 }
566566
567567 function test_fingerprintSuccess() {
568− Biometryd.reset(true);
568+ Biometryd.valid = true;
569569 AccountsService.enableFingerprintIdentification = true;
570570 var index = selectUser("has-password");
571571
@@ -578,7 +578,7 @@ Item {
578578 }
579579
580580 function test_fingerprintFailureMessage() {
581− Biometryd.reset(true);
581+ Biometryd.valid = true;
582582 AccountsService.enableFingerprintIdentification = true;
583583 var index = selectUser("has-password");
584584
@@ -592,7 +592,7 @@ Item {
592592 }
593593
594594 function test_fingerprintTooManyFailures() {
595− Biometryd.reset(true);
595+ Biometryd.valid = true;
596596 AccountsService.enableFingerprintIdentification = true;
597597 selectUser("has-password");
598598
@@ -608,7 +608,7 @@ Item {
608608 }
609609
610610 function test_fingerprintFailureCountReset() {
611− Biometryd.reset(true);
611+ Biometryd.valid = true;
612612 AccountsService.enableFingerprintIdentification = true;
613613 selectUser("has-password");
614614
@@ -629,7 +629,7 @@ Item {
629629 }
630630
631631 function test_fingerprintWrongUid() {
632− Biometryd.reset(true);
632+ Biometryd.valid = true;
633633 AccountsService.enableFingerprintIdentification = true;
634634 selectUser("has-password");
635635
@@ -642,7 +642,7 @@ Item {
642642 }
643643
644644 function test_fingerprintNotEnabled() {
645− Biometryd.reset(true);
645+ Biometryd.valid = true;
646646 selectUser("has-password");
647647
648648 var biometryd = findInvisibleChild(greeter, "biometryd");
@@ -660,21 +660,21 @@ Item {
660660 AccountsService.enableFingerprintIdentification = true;
661661 selectUser("has-password");
662662
663− verify(!Biometryd.defaultDevice);
663+ verify(!Biometryd.valid);
664664
665665 var biometryd = findInvisibleChild(greeter, "biometryd");
666666 verify(!biometryd.operation);
667667
668− Biometryd.reset(true);
668+ Biometryd.valid = true;
669669 verify(biometryd.operation);
670670 verify(biometryd.operation.running);
671671
672− Biometryd.reset(false);
672+ Biometryd.valid = false;
673673 verify(!biometryd.operation);
674674 }
675675
676676 function test_fingerprintGreeterNotActive() {
677− Biometryd.reset(true);
677+ Biometryd.valid = true;
678678 AccountsService.enableFingerprintIdentification = true;
679679 selectUser("has-password");
680680