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 <list> | 5 #include <list> |
6 | 6 |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/test/test_io_thread.h" | 8 #include "base/test/test_io_thread.h" |
9 #include "device/base/mock_device_client.h" | 9 #include "device/base/mock_device_client.h" |
10 #include "device/hid/mock_hid_service.h" | 10 #include "device/hid/mock_hid_service.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 }; | 30 }; |
31 | 31 |
32 class TestSignCallback { | 32 class TestSignCallback { |
33 public: | 33 public: |
34 TestSignCallback() | 34 TestSignCallback() |
35 : callback_(base::Bind(&TestSignCallback::ReceivedCallback, | 35 : callback_(base::Bind(&TestSignCallback::ReceivedCallback, |
36 base::Unretained(this))) {} | 36 base::Unretained(this))) {} |
37 ~TestSignCallback() {} | 37 ~TestSignCallback() {} |
38 | 38 |
39 void ReceivedCallback(U2fReturnCode status_code, | 39 void ReceivedCallback(U2fReturnCode status_code, |
40 std::vector<uint8_t> response) { | 40 const std::vector<uint8_t>& response) { |
41 response_ = std::make_pair(status_code, response); | 41 response_ = std::make_pair(status_code, response); |
42 closure_.Run(); | 42 closure_.Run(); |
43 } | 43 } |
44 | 44 |
45 std::pair<U2fReturnCode, std::vector<uint8_t>>& WaitForCallback() { | 45 std::pair<U2fReturnCode, std::vector<uint8_t>>& WaitForCallback() { |
46 closure_ = run_loop_.QuitClosure(); | 46 closure_ = run_loop_.QuitClosure(); |
47 run_loop_.Run(); | 47 run_loop_.Run(); |
48 return response_; | 48 return response_; |
49 } | 49 } |
50 | 50 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 std::pair<U2fReturnCode, std::vector<uint8_t>>& response = | 206 std::pair<U2fReturnCode, std::vector<uint8_t>>& response = |
207 cb.WaitForCallback(); | 207 cb.WaitForCallback(); |
208 EXPECT_EQ(U2fReturnCode::SUCCESS, response.first); | 208 EXPECT_EQ(U2fReturnCode::SUCCESS, response.first); |
209 // Device that responded had no correct keys, so a registration response is | 209 // Device that responded had no correct keys, so a registration response is |
210 // expected | 210 // expected |
211 ASSERT_LT(static_cast<size_t>(0), response.second.size()); | 211 ASSERT_LT(static_cast<size_t>(0), response.second.size()); |
212 EXPECT_EQ(static_cast<uint8_t>(MockU2fDevice::kRegister), response.second[0]); | 212 EXPECT_EQ(static_cast<uint8_t>(MockU2fDevice::kRegister), response.second[0]); |
213 } | 213 } |
214 | 214 |
215 } // namespace device | 215 } // namespace device |
OLD | NEW |