Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROMEOS_DBUS_BIOD_TEST_UTILS_H_ | |
| 6 #define CHROMEOS_DBUS_BIOD_TEST_UTILS_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "chromeos/dbus/biod/biod_client.h" | |
| 13 | |
| 14 namespace dbus { | |
| 15 class ObjectPath; | |
| 16 } | |
| 17 | |
| 18 namespace chromeos { | |
| 19 namespace test_utils { | |
| 20 | |
| 21 // Copies |src_path| to |dest_path|. | |
| 22 void CopyObjectPath(dbus::ObjectPath* dest_path, | |
| 23 const dbus::ObjectPath& src_path); | |
| 24 | |
| 25 // Copies |src_object_paths| to |dst_object_paths|. | |
| 26 void CopyObjectPathArray(std::vector<dbus::ObjectPath>* dest_object_paths, | |
| 27 const std::vector<dbus::ObjectPath>& src_object_paths); | |
| 28 | |
| 29 // Copies |src_str| to |dest_str|. | |
| 30 void CopyString(std::string* dest_str, const std::string& src_str); | |
| 31 | |
| 32 // Copies |src_status| to |dest_status|. | |
| 33 void CopyDBusMethodCallStatus(DBusMethodCallStatus* dest_status, | |
| 34 DBusMethodCallStatus src_status); | |
| 35 | |
| 36 // Copies |src_type| to |dest_type|. | |
| 37 void CopyBiometricType(biod::BiometricType* dest_type, | |
| 38 biod::BiometricType src_type); | |
| 39 | |
| 40 // Implementation of BiodClient::Observer for testing. | |
| 41 class TestBiodObserver : public BiodClient::Observer { | |
| 42 public: | |
| 43 TestBiodObserver(); | |
| 44 ~TestBiodObserver() override; | |
| 45 | |
| 46 int num_complete_enroll_scans_received() const { | |
| 47 return num_complete_enroll_scans_received_; | |
| 48 } | |
| 49 int num_incomplete_enroll_scans_received() const { | |
| 50 return num_incomplete_enroll_scans_received_; | |
| 51 } | |
| 52 int num_matched_auth_scans_received() const { | |
| 53 return num_matched_auth_scans_received_; | |
| 54 } | |
| 55 int num_unmatched_auth_scans_received() const { | |
| 56 return num_unmatched_auth_scans_received_; | |
| 57 } | |
| 58 int num_failures_received() const { return num_failures_received_; } | |
| 59 | |
| 60 // Check's if the last attempt received in BiodAuthScanDoneReceived is equal | |
|
Daniel Erat
2017/04/11 17:50:14
nit: s/Check's/Check/
sammiequon
2017/04/11 18:37:50
Done.
| |
| 61 // to |expected_matches|. | |
| 62 bool CheckExpectedLastAttemptMatches(const AuthScanMatches& expected_matches); | |
| 63 int NumEnrollScansReceived() const; | |
| 64 int NumAuthScansReceived() const; | |
| 65 | |
| 66 // BiodClient::Observer: | |
| 67 void BiodServiceRestarted() override; | |
| 68 void BiodEnrollScanDoneReceived(biod::ScanResult scan_result, | |
| 69 bool is_complete) override; | |
| 70 void BiodAuthScanDoneReceived(biod::ScanResult scan_result, | |
| 71 const AuthScanMatches& matches) override; | |
| 72 void BiodSessionFailedReceived() override; | |
| 73 | |
| 74 private: | |
| 75 int num_complete_enroll_scans_received_ = 0; | |
| 76 int num_incomplete_enroll_scans_received_ = 0; | |
| 77 int num_matched_auth_scans_received_ = 0; | |
| 78 int num_unmatched_auth_scans_received_ = 0; | |
| 79 int num_failures_received_ = 0; | |
| 80 | |
| 81 // When auth scan is received, store the result. | |
| 82 AuthScanMatches last_auth_scan_matches_; | |
| 83 | |
| 84 DISALLOW_COPY_AND_ASSIGN(TestBiodObserver); | |
| 85 }; | |
| 86 | |
| 87 } // namespace test_utils | |
| 88 } // chromeos | |
| 89 | |
| 90 #endif // CHROMEOS_DBUS_BIOD_TEST_UTILS_H_ | |
| OLD | NEW |