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 20 matching lines...) Expand all Loading... |
31 }; | 31 }; |
32 | 32 |
33 class TestRegisterCallback { | 33 class TestRegisterCallback { |
34 public: | 34 public: |
35 TestRegisterCallback() | 35 TestRegisterCallback() |
36 : callback_(base::Bind(&TestRegisterCallback::ReceivedCallback, | 36 : callback_(base::Bind(&TestRegisterCallback::ReceivedCallback, |
37 base::Unretained(this))) {} | 37 base::Unretained(this))) {} |
38 ~TestRegisterCallback() {} | 38 ~TestRegisterCallback() {} |
39 | 39 |
40 void ReceivedCallback(U2fReturnCode status_code, | 40 void ReceivedCallback(U2fReturnCode status_code, |
41 std::vector<uint8_t> response) { | 41 const std::vector<uint8_t>& response) { |
42 response_ = std::make_pair(status_code, response); | 42 response_ = std::make_pair(status_code, response); |
43 closure_.Run(); | 43 closure_.Run(); |
44 } | 44 } |
45 | 45 |
46 std::pair<U2fReturnCode, std::vector<uint8_t>>& WaitForCallback() { | 46 std::pair<U2fReturnCode, std::vector<uint8_t>>& WaitForCallback() { |
47 closure_ = run_loop_.QuitClosure(); | 47 closure_ = run_loop_.QuitClosure(); |
48 run_loop_.Run(); | 48 run_loop_.Run(); |
49 return response_; | 49 return response_; |
50 } | 50 } |
51 | 51 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 request->AddDeviceForTesting(std::move(device0)); | 121 request->AddDeviceForTesting(std::move(device0)); |
122 request->AddDeviceForTesting(std::move(device1)); | 122 request->AddDeviceForTesting(std::move(device1)); |
123 std::pair<U2fReturnCode, std::vector<uint8_t>>& response = | 123 std::pair<U2fReturnCode, std::vector<uint8_t>>& response = |
124 cb.WaitForCallback(); | 124 cb.WaitForCallback(); |
125 EXPECT_EQ(U2fReturnCode::SUCCESS, response.first); | 125 EXPECT_EQ(U2fReturnCode::SUCCESS, response.first); |
126 ASSERT_LT(static_cast<size_t>(0), response.second.size()); | 126 ASSERT_LT(static_cast<size_t>(0), response.second.size()); |
127 EXPECT_EQ(static_cast<uint8_t>(MockU2fDevice::kRegister), response.second[0]); | 127 EXPECT_EQ(static_cast<uint8_t>(MockU2fDevice::kRegister), response.second[0]); |
128 } | 128 } |
129 | 129 |
130 } // namespace device | 130 } // namespace device |
OLD | NEW |