plugin: shell
name: graphics/driver_version
command: graphics_driver
estimated_duration: 0.500
_description: Parses Xorg.0.Log and discovers the running X driver and version

plugin: shell
name: graphics/xorg-version
requires: package.name == "x11-utils"
command: xdpyinfo | grep "^X.Org version" | cut -d ':' -f 2 | tr -d ' '
estimated_duration: 0.018
_description: Test to output the Xorg version

plugin: manual
name: graphics/resolution-change
depends: graphics/xorg-version
_description:
 PURPOSE:
     This test will verify that the GUI is usable after manually changing resolution
 STEPS:
     1. Open the Displays application
     2. Select a new resolution from the dropdown list
     3. Click on Apply
     4. Select the original resolution from the dropdown list
     5. Click on Apply
 VERIFICATION:
     Did the resolution change as expected?

plugin: shell
name: graphics/xorg-process
requires:
 package.name == 'xorg'
 package.name == 'procps'
command: pgrep -f '/usr/bin/X' >/dev/null
estimated_duration: 0.100
_description: Test that the X process is running.

plugin: shell
name: graphics/xorg-failsafe
requires: package.name == 'xorg'
command: ! test -e /var/log/Xorg.failsafe.log
estimated_duration: 0.030
_description: Test that the X is not running in failsafe mode.

plugin: user-verify
name: graphics/resolution
requires:
 device.category == 'VIDEO'
command: resolution_test
estimated_duration: 0.750
_description:
 PURPOSE:
     This test will verify the default display resolution
 STEPS:
     1. This display is using the following resolution:
 INFO:
     $output
 VERIFICATION:
     Is this acceptable for your display?

plugin: user-verify
name: graphics/screen-resolution
requires:
 device.category == 'VIDEO'
 package.name == 'qmlscene'
command: timeout 5 qmlscene --transparent --fullscreen $CHECKBOX_SHARE/scripts/resolution_test.qml
estimated_duration: 10
_description:
 PURPOSE:
     This test will verify the default display resolution
 STEPS:
     1. Click on Test to display the screen resolution overlay for 5 seconds.
 VERIFICATION:
     Is this acceptable for your display?

plugin: shell
name: graphics/minimum_resolution
requires:
 device.category == 'VIDEO'
command: resolution_test --horizontal 800 --vertical 600
estimated_duration: 0.331
_description:
 Ensure the current resolution meets or exceeds the recommended minimum
 resolution (800x600). See here for details:
 .
 https://help.ubuntu.com/community/Installation/SystemRequirements

plugin: user-verify
name: graphics/maximum_resolution
requires:
 device.category == 'VIDEO'
 package.name == 'zenity'
command: zenity --info --text "Maximum resolution: $(xrandr -q |grep -A 1 "connected\( primary\)* [0-9]" |tail -1 |awk '{print $1}')"
estimated_duration: 10
_description:
 PURPOSE:
     This test will verify the display is operating at its maximum supported resolution 
 STEPS:
     1. Consult the system's specifications and locate the screen's maximum supported resolution.
     2. Click on Test to display the maximum resolution that can be used by Ubuntu on the current display.
 VERIFICATION:
     Is this the display's maximum resolution?

name: graphics/modes
plugin: shell
command: graphics_modes_info
estimated_duration: 0.250
_description: Collect info on graphics modes (screen resolution and refresh rate)

name: graphics/color_depth
plugin: shell
command: color_depth_info
estimated_duration: 0.150
_description: Collect info on color depth and pixel format.

name: graphics/fresh_rate
plugin: shell
command: fresh_rate_info
_description: Collect info on fresh rate.

name: graphics/graphic_memory
plugin: shell
command: graphic_memory_info
_description: Collect info on graphic memory.

plugin: user-verify
name: graphics/display
requires: 
 package.name == 'xorg'
 package.name == 'gir1.2-gst-plugins-base-0.10' or package.name == 'gir1.2-gst-plugins-base-1.0'
command: gst_pipeline_test -t 2 'videotestsrc ! videoconvert ! autovideosink' || gst_pipeline_test -t 2 'videotestsrc ! ffmpegcolorspace ! autovideosink' 
_description:
 PURPOSE:
     This test will test the default display
 STEPS:
     1. Click "Test" to display a video test.
 VERIFICATION:
     Do you see color bars and static?

plugin: shell
name: graphics/VESA_drivers_not_in_use
command: cat /var/log/Xorg.0.log | perl -e '$a=0;while(<>){$a++ if /Loading.*vesa_drv\.so/;$a-- if /Unloading.*vesa/&&$a}exit 1 if $a'
estimated_duration: 0.011
_description: Check that VESA drivers are not in use

plugin: user-verify
name: graphics/cycle_resolution
requires: package.name == 'xorg'
depends: graphics/VESA_drivers_not_in_use
command: xrandr_cycle --screenshot-dir $CHECKBOX_DATA
estimated_duration: 250.000
_description:
 PURPOSE:
     This test cycles through the detected video modes
 STEPS:
     1. Click "Test" to start cycling through the video modes
 VERIFICATION:
     Did the screen appear to be working for each mode?

