Skip to content

Commit fdaa632

Browse files
committed
get color values for all bgs
1 parent c8ba321 commit fdaa632

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

tests/theme_and_toolbar/test_customize_themes_and_redirect.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from platform import system
1+
import logging
22

33
import pytest
44
from selenium.webdriver import Firefox
@@ -20,6 +20,21 @@ def test_case():
2020
alpenglow_map = {"light": "rgba(255, 255, 255, 0.76)", "dark": "rgba(40, 29, 78, 0.96)"}
2121

2222

23+
def colors_match(a, b):
24+
"""Determine if two colors are close enough to be considered matches"""
25+
tolerance = 0.14
26+
a_colorstring = a.split("(")[1][:-1]
27+
b_colorstring = b.split("(")[1][:-1]
28+
a_colors = [float(n) for n in a_colorstring.split(",")]
29+
b_colors = [float(n) for n in b_colorstring.split(",")]
30+
for i in range(len(a_colors)):
31+
diff = abs((a_colors[i] / b_colors[i]) - 1.0)
32+
logging.warning(f"a: {a_colors[i]}, b: {b_colors[i]}, diff: {diff}")
33+
if diff > tolerance:
34+
return False
35+
return True
36+
37+
2338
@pytest.mark.ci
2439
def test_redirect_to_addons(driver: Firefox):
2540
"""
@@ -34,7 +49,6 @@ def test_redirect_to_addons(driver: Firefox):
3449
assert driver.current_url == "about:addons"
3550

3651

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

59-
abt_addons.activate_theme(nav, theme_name, themes[theme_name])
73+
current_bg = abt_addons.activate_theme(
74+
nav, theme_name, themes[theme_name], perform_assert=False
75+
)
76+
assert current_bg == themes[theme_name]
6077

6178

62-
@pytest.mark.skipif(system().lower().startswith("win"), reason="Bug 1974109")
6379
def test_alpenglow_theme(driver: Firefox):
6480
"""
6581
C118173, specifically for alpenglow theme because color can be two values for dark or light mode
@@ -72,4 +88,8 @@ def test_alpenglow_theme(driver: Firefox):
7288
nav, "firefox-alpenglow_mozilla_org-heading", "", perform_assert=False
7389
)
7490

75-
assert current_bg == alpenglow_map["light"] or current_bg == alpenglow_map["dark"]
91+
logging.warning(f"alpenglow: {current_bg}")
92+
# assert current_bg == alpenglow_map["light"] or current_bg == alpenglow_map["dark"]
93+
assert colors_match(current_bg, alpenglow_map["light"]) or colors_match(
94+
current_bg, alpenglow_map["dark"]
95+
)

0 commit comments

Comments
 (0)