Esempio n. 1
0
    def get_expected_keybits(self):
        expected_keys = self._expected_key_ntrig_dell_xt2.keys()
        keymax = event_get_value("EV_KEY", "KEY_MAX")
        expected = dict.fromkeys(range(0, keymax + 1), False)
        expected.update((k, True) for k in expected_keys)

        return expected
Esempio n. 2
0
    def get_expected_keybits(self):
        expected_keys = self._expected_key_ntrig_dell_xt2.keys()
        keymax = event_get_value("EV_KEY", "KEY_MAX")
        expected = dict.fromkeys(range(0, keymax + 1), False)
        expected.update((k, True) for k in expected_keys)

        return expected
Esempio n. 3
0
    def get_expected_absbits(self):
        expected_keys = self._expected_abs_ntrig_dell_xt2.keys()

        absmax = event_get_value("EV_ABS", "ABS_MAX")
        expected = dict.fromkeys(range(0, absmax + 1), False)
        expected.update((k, True) for k in expected_keys)

        return expected
Esempio n. 4
0
    def get_expected_abs(self, sub_key):
        expected_items = self._expected_abs_ntrig_dell_xt2.items()

        absmax = event_get_value("EV_ABS", "ABS_MAX")
        expected = dict.fromkeys(range(0, absmax + 1), 0)
        expected.update((k, v[sub_key]) for (k, v) in expected_items)

        return expected
Esempio n. 5
0
    def get_expected_absbits(self):
        expected_keys = self._expected_abs_ntrig_dell_xt2.keys()

        absmax = event_get_value("EV_ABS", "ABS_MAX")
        expected = dict.fromkeys(range(0, absmax + 1), False)
        expected.update((k, True) for k in expected_keys)

        return expected
Esempio n. 6
0
    def get_expected_abs(self, sub_key):
        expected_items = self._expected_abs_ntrig_dell_xt2.items()

        absmax = event_get_value("EV_ABS", "ABS_MAX")
        expected = dict.fromkeys(range(0, absmax + 1), 0)
        expected.update((k, v[sub_key]) for (k, v) in expected_items)

        return expected
    def test_btntool_state_not_set_twice(self):
        state = [ 0 ] * 5
        for e in self.d.events():
            if e.type != evemu.event_get_value("EV_KEY"):
                continue

            if e.matches("EV_KEY", "BTN_TOOL_FINGER"):
                index = 0
            elif e.matches("EV_KEY", "BTN_TOOL_DOUBLETAP"):
                index = 1
            elif e.matches("EV_KEY", "BTN_TOOL_TRIPLETAP"):
                index = 2
            elif e.matches("EV_KEY", "BTN_TOOL_QUADTAP"):
                index = 3
            elif e.matches("EV_KEY", "BTN_TOOL_QUINTTAP"):
                index = 4
            else:
                continue

            expected = 1 - e.value
            self.assertEqual(state[index], expected)
            state[index] = e.value
Esempio n. 8
0
    def test_has_event_ev_abs(self):
        absmax = evemu.event_get_value("EV_ABS", "ABS_MAX")
        keys = range(0, absmax + 1)
        results = dict((x, self._device.has_event("EV_ABS", x)) for x in keys)

        self.assertEqual(results, self.get_expected_absbits())
Esempio n. 9
0
    def test_get_abs_resolution(self):
        absmax = evemu.event_get_value("EV_ABS", "ABS_MAX")
        keys = range(0, absmax + 1)
        results = dict((x, self._device.get_abs_resolution(x)) for x in keys)

        self.assertEqual(results, self.get_expected_abs("res"))
