OLD | NEW |
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 <stdint.h> |
| 6 |
| 7 #include "build/build_config.h" |
5 #include "device/hid/hid_device_filter.h" | 8 #include "device/hid/hid_device_filter.h" |
6 #include "device/hid/hid_device_info.h" | 9 #include "device/hid/hid_device_info.h" |
7 #include "device/hid/test_report_descriptors.h" | 10 #include "device/hid/test_report_descriptors.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
9 | 12 |
10 namespace device { | 13 namespace device { |
11 | 14 |
12 namespace { | 15 namespace { |
13 | 16 |
14 #if defined(OS_MACOSX) | 17 #if defined(OS_MACOSX) |
15 const uint64_t kTestDeviceId = 42; | 18 const uint64_t kTestDeviceId = 42; |
16 #else | 19 #else |
17 const char* kTestDeviceId = "device1"; | 20 const char* kTestDeviceId = "device1"; |
18 #endif | 21 #endif |
19 | 22 |
20 } // namespace | 23 } // namespace |
21 | 24 |
22 class HidFilterTest : public testing::Test { | 25 class HidFilterTest : public testing::Test { |
23 public: | 26 public: |
24 void SetUp() override { | 27 void SetUp() override { |
25 device_info_ = new HidDeviceInfo( | 28 device_info_ = new HidDeviceInfo( |
26 kTestDeviceId, 0x046d, 0xc31c, "Test Keyboard", "123ABC", | 29 kTestDeviceId, 0x046d, 0xc31c, "Test Keyboard", "123ABC", |
27 kHIDBusTypeUSB, | 30 kHIDBusTypeUSB, |
28 std::vector<uint8>(kKeyboard, kKeyboard + kKeyboardSize)); | 31 std::vector<uint8_t>(kKeyboard, kKeyboard + kKeyboardSize)); |
29 } | 32 } |
30 | 33 |
31 protected: | 34 protected: |
32 scoped_refptr<HidDeviceInfo> device_info_; | 35 scoped_refptr<HidDeviceInfo> device_info_; |
33 }; | 36 }; |
34 | 37 |
35 TEST_F(HidFilterTest, MatchAny) { | 38 TEST_F(HidFilterTest, MatchAny) { |
36 HidDeviceFilter filter; | 39 HidDeviceFilter filter; |
37 ASSERT_TRUE(filter.Matches(device_info_)); | 40 ASSERT_TRUE(filter.Matches(device_info_)); |
38 } | 41 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 114 |
112 TEST_F(HidFilterTest, MatchFilterListNegative) { | 115 TEST_F(HidFilterTest, MatchFilterListNegative) { |
113 std::vector<HidDeviceFilter> filters; | 116 std::vector<HidDeviceFilter> filters; |
114 HidDeviceFilter filter; | 117 HidDeviceFilter filter; |
115 filter.SetUsagePage(HidUsageAndPage::kPageLed); | 118 filter.SetUsagePage(HidUsageAndPage::kPageLed); |
116 filters.push_back(filter); | 119 filters.push_back(filter); |
117 ASSERT_FALSE(HidDeviceFilter::MatchesAny(device_info_, filters)); | 120 ASSERT_FALSE(HidDeviceFilter::MatchesAny(device_info_, filters)); |
118 } | 121 } |
119 | 122 |
120 } // namespace device | 123 } // namespace device |
OLD | NEW |