Esempio n. 1
0
 def test_interfaces_matches_spec(self):
     device_spec = usb_device_spec.UsbDeviceSpec(
         vid='vid',
         pid='pid',
         product='product',
         interfaces=['a', 'b'])
     self.assertTrue(self._usb_device.interfaces_match_spec(device_spec))
 def test_assert_usb_device_collector_matching_predicate(self):
     spec = usb_device_spec.UsbDeviceSpec('vid', 'pid', 'product',
                                          ['iface'])
     device = usb_device.UsbDevice('v', 'p', 'prod', ['if'], 1, 2, 1)
     self.usb_device_collector_mock.get_devices_by_spec = mock.Mock(
         return_value=[device])
     action = actions.AssertUsbDevices([spec],
                                       lambda x: x[0].product_id == 'p')
     action.execute(self.context_with_mocks)
Esempio n. 3
0
 - interfaces

This is different from a UsbDevice instance which represents a device actually
connected to the CfM and found by the usb-device command.

A UsbDevice instance found connected to a CfM is expected to match a known
UsbDeviceSpec (mapping is done using vid:pid), but due to bugs that might
not be the case (list of interfaces might be different for example).
"""

from autotest_lib.client.common_lib.cros.cfm.usb import usb_device_spec

# Cameras
AVER_CAM520_CAMERA = usb_device_spec.UsbDeviceSpec(
    vid='2574',
    pid='0910',
    product='CAM520',
    interfaces=['uvcvideo', 'uvcvideo', 'usbhid'],
)

AVER_VC520_CAMERA = usb_device_spec.UsbDeviceSpec(
    vid='2574',
    pid='0901',
    product='VC520+',
    interfaces=[
        'uvcvideo', 'uvcvideo', 'snd-usb-audio', 'snd-usb-audio',
        'snd-usb-audio', 'usbhid'
    ],
)

HUDDLY_GO = usb_device_spec.UsbDeviceSpec(
    vid='2bd9',
 def setUp(self):
     self._spec = usb_device_spec.UsbDeviceSpec(vid='vid',
                                                pid='pid',
                                                product='product',
                                                interfaces=['a', 'b'])
Esempio n. 5
0
 def test_get_devices_by_not_matching_specs(self):
     specs = (usb_device_spec.UsbDeviceSpec('no', 'match', 'PRODUCT', []),
              usb_device_spec.UsbDeviceSpec('nono', 'match', 'PRODUCT', []))
     devices = self.collector.get_devices_by_spec(*specs)
     self.assertEquals(devices, [])
Esempio n. 6
0
 def test_get_devices_by_specs(self):
     specs = (usb_device_spec.UsbDeviceSpec('0a0a', '9f9f', 'PRODUCT', []),
              usb_device_spec.UsbDeviceSpec('0000', 'aaaa', 'PRODUCT', []))
     devices = self.collector.get_devices_by_spec(*specs)
     self.assertEquals(len(devices), 2)
Esempio n. 7
0
 def test_get_devices_by_spec(self):
     spec = usb_device_spec.UsbDeviceSpec('0a0a', '9f9f', 'PRODUCT', [])
     devices = self.collector.get_devices_by_spec(spec)
     self.assertEquals(len(devices), 1)
 def test_assert_usb_device_collector(self):
     spec = usb_device_spec.UsbDeviceSpec('vid', 'pid', 'product',
                                          ['iface'])
     action = actions.AssertUsbDevices([spec], lambda x: True)
     action.execute(self.context_with_mocks)
import mock
import unittest

from autotest_lib.client.common_lib.cros.cfm.usb import usb_device
from autotest_lib.client.common_lib.cros.cfm.usb import usb_device_spec
from autotest_lib.server.cros.cfm.configurable_test import actions
from autotest_lib.server.cros.cfm.configurable_test import action_context
from autotest_lib.server.cros.cfm.configurable_test import scenario

# Constants to use in case the actual values are irrelevant.
USB_DEVICE_SPEC = usb_device_spec.UsbDeviceSpec('vid', 'pid', 'product',
                                                ['iface'])

USB_DEVICE = usb_device.UsbDevice('v', 'p', 'prod', ['if'], 1, 2, 1)


# Test, disable missing-docstring
# pylint: disable=missing-docstring
class TestActions(unittest.TestCase):
    """
    Tests for the available actions for configurable CFM tests to run.
    """
    def setUp(self):
        self.host_mock = mock.MagicMock()
        self.cfm_facade_mock = mock.MagicMock()
        self.usb_device_collector_mock = mock.MagicMock()
        self.usb_port_manager_mock = mock.MagicMock()
        self.crash_detector_mock = mock.MagicMock()
        self.metrics_collector_mock = mock.MagicMock()
        self.context_with_mocks = action_context.ActionContext(
            host=self.host_mock,