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

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

Issue 2849613002: Use ScopedTaskEnvironment instead of MessageLoopForUI in device tests. (Closed)
Patch Set: self-review 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_unittest.cc ('k') | device/u2f/u2f_sign_unittest.cc » ('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/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/test/scoped_task_environment.h"
9 #include "base/test/test_io_thread.h" 10 #include "base/test/test_io_thread.h"
10 #include "device/base/mock_device_client.h" 11 #include "device/base/mock_device_client.h"
11 #include "device/hid/mock_hid_service.h" 12 #include "device/hid/mock_hid_service.h"
12 #include "device/test/test_device_client.h" 13 #include "device/test/test_device_client.h"
13 #include "device/test/usb_test_gadget.h" 14 #include "device/test/usb_test_gadget.h"
14 #include "device/u2f/u2f_hid_device.h" 15 #include "device/u2f/u2f_hid_device.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "u2f_request.h" 17 #include "u2f_request.h"
17 18
18 namespace device { 19 namespace device {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 U2fRequest::ResponseCallback& callback() { return callback_; } 59 U2fRequest::ResponseCallback& callback() { return callback_; }
59 60
60 private: 61 private:
61 base::Closure closure_; 62 base::Closure closure_;
62 U2fRequest::ResponseCallback callback_; 63 U2fRequest::ResponseCallback callback_;
63 base::RunLoop run_loop_; 64 base::RunLoop run_loop_;
64 }; 65 };
65 66
66 class U2fRequestTest : public testing::Test { 67 class U2fRequestTest : public testing::Test {
67 public: 68 public:
68 U2fRequestTest() : io_thread_(base::TestIOThread::kAutoStart) {} 69 U2fRequestTest()
70 : scoped_task_environment_(
71 base::test::ScopedTaskEnvironment::MainThreadType::UI),
72 io_thread_(base::TestIOThread::kAutoStart) {}
69 73
70 protected: 74 protected:
71 base::MessageLoopForUI message_loop_; 75 base::test::ScopedTaskEnvironment scoped_task_environment_;
72 base::TestIOThread io_thread_; 76 base::TestIOThread io_thread_;
73 device::MockDeviceClient device_client_; 77 device::MockDeviceClient device_client_;
74 }; 78 };
75 79
76 TEST_F(U2fRequestTest, TestAddRemoveDevice) { 80 TEST_F(U2fRequestTest, TestAddRemoveDevice) {
77 MockHidService* hid_service = device_client_.hid_service(); 81 MockHidService* hid_service = device_client_.hid_service();
78 HidCollectionInfo c_info; 82 HidCollectionInfo c_info;
79 hid_service->FirstEnumerationComplete(); 83 hid_service->FirstEnumerationComplete();
80 84
81 TestResponseCallback cb; 85 TestResponseCallback cb;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 c_info.usage = HidUsageAndPage(1, static_cast<HidUsageAndPage::Page>(0xf1d0)); 155 c_info.usage = HidUsageAndPage(1, static_cast<HidUsageAndPage::Page>(0xf1d0));
152 scoped_refptr<HidDeviceInfo> u2f_device = make_scoped_refptr( 156 scoped_refptr<HidDeviceInfo> u2f_device = make_scoped_refptr(
153 new HidDeviceInfo(kTestDeviceId0, 0, 0, "Test Fido Device", "123FIDO", 157 new HidDeviceInfo(kTestDeviceId0, 0, 0, "Test Fido Device", "123FIDO",
154 kHIDBusTypeUSB, c_info, 64, 64, 0)); 158 kHIDBusTypeUSB, c_info, 64, 64, 0));
155 hid_service->AddDevice(u2f_device); 159 hid_service->AddDevice(u2f_device);
156 cb.WaitForCallback(); 160 cb.WaitForCallback();
157 EXPECT_EQ(U2fRequest::State::BUSY, request.state_); 161 EXPECT_EQ(U2fRequest::State::BUSY, request.state_);
158 } 162 }
159 163
160 } // namespace device 164 } // namespace device
OLDNEW
« no previous file with comments | « device/u2f/u2f_register_unittest.cc ('k') | device/u2f/u2f_sign_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698