|
|
|
|
@@ -178,18 +178,43 @@ def check_list(result: str, rules: Dict[str, List[str]]) -> float:
|
|
|
|
|
return float(all(expect_metrics) and unexpect_metric)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_accessibility_ns_map = {"st": "uri:deskat:state.at-spi.gnome.org"
|
|
|
|
|
, "attr": "uri:deskat:attributes.at-spi.gnome.org"
|
|
|
|
|
, "cp": "uri:deskat:component.at-spi.gnome.org"
|
|
|
|
|
, "doc": "uri:deskat:document.at-spi.gnome.org"
|
|
|
|
|
, "docattr": "uri:deskat:attributes.document.at-spi.gnome.org"
|
|
|
|
|
, "txt": "uri:deskat:text.at-spi.gnome.org"
|
|
|
|
|
, "val": "uri:deskat:value.at-spi.gnome.org"
|
|
|
|
|
, "act": "uri:deskat:action.at-spi.gnome.org"
|
|
|
|
|
}
|
|
|
|
|
_accessibility_ns_map = {
|
|
|
|
|
"ubuntu": {
|
|
|
|
|
"st": "https://accessibility.ubuntu.example.org/ns/state",
|
|
|
|
|
"attr": "https://accessibility.ubuntu.example.org/ns/attributes",
|
|
|
|
|
"cp": "https://accessibility.ubuntu.example.org/ns/component",
|
|
|
|
|
"doc": "https://accessibility.ubuntu.example.org/ns/document",
|
|
|
|
|
"docattr": "https://accessibility.ubuntu.example.org/ns/document/attributes",
|
|
|
|
|
"txt": "https://accessibility.ubuntu.example.org/ns/text",
|
|
|
|
|
"val": "https://accessibility.ubuntu.example.org/ns/value",
|
|
|
|
|
"act": "https://accessibility.ubuntu.example.org/ns/action",
|
|
|
|
|
},
|
|
|
|
|
"windows": {
|
|
|
|
|
"st": "https://accessibility.windows.example.org/ns/state",
|
|
|
|
|
"attr": "https://accessibility.windows.example.org/ns/attributes",
|
|
|
|
|
"cp": "https://accessibility.windows.example.org/ns/component",
|
|
|
|
|
"doc": "https://accessibility.windows.example.org/ns/document",
|
|
|
|
|
"docattr": "https://accessibility.windows.example.org/ns/document/attributes",
|
|
|
|
|
"txt": "https://accessibility.windows.example.org/ns/text",
|
|
|
|
|
"val": "https://accessibility.windows.example.org/ns/value",
|
|
|
|
|
"act": "https://accessibility.windows.example.org/ns/action",
|
|
|
|
|
"class": "https://accessibility.windows.example.org/ns/class"
|
|
|
|
|
},
|
|
|
|
|
"macos": {
|
|
|
|
|
"st": "https://accessibility.macos.example.org/ns/state",
|
|
|
|
|
"attr": "https://accessibility.macos.example.org/ns/attributes",
|
|
|
|
|
"cp": "https://accessibility.macos.example.org/ns/component",
|
|
|
|
|
"doc": "https://accessibility.macos.example.org/ns/document",
|
|
|
|
|
"txt": "https://accessibility.macos.example.org/ns/text",
|
|
|
|
|
"val": "https://accessibility.macos.example.org/ns/value",
|
|
|
|
|
"act": "https://accessibility.macos.example.org/ns/action",
|
|
|
|
|
"role": "https://accessibility.macos.example.org/ns/role",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_accessibility_tree(result: str, rules: List[Dict[str, Any]]) -> float:
|
|
|
|
|
def check_accessibility_tree(result: str, rules: List[Dict[str, Any]], osname: str = "ubuntu") -> float:
|
|
|
|
|
"""
|
|
|
|
|
Args:
|
|
|
|
|
result (str): XML of GNOME Accessibility Tree
|
|
|
|
|
@@ -205,18 +230,21 @@ def check_accessibility_tree(result: str, rules: List[Dict[str, Any]]) -> float:
|
|
|
|
|
"exact": bool specifying whether exact match or fuzzy match should
|
|
|
|
|
be performed. defaults to True.
|
|
|
|
|
}
|
|
|
|
|
osname (str): "ubuntu" | "windows" | "macos". "ubuntu" by default.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
float
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
a11y_ns_map = _accessibility_ns_map[osname]
|
|
|
|
|
|
|
|
|
|
at: _Element = lxml.etree.fromstring(result)
|
|
|
|
|
total_match_score = 1.
|
|
|
|
|
for r in rules:
|
|
|
|
|
if "xpath" in r:
|
|
|
|
|
elements: List[_Element] = at.xpath(r["xpath"], namespaces=_accessibility_ns_map)
|
|
|
|
|
elements: List[_Element] = at.xpath(r["xpath"], namespaces=a11y_ns_map)
|
|
|
|
|
elif "selectors" in r:
|
|
|
|
|
selector = CSSSelector(", ".join(r["selectors"]), namespaces=_accessibility_ns_map)
|
|
|
|
|
selector = CSSSelector(", ".join(r["selectors"]), namespaces=a11y_ns_map)
|
|
|
|
|
elements: List[_Element] = selector(at)
|
|
|
|
|
else:
|
|
|
|
|
raise ValueError("At least one of xpath and selectors is required")
|
|
|
|
|
@@ -403,7 +431,7 @@ def compare_time_in_speedtest_results(speedtest_result_path, time_diff):
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
# open the speedtest results file(csv)
|
|
|
|
|
date_col = None
|
|
|
|
|
#date_col = None
|
|
|
|
|
try:
|
|
|
|
|
with open(speedtest_result_path, 'r') as f:
|
|
|
|
|
for i, line in enumerate(f):
|
|
|
|
|
|