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

Side by Side Diff: device/usb/usb_device_filter_unittest.cc

Issue 1468423003: Construct USB descriptors over explicit values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Android code. 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 unified diff | Download patch
« no previous file with comments | « device/usb/usb_device_android.cc ('k') | device/usb/usb_device_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "device/usb/mock_usb_device.h" 8 #include "device/usb/mock_usb_device.h"
9 #include "device/usb/usb_descriptors.h" 9 #include "device/usb/usb_descriptors.h"
10 #include "device/usb/usb_device_filter.h" 10 #include "device/usb/usb_device_filter.h"
11 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace device { 14 namespace device {
15 15
16 namespace { 16 namespace {
17 17
18 using testing::Return; 18 using testing::Return;
19 19
20 class UsbFilterTest : public testing::Test { 20 class UsbFilterTest : public testing::Test {
21 public: 21 public:
22 void SetUp() override { 22 void SetUp() override {
23 UsbInterfaceDescriptor interface; 23 UsbConfigDescriptor config(1, false, false, 0);
24 interface.interface_number = 1; 24 config.interfaces.emplace_back(1, 0, 0xff, 0x42, 0x01);
25 interface.alternate_setting = 0;
26 interface.interface_class = 0xFF;
27 interface.interface_subclass = 0x42;
28 interface.interface_protocol = 0x01;
29
30 UsbConfigDescriptor config;
31 config.interfaces.push_back(interface);
32 25
33 android_phone_ = new MockUsbDevice(0x18d1, 0x4ee2, config); 26 android_phone_ = new MockUsbDevice(0x18d1, 0x4ee2, config);
34 } 27 }
35 28
36 protected: 29 protected:
37 scoped_refptr<MockUsbDevice> android_phone_; 30 scoped_refptr<MockUsbDevice> android_phone_;
38 }; 31 };
39 32
40 TEST_F(UsbFilterTest, MatchAny) { 33 TEST_F(UsbFilterTest, MatchAny) {
41 UsbDeviceFilter filter; 34 UsbDeviceFilter filter;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 116
124 TEST_F(UsbFilterTest, MatchesAnyVendorIdNegative) { 117 TEST_F(UsbFilterTest, MatchesAnyVendorIdNegative) {
125 std::vector<UsbDeviceFilter> filters(1); 118 std::vector<UsbDeviceFilter> filters(1);
126 filters.back().SetVendorId(0x1d6b); 119 filters.back().SetVendorId(0x1d6b);
127 ASSERT_FALSE(UsbDeviceFilter::MatchesAny(android_phone_, filters)); 120 ASSERT_FALSE(UsbDeviceFilter::MatchesAny(android_phone_, filters));
128 } 121 }
129 122
130 } // namespace 123 } // namespace
131 124
132 } // namespace device 125 } // namespace device
OLDNEW
« no previous file with comments | « device/usb/usb_device_android.cc ('k') | device/usb/usb_device_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698