-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathusb_device_descriptor_test.cc
42 lines (34 loc) · 1.38 KB
/
usb_device_descriptor_test.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "mist/usb_device_descriptor.h"
#include <libusb.h>
#include <gtest/gtest.h>
#include "mist/usb_device.h"
namespace mist {
TEST(UsbDeviceDescriptorTest, TrivialGetters) {
libusb_device_descriptor descriptor;
descriptor.bLength = 18;
descriptor.bDescriptorType = LIBUSB_DT_DEVICE;
descriptor.bcdUSB = 200;
descriptor.bDeviceClass = 0x02;
descriptor.bDeviceSubClass = 0x03;
descriptor.bDeviceProtocol = 0x04;
descriptor.bMaxPacketSize0 = 128;
descriptor.idVendor = 0x1234;
descriptor.idProduct = 0xabcd;
descriptor.bcdDevice = 567;
descriptor.bNumConfigurations = 2;
base::WeakPtr<UsbDevice> device;
UsbDeviceDescriptor device_descriptor(device, &descriptor);
EXPECT_EQ(18, device_descriptor.GetLength());
EXPECT_EQ(LIBUSB_DT_DEVICE, device_descriptor.GetDescriptorType());
EXPECT_EQ(0x02, device_descriptor.GetDeviceClass());
EXPECT_EQ(0x03, device_descriptor.GetDeviceSubclass());
EXPECT_EQ(0x04, device_descriptor.GetDeviceProtocol());
EXPECT_EQ(128, device_descriptor.GetMaxPacketSize0());
EXPECT_EQ(0x1234, device_descriptor.GetVendorId());
EXPECT_EQ(0xabcd, device_descriptor.GetProductId());
EXPECT_EQ(2, device_descriptor.GetNumConfigurations());
}
} // namespace mist