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

Unified Diff: device/usb/usb_device_handle_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_device_handle_android.cc ('k') | device/usb/usb_device_linux.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/usb_device_handle_unittest.cc
diff --git a/device/usb/usb_device_handle_unittest.cc b/device/usb/usb_device_handle_unittest.cc
index 2eaaadd39384bdf7daa1ccc4ae2e35c79753f727..6f1b93ee86264e36681c4278e3b18f64040f9f7a 100644
--- a/device/usb/usb_device_handle_unittest.cc
+++ b/device/usb/usb_device_handle_unittest.cc
@@ -12,6 +12,7 @@
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/test/scoped_task_environment.h"
#include "base/test/test_io_thread.h"
#include "device/test/test_device_client.h"
#include "device/test/usb_test_gadget.h"
@@ -25,18 +26,18 @@ namespace {
class UsbDeviceHandleTest : public ::testing::Test {
public:
- 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()));
- }
+ UsbDeviceHandleTest()
+ : io_thread_(base::TestIOThread::kAutoStart),
+ scoped_task_environment_(
+ base::test::ScopedTaskEnvironment::MainThreadType::UI),
+ device_client_(io_thread_.task_runner()) {}
protected:
- std::unique_ptr<base::TestIOThread> io_thread_;
+ base::TestIOThread io_thread_;
private:
- std::unique_ptr<base::MessageLoop> message_loop_;
- std::unique_ptr<TestDeviceClient> device_client_;
+ base::test::ScopedTaskEnvironment scoped_task_environment_;
+ TestDeviceClient device_client_;
};
class TestOpenCallback {
@@ -132,7 +133,7 @@ TEST_F(UsbDeviceHandleTest, InterruptTransfer) {
}
std::unique_ptr<UsbTestGadget> gadget =
- UsbTestGadget::Claim(io_thread_->task_runner());
+ UsbTestGadget::Claim(io_thread_.task_runner());
ASSERT_TRUE(gadget.get());
ASSERT_TRUE(gadget->SetType(UsbTestGadget::ECHO));
@@ -200,7 +201,7 @@ TEST_F(UsbDeviceHandleTest, BulkTransfer) {
}
std::unique_ptr<UsbTestGadget> gadget =
- UsbTestGadget::Claim(io_thread_->task_runner());
+ UsbTestGadget::Claim(io_thread_.task_runner());
ASSERT_TRUE(gadget.get());
ASSERT_TRUE(gadget->SetType(UsbTestGadget::ECHO));
@@ -268,7 +269,7 @@ TEST_F(UsbDeviceHandleTest, ControlTransfer) {
return;
std::unique_ptr<UsbTestGadget> gadget =
- UsbTestGadget::Claim(io_thread_->task_runner());
+ UsbTestGadget::Claim(io_thread_.task_runner());
ASSERT_TRUE(gadget.get());
TestOpenCallback open_device;
@@ -300,7 +301,7 @@ TEST_F(UsbDeviceHandleTest, SetInterfaceAlternateSetting) {
}
std::unique_ptr<UsbTestGadget> gadget =
- UsbTestGadget::Claim(io_thread_->task_runner());
+ UsbTestGadget::Claim(io_thread_.task_runner());
ASSERT_TRUE(gadget.get());
ASSERT_TRUE(gadget->SetType(UsbTestGadget::ECHO));
@@ -330,7 +331,7 @@ TEST_F(UsbDeviceHandleTest, CancelOnClose) {
}
std::unique_ptr<UsbTestGadget> gadget =
- UsbTestGadget::Claim(io_thread_->task_runner());
+ UsbTestGadget::Claim(io_thread_.task_runner());
ASSERT_TRUE(gadget.get());
ASSERT_TRUE(gadget->SetType(UsbTestGadget::ECHO));
@@ -361,7 +362,7 @@ TEST_F(UsbDeviceHandleTest, CancelOnDisconnect) {
}
std::unique_ptr<UsbTestGadget> gadget =
- UsbTestGadget::Claim(io_thread_->task_runner());
+ UsbTestGadget::Claim(io_thread_.task_runner());
ASSERT_TRUE(gadget.get());
ASSERT_TRUE(gadget->SetType(UsbTestGadget::ECHO));
@@ -394,7 +395,7 @@ TEST_F(UsbDeviceHandleTest, Timeout) {
}
std::unique_ptr<UsbTestGadget> gadget =
- UsbTestGadget::Claim(io_thread_->task_runner());
+ UsbTestGadget::Claim(io_thread_.task_runner());
ASSERT_TRUE(gadget.get());
ASSERT_TRUE(gadget->SetType(UsbTestGadget::ECHO));
@@ -425,7 +426,7 @@ TEST_F(UsbDeviceHandleTest, CloseReentrancy) {
return;
std::unique_ptr<UsbTestGadget> gadget =
- UsbTestGadget::Claim(io_thread_->task_runner());
+ UsbTestGadget::Claim(io_thread_.task_runner());
ASSERT_TRUE(gadget.get());
ASSERT_TRUE(gadget->SetType(UsbTestGadget::ECHO));
« no previous file with comments | « device/usb/usb_device_handle_android.cc ('k') | device/usb/usb_device_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698