Esempio n. 10
0
    def test_event_names(self):
        self.assertEqual(evemu.event_get_value("EV_SYN"), 0x00)
        self.assertEqual(evemu.event_get_value("EV_KEY"), 0x01)
        self.assertEqual(evemu.event_get_value("EV_ABS"), 0x03)
        self.assertEqual(evemu.event_get_value("EV_FOO"), None)
        self.assertEqual(evemu.event_get_value(1), 1)
        self.assertEqual(evemu.event_get_value(100), None)

        self.assertEqual(evemu.event_get_value("EV_SYN", "SYN_REPORT"), 0x00)
        self.assertEqual(evemu.event_get_value("EV_KEY", "KEY_Z"), 44)
        self.assertEqual(evemu.event_get_value("EV_ABS", "ABS_X"), 0x00)
        self.assertEqual(evemu.event_get_value("EV_ABS", "ABS_FOO"), None)
        self.assertEqual(evemu.event_get_value(1), 1)
        self.assertEqual(evemu.event_get_value(100), None)

        self.assertEqual(evemu.event_get_name(0x00), "EV_SYN")
        self.assertEqual(evemu.event_get_name(0x01), "EV_KEY")
        self.assertEqual(evemu.event_get_name(0x03), "EV_ABS")
        self.assertEqual(evemu.event_get_name(0xFFFF), None)
        self.assertEqual(evemu.event_get_name("foo"), None)
        self.assertEqual(evemu.event_get_name("EV_SYN"), "EV_SYN")

        self.assertEqual(evemu.event_get_name("EV_SYN", 0x00), "SYN_REPORT")
        self.assertEqual(evemu.event_get_name("EV_REL", 0x01), "REL_Y")
        self.assertEqual(evemu.event_get_name("EV_ABS", 0x00), "ABS_X")
        self.assertEqual(evemu.event_get_name("EV_ABS", 0xFFFF), None)
        self.assertEqual(evemu.event_get_name("EV_ABS", "foo"), None)
        self.assertEqual(evemu.event_get_name("EV_ABS", "ABS_X"), "ABS_X")

        self.assertEqual(evemu.event_get_name(None), None)
        self.assertEqual(evemu.event_get_name(None, None), None)
Esempio n. 11
0
    def test_has_event_ev_abs(self):
        absmax = evemu.event_get_value("EV_ABS", "ABS_MAX")
        keys = range(0, absmax + 1)
        results = dict((x, self._device.has_event("EV_ABS", x)) for x in keys)

        self.assertEqual(results, self.get_expected_absbits())
Esempio n. 12
0
    def test_get_abs_resolution(self):
        absmax = evemu.event_get_value("EV_ABS", "ABS_MAX")
        keys = range(0, absmax + 1)
        results = dict((x, self._device.get_abs_resolution(x)) for x in keys)

        self.assertEqual(results, self.get_expected_abs("res"))
 def test_touchpad_device_has_no_rel_axes(self):
     for i in range(0, evemu.event_get_value("EV_REL", "REL_MAX")):
         self.assertFalse(self.d.has_event("EV_REL", i))
Esempio n. 14
0
class BaseTestCase(unittest.TestCase):
    def setUp(self):
        super(BaseTestCase, self).setUp()
        basedir = get_top_directory()
        self.data_dir = os.path.join(basedir, "..", "..", "data")
        self.device = None

    def tearDown(self):
        if self.device:
            self.device.destroy()
        super(BaseTestCase, self).tearDown()

    def get_device_file(self):
        return os.path.join(self.data_dir, "ntrig-dell-xt2.prop")

    def get_events_file(self):
        return os.path.join(self.data_dir, "ntrig-dell-xt2.event")

    _expected_abs_ntrig_dell_xt2 = {
        # A: 00 0 9600 75 0 0
        evemu.event_get_value("EV_ABS", "ABS_X"): {
            "min": 0,
            "max": 9600,
            "fuzz": 75,
            "flat": 0,
            "res": 0
        },
        # A: 01 0 7200 78 0 0
        evemu.event_get_value("EV_ABS", "ABS_Y"): {
            "min": 0,
            "max": 7200,
            "fuzz": 78,
            "flat": 0,
            "res": 0
        },
        # A: 30 0 9600 200 0 0
        evemu.event_get_value("EV_ABS", "ABS_MT_TOUCH_MAJOR"): {
            "min": 0,
            "max": 9600,
            "fuzz": 200,
            "flat": 0,
            "res": 0
        },
        # A: 31 0 7200 150 0 0
        evemu.event_get_value("EV_ABS", "ABS_MT_TOUCH_MINOR"): {
            "min": 0,
            "max": 7200,
            "fuzz": 150,
            "flat": 0,
            "res": 0
        },
        # A: 34 0 1 0 0 0
        evemu.event_get_value("EV_ABS", "ABS_MT_ORIENTATION"): {
            "min": 0,
            "max": 1,
            "fuzz": 0,
            "flat": 0,
            "res": 0
        },
        # A: 35 0 9600 75 0 0
        evemu.event_get_value("EV_ABS", "ABS_MT_POSITION_X"): {
            "min": 0,
            "max": 9600,
            "fuzz": 75,
            "flat": 0,
            "res": 0
        },
        # A: 36 0 7200 78 0 0
        evemu.event_get_value("EV_ABS", "ABS_MT_POSITION_Y"): {
            "min": 0,
            "max": 7200,
            "fuzz": 78,
            "flat": 0,
            "res": 0
        }
    }
    _expected_key_ntrig_dell_xt2 = {
        evemu.event_get_value("EV_KEY", "BTN_TOUCH"): True
    }

    def get_expected_abs(self, sub_key):
        expected_items = self._expected_abs_ntrig_dell_xt2.items()

        absmax = event_get_value("EV_ABS", "ABS_MAX")
        expected = dict.fromkeys(range(0, absmax + 1), 0)
        expected.update((k, v[sub_key]) for (k, v) in expected_items)

        return expected

    def get_expected_absbits(self):
        expected_keys = self._expected_abs_ntrig_dell_xt2.keys()

        absmax = event_get_value("EV_ABS", "ABS_MAX")
        expected = dict.fromkeys(range(0, absmax + 1), False)
        expected.update((k, True) for k in expected_keys)

        return expected

    def get_expected_keybits(self):
        expected_keys = self._expected_key_ntrig_dell_xt2.keys()
        keymax = event_get_value("EV_KEY", "KEY_MAX")
        expected = dict.fromkeys(range(0, keymax + 1), False)
        expected.update((k, True) for k in expected_keys)

        return expected

    def get_expected_propbits(self):
        # no props for N-Trig-MultiTouch-Virtual-Device, so we
        # return a dict with all keys on False
        propmax = input_prop_get_value("INPUT_PROP_MAX")
        keys = range(0, propmax + 1)
        return dict.fromkeys(keys, False)
