OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "services/device/fingerprint/fingerprint_chromeos.h" | 5 #include "services/device/fingerprint/fingerprint_chromeos.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "chromeos/dbus/biod/fake_biod_client.h" | 10 #include "chromeos/dbus/biod/fake_biod_client.h" |
11 #include "chromeos/dbus/dbus_thread_manager.h" | 11 #include "chromeos/dbus/dbus_thread_manager.h" |
12 #include "mojo/public/cpp/bindings/binding.h" | 12 #include "mojo/public/cpp/bindings/binding.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace device { | 15 namespace device { |
16 | 16 |
17 class FakeFingerprintObserver : public mojom::FingerprintObserver { | 17 class FakeFingerprintObserver : public mojom::FingerprintObserver { |
18 public: | 18 public: |
19 explicit FakeFingerprintObserver(mojom::FingerprintObserverRequest request) | 19 explicit FakeFingerprintObserver(mojom::FingerprintObserverRequest request) |
20 : binding_(this, std::move(request)) {} | 20 : binding_(this, std::move(request)) {} |
21 ~FakeFingerprintObserver() override {} | 21 ~FakeFingerprintObserver() override {} |
22 | 22 |
23 // mojom::FingerprintObserver | 23 // mojom::FingerprintObserver |
24 void OnRestarted() override { restarts_++; } | 24 void OnRestarted() override { restarts_++; } |
25 | 25 |
26 void OnEnrollScanDone(uint32_t scan_result, bool is_complete) override { | 26 void OnEnrollScanDone(uint32_t scan_result, |
27 bool is_complete, | |
28 int32_t percent_complete) override { | |
27 enroll_scan_dones_++; | 29 enroll_scan_dones_++; |
28 } | 30 } |
29 | 31 |
30 void OnAuthScanDone( | 32 void OnAuthScanDone( |
31 uint32_t scan_result, | 33 uint32_t scan_result, |
32 const std::unordered_map<std::string, std::vector<std::string>>& matches) | 34 const std::unordered_map<std::string, std::vector<std::string>>& matches) |
33 override { | 35 override { |
34 auth_scan_dones_++; | 36 auth_scan_dones_++; |
35 } | 37 } |
36 | 38 |
(...skipping 26 matching lines...) Expand all Loading... | |
63 fingerprint_ = base::WrapUnique(new FingerprintChromeOS()); | 65 fingerprint_ = base::WrapUnique(new FingerprintChromeOS()); |
64 } | 66 } |
65 ~FingerprintChromeOSTest() override {} | 67 ~FingerprintChromeOSTest() override {} |
66 | 68 |
67 FingerprintChromeOS* fingerprint() { return fingerprint_.get(); } | 69 FingerprintChromeOS* fingerprint() { return fingerprint_.get(); } |
68 | 70 |
69 void GenerateRestartSignal() { fingerprint_->BiodServiceRestarted(); } | 71 void GenerateRestartSignal() { fingerprint_->BiodServiceRestarted(); } |
70 | 72 |
71 void GenerateEnrollScanDoneSignal() { | 73 void GenerateEnrollScanDoneSignal() { |
72 std::string fake_fingerprint_data; | 74 std::string fake_fingerprint_data; |
73 fake_biod_client_->SendEnrollScanDone(fake_fingerprint_data, | 75 fake_biod_client_->SendEnrollScanDone( |
74 biod::SCAN_RESULT_SUCCESS, true); | 76 fake_fingerprint_data, biod::SCAN_RESULT_SUCCESS, true, |
77 -1 /* percent_complete not supported*/); | |
Daniel Erat
2017/05/03 20:47:34
drop the "not supported" here; we usually just put
xiaoyinh(OOO Sep 11-29)
2017/05/04 00:29:51
Done.
| |
75 } | 78 } |
76 | 79 |
77 void GenerateAuthScanDoneSignal() { | 80 void GenerateAuthScanDoneSignal() { |
78 std::string fake_fingerprint_data; | 81 std::string fake_fingerprint_data; |
79 fake_biod_client_->SendAuthScanDone(fake_fingerprint_data, | 82 fake_biod_client_->SendAuthScanDone(fake_fingerprint_data, |
80 biod::SCAN_RESULT_SUCCESS); | 83 biod::SCAN_RESULT_SUCCESS); |
81 } | 84 } |
82 | 85 |
83 void GenerateSessionFailedSignal() { fake_biod_client_->SendSessionFailed(); } | 86 void GenerateSessionFailedSignal() { fake_biod_client_->SendSessionFailed(); } |
84 | 87 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 GenerateAuthScanDoneSignal(); | 124 GenerateAuthScanDoneSignal(); |
122 base::RunLoop().RunUntilIdle(); | 125 base::RunLoop().RunUntilIdle(); |
123 EXPECT_EQ(observer.auth_scan_dones(), 1); | 126 EXPECT_EQ(observer.auth_scan_dones(), 1); |
124 | 127 |
125 GenerateSessionFailedSignal(); | 128 GenerateSessionFailedSignal(); |
126 base::RunLoop().RunUntilIdle(); | 129 base::RunLoop().RunUntilIdle(); |
127 EXPECT_EQ(observer.session_failures(), 1); | 130 EXPECT_EQ(observer.session_failures(), 1); |
128 } | 131 } |
129 | 132 |
130 } // namespace device | 133 } // namespace device |
OLD | NEW |