From def6a444c473637a5467b900a0ff70c248c3927c Mon Sep 17 00:00:00 2001 From: Sean Budd Date: Mon, 2 Dec 2024 14:46:34 +1100 Subject: [PATCH] Skip Screen Curtain unit test if active (#17467) Follow up to #17413 (comment) Summary of the issue: The screen curtain unit tests fail if the screen curtain (or another colour transform e.g. contrast mode) is active. Instead these test should be skipped. Alternatively, they could be run in debug mode to do the test without collecting the failure --- .../test_magnificationAPI.py | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/tests/unit/test_visionEnhancementProviders/test_magnificationAPI.py b/tests/unit/test_visionEnhancementProviders/test_magnificationAPI.py index 819baaebb04..fe46b23d621 100644 --- a/tests/unit/test_visionEnhancementProviders/test_magnificationAPI.py +++ b/tests/unit/test_visionEnhancementProviders/test_magnificationAPI.py @@ -7,7 +7,7 @@ import unittest -from visionEnhancementProviders.screenCurtain import Magnification, TRANSFORM_BLACK +from visionEnhancementProviders.screenCurtain import Magnification, TRANSFORM_BLACK, MAGCOLOREFFECT class _Test_MagnificationAPI(unittest.TestCase): @@ -19,6 +19,29 @@ def tearDown(self): class Test_ScreenCurtain(_Test_MagnificationAPI): + def _isIdentityMatrix(self, magTransformMatrix: MAGCOLOREFFECT) -> bool: + for i in range(5): + for j in range(5): + if i == j: + if magTransformMatrix.transform[i][j] != 1: + return False + else: + if magTransformMatrix.transform[i][j] != 0: + return False + return True + + def setUp(self): + super().setUp() + resultEffect = Magnification.MagGetFullscreenColorEffect() + if not self._isIdentityMatrix(resultEffect): + # If the resultEffect is not the identity matrix, skip the test. + # This is because a full screen colour effect is already set external to testing. + self.skipTest( + f"{resultEffect=}, should be identity matrix. " + "Full screen colour effect set external to tests. ", + ) + return + def test_setAndConfirmBlackFullscreenColorEffect(self): result = Magnification.MagSetFullscreenColorEffect(TRANSFORM_BLACK) self.assertTrue(result) @@ -32,18 +55,6 @@ def test_setAndConfirmBlackFullscreenColorEffect(self): msg=f"i={i}, j={j}, resultEffect={resultEffect}", ) - def test_getDefaultIdentityFullscreenColorEffect(self): - resultEffect = Magnification.MagGetFullscreenColorEffect() - for i in range(5): - for j in range(5): - with self.subTest(i=i, j=j): - # The transform matrix should be the identity matrix - self.assertEqual( - int(i == j), - resultEffect.transform[i][j], - msg=f"i={i}, j={j}, resultEffect={resultEffect}", - ) - class Test_Mouse(_Test_MagnificationAPI): def test_MagShowSystemCursor(self):