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/scoped_task_environment.h" |
8 #include "base/test/test_io_thread.h" | 9 #include "base/test/test_io_thread.h" |
9 #include "device/base/mock_device_client.h" | 10 #include "device/base/mock_device_client.h" |
10 #include "device/hid/mock_hid_service.h" | 11 #include "device/hid/mock_hid_service.h" |
11 #include "device/test/test_device_client.h" | 12 #include "device/test/test_device_client.h" |
12 #include "mock_u2f_device.h" | 13 #include "mock_u2f_device.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "u2f_sign.h" | 15 #include "u2f_sign.h" |
15 | 16 |
16 namespace device { | 17 namespace device { |
17 class U2fSignTest : public testing::Test { | 18 class U2fSignTest : public testing::Test { |
18 public: | 19 public: |
19 U2fSignTest() : io_thread_(base::TestIOThread::kAutoStart) {} | 20 U2fSignTest() |
| 21 : scoped_task_environment_( |
| 22 base::test::ScopedTaskEnvironment::MainThreadType::UI), |
| 23 io_thread_(base::TestIOThread::kAutoStart) {} |
20 | 24 |
21 void SetUp() override { | 25 void SetUp() override { |
22 MockHidService* hid_service = device_client_.hid_service(); | 26 MockHidService* hid_service = device_client_.hid_service(); |
23 hid_service->FirstEnumerationComplete(); | 27 hid_service->FirstEnumerationComplete(); |
24 } | 28 } |
25 | 29 |
26 protected: | 30 protected: |
27 base::MessageLoopForUI message_loop_; | 31 base::test::ScopedTaskEnvironment scoped_task_environment_; |
28 base::TestIOThread io_thread_; | 32 base::TestIOThread io_thread_; |
29 device::MockDeviceClient device_client_; | 33 device::MockDeviceClient device_client_; |
30 }; | 34 }; |
31 | 35 |
32 class TestSignCallback { | 36 class TestSignCallback { |
33 public: | 37 public: |
34 TestSignCallback() | 38 TestSignCallback() |
35 : callback_(base::Bind(&TestSignCallback::ReceivedCallback, | 39 : callback_(base::Bind(&TestSignCallback::ReceivedCallback, |
36 base::Unretained(this))) {} | 40 base::Unretained(this))) {} |
37 ~TestSignCallback() {} | 41 ~TestSignCallback() {} |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 std::pair<U2fReturnCode, std::vector<uint8_t>>& response = | 210 std::pair<U2fReturnCode, std::vector<uint8_t>>& response = |
207 cb.WaitForCallback(); | 211 cb.WaitForCallback(); |
208 EXPECT_EQ(U2fReturnCode::SUCCESS, response.first); | 212 EXPECT_EQ(U2fReturnCode::SUCCESS, response.first); |
209 // Device that responded had no correct keys, so a registration response is | 213 // Device that responded had no correct keys, so a registration response is |
210 // expected | 214 // expected |
211 ASSERT_LT(static_cast<size_t>(0), response.second.size()); | 215 ASSERT_LT(static_cast<size_t>(0), response.second.size()); |
212 EXPECT_EQ(static_cast<uint8_t>(MockU2fDevice::kRegister), response.second[0]); | 216 EXPECT_EQ(static_cast<uint8_t>(MockU2fDevice::kRegister), response.second[0]); |
213 } | 217 } |
214 | 218 |
215 } // namespace device | 219 } // namespace device |
OLD | NEW |