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_register.h" | 15 #include "u2f_register.h" |
15 | 16 |
16 namespace device { | 17 namespace device { |
17 | 18 |
18 class U2fRegisterTest : public testing::Test { | 19 class U2fRegisterTest : public testing::Test { |
19 public: | 20 public: |
20 U2fRegisterTest() : io_thread_(base::TestIOThread::kAutoStart) {} | 21 U2fRegisterTest() |
| 22 : scoped_task_environment_( |
| 23 base::test::ScopedTaskEnvironment::MainThreadType::UI), |
| 24 io_thread_(base::TestIOThread::kAutoStart) {} |
21 | 25 |
22 void SetUp() override { | 26 void SetUp() override { |
23 MockHidService* hid_service = device_client_.hid_service(); | 27 MockHidService* hid_service = device_client_.hid_service(); |
24 hid_service->FirstEnumerationComplete(); | 28 hid_service->FirstEnumerationComplete(); |
25 } | 29 } |
26 | 30 |
27 protected: | 31 protected: |
28 base::MessageLoopForUI message_loop_; | 32 base::test::ScopedTaskEnvironment scoped_task_environment_; |
29 base::TestIOThread io_thread_; | 33 base::TestIOThread io_thread_; |
30 device::MockDeviceClient device_client_; | 34 device::MockDeviceClient device_client_; |
31 }; | 35 }; |
32 | 36 |
33 class TestRegisterCallback { | 37 class TestRegisterCallback { |
34 public: | 38 public: |
35 TestRegisterCallback() | 39 TestRegisterCallback() |
36 : callback_(base::Bind(&TestRegisterCallback::ReceivedCallback, | 40 : callback_(base::Bind(&TestRegisterCallback::ReceivedCallback, |
37 base::Unretained(this))) {} | 41 base::Unretained(this))) {} |
38 ~TestRegisterCallback() {} | 42 ~TestRegisterCallback() {} |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 request->AddDeviceForTesting(std::move(device0)); | 125 request->AddDeviceForTesting(std::move(device0)); |
122 request->AddDeviceForTesting(std::move(device1)); | 126 request->AddDeviceForTesting(std::move(device1)); |
123 std::pair<U2fReturnCode, std::vector<uint8_t>>& response = | 127 std::pair<U2fReturnCode, std::vector<uint8_t>>& response = |
124 cb.WaitForCallback(); | 128 cb.WaitForCallback(); |
125 EXPECT_EQ(U2fReturnCode::SUCCESS, response.first); | 129 EXPECT_EQ(U2fReturnCode::SUCCESS, response.first); |
126 ASSERT_LT(static_cast<size_t>(0), response.second.size()); | 130 ASSERT_LT(static_cast<size_t>(0), response.second.size()); |
127 EXPECT_EQ(static_cast<uint8_t>(MockU2fDevice::kRegister), response.second[0]); | 131 EXPECT_EQ(static_cast<uint8_t>(MockU2fDevice::kRegister), response.second[0]); |
128 } | 132 } |
129 | 133 |
130 } // namespace device | 134 } // namespace device |
OLD | NEW |