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

Unified Diff: device/usb/usb_descriptors_unittest.cc

Issue 1697863003: Revert of Parse USB interface association descriptors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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_descriptors.cc ('k') | device/usb/usb_device_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/usb_descriptors_unittest.cc
diff --git a/device/usb/usb_descriptors_unittest.cc b/device/usb/usb_descriptors_unittest.cc
index 5bc2943da6ee91b7dc223c37962497c7b4c6fa7c..402304f6b855fc25f0c008e1539ee6fa7e10fd66 100644
--- a/device/usb/usb_descriptors_unittest.cc
+++ b/device/usb/usb_descriptors_unittest.cc
@@ -31,81 +31,6 @@
}
class UsbDescriptorsTest : public ::testing::Test {};
-
-TEST_F(UsbDescriptorsTest, NoInterfaceAssociations) {
- UsbConfigDescriptor config(1, false, false, 0);
- config.interfaces.emplace_back(0, 0, 255, 255, 255);
- config.interfaces.emplace_back(0, 1, 255, 255, 255);
- config.interfaces.emplace_back(1, 0, 255, 255, 255);
- config.AssignFirstInterfaceNumbers();
-
- EXPECT_EQ(0, config.interfaces[0].first_interface);
- EXPECT_EQ(0, config.interfaces[1].first_interface);
- EXPECT_EQ(1, config.interfaces[2].first_interface);
-}
-
-TEST_F(UsbDescriptorsTest, InterfaceAssociations) {
- // Links interfaces 0 and 1 into a single function.
- static const uint8_t kIAD1[] = {0x08, 0x0b, 0x00, 0x02,
- 0xff, 0xff, 0xff, 0x00};
- // Only references a single interface, 2.
- static const uint8_t kIAD2[] = {0x08, 0x0b, 0x02, 0x01,
- 0xff, 0xff, 0xff, 0x00};
- // Malformed. References interface 3 but bInterfaceCount is 0.
- static const uint8_t kIAD3[] = {0x08, 0x0b, 0x03, 0x00,
- 0xff, 0xff, 0xff, 0x00};
- // Malformed. References an indefined interface.
- static const uint8_t kIAD4[] = {0x08, 0x0b, 0x07, 0x00,
- 0xff, 0xff, 0xff, 0x00};
- // Links interfaces 4 and 5 into a single function.
- static const uint8_t kIAD5[] = {0x08, 0x0b, 0x04, 0x01,
- 0xff, 0xff, 0xff, 0x00};
-
- UsbConfigDescriptor config(1, false, false, 0);
- config.extra_data.assign(kIAD1, kIAD1 + sizeof(kIAD1));
- config.extra_data.insert(config.extra_data.end(), kIAD2,
- kIAD2 + sizeof(kIAD2));
- config.interfaces.emplace_back(0, 0, 255, 255, 255);
- config.interfaces.emplace_back(1, 0, 255, 255, 255);
- UsbInterfaceDescriptor iface1a(1, 1, 255, 255, 255);
- iface1a.extra_data.assign(kIAD3, kIAD3 + sizeof(kIAD3));
- config.interfaces.push_back(std::move(iface1a));
- config.interfaces.emplace_back(2, 0, 255, 255, 255);
- config.interfaces.emplace_back(3, 0, 255, 255, 255);
- UsbInterfaceDescriptor iface4(4, 0, 255, 255, 255);
- iface4.extra_data.assign(kIAD4, kIAD4 + sizeof(kIAD4));
- iface4.extra_data.insert(iface4.extra_data.end(), kIAD5,
- kIAD5 + sizeof(kIAD5));
- config.interfaces.push_back(std::move(iface4));
- config.interfaces.emplace_back(5, 0, 255, 255, 255);
- config.AssignFirstInterfaceNumbers();
-
- EXPECT_EQ(0, config.interfaces[0].first_interface);
- EXPECT_EQ(0, config.interfaces[1].first_interface);
- EXPECT_EQ(0, config.interfaces[2].first_interface);
- EXPECT_EQ(2, config.interfaces[3].first_interface);
- EXPECT_EQ(3, config.interfaces[4].first_interface);
- EXPECT_EQ(4, config.interfaces[5].first_interface);
- EXPECT_EQ(4, config.interfaces[5].first_interface);
-}
-
-TEST_F(UsbDescriptorsTest, CorruptInterfaceAssociations) {
- {
- // Descriptor is too short.
- static const uint8_t kIAD[] = {0x01};
- UsbConfigDescriptor config(1, false, false, 0);
- config.extra_data.assign(kIAD, kIAD + sizeof(kIAD));
- config.AssignFirstInterfaceNumbers();
- }
- {
- // Descriptor is too long.
- static const uint8_t kIAD[] = {0x09, 0x0b, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00};
- UsbConfigDescriptor config(1, false, false, 0);
- config.extra_data.assign(kIAD, kIAD + sizeof(kIAD));
- config.AssignFirstInterfaceNumbers();
- }
-}
TEST_F(UsbDescriptorsTest, StringDescriptor) {
static const uint8_t kBuffer[] = {0x1a, 0x03, 'H', 0, 'e', 0, 'l', 0, 'l', 0,
« no previous file with comments | « device/usb/usb_descriptors.cc ('k') | device/usb/usb_device_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698