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 AuthScanMatches last_auth_scan_matches() const { | |
Daniel Erat
2017/04/11 18:45:21
can this return a const ref instead of a copy?
sammiequon
2017/04/11 18:55:19
Done.
| |
60 return last_auth_scan_matches_; | |
61 } | |
62 | |
63 int NumEnrollScansReceived() const; | |
64 int NumAuthScansReceived() const; | |
65 | |
66 void ResetAllCounts(); | |
67 | |
68 // BiodClient::Observer: | |
69 void BiodServiceRestarted() override; | |
70 void BiodEnrollScanDoneReceived(biod::ScanResult scan_result, | |
71 bool is_complete) override; | |
72 void BiodAuthScanDoneReceived(biod::ScanResult scan_result, | |
73 const AuthScanMatches& matches) override; | |
74 void BiodSessionFailedReceived() override; | |
75 | |
76 private: | |
77 int num_complete_enroll_scans_received_ = 0; | |
78 int num_incomplete_enroll_scans_received_ = 0; | |
79 int num_matched_auth_scans_received_ = 0; | |
80 int num_unmatched_auth_scans_received_ = 0; | |
81 int num_failures_received_ = 0; | |
82 | |
83 // When auth scan is received, store the result. | |
84 AuthScanMatches last_auth_scan_matches_; | |
85 | |
86 DISALLOW_COPY_AND_ASSIGN(TestBiodObserver); | |
87 }; | |
88 | |
89 } // namespace test_utils | |
90 } // chromeos | |
91 | |
92 #endif // CHROMEOS_DBUS_BIOD_TEST_UTILS_H_ | |
OLD | NEW |