plugin: user-verify
name: graphics/rotation
depends: graphics/xorg-version
command: rotation_test
estimated_duration: 20.000
_description:
 PURPOSE:
     This test will test display rotation
 STEPS:
     1. Click "Test" to test display rotation. The display will be rotated every 4 seconds.
     2. Check if all rotations (normal right inverted left) took place without permanent screen corruption
 VERIFICATION:
     Did the display rotation take place without without permanent screen corruption?

plugin: shell
name: graphics/compiz_check
requires: package.name == 'nux-tools'
command: ! /usr/lib/nux/unity_support_test -c -p | ansi_parser | grep ":\(\s\+\)no"
estimated_duration: 0.130
_description: Check that hardware is able to run compiz

plugin: shell
name: graphics/unity-support
requires: package.name == 'nux-tools'
command: ! /usr/lib/nux/unity_support_test -p | ansi_parser | grep ":\(\s\+\)no"
estimated_duration: 0.131
_description: Check that hardware is able to run Unity 3D

plugin: user-verify
name: graphics/glxgears
requires: package.name == 'mesa-utils'
command: glxgears; true
_description:
 PURPOSE:
     This test tests the basic 3D capabilities of your video card
 STEPS:
     1. Click "Test" to execute an OpenGL demo. Press ESC at any time to close.
     2. Verify that the animation is not jerky or slow.
 VERIFICATION:
     1. Did the 3d animation appear?
     2. Was the animation free from slowness/jerkiness?

plugin: shell
name: graphics/3d_window_open_close
requires: package.name == 'mesa-utils'
command: window_test -t open-close -i 10
estimated_duration: 60.525
_description: Open and close a 3D window multiple times

plugin: shell
name: graphics/3d_window_suspend_resume
requires: package.name == 'mesa-utils'
command: window_test -t suspend-resume -i 10
estimated_duration: 121.00
_description: Open, suspend resume and close a 3D window multiple times

plugin: shell
name: graphics/multi_3d_windows_open_close
requires: package.name == 'mesa-utils'
command: window_test -t open-close-multi -i 10 -w 4
estimated_duration: 60.000
_description: Open and close 4 3D windows multiple times

plugin: shell
name: graphics/3d_window_move
requires: package.name == 'mesa-utils'
command: window_test -t move
estimated_duration: 50.000
_description: Move a 3D window around the screen

plugin: shell
name: graphics/screenshot
requires: package.name == 'fswebcam'
command: set -o pipefail; camera_test still --device=/dev/external_webcam -f ${CHECKBOX_DATA}/screenshot.jpg -q 2>&1 | ansi_parser
_description:
 PURPOSE:
     Take a screengrab of the current screen (logged on Unity desktop)
 STEPS:
     1. Take picture using USB webcam
 VERIFICATION:
     Review attachment manually later

plugin: attachment
name: screenshot.jpg
depends: graphics/screenshot
command: base64 ${CHECKBOX_DATA}/screenshot.jpg
_description: Attaches the screenshot captured in graphics/screenshot.

plugin: shell
name: graphics/screenshot_fullscreen_video
requires: package.name == 'fswebcam'
command:
 [ -f ${CHECKBOX_SHARE}/data/video/Ogg_Theora_Video.ogv ] || { echo "Video file not found"; exit 1; }
 dbus-launch gsettings set org.gnome.totem repeat true
 totem --fullscreen ${CHECKBOX_SHARE}/data/video/Ogg_Theora_Video.ogv 2>/dev/null &
 set -o pipefail
 sleep 15 && camera_test still --device=/dev/external_webcam -f ${CHECKBOX_DATA}/screenshot_fullscreen_video.jpg -q 2>&1 | ansi_parser
 sleep 5 && totem --quit 2>/dev/null
 dbus-launch gsettings set org.gnome.totem repeat false
_description:
 PURPOSE:
     Take a screengrab of the current screen during fullscreen video playback
 STEPS:
     1. Start a fullscreen video playback
     2. Take picture using USB webcam after a few seconds
 VERIFICATION:
     Review attachment manually later

plugin: attachment
name: screenshot_fullscreen_video.jpg
depends: graphics/screenshot_fullscreen_video
command: base64 ${CHECKBOX_DATA}/screenshot_fullscreen_video.jpg
_description: Attaches the screenshot captured in graphics/screenshot_fullscreen_video.

plugin: shell
name: graphics/screenshot_opencv_validation
requires: package.name == 'python-opencv'
environ: EXTERNAL_WEBCAM_DEVICE
command:
 screenshot_validation \
    ${CHECKBOX_SHARE}/data/images/logo_Ubuntu_stacked_black.png \
    --device=${EXTERNAL_WEBCAM_DEVICE:-/dev/external_webcam} \
    -o ${CHECKBOX_DATA}/screenshot_opencv_validation.jpg
_description:
 Take a screengrab of the screen displaying a black and white Ubuntu logo.
 Check that the screenshot matches the original file using OpenCV ORB detection.

plugin: attachment
name: screenshot_opencv_validation.jpg
depends: graphics/screenshot_opencv_validation
command: base64 ${CHECKBOX_DATA}/screenshot_opencv_validation.jpg
_description: Attaches the screenshot captured in graphics/screenshot_opencv_validation.
