-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_Control_System.py
More file actions
135 lines (101 loc) · 6.65 KB
/
test_Control_System.py
File metadata and controls
135 lines (101 loc) · 6.65 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
###########################################################################################################################
#################################################### LIBRARIES ####################################################
###########################################################################################################################
# Set the cwd to the one of the file
import os
if __name__ == '__main__':
try: os.chdir(os.path.dirname(__file__))
except: pass
import json
import unittest
from parameterized import parameterized_class
import sys
folders = ['../', '../Modules']
for folder in folders: sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), folder)))
# Mock Qt modules to make them optional in the tests
from unittest.mock import MagicMock
sys.modules['PyQt5'] = MagicMock()
sys.modules['PyQt5.QtGui'] = MagicMock()
from Image_Processing import Image_Processing
import Control_System
###########################################################################################################################
################################################# INITIALIZATIONS #################################################
###########################################################################################################################
IMAGE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), 'Media/Images'))
TESTS_DATA_FILE = os.path.abspath(os.path.join(os.path.dirname(__file__), 'Tests Data/Control_System_Data.json'))
# Load test data, where tests are defined
with open(TESTS_DATA_FILE, 'r') as file:
TEST_DATA = json.load(file)
for item in TEST_DATA:
item['image_path'] = os.path.join(IMAGE_DIR, item['image_path'])
###########################################################################################################################
@parameterized_class(TEST_DATA)
class Test_Control_System(unittest.TestCase):
def setUp(self):
# Ensure the file exists
self.assertTrue(os.path.exists(self.image_path), f'File not found: {self.image_path}')
# Initialize the ImageProcessor object
self.image = Image_Processing(self.image_path)
self.image.resize_image()
#######################################################################################################################
def test_is_pairing_screen_visible(self):
# Test if black screen is visible
pairing_screen_visible = Control_System.is_pairing_screen_visible(self.image)
self.assertEqual(self.is_pairing_screen_visible, pairing_screen_visible, 'Failed to recognize pairing screen')
#######################################################################################################################
def test_is_home_screen_visible(self):
# Test if black screen is visible
home_screen_visible = Control_System.is_home_screen_visible(self.image)
self.assertEqual(self.is_home_screen_visible, home_screen_visible, 'Failed to recognize home screen')
#######################################################################################################################
def test_is_bdsp_load_screen_visible(self):
# Test if black screen is visible
bdsp_load_screen_visible = Control_System.is_bdsp_loading_screen_visible(self.image)
self.assertEqual(
self.is_bdsp_load_white_screen_visible, bdsp_load_screen_visible, 'Failed to recognize BDSP load screen'
)
#######################################################################################################################
def test_is_load_black_screen_visible(self):
# Test if black screen is visible
black_screen_visible = Control_System.is_black_screen_visible(self.image)
self.assertEqual(self.is_load_black_screen_visible, black_screen_visible, 'Failed to recognize black load screen')
#######################################################################################################################
def test_is_load_white_screen_visible(self):
# Test if the white screen is visible
white_screen_visible = Control_System.is_white_screen_visible(self.image)
self.assertEqual(self.is_load_white_screen_visible, white_screen_visible, 'Failed to recognize white load screen')
#######################################################################################################################
def test_is_overworld_text_box_visible(self):
# Test if the overworld text box is visible
overworld_text_box_visible = Control_System.is_overworld_text_box_visible(self.image)
self.assertEqual(
self.is_overworld_text_box_visible, overworld_text_box_visible, 'Failed to recognize overworld text box'
)
#######################################################################################################################
def test_is_combat_text_box_visible(self):
# Test if the combat text box is visible
combat_text_box_visible = Control_System.is_combat_text_box_visible(self.image)
self.assertEqual(self.is_combat_text_box_visible, combat_text_box_visible, 'Failed to recognize combat text box')
#######################################################################################################################
def test_is_life_box_visible(self):
# Test if life box is visible
life_box_visible = Control_System.is_life_box_visible(self.image)
self.assertEqual(self.is_life_box_visible, life_box_visible, 'Failed to recognize life box')
#######################################################################################################################
def test_is_double_combat_life_box_visible(self):
# Test if life box is visible
double_combat_life_box_visible = Control_System.is_double_combat_life_box_visible(self.image)
self.assertEqual(
self.is_double_combat_life_box_visible,
double_combat_life_box_visible,
'Failed to recognize life box in double combat'
)
#######################################################################################################################
def tearDown(self):
# Clean up any resources if needed
pass
###########################################################################################################################
##################################################### PROGRAM #####################################################
###########################################################################################################################
if __name__ == '__main__':
unittest.main()