-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathusb_config_descriptor_test.cc
36 lines (28 loc) · 1.13 KB
/
usb_config_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
// 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_config_descriptor.h"
#include <libusb.h>
#include <gtest/gtest.h>
#include "mist/usb_device.h"
namespace mist {
TEST(UsbConfigDescriptorTest, TrivialGetters) {
libusb_config_descriptor descriptor;
descriptor.bLength = 9;
descriptor.bDescriptorType = LIBUSB_DT_CONFIG;
descriptor.wTotalLength = 300;
descriptor.bNumInterfaces = 3;
descriptor.bConfigurationValue = 1;
descriptor.bmAttributes = 0xa0;
descriptor.MaxPower = 2;
base::WeakPtr<UsbDevice> device;
UsbConfigDescriptor config_descriptor(device, &descriptor, false);
EXPECT_EQ(9, config_descriptor.GetLength());
EXPECT_EQ(LIBUSB_DT_CONFIG, config_descriptor.GetDescriptorType());
EXPECT_EQ(300, config_descriptor.GetTotalLength());
EXPECT_EQ(3, config_descriptor.GetNumInterfaces());
EXPECT_EQ(1, config_descriptor.GetConfigurationValue());
EXPECT_EQ(0xa0, config_descriptor.GetAttributes());
EXPECT_EQ(2, config_descriptor.GetMaxPower());
}
} // namespace mist