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

Side by Side Diff: extensions/browser/api/hid/hid_apitest.cc

Issue 1549643002: Switch to standard integer types in extensions/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@clean
Patch Set: Created 5 years 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
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 <stddef.h>
6 #include <stdint.h>
7
5 #include "base/bind.h" 8 #include "base/bind.h"
6 #include "base/run_loop.h" 9 #include "base/run_loop.h"
7 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
11 #include "build/build_config.h"
8 #include "device/core/mock_device_client.h" 12 #include "device/core/mock_device_client.h"
9 #include "device/hid/hid_collection_info.h" 13 #include "device/hid/hid_collection_info.h"
10 #include "device/hid/hid_connection.h" 14 #include "device/hid/hid_connection.h"
11 #include "device/hid/hid_device_info.h" 15 #include "device/hid/hid_device_info.h"
12 #include "device/hid/hid_usage_and_page.h" 16 #include "device/hid/hid_usage_and_page.h"
13 #include "device/hid/mock_hid_service.h" 17 #include "device/hid/mock_hid_service.h"
14 #include "extensions/browser/api/device_permissions_prompt.h" 18 #include "extensions/browser/api/device_permissions_prompt.h"
15 #include "extensions/shell/browser/shell_extensions_api_client.h" 19 #include "extensions/shell/browser/shell_extensions_api_client.h"
16 #include "extensions/shell/test/shell_apitest.h" 20 #include "extensions/shell/test/shell_apitest.h"
17 #include "extensions/test/extension_test_message_listener.h" 21 #include "extensions/test/extension_test_message_listener.h"
(...skipping 11 matching lines...) Expand all
29 #if defined(OS_MACOSX) 33 #if defined(OS_MACOSX)
30 const uint64_t kTestDeviceIds[] = {1, 2, 3, 4, 5}; 34 const uint64_t kTestDeviceIds[] = {1, 2, 3, 4, 5};
31 #else 35 #else
32 const char* kTestDeviceIds[] = {"A", "B", "C", "D", "E"}; 36 const char* kTestDeviceIds[] = {"A", "B", "C", "D", "E"};
33 #endif 37 #endif
34 38
35 // These report descriptors define two devices with 8-byte input, output and 39 // These report descriptors define two devices with 8-byte input, output and
36 // feature reports. The first implements usage page 0xFF00 and has a single 40 // feature reports. The first implements usage page 0xFF00 and has a single
37 // report without and ID. The second implements usage page 0xFF01 and has a 41 // report without and ID. The second implements usage page 0xFF01 and has a
38 // single report with ID 1. 42 // single report with ID 1.
39 const uint8 kReportDescriptor[] = {0x06, 0x00, 0xFF, 0x08, 0xA1, 0x01, 0x15, 43 const uint8_t kReportDescriptor[] = {0x06, 0x00, 0xFF, 0x08, 0xA1, 0x01, 0x15,
40 0x00, 0x26, 0xFF, 0x00, 0x75, 0x08, 0x95, 44 0x00, 0x26, 0xFF, 0x00, 0x75, 0x08, 0x95,
41 0x08, 0x08, 0x81, 0x02, 0x08, 0x91, 0x02, 45 0x08, 0x08, 0x81, 0x02, 0x08, 0x91, 0x02,
42 0x08, 0xB1, 0x02, 0xC0}; 46 0x08, 0xB1, 0x02, 0xC0};
43 const uint8 kReportDescriptorWithIDs[] = { 47 const uint8_t kReportDescriptorWithIDs[] = {
44 0x06, 0x01, 0xFF, 0x08, 0xA1, 0x01, 0x15, 0x00, 0x26, 48 0x06, 0x01, 0xFF, 0x08, 0xA1, 0x01, 0x15, 0x00, 0x26,
45 0xFF, 0x00, 0x85, 0x01, 0x75, 0x08, 0x95, 0x08, 0x08, 49 0xFF, 0x00, 0x85, 0x01, 0x75, 0x08, 0x95, 0x08, 0x08,
46 0x81, 0x02, 0x08, 0x91, 0x02, 0x08, 0xB1, 0x02, 0xC0}; 50 0x81, 0x02, 0x08, 0x91, 0x02, 0x08, 0xB1, 0x02, 0xC0};
47 51
48 namespace extensions { 52 namespace extensions {
49 53
50 class MockHidConnection : public device::HidConnection { 54 class MockHidConnection : public device::HidConnection {
51 public: 55 public:
52 explicit MockHidConnection(scoped_refptr<HidDeviceInfo> device_info) 56 explicit MockHidConnection(scoped_refptr<HidDeviceInfo> device_info)
53 : HidConnection(device_info) {} 57 : HidConnection(device_info) {}
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 AddDevice(kTestDeviceIds[0], 0x18D1, 0x58F0, false); 185 AddDevice(kTestDeviceIds[0], 0x18D1, 0x58F0, false);
182 AddDevice(kTestDeviceIds[1], 0x18D1, 0x58F0, true); 186 AddDevice(kTestDeviceIds[1], 0x18D1, 0x58F0, true);
183 AddDevice(kTestDeviceIds[2], 0x18D1, 0x58F1, false); 187 AddDevice(kTestDeviceIds[2], 0x18D1, 0x58F1, false);
184 device_client_->hid_service()->FirstEnumerationComplete(); 188 device_client_->hid_service()->FirstEnumerationComplete();
185 } 189 }
186 190
187 void AddDevice(const HidDeviceId& device_id, 191 void AddDevice(const HidDeviceId& device_id,
188 int vendor_id, 192 int vendor_id,
189 int product_id, 193 int product_id,
190 bool report_id) { 194 bool report_id) {
191 std::vector<uint8> report_descriptor; 195 std::vector<uint8_t> report_descriptor;
192 if (report_id) { 196 if (report_id) {
193 report_descriptor.insert( 197 report_descriptor.insert(
194 report_descriptor.begin(), kReportDescriptorWithIDs, 198 report_descriptor.begin(), kReportDescriptorWithIDs,
195 kReportDescriptorWithIDs + sizeof(kReportDescriptorWithIDs)); 199 kReportDescriptorWithIDs + sizeof(kReportDescriptorWithIDs));
196 } else { 200 } else {
197 report_descriptor.insert(report_descriptor.begin(), kReportDescriptor, 201 report_descriptor.insert(report_descriptor.begin(), kReportDescriptor,
198 kReportDescriptor + sizeof(kReportDescriptor)); 202 kReportDescriptor + sizeof(kReportDescriptor));
199 } 203 }
200 device_client_->hid_service()->AddDevice( 204 device_client_->hid_service()->AddDevice(
201 new HidDeviceInfo(device_id, vendor_id, product_id, "Test Device", "A", 205 new HidDeviceInfo(device_id, vendor_id, product_id, "Test Device", "A",
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 ExtensionTestMessageListener remove_listener("removed", false); 257 ExtensionTestMessageListener remove_listener("removed", false);
254 device_client_->hid_service()->RemoveDevice(kTestDeviceIds[0]); 258 device_client_->hid_service()->RemoveDevice(kTestDeviceIds[0]);
255 ASSERT_TRUE(remove_listener.WaitUntilSatisfied()); 259 ASSERT_TRUE(remove_listener.WaitUntilSatisfied());
256 260
257 ExtensionTestMessageListener add_listener("added", false); 261 ExtensionTestMessageListener add_listener("added", false);
258 AddDevice(kTestDeviceIds[0], 0x18D1, 0x58F0, true); 262 AddDevice(kTestDeviceIds[0], 0x18D1, 0x58F0, true);
259 ASSERT_TRUE(add_listener.WaitUntilSatisfied()); 263 ASSERT_TRUE(add_listener.WaitUntilSatisfied());
260 } 264 }
261 265
262 } // namespace extensions 266 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/hid/hid_api.cc ('k') | extensions/browser/api/hid/hid_connection_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698