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

Unified Diff: device/usb/usb_device_filter_unittest.cc

Issue 2727633004: Change UsbDeviceFilter to use const references instead of (Closed)
Patch Set: Fix callsite missed earlier due to not building for CrOS Created 3 years, 9 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_filter.cc ('k') | extensions/browser/api/device_permissions_prompt.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7d1e2d114e22e900fd909d9cf14206c4089d7879..dd7840e088d68fa94327005276e90d667cf7fb95 100644
--- a/device/usb/usb_device_filter_unittest.cc
+++ b/device/usb/usb_device_filter_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <string>
#include <vector>
#include "base/memory/ref_counted.h"
@@ -33,59 +34,59 @@ class UsbFilterTest : public testing::Test {
TEST_F(UsbFilterTest, MatchAny) {
UsbDeviceFilter filter;
- ASSERT_TRUE(filter.Matches(android_phone_));
+ ASSERT_TRUE(filter.Matches(*android_phone_));
}
TEST_F(UsbFilterTest, MatchVendorId) {
UsbDeviceFilter filter;
filter.vendor_id = 0x18d1;
- ASSERT_TRUE(filter.Matches(android_phone_));
+ ASSERT_TRUE(filter.Matches(*android_phone_));
}
TEST_F(UsbFilterTest, MatchVendorIdNegative) {
UsbDeviceFilter filter;
filter.vendor_id = 0x1d6b;
- ASSERT_FALSE(filter.Matches(android_phone_));
+ ASSERT_FALSE(filter.Matches(*android_phone_));
}
TEST_F(UsbFilterTest, MatchProductId) {
UsbDeviceFilter filter;
filter.vendor_id = 0x18d1;
filter.product_id = 0x4ee2;
- ASSERT_TRUE(filter.Matches(android_phone_));
+ ASSERT_TRUE(filter.Matches(*android_phone_));
}
TEST_F(UsbFilterTest, MatchProductIdNegative) {
UsbDeviceFilter filter;
filter.vendor_id = 0x18d1;
filter.product_id = 0x4ee1;
- ASSERT_FALSE(filter.Matches(android_phone_));
+ ASSERT_FALSE(filter.Matches(*android_phone_));
}
TEST_F(UsbFilterTest, MatchInterfaceClass) {
UsbDeviceFilter filter;
filter.interface_class = 0xff;
- ASSERT_TRUE(filter.Matches(android_phone_));
+ ASSERT_TRUE(filter.Matches(*android_phone_));
}
TEST_F(UsbFilterTest, MatchInterfaceClassNegative) {
UsbDeviceFilter filter;
filter.interface_class = 0xe0;
- ASSERT_FALSE(filter.Matches(android_phone_));
+ ASSERT_FALSE(filter.Matches(*android_phone_));
}
TEST_F(UsbFilterTest, MatchInterfaceSubclass) {
UsbDeviceFilter filter;
filter.interface_class = 0xff;
filter.interface_subclass = 0x42;
- ASSERT_TRUE(filter.Matches(android_phone_));
+ ASSERT_TRUE(filter.Matches(*android_phone_));
}
TEST_F(UsbFilterTest, MatchInterfaceSubclassNegative) {
UsbDeviceFilter filter;
filter.interface_class = 0xff;
filter.interface_subclass = 0x01;
- ASSERT_FALSE(filter.Matches(android_phone_));
+ ASSERT_FALSE(filter.Matches(*android_phone_));
}
TEST_F(UsbFilterTest, MatchInterfaceProtocol) {
@@ -93,7 +94,7 @@ TEST_F(UsbFilterTest, MatchInterfaceProtocol) {
filter.interface_class = 0xff;
filter.interface_subclass = 0x42;
filter.interface_protocol = 0x01;
- ASSERT_TRUE(filter.Matches(android_phone_));
+ ASSERT_TRUE(filter.Matches(*android_phone_));
}
TEST_F(UsbFilterTest, MatchInterfaceProtocolNegative) {
@@ -101,37 +102,37 @@ TEST_F(UsbFilterTest, MatchInterfaceProtocolNegative) {
filter.interface_class = 0xff;
filter.interface_subclass = 0x42;
filter.interface_protocol = 0x02;
- ASSERT_FALSE(filter.Matches(android_phone_));
+ ASSERT_FALSE(filter.Matches(*android_phone_));
}
TEST_F(UsbFilterTest, MatchSerialNumber) {
UsbDeviceFilter filter;
filter.serial_number = std::string("ABC123");
- EXPECT_TRUE(filter.Matches(android_phone_));
+ EXPECT_TRUE(filter.Matches(*android_phone_));
filter.vendor_id = 0x18d1;
- EXPECT_TRUE(filter.Matches(android_phone_));
+ EXPECT_TRUE(filter.Matches(*android_phone_));
filter.vendor_id = 0x18d2;
- EXPECT_FALSE(filter.Matches(android_phone_));
+ EXPECT_FALSE(filter.Matches(*android_phone_));
filter.vendor_id = 0x18d1;
filter.serial_number = std::string("DIFFERENT");
- EXPECT_FALSE(filter.Matches(android_phone_));
+ EXPECT_FALSE(filter.Matches(*android_phone_));
}
TEST_F(UsbFilterTest, MatchAnyEmptyList) {
std::vector<UsbDeviceFilter> filters;
- ASSERT_TRUE(UsbDeviceFilter::MatchesAny(android_phone_, filters));
+ ASSERT_TRUE(UsbDeviceFilter::MatchesAny(*android_phone_, filters));
}
TEST_F(UsbFilterTest, MatchesAnyVendorId) {
std::vector<UsbDeviceFilter> filters(1);
filters.back().vendor_id = 0x18d1;
- ASSERT_TRUE(UsbDeviceFilter::MatchesAny(android_phone_, filters));
+ ASSERT_TRUE(UsbDeviceFilter::MatchesAny(*android_phone_, filters));
}
TEST_F(UsbFilterTest, MatchesAnyVendorIdNegative) {
std::vector<UsbDeviceFilter> filters(1);
filters.back().vendor_id = 0x1d6b;
- ASSERT_FALSE(UsbDeviceFilter::MatchesAny(android_phone_, filters));
+ ASSERT_FALSE(UsbDeviceFilter::MatchesAny(*android_phone_, filters));
}
} // namespace
« no previous file with comments | « device/usb/usb_device_filter.cc ('k') | extensions/browser/api/device_permissions_prompt.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698