Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: device/u2f/u2f_sign_unittest.cc

Issue 2839043002: Pass u2f message callback vector as a const reference (Closed)
Patch Set: Change response callback to const ref Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/u2f/u2f_sign.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « device/u2f/u2f_sign.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698