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

Unified Diff: device/usb/usb_service_unittest.cc

Issue 980023002: Move device/usb classes from the FILE thread to UI thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add more thread assertions. Created 5 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_impl.cc ('k') | extensions/browser/api/device_permissions_manager.h » ('j') | 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 edd07123ecd57e28c4d4b398ca55fe10994ed8df..f0e5ae272af14ba101736523e17431c056caac27 100644
--- a/device/usb/usb_service_unittest.cc
+++ b/device/usb/usb_service_unittest.cc
@@ -4,6 +4,7 @@
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/test/test_io_thread.h"
#include "device/test/usb_test_gadget.h"
#include "device/usb/usb_device.h"
#include "device/usb/usb_device_handle.h"
@@ -15,34 +16,34 @@ namespace {
class UsbServiceTest : public ::testing::Test {
public:
- void SetUp() override { message_loop_.reset(new base::MessageLoopForIO); }
+ void SetUp() override {
+ message_loop_.reset(new base::MessageLoopForUI);
+ io_thread_.reset(new base::TestIOThread(base::TestIOThread::kAutoStart));
+ }
- private:
+ protected:
scoped_ptr<base::MessageLoop> message_loop_;
+ scoped_ptr<base::TestIOThread> io_thread_;
};
TEST_F(UsbServiceTest, ClaimGadget) {
if (!UsbTestGadget::IsTestEnabled()) return;
- scoped_ptr<UsbTestGadget> gadget = UsbTestGadget::Claim();
+ scoped_ptr<UsbTestGadget> gadget =
+ UsbTestGadget::Claim(io_thread_->task_runner());
ASSERT_TRUE(gadget.get());
scoped_refptr<UsbDevice> device = gadget->GetDevice();
- base::string16 utf16;
- ASSERT_TRUE(device->GetManufacturer(&utf16));
- ASSERT_EQ("Google Inc.", base::UTF16ToUTF8(utf16));
-
- ASSERT_TRUE(device->GetProduct(&utf16));
- ASSERT_EQ("Test Gadget (default state)", base::UTF16ToUTF8(utf16));
-
- ASSERT_TRUE(device->GetSerialNumber(&utf16));
- ASSERT_EQ(gadget->GetSerialNumber(), base::UTF16ToUTF8(utf16));
+ ASSERT_EQ("Google Inc.", base::UTF16ToUTF8(device->manufacturer_string()));
+ ASSERT_EQ("Test Gadget (default state)",
+ base::UTF16ToUTF8(device->product_string()));
}
TEST_F(UsbServiceTest, DisconnectAndReconnect) {
if (!UsbTestGadget::IsTestEnabled()) return;
- scoped_ptr<UsbTestGadget> gadget = UsbTestGadget::Claim();
+ scoped_ptr<UsbTestGadget> gadget =
+ UsbTestGadget::Claim(io_thread_->task_runner());
ASSERT_TRUE(gadget.get());
ASSERT_TRUE(gadget->Disconnect());
ASSERT_TRUE(gadget->Reconnect());
« no previous file with comments | « device/usb/usb_service_impl.cc ('k') | extensions/browser/api/device_permissions_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698