1# Lint as: python3 2# Copyright 2022 The Chromium OS Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6import unittest 7from autotest_lib.client.cros.bluetooth.hcitool import HciToolParser 8 9 10class HciToolParserTest(unittest.TestCase): 11 """Unit test for class HciToolParser.""" 12 13 def test_parse_output(self): 14 VALID_OUTPUT = ('< HCI Command: ogf 0x04, ocf 0x0003, plen 0\n' 15 '> HCI Event: 0x0e plen 12\n' 16 ' 01 03 10 00 BF FE 0F FE DB FF 7B 87') 17 18 VALID_EVENT_TYPE = '0x0e' 19 VALID_PLEN_VALUE = 9 20 VALID_PASS_STATUS_CODE = 0 21 VALID_PAYLOAD = bytearray.fromhex('00 BF FE 0F FE DB FF 7B 87') 22 23 parser_output = HciToolParser.parse_output(VALID_OUTPUT) 24 event_type, plen_value, status, payload = parser_output 25 self.assertEqual(event_type, VALID_EVENT_TYPE) 26 self.assertEqual(plen_value, VALID_PLEN_VALUE) 27 self.assertEqual(status, VALID_PASS_STATUS_CODE) 28 self.assertEqual(payload, VALID_PAYLOAD) 29