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

Unified Diff: device/usb/usb_service_unittest.cc

Issue 2849953003: Use the task scheduler for blocking tasks in the USB service on Linux (Closed)
Patch Set: Remove more passing of the SequencedTaskRunner 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/usb/usb_service_linux.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/usb_service_unittest.cc
diff --git a/device/usb/usb_service_unittest.cc b/device/usb/usb_service_unittest.cc
index 559e52a82fa3f3d3c6ce9920a6eb89878029421b..d3991ad7f8573e9726b74219a48b32a15b12274c 100644
--- a/device/usb/usb_service_unittest.cc
+++ b/device/usb/usb_service_unittest.cc
@@ -5,10 +5,10 @@
#include <memory>
#include "base/bind.h"
-#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
+#include "base/test/scoped_task_environment.h"
#include "base/test/test_io_thread.h"
#include "device/base/features.h"
#include "device/test/test_device_client.h"
@@ -24,15 +24,18 @@ namespace {
class UsbServiceTest : public ::testing::Test {
public:
+ UsbServiceTest()
+ : scoped_task_environment_(
+ base::test::ScopedTaskEnvironment::MainThreadType::UI),
+ io_thread_(base::TestIOThread::kAutoStart) {}
+
void SetUp() override {
- message_loop_.reset(new base::MessageLoopForUI);
- io_thread_.reset(new base::TestIOThread(base::TestIOThread::kAutoStart));
- device_client_.reset(new TestDeviceClient(io_thread_->task_runner()));
+ device_client_.reset(new TestDeviceClient(io_thread_.task_runner()));
}
protected:
- std::unique_ptr<base::MessageLoop> message_loop_;
- std::unique_ptr<base::TestIOThread> io_thread_;
+ base::test::ScopedTaskEnvironment scoped_task_environment_;
+ base::TestIOThread io_thread_;
std::unique_ptr<TestDeviceClient> device_client_;
};
@@ -77,7 +80,7 @@ TEST_F(UsbServiceTest, ClaimGadget) {
if (!UsbTestGadget::IsTestEnabled()) return;
std::unique_ptr<UsbTestGadget> gadget =
- UsbTestGadget::Claim(io_thread_->task_runner());
+ UsbTestGadget::Claim(io_thread_.task_runner());
ASSERT_TRUE(gadget);
scoped_refptr<UsbDevice> device = gadget->GetDevice();
@@ -90,7 +93,7 @@ TEST_F(UsbServiceTest, DisconnectAndReconnect) {
if (!UsbTestGadget::IsTestEnabled()) return;
std::unique_ptr<UsbTestGadget> gadget =
- UsbTestGadget::Claim(io_thread_->task_runner());
+ UsbTestGadget::Claim(io_thread_.task_runner());
ASSERT_TRUE(gadget);
ASSERT_TRUE(gadget->Disconnect());
ASSERT_TRUE(gadget->Reconnect());
@@ -101,7 +104,7 @@ TEST_F(UsbServiceTest, Shutdown) {
return;
std::unique_ptr<UsbTestGadget> gadget =
- UsbTestGadget::Claim(io_thread_->task_runner());
+ UsbTestGadget::Claim(io_thread_.task_runner());
ASSERT_TRUE(gadget);
base::RunLoop loop;
« no previous file with comments | « device/usb/usb_service_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698