From 2c99d54d645ce1c55d8d02194fb90223fb616fbc Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 4 Sep 2023 16:18:23 +0300 Subject: [PATCH] test: Some "rtl" layout cleanups Call `_set_direction` directly from `set_layout` instead of from `assert_pixels`, so that test code can use `set_layout("rtl")` and have it do the right thing. Also, `_set_direction` only sets the direction of either the page or the shell, but does it in a confusing way. Let's do it more directly. --- test/common/testlib.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/test/common/testlib.py b/test/common/testlib.py index 2aa232c2028d..48b2fb5baa25 100644 --- a/test/common/testlib.py +++ b/test/common/testlib.py @@ -152,7 +152,8 @@ "name": "rtl", "theme": "light", "shell_size": [1920, 1200], - "content_size": [1680, 1130] + "content_size": [1680, 1130], + "direction": "rtl" }, ] @@ -957,12 +958,10 @@ def _set_emulated_media_theme(self, name: str): self.cdp.invoke("Emulation.setEmulatedMedia", features=[{'name': 'prefers-color-scheme', 'value': name}]) def _set_direction(self, direction: str): - cur_frame = self.cdp.cur_frame if self.is_present("#shell-page"): - self.switch_to_top() self.set_attr("#shell-page", "dir", direction) - self.switch_to_frame(cur_frame) - self.set_attr("html", "dir", direction) + else: + self.set_attr("html", "dir", direction) def set_layout(self, name: str): layout = next(lo for lo in self.layouts if lo["name"] == name) @@ -972,6 +971,7 @@ def set_layout(self, name: str): self._set_window_size(size[0], size[1]) self._adjust_window_for_fixed_content_size() self._set_emulated_media_theme(layout["theme"]) + self._set_direction(layout.get("direction") or "ltr") def _adjust_window_for_fixed_content_size(self): if self.eval_js("window.name").startswith("cockpit1:"): @@ -1180,16 +1180,11 @@ def assert_pixels(self, selector: str, key: str, for layout in self.layouts: if layout["name"] not in skip_layouts: self.set_layout(layout["name"]) - if "rtl" in self.current_layout["name"]: - self._set_direction("rtl") self.assert_pixels_in_current_layout(selector, key, ignore=ignore, mock=mock, sit_after_mock=sit_after_mock, scroll_into_view=scroll_into_view, wait_animations=wait_animations, wait_delay=wait_delay) - - if "rtl" in self.current_layout["name"]: - self._set_direction("ltr") self.set_layout(previous_layout) def assert_no_unused_pixel_test_references(self):