external_display

Source code: external_display.py

Test external display with optional audio playback test.

Description

Verify the external display (HDMI, DP, USB to HDMI or USB to DP) is functional.

The test is defined by a list [display_label, display_id, audio_info, usbpd_spec]. Each item represents an external port:

  • display_label: I18n display name. e.g. _('DisplayPort) or _('HDMI External Display') or _('Type-C').

  • display_id: (str) ID used to identify target display path. e.g. DP-1, HDMI-A-1.

  • audio_info: A list of [audio_card, audio_device, init_actions], or None:

    • audio_card is either the card’s name (str), or the card’s index (int).

    • audio_device is the device’s index (int).

    • init_actions is a list of [card_name, action] (list). action is a dict key defined in audio.json (ref: audio.py) to be passed into dut.audio.ApplyAudioConfig.

    e.g. [["rt5650", "init_audio"], ["rt5650", "enable_hdmi"]]. This argument is optional. If set, the audio playback test is added.

  • usbpd_spec: An object of cros.factory.device.usb_c.USB_PD_SPEC_SCHEMA, or None.

It can also be configured to run automatically by specifying bft_fixture argument, and skip some steps by setting connect_only, start_output_only and stop_output_only.

Test Procedure

This test can be manual or automated depends on whether bft_fixture is specified. The test loops through all items in display_info and:

  1. Plug an external monitor to the port specified in dargs.

  2. If usbpd_spec is specified or display_label is Type-C, verify usbpd status automatically.

  3. Main display will automatically switch to the external one.

  4. Press the number or HW buttons shown on the display to verify display works.

  5. (Optional) If audio_info is specified, the speaker will play a random number, and operator has to press the number to verify audio functionality.

  6. Unplug the external monitor to finish the test.

Dependency

  • display component in device API.

  • Optional audio and usb_c components in device API.

  • Optional fixture can be used to support automated test.

Examples

To manually check external display, add this in test list:

{
  "pytest_name": "external_display",
  "args": {
    "display_info": [
      {
        "display_label": "i18n! HDMI External Display",
        "display_id": "HDMI-A-1"
      }
    ]
  }
}

To manually check external display at USB Port 0 with CC1 or CC2, add this in test list:

{
  "pytest_name": "external_display",
  "args": {
    "display_info": [
      {
        "display_label": "DisplayPort",
        "display_id": "DP-1",
        "usbpd_spec": 0
      }
    ]
  }
}

To manually check external display at USB Port 0 CC1, add this in test list:

{
  "pytest_name": "external_display",
  "args": {
    "display_info": [
      {
        "display_label": "DisplayPort",
        "display_id": "DP-1",
        "usbpd_spec": {
          "port": 0,
          "polarity": 1
        }
      }
    ]
  }
}

To manually check two external display USB ports and automatically detect display_id and usbpd_spec, add this in test list:

{
  "pytest_name": "external_display",
  "args": {
    "display_info": [
      {
        "display_label": "Type-C"
      },
      {
        "display_label": "Type-C"
      }
    ]
  }
}

For tablet or Chromebox, use HW buttons instead of keyboard numbers:

{
  "args": {
    "hw_buttons": [
      ["KEY_VOLUMEDOWN", "Volume Down"],
      ["KEY_VOLUMEUP", "Volume Up"],
      ["KEY_POWER", "Power Button"]
    ],
    "device_filter": "cros_ec_buttons"
  }
}

Test Arguments

Name

Type

Description

display_info

list

A list of tuples (display_label, display_id, audio_info, usbpd_spec) represents an external port to test. display_id and usbpd_spec can be detected automatically if display_label is in TYPE_FROM_LABEL.

bft_fixture

dict, None

(optional; default: None) A dictionary with the following items:

class_name

Fully-qualified class name of the BFTFixture implementation to use.

params

A dictionary of parameters for the BFTFixture class’s Init() method.

The default value of None means that no BFT fixture is used.

connect_only

bool

(optional; default: False) Just detect ext display connection. This is for a hack that DUT needs reboot after connect to prevent X crash.

start_output_only

bool

(optional; default: False) Only start output of external display. This is for bringing up the external display for other tests that need it.

stop_output_only

bool

(optional; default: False) Only stop output of external display. This is for bringing down the external display that other tests have finished using.

already_connect

bool

(optional; default: False) Also for the reboot hack with fixture. With it set to True, DUT does not issue plug ext display command.

drm_sysfs_path

str

(optional; default: '/sys/class/drm/card?') Path of drm sysfs entry. When given this arg, the pytest will directly get connection status from sysfs path rather than calling drm_utils. This is needed when the port is running under MST and thus the display id is dynamic generated.

timeout_secs

int

(optional; default: 30) Timeout in seconds when we ask operator to complete the challenge. None means no timeout.

hw_buttons

list, None

(optional; default: None) A list of [button_key_name, button_name] represents a HW button to use. You can refer to HWButton test if you need the params.

device_filter

int, str, None

(optional; default: None) Event ID or name for evdev. None for auto probe.