2 # Copyright 2014 The Chromium 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.
15 class MouseGadgetTest(unittest
.TestCase
):
18 g
= mouse_gadget
.MouseGadget()
20 g
.Connected(chip
, usb_constants
.Speed
.FULL
)
21 g
.ButtonDown(hid_constants
.Mouse
.BUTTON_1
)
22 self
.assertEqual(g
.ControlRead(0xA1, 1, 0x0100, 0, 8), '\x01\x00\x00')
23 g
.ButtonUp(hid_constants
.Mouse
.BUTTON_1
)
24 chip
.SendPacket
.assert_has_calls([
25 mock
.call(0x81, '\x01\x00\x00'),
26 mock
.call(0x81, '\x00\x00\x00'),
30 g
= mouse_gadget
.MouseGadget()
32 g
.Connected(chip
, usb_constants
.Speed
.FULL
)
34 chip
.SendPacket
.assert_called(0x81, '\x00\xFF\x01')
37 g
= mouse_gadget
.MouseGadget()
39 g
.Connected(chip
, usb_constants
.Speed
.FULL
)
40 g
.ButtonDown(hid_constants
.Mouse
.BUTTON_1
)
42 g
.ButtonUp(hid_constants
.Mouse
.BUTTON_1
)
43 chip
.SendPacket
.assert_has_calls([
44 mock
.call(0x81, '\x01\x00\x00'),
45 mock
.call(0x81, '\x01\x05\x05'),
46 mock
.call(0x81, '\x00\x00\x00'),
49 if __name__
== '__main__':