Esempio n. 15
0
    def test_has_event_ev_key(self):
        keymax = evemu.event_get_value("EV_KEY", "KEY_MAX")
        keys = range(0, keymax + 1)
        results = dict((x, self._device.has_event("EV_KEY", x)) for x in keys)

        self.assertEqual(results, self.get_expected_keybits())
Esempio n. 16
0
    def test_event_names(self):
        self.assertEqual(evemu.event_get_value("EV_SYN"), 0x00)
        self.assertEqual(evemu.event_get_value("EV_KEY"), 0x01)
        self.assertEqual(evemu.event_get_value("EV_ABS"), 0x03)
        self.assertEqual(evemu.event_get_value("EV_FOO"), None)
        self.assertEqual(evemu.event_get_value(1), 1)
        self.assertEqual(evemu.event_get_value(100), None)

        self.assertEqual(evemu.event_get_value("EV_SYN", "SYN_REPORT"), 0x00)
        self.assertEqual(evemu.event_get_value("EV_KEY", "KEY_Z"), 44)
        self.assertEqual(evemu.event_get_value("EV_ABS", "ABS_X"), 0x00)
        self.assertEqual(evemu.event_get_value("EV_ABS", "ABS_FOO"), None)
        self.assertEqual(evemu.event_get_value(1), 1)
        self.assertEqual(evemu.event_get_value(100), None)

        self.assertEqual(evemu.event_get_name(0x00), "EV_SYN")
        self.assertEqual(evemu.event_get_name(0x01), "EV_KEY")
        self.assertEqual(evemu.event_get_name(0x03), "EV_ABS")
        self.assertEqual(evemu.event_get_name(0xFFFF), None)
        self.assertEqual(evemu.event_get_name("foo"), None)
        self.assertEqual(evemu.event_get_name("EV_SYN"), "EV_SYN")

        self.assertEqual(evemu.event_get_name("EV_SYN", 0x00), "SYN_REPORT")
        self.assertEqual(evemu.event_get_name("EV_REL", 0x01), "REL_Y")
        self.assertEqual(evemu.event_get_name("EV_ABS", 0x00), "ABS_X")
        self.assertEqual(evemu.event_get_name("EV_ABS", 0xFFFF), None)
        self.assertEqual(evemu.event_get_name("EV_ABS", "foo"), None)
        self.assertEqual(evemu.event_get_name("EV_ABS", "ABS_X"), "ABS_X")

        self.assertEqual(evemu.event_get_name(None), None)
        self.assertEqual(evemu.event_get_name(None, None), None)
Esempio n. 17
0
    def test_has_event_ev_key(self):
        keymax = evemu.event_get_value("EV_KEY", "KEY_MAX")
        keys = range(0, keymax + 1)
        results = dict((x, self._device.has_event("EV_KEY", x)) for x in keys)

        self.assertEqual(results, self.get_expected_keybits())