def test_set_wheel_color(self, mouse): mouse.set_wheel_color( "rgbgradient(duration=5000; colors=0%: #112233, 25%: #445566, 50%: #778899, 75%: #AABBCC)" ) # noqa mouse._hid_device.bytes.seek(0) hid_report = mouse._hid_device.bytes.read() expected_hid_report = b"" expected_hid_report += b"\x03\x00\x5B\x00\x01\x88\x13\x00\x00\x00" # |wValue |command|LED|duratio| expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" # expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05" # |rpt| |trg| |clr count expected_hid_report += b"\x11\x22\x33" # |init color | expected_hid_report += b"\x11\x22\x33\x00" # |color1 |pos1| expected_hid_report += b"\x44\x55\x66\x3F" # |color2 |pos2| expected_hid_report += b"\x77\x88\x99\x40" # |color3 |pos3| expected_hid_report += b"\xAA\xBB\xCC\x40" # |color4 |pos4| expected_hid_report += b"\x11\x22\x33\x40" # (=color1: smoothing) |color5 |pos5| assert hid_report == expected_hid_report
def test_set_wheel_color_with_color_string(self, mouse): mouse.set_wheel_color("#FF1800") mouse._hid_device.bytes.seek(0) hid_report = mouse._hid_device.bytes.read() expected_hid_report = b"" expected_hid_report += b"\x03\x00\x05\x00" expected_hid_report += b"\x01\x1D\x01\x02\x31\x51\xFF\xC8\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\xF0" expected_hid_report += b"\x0F\x80\x01\x00\x00\xFF\x00\xDC\x05\x8A" expected_hid_report += b"\x02\x00\x00\x00\x00\x01\x00\x00\x00\xE8" expected_hid_report += b"\x03" assert hid_report == expected_hid_report
def test_set_wheel_color(self, mouse): mouse.set_wheel_color( "rgbgradient(duration=5000; colors=0%: #112233, 25%: #445566, 50%: #778899, 75%: #AABBCC)" ) # noqa mouse._hid_device.bytes.seek(0) hid_report = mouse._hid_device.bytes.read() expected_hid_report = b"" expected_hid_report += b"\x03\x00\x05\x00" expected_hid_report += b"\x01\x1D\x01\x02\x31\x51\xFF\xC8\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\xE2\x04\x01\x00\x00" expected_hid_report += b"\x00\x00\x00\xE2\x04\x02\x00\x00\x00\x00" expected_hid_report += b"\x00\xE2\x04\x03\x00\xFF\xFF\xFF\x00\xE2" expected_hid_report += b"\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10" expected_hid_report += b"\x01\x20\x02\x30\x03\xFF\x00\xDC\x05\x8A" expected_hid_report += b"\x02\x00\x00\x00\x00\x01\x00\x04\x00\x88" expected_hid_report += b"\x13" assert hid_report == expected_hid_report
def test_set_wheel_color(self, mouse): mouse.set_wheel_color( "rgbgradient(duration=5000; colors=0%: #ff0000, 33%: #00ff00, 66%: #0000ff)" ) # noqa mouse._hid_device.bytes.seek(0) hid_report = mouse._hid_device.bytes.read() expected_hid_report = b"" expected_hid_report += b"\x03\x00\x05\x00\x00\x00\x00\x00\x00\x00" # |wValue |command|led| |led| expected_hid_report += b"\x88\x13\x00\x00\x00\x00\x00\x00\x00\x00" # |duratio| expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" # |rpt|trg| expected_hid_report += b"\x00\x04\xFF\x00\x00" # |init color | expected_hid_report += b"\xFF\x00\x00\x00" # |color1 |ps1| expected_hid_report += b"\x00\xFF\x00\x54" # |color2 |ps2| expected_hid_report += b"\x00\x00\xFF\x54" # |color3 |ps3| expected_hid_report += b"\xFF\x00\x00\x57" # |color4 |ps4| # color4 = color1 (added for smoothing) assert hid_report == expected_hid_report
def test_set_wheel_color_with_color_string(self, mouse): mouse.set_wheel_color("#FF1800") mouse._hid_device.bytes.seek(0) hid_report = mouse._hid_device.bytes.read() expected_hid_report = b"" expected_hid_report += b"\x03\x00\x5B\x00\x01\xe8\x03\x00\x00\x00" # |wValue |command|LED|duratio| expected_hid_report += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" # expected_hid_report += b"\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01" # |rpt| |trg| |clr count expected_hid_report += b"\xff\x18\x00\xff\x18\x00\x00" # |init color |color1 |ps1| assert hid_report == expected_hid_report
def test_set_wheel_color(self, mouse, value, expected_hid_report): mouse.set_wheel_color(value) mouse._hid_device.bytes.seek(0) hid_report = mouse._hid_device.bytes.read() assert hid_report == expected_hid_report