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

Unified Diff: device/usb/usb_device_filter_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: 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
Index: device/usb/usb_device_filter_unittest.cc
diff --git a/device/usb/usb_device_filter_unittest.cc b/device/usb/usb_device_filter_unittest.cc
index 1c3fb920cf0d8436d1733b245e77187647d495f7..eb6ec0f5a58a8e3451e800efb671996529376fcc 100644
--- a/device/usb/usb_device_filter_unittest.cc
+++ b/device/usb/usb_device_filter_unittest.cc
@@ -21,15 +21,17 @@ using testing::Return;
class MockUsbDevice : public UsbDevice {
public:
MockUsbDevice(uint16 vendor_id, uint16 product_id, uint32 unique_id)
- : UsbDevice(vendor_id, product_id, unique_id) {}
+ : UsbDevice(vendor_id,
Ken Rockot(use gerrit already) 2015/04/07 22:09:43 nit: (Here and other places) I'm surprised by some
Reilly Grant (use Gerrit) 2015/04/08 21:39:03 Yeah. It's odd because here it prefers one item pe
+ product_id,
+ unique_id,
+ base::string16(),
+ base::string16(),
+ base::string16()) {}
MOCK_METHOD2(RequestUsbAccess, void(int, const base::Callback<void(bool)>&));
- MOCK_METHOD0(Open, scoped_refptr<UsbDeviceHandle>());
+ MOCK_METHOD1(Open, void(const OpenCallback&));
MOCK_METHOD1(Close, bool(scoped_refptr<UsbDeviceHandle>));
MOCK_METHOD0(GetConfiguration, const device::UsbConfigDescriptor*());
- MOCK_METHOD1(GetManufacturer, bool(base::string16*));
- MOCK_METHOD1(GetProduct, bool(base::string16*));
- MOCK_METHOD1(GetSerialNumber, bool(base::string16*));
private:
virtual ~MockUsbDevice() {}
@@ -47,8 +49,6 @@ class UsbFilterTest : public testing::Test {
config_.interfaces.push_back(interface);
android_phone_ = new MockUsbDevice(0x18d1, 0x4ee2, 0);
- ON_CALL(*android_phone_.get(), GetConfiguration())
- .WillByDefault(Return(&config_));
}
protected:
@@ -90,12 +90,16 @@ TEST_F(UsbFilterTest, MatchProductIdNegative) {
TEST_F(UsbFilterTest, MatchInterfaceClass) {
UsbDeviceFilter filter;
filter.SetInterfaceClass(0xff);
+ EXPECT_CALL(*android_phone_.get(), GetConfiguration())
+ .WillOnce(Return(&config_));
ASSERT_TRUE(filter.Matches(android_phone_));
}
TEST_F(UsbFilterTest, MatchInterfaceClassNegative) {
UsbDeviceFilter filter;
filter.SetInterfaceClass(0xe0);
+ EXPECT_CALL(*android_phone_.get(), GetConfiguration())
+ .WillOnce(Return(&config_));
ASSERT_FALSE(filter.Matches(android_phone_));
}
@@ -103,6 +107,8 @@ TEST_F(UsbFilterTest, MatchInterfaceSubclass) {
UsbDeviceFilter filter;
filter.SetInterfaceClass(0xff);
filter.SetInterfaceSubclass(0x42);
+ EXPECT_CALL(*android_phone_.get(), GetConfiguration())
+ .WillOnce(Return(&config_));
ASSERT_TRUE(filter.Matches(android_phone_));
}
@@ -110,6 +116,8 @@ TEST_F(UsbFilterTest, MatchInterfaceSubclassNegative) {
UsbDeviceFilter filter;
filter.SetInterfaceClass(0xff);
filter.SetInterfaceSubclass(0x01);
+ EXPECT_CALL(*android_phone_.get(), GetConfiguration())
+ .WillOnce(Return(&config_));
ASSERT_FALSE(filter.Matches(android_phone_));
}
@@ -118,6 +126,8 @@ TEST_F(UsbFilterTest, MatchInterfaceProtocol) {
filter.SetInterfaceClass(0xff);
filter.SetInterfaceSubclass(0x42);
filter.SetInterfaceProtocol(0x01);
+ EXPECT_CALL(*android_phone_.get(), GetConfiguration())
+ .WillOnce(Return(&config_));
ASSERT_TRUE(filter.Matches(android_phone_));
}
@@ -126,6 +136,8 @@ TEST_F(UsbFilterTest, MatchInterfaceProtocolNegative) {
filter.SetInterfaceClass(0xff);
filter.SetInterfaceSubclass(0x42);
filter.SetInterfaceProtocol(0x02);
+ EXPECT_CALL(*android_phone_.get(), GetConfiguration())
+ .WillOnce(Return(&config_));
ASSERT_FALSE(filter.Matches(android_phone_));
}

Powered by Google App Engine
This is Rietveld 408576698