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

Side by Side Diff: device/u2f/u2f_register_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, 7 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_register.cc ('k') | device/u2f/u2f_request.h » ('j') | 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 20 matching lines...) Expand all
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
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
OLDNEW
« no previous file with comments | « device/u2f/u2f_register.cc ('k') | device/u2f/u2f_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698