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

Unified Diff: extensions/browser/api/hid/hid_apitest.cc

Issue 1025553004: Switch HidDeviceId from IORegistry path to IORegistry entry ID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/hid/hid_service_mac.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/api/hid/hid_apitest.cc
diff --git a/extensions/browser/api/hid/hid_apitest.cc b/extensions/browser/api/hid/hid_apitest.cc
index 63012a10663c01d282df1dd9b4fa00678bc371e5..c53bc336ce8c3bfc2314951a8a4d3170e2b2193a 100644
--- a/extensions/browser/api/hid/hid_apitest.cc
+++ b/extensions/browser/api/hid/hid_apitest.cc
@@ -23,6 +23,12 @@ using device::HidService;
using device::HidUsageAndPage;
using net::IOBuffer;
+#if defined(OS_MACOSX)
+const uint64_t kTestDeviceIds[] = {1, 2, 3, 4, 5};
+#else
+const char* kTestDeviceIds[] = {"A", "B", "C", "D", "E"};
+#endif
+
namespace device {
// These report descriptors define two devices with 8-byte input, output and
@@ -131,13 +137,13 @@ class MockHidService : public HidService {
}
void LazyFirstEnumeration() {
- AddDevice("A", 0x18D1, 0x58F0, false);
- AddDevice("B", 0x18D1, 0x58F0, true);
- AddDevice("C", 0x18D1, 0x58F1, false);
+ AddDevice(kTestDeviceIds[0], 0x18D1, 0x58F0, false);
+ AddDevice(kTestDeviceIds[1], 0x18D1, 0x58F0, true);
+ AddDevice(kTestDeviceIds[2], 0x18D1, 0x58F1, false);
FirstEnumerationComplete();
}
- void AddDevice(const std::string& device_id,
+ void AddDevice(const HidDeviceId& device_id,
int vendor_id,
int product_id,
bool report_id) {
@@ -155,7 +161,7 @@ class MockHidService : public HidService {
report_descriptor));
}
- void RemoveDevice(const std::string& device_id) {
+ void RemoveDevice(const HidDeviceId& device_id) {
HidService::RemoveDevice(device_id);
}
};
@@ -190,8 +196,8 @@ IN_PROC_BROWSER_TEST_F(HidApiTest, OnDeviceAdded) {
// Add a blocked device first so that the test will fail if a notification is
// received.
- hid_service_->AddDevice("D", 0x18D1, 0x58F1, false);
- hid_service_->AddDevice("E", 0x18D1, 0x58F0, false);
+ hid_service_->AddDevice(kTestDeviceIds[3], 0x18D1, 0x58F1, false);
+ hid_service_->AddDevice(kTestDeviceIds[4], 0x18D1, 0x58F0, false);
ASSERT_TRUE(result_listener.WaitUntilSatisfied());
EXPECT_EQ("success", result_listener.message());
}
@@ -206,9 +212,9 @@ IN_PROC_BROWSER_TEST_F(HidApiTest, OnDeviceRemoved) {
// Device C was not returned by chrome.hid.getDevices, the app will not get
// a notification.
- hid_service_->RemoveDevice("C");
+ hid_service_->RemoveDevice(kTestDeviceIds[2]);
// Device A was returned, the app will get a notification.
- hid_service_->RemoveDevice("A");
+ hid_service_->RemoveDevice(kTestDeviceIds[0]);
ASSERT_TRUE(result_listener.WaitUntilSatisfied());
EXPECT_EQ("success", result_listener.message());
}
« no previous file with comments | « device/hid/hid_service_mac.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698