Skip to content

Commit

Permalink
test: Add assert_pixels() API for disabling animation waiting
Browse files Browse the repository at this point in the history
PF4's "Drawer" component has a bug (or hack) to use an infinite
animation. This breaks Anaconda's pixel tests, as the waiting never
completes.

Add a flag to disable the waiting.
  • Loading branch information
martinpitt committed Jul 20, 2022
1 parent b0a21b0 commit b971699
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions test/common/testlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,10 @@ def _adjust_window_for_fixed_content_size(self):
if delta[0] != 0 or delta[1] != 0:
self._set_window_size(shell_size[0] + delta[0], shell_size[1] + delta[1])

def assert_pixels_in_current_layout(self, selector: str, key: str, ignore: List[str] = [], scroll_into_view: Optional[str] = None):
def assert_pixels_in_current_layout(self, selector: str, key: str,
ignore: List[str] = [],
scroll_into_view: Optional[str] = None,
wait_animations: bool = True):
"""Compare the given element with its reference in the current layout"""

if not (Image and self.pixels_label):
Expand Down Expand Up @@ -1003,7 +1006,8 @@ def assert_pixels_in_current_layout(self, selector: str, key: str, ignore: List[
# wait half a second to and side-step all that complexity.

time.sleep(0.5)
self.wait_js_cond('ph_count_animations(%s) == 0' % jsquote(selector))
if wait_animations:
self.wait_js_cond('ph_count_animations(%s) == 0' % jsquote(selector))

rect = self.call_js_func('ph_element_clip', selector)

Expand Down Expand Up @@ -1111,7 +1115,11 @@ def img_eq(ref, now, delta):
print("Differences in pixel test " + base)
self.failed_pixel_tests += 1

def assert_pixels(self, selector: str, key: str, ignore: List[str] = [], skip_layouts: List[str] = [], scroll_into_view: Optional[str] = None):
def assert_pixels(self, selector: str, key: str,
ignore: List[str] = [],
skip_layouts: List[str] = [],
scroll_into_view: Optional[str] = None,
wait_animations: bool = True):
"""Compare the given element with its reference in all layouts"""

if not (Image and self.pixels_label):
Expand All @@ -1122,7 +1130,8 @@ def assert_pixels(self, selector: str, key: str, ignore: List[str] = [], skip_la
if layout["name"] not in skip_layouts:
self.set_layout(layout["name"])
self.assert_pixels_in_current_layout(selector, key, ignore=ignore,
scroll_into_view=scroll_into_view)
scroll_into_view=scroll_into_view,
wait_animations=wait_animations)
self.set_layout(previous_layout)

def assert_no_unused_pixel_test_references(self):
Expand Down

0 comments on commit b971699

Please sign in to comment.