This file is indexed.

/usr/lib/python3/dist-packages/checkbox/parsers/tests/test_xinput.py is in python3-checkbox 0.17.6-0ubuntu6.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# -*- coding: utf-8 -*-
#
# This file is part of Checkbox.
#
# Copyright 2012 Canonical Ltd.
#
# Checkbox is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3,
# as published by the Free Software Foundation.

#
# Checkbox is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Checkbox.  If not, see <http://www.gnu.org/licenses/>.
#
import os

from unittest import TestCase

from checkbox.parsers.xinput import (
    DEVICE_RE,
    ATTRIBUTE_RE,
    CLASS_VALUE_RE,
    LIST_VALUE_RE,
    IXinputResult,
    XinputParser,
    )


class TestDeviceRe(TestCase):

    def test_string(self):
        match = DEVICE_RE.match(
            """⎡ Virtual core pointer                      """
            """id=2    [master pointer  (3)]""")
        self.assertTrue(match)
        self.assertEqual(match.group("name"), "Virtual core pointer")
        self.assertEqual(match.group("id"), "2")


class TestAttributeRe(TestCase):

    def test_string(self):
        match = ATTRIBUTE_RE.match("""Buttons supported: 12""")
        self.assertTrue(match)
        self.assertEqual(match.group("key"), "Buttons supported")
        self.assertEqual(match.group("value"), "12")


class TestClassValueRe(TestCase):

    def test_string(self):
        match = CLASS_VALUE_RE.match("""12. Type: XIButtonClass""")
        self.assertTrue(match)
        self.assertEqual(match.group("class"), "XIButtonClass")


class TestListValueRe(TestCase):

    def test_string(self):
        elements = LIST_VALUE_RE.split(
            """"Button Horiz Wheel Right" None None""")[1::2]
        self.assertTrue(elements)
        self.assertEqual(len(elements), 3)
        self.assertEqual(elements[0], '"Button Horiz Wheel Right"')
        self.assertEqual(elements[1], "None")
        self.assertEqual(elements[2], "None")


class XinputResult(IXinputResult):

    def __init__(self):
        self.devices = {}

    def addXinputDevice(self, device):
        self.devices[device["id"]] = device

    def addXinputDeviceClass(self, device, device_class):
        self.devices[device["id"]].setdefault("classes", [])
        self.devices[device["id"]]["classes"].append(device_class)


class TestXinputParser(TestCase):


    def getResult(self, name):
        fixture = os.path.join(os.path.dirname(__file__), "fixtures", name)
        result = XinputResult()
        with open(fixture, encoding="utf-8") as stream:
            parser = XinputParser(stream)
            parser.run(result)
        return result

    def test_number_of_devices_with_spaces(self):
        """The toshiba xinput with spaces contains 12 devices."""
        result = self.getResult("xinput_toshiba.txt")
        self.assertEqual(len(result.devices), 12)

    def test_number_of_devices_without_spaces(self):
        """The quantal xinput without spaces contains 14 devices."""
        result = self.getResult("xinput_quantal.txt")
        self.assertEqual(len(result.devices), 14)

    def test_multitouch_touchpad_device(self):
        """The toshiba xinput contains a multitouch touchpad device."""
        result = self.getResult("xinput_toshiba.txt")
        devices = [device for device in result.devices.values()
            if device["name"] == "AlpsPS/2 ALPS DualPoint TouchPad"]
        self.assertEqual(len(devices), 1)

        classes = [cls for cls in devices[0]["classes"]
            if cls["device_class"] == "XITouchClass"]
        self.assertEqual(len(classes), 1)
        self.assertEqual(classes[0]["touch_mode"], "dependent")

    def test_multitouch_touchscreen_device(self):
        """The quantal xinput contains a multitouch touchscreen device."""
        result = self.getResult("xinput_quantal.txt")
        devices = [device for device in result.devices.values()
            if device["name"] == "Quanta OpticalTouchScreen"]
        self.assertEqual(len(devices), 1)

        classes = [cls for cls in devices[0]["classes"]
            if cls["device_class"] == "XITouchClass"]
        self.assertEqual(len(classes), 1)
        self.assertEqual(classes[0]["touch_mode"], "direct")