Add cycler method for cycling change the resolution and transform (New)#1576
Add cycler method for cycling change the resolution and transform (New)#1576
Conversation
replace the old gnome_randr_cycle.py.
2. try to fix TypeError
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1576 +/- ##
=======================================
Coverage 48.00% 48.00%
=======================================
Files 371 370 -1
Lines 39833 39832 -1
Branches 6730 6728 -2
=======================================
Hits 19121 19121
Misses 19994 19994
+ Partials 718 717 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
p-gentili
left a comment
There was a problem hiding this comment.
Thanks for working on this! A few suggestions below, mostly for clearness.
Do you have a test job we can use for testing?
Co-authored-by: Paolo Gentili <paolo.gentili@canonical.com>
The example code is #!/usr/bin/env python3
from collections import namedtuple
from typing import List
from fractions import Fraction
from checkbox_support.monitor_config import MonitorConfig
from checkbox_support.helpers import display_info
import subprocess
import time
Mode = namedtuple("Mode", ["id", "resolution", "is_preferred", "is_current"])
def resolution_filter(modes: List[Mode]):
new_modes = []
tmp_resolution = []
sort_modes = sorted(
modes, key=lambda m: int(m.resolution.split("x")[0]), reverse=True
)
for m in sort_modes:
width, height = [int(x) for x in m.resolution.split("x")]
aspect = Fraction(width, height)
if width < 675 or width / aspect < 530:
continue
if m.resolution in tmp_resolution:
continue
if len(new_modes) >= 5:
break
new_modes.append(m)
tmp_resolution.append(m.resolution)
return new_modes
def action(filename, **kwargs):
print(filename)
time.sleep(5)
subprocess.check_output(["sudo", "keyboard_mouse"])
subprocess.check_output(["gnome-screenshot", "-f", filename])
def cycle_test():
try:
monitor_config = display_info.get_monitor_config()
except ValueError as exc:
raise SystemExit("Current host is not support")
monitor_config.cycle(res=False, resolution_filter=None, transform=True, action=action)
if __name__ == "__main__":
cycle_test()the source code of keyboard_mouse command is in #1582 |
2. zip monitors and mode to make loop easier
logic as they want.
p-gentili
left a comment
There was a problem hiding this comment.
LGTM, thanks for all the changes!
* Add the new keyboard-mouse random test case See also: #1576 * Add the keyboard-mouse_test in EXECUTABLES
Description
According to the #855 , parsing the output from gnome_randr is not acceptable. Therefore, add cycler method for cycling change the resolution and transform to instead of modifying the old gnome_randr_cycle.py.
Resolved issues
The private bug
Documentation
Tests
Test this program on three prototypes. The mouse on each prototype can move randomly, and the keyboard can input letters randomly in the terminal.