-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathtest_NavPanel.py
More file actions
103 lines (75 loc) · 3.59 KB
/
test_NavPanel.py
File metadata and controls
103 lines (75 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import logging
import unittest
import cv2
from EDAP_data import FlagsDocked
from EDKeys import EDKeys
from EDlogger import logger
from EDNavigationPanel import EDNavigationPanel
from Screen import Screen
from StatusParser import StatusParser
def dummy_cb(msg, body=None):
pass
def is_running() -> bool:
scr = Screen(cb=dummy_cb)
return scr.elite_window_exists()
def is_docked() -> bool:
status = StatusParser()
return status.get_flag(FlagsDocked)
class NavPanelTestCase(unittest.TestCase):
running = is_running()
docked = is_docked()
@classmethod
def setUpClass(cls):
from ED_AP import EDAutopilot
cls.ed_ap = EDAutopilot(cb=dummy_cb)
scr = cls.ed_ap.scr
keys = cls.ed_ap.keys
keys.activate_window = True # Helps with single steps testing
# def test_draw_regions_on_images(self):
# """
# Does NOT require Elite Dangerous to be running.
# ======================================================================
# """
# nav_pnl = EDNavigationPanel(None, None, None)
# draw_station_regions('test/nav-panel/', nav_pnl.reg)
#
# self.assertEqual(True, True) # add assertion here
def test_draw_regions_on_image(self):
"""
Does NOT require Elite Dangerous to be running.
======================================================================
"""
# image_path = "test/nav-panel/Screenshot 1920x1080 2024-10-14 20-45-25.png"
# image_path = "test/nav-panel/Screenshot 1920x1200 2024-09-07 09-08-36.png"
#image_path = "test/nav-panel/Screenshot_2024-09-09_195949.png"
#image_path = "test/nav-panel/CBB63634-4208-49F6-A5DD-640E589D79B3.png"
# frame = cv2.imread(image_path)
# scr = Screen(cb=dummy_cb)
# scr.using_screen = False
# scr.set_screen_image(frame)
nav_pnl = EDNavigationPanel(self.ed_ap, self.ed_ap.scr, self.ed_ap.keys, cb=dummy_cb)
# straightened = nav_pnl.capture_region_straightened(scl_reg_rect)
straightened = nav_pnl.capture_panel_straightened()
# self.assertIsNone(straightened, "Could not grab Nav Panel image.") # add assertion here
res = nav_pnl.capture_tab_bar()
# self.assertIsNone(res, "Could not grab Nav Panel Tab bar image.") # add assertion here
res = nav_pnl.capture_location_panel()
# self.assertIsNone(res, "Could not grab Nav Panel Location image.") # add assertion here
self.assertEqual(True, True) # add assertion here
@unittest.skipUnless(running, "Elite Dangerous is not running")
def test_nav_panel_lock_station(self):
logger.setLevel(logging.DEBUG) # Default to log all debug when running this file.
name = "Nav Beacon"
nav_pnl = EDNavigationPanel(self.ed_ap, self.ed_ap.scr, self.ed_ap.keys, cb=dummy_cb)
self.ed_ap.keys.activate_window = True # Helps with single steps testing
res = nav_pnl.lock_destination(name)
self.assertTrue(res, "Failed to lock destination.") # add assertion here
@unittest.skipUnless(running, "Elite Dangerous is not running")
def test_nav_panel_request_docking(self):
logger.setLevel(logging.DEBUG) # Default to log all debug when running this file.
nav_pnl = EDNavigationPanel(self.ed_ap, self.ed_ap.scr, self.ed_ap.keys, cb=dummy_cb)
self.ed_ap.keys.activate_window = True # Helps with single steps testing
res = nav_pnl.request_docking()
self.assertTrue(res, "Failed to request docking.") # add assertion here
if __name__ == '__main__':
unittest.main()