Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions tests/theme_and_toolbar/test_customize_themes_and_redirect.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from platform import system

import pytest
from selenium.webdriver import Firefox

Expand All @@ -20,6 +18,20 @@ def test_case():
alpenglow_map = {"light": "rgba(255, 255, 255, 0.76)", "dark": "rgba(40, 29, 78, 0.96)"}


def colors_match(a, b):
"""Determine if two colors are close enough to be considered matches"""
tolerance = 0.14
a_colorstring = a.split("(")[1][:-1]
b_colorstring = b.split("(")[1][:-1]
a_colors = [float(n) for n in a_colorstring.split(",")]
b_colors = [float(n) for n in b_colorstring.split(",")]
for i in range(len(a_colors)):
diff = abs((a_colors[i] / b_colors[i]) - 1.0)
if diff > tolerance:
return False
return True


@pytest.mark.ci
def test_redirect_to_addons(driver: Firefox):
"""
Expand All @@ -34,7 +46,6 @@ def test_redirect_to_addons(driver: Firefox):
assert driver.current_url == "about:addons"


@pytest.mark.skipif(system().lower().startswith("win"), reason="Bug 1974109")
@pytest.mark.parametrize("theme_name", list(themes.keys()))
def test_open_addons(driver: Firefox, theme_name: str):
"""
Expand All @@ -56,10 +67,12 @@ def test_open_addons(driver: Firefox, theme_name: str):
# Already default on Firefox standard; skip activation/assertion
pytest.skip("Compact Light is default on Firefox, skipping.")

abt_addons.activate_theme(nav, theme_name, themes[theme_name])
current_bg = abt_addons.activate_theme(
nav, theme_name, themes[theme_name], perform_assert=False
)
assert colors_match(current_bg, themes[theme_name])


@pytest.mark.skipif(system().lower().startswith("win"), reason="Bug 1974109")
def test_alpenglow_theme(driver: Firefox):
"""
C118173, specifically for alpenglow theme because color can be two values for dark or light mode
Expand All @@ -72,4 +85,7 @@ def test_alpenglow_theme(driver: Firefox):
nav, "firefox-alpenglow_mozilla_org-heading", "", perform_assert=False
)

assert current_bg == alpenglow_map["light"] or current_bg == alpenglow_map["dark"]
# assert current_bg == alpenglow_map["light"] or current_bg == alpenglow_map["dark"]
assert colors_match(current_bg, alpenglow_map["light"]) or colors_match(
current_bg, alpenglow_map["dark"]
)
Loading