|
|
@ -8,9 +8,7 @@ import numpy as np |
|
|
|
import os |
|
|
|
import os |
|
|
|
import pywinctl |
|
|
|
import pywinctl |
|
|
|
import time |
|
|
|
import time |
|
|
|
import unittest # noqa: TID251 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from parameterized import parameterized |
|
|
|
|
|
|
|
from cereal import messaging, car, log |
|
|
|
from cereal import messaging, car, log |
|
|
|
from cereal.visionipc import VisionIpcServer, VisionStreamType |
|
|
|
from cereal.visionipc import VisionIpcServer, VisionStreamType |
|
|
|
|
|
|
|
|
|
|
@ -122,16 +120,11 @@ TEST_OUTPUT_DIR = TEST_DIR / "report" |
|
|
|
SCREENSHOTS_DIR = TEST_OUTPUT_DIR / "screenshots" |
|
|
|
SCREENSHOTS_DIR = TEST_OUTPUT_DIR / "screenshots" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestUI(unittest.TestCase): |
|
|
|
class TestUI: |
|
|
|
@classmethod |
|
|
|
def __init__(self): |
|
|
|
def setUpClass(cls): |
|
|
|
|
|
|
|
os.environ["SCALE"] = "1" |
|
|
|
os.environ["SCALE"] = "1" |
|
|
|
sys.modules["mouseinfo"] = False |
|
|
|
sys.modules["mouseinfo"] = False |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
|
|
|
def tearDownClass(cls): |
|
|
|
|
|
|
|
del sys.modules["mouseinfo"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def setup(self): |
|
|
|
def setup(self): |
|
|
|
self.sm = SubMaster(["uiDebug"]) |
|
|
|
self.sm = SubMaster(["uiDebug"]) |
|
|
|
self.pm = PubMaster(["deviceState", "pandaStates", "controlsState", 'roadCameraState', 'wideRoadCameraState', 'liveLocationKalman']) |
|
|
|
self.pm = PubMaster(["deviceState", "pandaStates", "controlsState", 'roadCameraState', 'wideRoadCameraState', 'liveLocationKalman']) |
|
|
@ -147,8 +140,8 @@ class TestUI(unittest.TestCase): |
|
|
|
def screenshot(self): |
|
|
|
def screenshot(self): |
|
|
|
import pyautogui |
|
|
|
import pyautogui |
|
|
|
im = pyautogui.screenshot(region=(self.ui.left, self.ui.top, self.ui.width, self.ui.height)) |
|
|
|
im = pyautogui.screenshot(region=(self.ui.left, self.ui.top, self.ui.width, self.ui.height)) |
|
|
|
self.assertEqual(im.width, 2160) |
|
|
|
assert im.width == 2160 |
|
|
|
self.assertEqual(im.height, 1080) |
|
|
|
assert im.height == 1080 |
|
|
|
img = np.array(im) |
|
|
|
img = np.array(im) |
|
|
|
im.close() |
|
|
|
im.close() |
|
|
|
return img |
|
|
|
return img |
|
|
@ -158,7 +151,6 @@ class TestUI(unittest.TestCase): |
|
|
|
pyautogui.click(self.ui.left + x, self.ui.top + y, *args, **kwargs) |
|
|
|
pyautogui.click(self.ui.left + x, self.ui.top + y, *args, **kwargs) |
|
|
|
time.sleep(UI_DELAY) # give enough time for the UI to react |
|
|
|
time.sleep(UI_DELAY) # give enough time for the UI to react |
|
|
|
|
|
|
|
|
|
|
|
@parameterized.expand(CASES.items()) |
|
|
|
|
|
|
|
@with_processes(["ui"]) |
|
|
|
@with_processes(["ui"]) |
|
|
|
def test_ui(self, name, setup_case): |
|
|
|
def test_ui(self, name, setup_case): |
|
|
|
self.setup() |
|
|
|
self.setup() |
|
|
@ -188,7 +180,10 @@ def create_screenshots(): |
|
|
|
shutil.rmtree(TEST_OUTPUT_DIR) |
|
|
|
shutil.rmtree(TEST_OUTPUT_DIR) |
|
|
|
|
|
|
|
|
|
|
|
SCREENSHOTS_DIR.mkdir(parents=True) |
|
|
|
SCREENSHOTS_DIR.mkdir(parents=True) |
|
|
|
unittest.main(exit=False) |
|
|
|
|
|
|
|
|
|
|
|
t = TestUI() |
|
|
|
|
|
|
|
for name, setup in CASES.items(): |
|
|
|
|
|
|
|
t.test_ui(name, setup) |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
if __name__ == "__main__": |
|
|
|
print("creating test screenshots") |
|
|
|
print("creating test screenshots") |
|
|
|