Chromium Code Reviews| Index: chromeos/dbus/biod/fake_biod_client.h |
| diff --git a/chromeos/dbus/biod/fake_biod_client.h b/chromeos/dbus/biod/fake_biod_client.h |
| index e4fd8410ce8f81f8ca952890d82e4a988af9cea6..b6c0be0a961db554ddf5a0e7e1848c702e37f5bd 100644 |
| --- a/chromeos/dbus/biod/fake_biod_client.h |
| +++ b/chromeos/dbus/biod/fake_biod_client.h |
| @@ -5,6 +5,9 @@ |
| #ifndef CHROMEOS_DBUS_BIOD_FAKE_BIOD_CLIENT_H_ |
| #define CHROMEOS_DBUS_BIOD_FAKE_BIOD_CLIENT_H_ |
| +#include <map> |
| +#include <string> |
| + |
| #include "base/macros.h" |
| #include "base/observer_list.h" |
| #include "chromeos/chromeos_export.h" |
| @@ -17,17 +20,41 @@ class ObjectPath; |
| namespace chromeos { |
| -// A fake implementation of BiodClient. |
| +class FakeBiodClientTest; |
| + |
| +// A fake implementation of BiodClient. It emulates the real Biod daemon by |
| +// providing the same API and storaging fingerprints locally. A fingerprint is |
|
Daniel Erat
2017/04/07 18:27:56
nit: storing
sammiequon
2017/04/07 20:45:50
Done.
|
| +// represented by a string. During enrollment, fake enrollments are sent as |
| +// chars. If they are successful they get appended to the current fingerprint, |
| +// until and compeleted enroll scan is sent. An attempt scan is also sent with a |
|
Daniel Erat
2017/04/07 18:27:56
nit: "until a completed enroll ..."
sammiequon
2017/04/07 20:45:50
Done.
|
| +// char. If that char matches any char in the stored fingerprint string, it is |
| +// considered a match. |
| class CHROMEOS_EXPORT FakeBiodClient : public BiodClient { |
| public: |
| + // The current session of fingerprint storage. The session determines which |
| + // events will be sent from user finger touches. |
| + enum class FingerprintSession { |
| + NONE = 0, |
|
Daniel Erat
2017/04/07 18:27:56
you don't need the '= 0' here
sammiequon
2017/04/07 20:45:50
Done.
|
| + ENROLL, |
| + AUTH, |
| + }; |
| + |
| FakeBiodClient(); |
| ~FakeBiodClient() override; |
| // Emulates the biod daemon by sending events which the daemon normally sends. |
| // Notifies |observers_| about various events. These will be used in tests. |
| - void SendEnrollScanDone(biod::ScanResult type_result, bool is_complete); |
| - void SendAuthScanDone(biod::ScanResult type_result, |
| - const AuthScanMatches& matches); |
| + |
| + // Emulates a scan that occurs during enrolling a new fingerprint. |
| + // |fingerprint| is the fake data of the finger as a char. If |is_complete| is |
|
Daniel Erat
2017/04/07 18:27:56
this char/string interface seems a bit odd. why no
sammiequon
2017/04/07 20:45:50
I could do that, but I am wondering why the vector
Daniel Erat
2017/04/07 20:57:25
yes, my main thought was that strings are much nic
sammiequon
2017/04/07 22:43:55
Acknowledged.
|
| + // true the enroll session is finished, and the record is stored. |
| + void SendEnrollScanDone(char fingerprint, |
| + biod::ScanResult type_result, |
| + bool is_complete); |
| + // Emulates a scan that occurs during a authentication session. |fingerprint| |
| + // is a char which represents the finger, and will be compared with all the |
| + // stored fingerprints. |
| + void SendAuthScanDone(char fingerprint, biod::ScanResult type_result); |
| void SendSessionFailed(); |
| // BiodClient: |
| @@ -52,7 +79,37 @@ class CHROMEOS_EXPORT FakeBiodClient : public BiodClient { |
| void RequestRecordLabel(const dbus::ObjectPath& record_path, |
| const LabelCallback& callback) override; |
| + // Clears and stored and current records from the fake storage. |
|
Daniel Erat
2017/04/07 18:27:56
s/and/all/
sammiequon
2017/04/07 20:45:50
Done.
|
| + void Reset(); |
| + |
| private: |
| + friend FakeBiodClientTest; |
| + |
| + // FakeRecord is the definition of a fake stored fingerprint template. |
| + struct FakeRecord { |
| + std::string user_id; |
| + std::string label; |
| + // A fake fingerprint is a string which consists of all the chars which were |
| + // "pressed" during the enroll session. |
| + std::string fake_fingerprint; |
| + }; |
| + |
| + // The stored fingerprints. |
| + std::map<dbus::ObjectPath, std::unique_ptr<FakeRecord>> records_; |
| + |
| + // Current record in process of getting enrolled and its path. These are |
| + // assigned at the start of an enroll session and freed when the enroll |
| + // session is finished or cancelled. |
| + std::unique_ptr<dbus::ObjectPath> current_record_path_; |
|
Daniel Erat
2017/04/07 18:27:56
you don't need unique_ptr; just use an empty path
sammiequon
2017/04/07 20:45:50
Done.
|
| + std::unique_ptr<FakeRecord> current_record_; |
| + |
| + // Unique indentifier that gets updated each time an enroll session is started |
| + // to ensure each record is stored at a different path. |
| + int next_record_unique_id_ = 1; |
| + |
| + // The current session of the fake storage. |
| + FingerprintSession current_session_ = FingerprintSession::NONE; |
| + |
| base::ObserverList<Observer> observers_; |
| DISALLOW_COPY_AND_ASSIGN(FakeBiodClient); |