| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <sstream> | 5 #include <sstream> |
| 6 | 6 |
| 7 #include "device/hid/hid_report_descriptor.h" | 7 #include "device/hid/hid_report_descriptor.h" |
| 8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 }; | 349 }; |
| 350 | 350 |
| 351 TEST_F(HidReportDescriptorTest, ValidateDetails_Digitizer) { | 351 TEST_F(HidReportDescriptorTest, ValidateDetails_Digitizer) { |
| 352 HidCollectionInfo digitizer; | 352 HidCollectionInfo digitizer; |
| 353 digitizer.usage = HidUsageAndPage(0x01, HidUsageAndPage::kPageDigitizer); | 353 digitizer.usage = HidUsageAndPage(0x01, HidUsageAndPage::kPageDigitizer); |
| 354 digitizer.report_ids.insert(1); | 354 digitizer.report_ids.insert(1); |
| 355 digitizer.report_ids.insert(2); | 355 digitizer.report_ids.insert(2); |
| 356 digitizer.report_ids.insert(3); | 356 digitizer.report_ids.insert(3); |
| 357 HidCollectionInfo expected[] = {digitizer}; | 357 HidCollectionInfo expected[] = {digitizer}; |
| 358 ValidateDetails(std::vector<HidCollectionInfo>( | 358 ValidateDetails(std::vector<HidCollectionInfo>( |
| 359 expected, expected + ARRAYSIZE_UNSAFE(expected)), | 359 expected, expected + arraysize(expected)), |
| 360 true, | 360 true, |
| 361 6, | 361 6, |
| 362 0, | 362 0, |
| 363 0, | 363 0, |
| 364 kDigitizer, | 364 kDigitizer, |
| 365 sizeof(kDigitizer)); | 365 sizeof(kDigitizer)); |
| 366 } | 366 } |
| 367 | 367 |
| 368 TEST_F(HidReportDescriptorTest, ValidateDetails_Keyboard) { | 368 TEST_F(HidReportDescriptorTest, ValidateDetails_Keyboard) { |
| 369 HidCollectionInfo keyboard; | 369 HidCollectionInfo keyboard; |
| 370 keyboard.usage = HidUsageAndPage(0x06, HidUsageAndPage::kPageGenericDesktop); | 370 keyboard.usage = HidUsageAndPage(0x06, HidUsageAndPage::kPageGenericDesktop); |
| 371 HidCollectionInfo expected[] = {keyboard}; | 371 HidCollectionInfo expected[] = {keyboard}; |
| 372 ValidateDetails(std::vector<HidCollectionInfo>( | 372 ValidateDetails(std::vector<HidCollectionInfo>( |
| 373 expected, expected + ARRAYSIZE_UNSAFE(expected)), | 373 expected, expected + arraysize(expected)), |
| 374 false, | 374 false, |
| 375 8, | 375 8, |
| 376 1, | 376 1, |
| 377 0, | 377 0, |
| 378 kKeyboard, | 378 kKeyboard, |
| 379 sizeof(kKeyboard)); | 379 sizeof(kKeyboard)); |
| 380 } | 380 } |
| 381 | 381 |
| 382 TEST_F(HidReportDescriptorTest, ValidateDetails_Monitor) { | 382 TEST_F(HidReportDescriptorTest, ValidateDetails_Monitor) { |
| 383 HidCollectionInfo monitor; | 383 HidCollectionInfo monitor; |
| 384 monitor.usage = HidUsageAndPage(0x01, HidUsageAndPage::kPageMonitor0); | 384 monitor.usage = HidUsageAndPage(0x01, HidUsageAndPage::kPageMonitor0); |
| 385 monitor.report_ids.insert(1); | 385 monitor.report_ids.insert(1); |
| 386 monitor.report_ids.insert(2); | 386 monitor.report_ids.insert(2); |
| 387 monitor.report_ids.insert(3); | 387 monitor.report_ids.insert(3); |
| 388 monitor.report_ids.insert(4); | 388 monitor.report_ids.insert(4); |
| 389 monitor.report_ids.insert(5); | 389 monitor.report_ids.insert(5); |
| 390 HidCollectionInfo expected[] = {monitor}; | 390 HidCollectionInfo expected[] = {monitor}; |
| 391 ValidateDetails(std::vector<HidCollectionInfo>( | 391 ValidateDetails(std::vector<HidCollectionInfo>( |
| 392 expected, expected + ARRAYSIZE_UNSAFE(expected)), | 392 expected, expected + arraysize(expected)), |
| 393 true, | 393 true, |
| 394 0, | 394 0, |
| 395 0, | 395 0, |
| 396 243, | 396 243, |
| 397 kMonitor, | 397 kMonitor, |
| 398 sizeof(kMonitor)); | 398 sizeof(kMonitor)); |
| 399 } | 399 } |
| 400 | 400 |
| 401 TEST_F(HidReportDescriptorTest, ValidateDetails_Mouse) { | 401 TEST_F(HidReportDescriptorTest, ValidateDetails_Mouse) { |
| 402 HidCollectionInfo mouse; | 402 HidCollectionInfo mouse; |
| 403 mouse.usage = HidUsageAndPage(0x02, HidUsageAndPage::kPageGenericDesktop); | 403 mouse.usage = HidUsageAndPage(0x02, HidUsageAndPage::kPageGenericDesktop); |
| 404 HidCollectionInfo expected[] = {mouse}; | 404 HidCollectionInfo expected[] = {mouse}; |
| 405 ValidateDetails(std::vector<HidCollectionInfo>( | 405 ValidateDetails(std::vector<HidCollectionInfo>( |
| 406 expected, expected + ARRAYSIZE_UNSAFE(expected)), | 406 expected, expected + arraysize(expected)), |
| 407 false, | 407 false, |
| 408 3, | 408 3, |
| 409 0, | 409 0, |
| 410 0, | 410 0, |
| 411 kMouse, | 411 kMouse, |
| 412 sizeof(kMouse)); | 412 sizeof(kMouse)); |
| 413 } | 413 } |
| 414 | 414 |
| 415 TEST_F(HidReportDescriptorTest, ValidateDetails_LogitechUnifyingReceiver) { | 415 TEST_F(HidReportDescriptorTest, ValidateDetails_LogitechUnifyingReceiver) { |
| 416 HidCollectionInfo hidpp_short; | 416 HidCollectionInfo hidpp_short; |
| 417 hidpp_short.usage = HidUsageAndPage(0x01, HidUsageAndPage::kPageVendor); | 417 hidpp_short.usage = HidUsageAndPage(0x01, HidUsageAndPage::kPageVendor); |
| 418 hidpp_short.report_ids.insert(0x10); | 418 hidpp_short.report_ids.insert(0x10); |
| 419 HidCollectionInfo hidpp_long; | 419 HidCollectionInfo hidpp_long; |
| 420 hidpp_long.usage = HidUsageAndPage(0x02, HidUsageAndPage::kPageVendor); | 420 hidpp_long.usage = HidUsageAndPage(0x02, HidUsageAndPage::kPageVendor); |
| 421 hidpp_long.report_ids.insert(0x11); | 421 hidpp_long.report_ids.insert(0x11); |
| 422 HidCollectionInfo hidpp_dj; | 422 HidCollectionInfo hidpp_dj; |
| 423 hidpp_dj.usage = HidUsageAndPage(0x04, HidUsageAndPage::kPageVendor); | 423 hidpp_dj.usage = HidUsageAndPage(0x04, HidUsageAndPage::kPageVendor); |
| 424 hidpp_dj.report_ids.insert(0x20); | 424 hidpp_dj.report_ids.insert(0x20); |
| 425 hidpp_dj.report_ids.insert(0x21); | 425 hidpp_dj.report_ids.insert(0x21); |
| 426 | 426 |
| 427 HidCollectionInfo expected[] = {hidpp_short, hidpp_long, hidpp_dj}; | 427 HidCollectionInfo expected[] = {hidpp_short, hidpp_long, hidpp_dj}; |
| 428 ValidateDetails(std::vector<HidCollectionInfo>( | 428 ValidateDetails(std::vector<HidCollectionInfo>( |
| 429 expected, expected + ARRAYSIZE_UNSAFE(expected)), | 429 expected, expected + arraysize(expected)), |
| 430 true, | 430 true, |
| 431 31, | 431 31, |
| 432 31, | 432 31, |
| 433 0, | 433 0, |
| 434 kLogitechUnifyingReceiver, | 434 kLogitechUnifyingReceiver, |
| 435 sizeof(kLogitechUnifyingReceiver)); | 435 sizeof(kLogitechUnifyingReceiver)); |
| 436 } | 436 } |
| 437 | 437 |
| 438 } // namespace device | 438 } // namespace device |
| OLD | NEW |