1#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6from oeqa.runtime.case import OERuntimeTestCase
7from oeqa.core.decorator.depends import OETestDepends
8from oeqa.core.decorator.data import skipIfQemu
9from oeqa.runtime.decorator.package import OEHasPackage
10
11class USB_HID_Test(OERuntimeTestCase):
12
13    def keyboard_mouse_simulation(self):
14        (status, output) = self.target.run('export DISPLAY=:0 && xdotool key F2 && xdotool mousemove 100 100')
15        return self.assertEqual(status, 0,  msg = 'Failed to simulate keyboard/mouse input event, output : %s' % output)
16
17    def set_suspend(self):
18        (status, output) = self.target.run('sudo rtcwake -m mem -s 10')
19        return self.assertEqual(status, 0,  msg = 'Failed to suspends your system to RAM, output : %s' % output)
20
21    @OEHasPackage(['xdotool'])
22    @skipIfQemu()
23    @OETestDepends(['ssh.SSHTest.test_ssh'])
24    def test_USB_Hid_input(self):
25        self.keyboard_mouse_simulation()
26        self.set_suspend()
27        self.keyboard_mouse_simulation()
28