Index: chromeos/dbus/biod/biod_test_utils.h |
diff --git a/chromeos/dbus/biod/biod_test_utils.h b/chromeos/dbus/biod/biod_test_utils.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1320ad22a402c4980f167671da9403abdbcac147 |
--- /dev/null |
+++ b/chromeos/dbus/biod/biod_test_utils.h |
@@ -0,0 +1,87 @@ |
+// 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_BIOD_TEST_UTILS_H_ |
Daniel Erat
2017/04/07 23:40:55
consider renaming this file to test_utils to match
sammiequon
2017/04/11 17:11:37
Done.
|
+#define CHROMEOS_DBUS_BIOD_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 { |
+ |
+void CopyObjectPath(dbus::ObjectPath* dest_path, |
Daniel Erat
2017/04/07 23:40:55
add brief comments to all of these like:
// Cop
sammiequon
2017/04/08 00:43:32
Done.
|
+ const dbus::ObjectPath& src_path); |
+ |
+void CopyObjectPathArray(std::vector<dbus::ObjectPath>* dest_object_paths, |
+ const std::vector<dbus::ObjectPath>& src_object_paths); |
+ |
+void CopyNumRecords(int* out_num, |
+ const std::vector<dbus::ObjectPath>& object_path_array); |
+ |
+void CopyLabel(std::string* expected_label, const std::string& src_label); |
Daniel Erat
2017/04/07 23:40:55
CopyString? it's not label-specific.
sammiequon
2017/04/08 00:43:32
Done.
|
+ |
+// Implementation of BiodClient::Observer for testing. |
+class TestBiodObserver : public BiodClient::Observer { |
+ public: |
+ TestBiodObserver(); |
+ ~TestBiodObserver() override; |
+ |
+ bool CheckExpectedLastAttemptMatches(const AuthScanMatches& expected_matches); |
Daniel Erat
2017/04/07 23:40:55
nit: document what this dose; also move non-inline
sammiequon
2017/04/08 00:43:32
Done.
|
+ |
+ int NumEnrollScansReceived() const; |
+ |
+ int num_complete_enroll_scans_received() const { |
+ return num_complete_enroll_scans_received_; |
+ } |
+ |
Daniel Erat
2017/04/07 23:40:55
nit: remove blank lines between accessors
sammiequon
2017/04/08 00:43:32
Done.
|
+ int num_incomplete_enroll_scans_received() const { |
+ return num_incomplete_enroll_scans_received_; |
+ } |
+ |
+ int NumAuthScansReceived() const; |
+ |
+ 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_; } |
+ |
+ // BiodClient::Observer: |
+ void BiodServiceRestarted() override {} |
Daniel Erat
2017/04/07 23:40:55
move this empty impl to the .cc file: https://www.
sammiequon
2017/04/08 00:43:32
Done.
|
+ void BiodEnrollScanDoneReceived(biod::ScanResult scan_result, |
+ bool is_complete) override; |
+ void BiodAuthScanDoneReceived(biod::ScanResult scan_result, |
+ const AuthScanMatches& matches) override; |
+ |
Daniel Erat
2017/04/07 23:40:55
nit: delete extra blank line
sammiequon
2017/04/08 00:43:32
Done.
|
+ 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_BIOD_TEST_UTILS_H_ |