Index: chromeos/dbus/biod/test_utils.h |
diff --git a/chromeos/dbus/biod/test_utils.h b/chromeos/dbus/biod/test_utils.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..68e64ce44d7e1f363a2f7333782c94c3714cd933 |
--- /dev/null |
+++ b/chromeos/dbus/biod/test_utils.h |
@@ -0,0 +1,92 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROMEOS_DBUS_BIOD_TEST_UTILS_H_ |
+#define CHROMEOS_DBUS_BIOD_TEST_UTILS_H_ |
+ |
+#include <string> |
+#include <vector> |
+ |
+#include "base/macros.h" |
+#include "chromeos/dbus/biod/biod_client.h" |
+ |
+namespace dbus { |
+class ObjectPath; |
+} |
+ |
+namespace chromeos { |
+namespace test_utils { |
+ |
+// Copies |src_path| to |dest_path|. |
+void CopyObjectPath(dbus::ObjectPath* dest_path, |
+ const dbus::ObjectPath& src_path); |
+ |
+// Copies |src_object_paths| to |dst_object_paths|. |
+void CopyObjectPathArray(std::vector<dbus::ObjectPath>* dest_object_paths, |
+ const std::vector<dbus::ObjectPath>& src_object_paths); |
+ |
+// Copies |src_str| to |dest_str|. |
+void CopyString(std::string* dest_str, const std::string& src_str); |
+ |
+// Copies |src_status| to |dest_status|. |
+void CopyDBusMethodCallStatus(DBusMethodCallStatus* dest_status, |
+ DBusMethodCallStatus src_status); |
+ |
+// Copies |src_type| to |dest_type|. |
+void CopyBiometricType(biod::BiometricType* dest_type, |
+ biod::BiometricType src_type); |
+ |
+// Implementation of BiodClient::Observer for testing. |
+class TestBiodObserver : public BiodClient::Observer { |
+ public: |
+ TestBiodObserver(); |
+ ~TestBiodObserver() override; |
+ |
+ int num_complete_enroll_scans_received() const { |
+ return num_complete_enroll_scans_received_; |
+ } |
+ int num_incomplete_enroll_scans_received() const { |
+ return num_incomplete_enroll_scans_received_; |
+ } |
+ int num_matched_auth_scans_received() const { |
+ return num_matched_auth_scans_received_; |
+ } |
+ int num_unmatched_auth_scans_received() const { |
+ return num_unmatched_auth_scans_received_; |
+ } |
+ int num_failures_received() const { return num_failures_received_; } |
+ const AuthScanMatches& last_auth_scan_matches() const { |
+ return last_auth_scan_matches_; |
+ } |
+ |
+ int NumEnrollScansReceived() const; |
+ int NumAuthScansReceived() const; |
+ |
+ void ResetAllCounts(); |
+ |
+ // BiodClient::Observer: |
+ void BiodServiceRestarted() override; |
+ void BiodEnrollScanDoneReceived(biod::ScanResult scan_result, |
+ bool is_complete) override; |
+ void BiodAuthScanDoneReceived(biod::ScanResult scan_result, |
+ const AuthScanMatches& matches) override; |
+ void BiodSessionFailedReceived() override; |
+ |
+ private: |
+ int num_complete_enroll_scans_received_ = 0; |
+ int num_incomplete_enroll_scans_received_ = 0; |
+ int num_matched_auth_scans_received_ = 0; |
+ int num_unmatched_auth_scans_received_ = 0; |
+ int num_failures_received_ = 0; |
+ |
+ // When auth scan is received, store the result. |
+ AuthScanMatches last_auth_scan_matches_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(TestBiodObserver); |
+}; |
+ |
+} // namespace test_utils |
+} // chromeos |
+ |
+#endif // CHROMEOS_DBUS_BIOD_TEST_UTILS_H_ |