forked from Dinones/Unit-Tests
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_Control_System.py
More file actions
101 lines (80 loc) · 4.53 KB
/
test_Control_System.py
File metadata and controls
101 lines (80 loc) · 4.53 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
###########################################################################################################################
#################################################### 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 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)))
from Image_Processing import Image_Processing
import Control_System
###########################################################################################################################
################################################# INITIALIZATIONS #################################################
###########################################################################################################################
IMAGE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), 'Media/Images'))
###########################################################################################################################
# Add new tests here
@parameterized_class([
{
'image_path': os.path.join(IMAGE_DIR, 'Regice_720p.png'),
'has_text_box': True,
'has_life_box': False,
'has_load_black_screen': False,
'has_load_white_screen': False,
},
{
'image_path': os.path.join(IMAGE_DIR, 'Regice_1080p.png'),
'has_text_box': True,
'has_life_box': False,
'has_load_black_screen': False,
'has_load_white_screen': False,
},
{
'image_path': os.path.join(IMAGE_DIR, 'white_screen_test1_720p.png'),
'has_text_box': False,
'has_life_box': False,
'has_load_black_screen': False,
'has_load_white_screen': False,
},
])
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_text_box_visibility(self):
# Test if the text box is visible
text_box_visible = Control_System.is_text_box_visible(self.image)
self.assertEqual(self.has_text_box, text_box_visible, 'Failed to recognize text box')
#######################################################################################################################
def test_is_black_screen_visible(self):
# Test if black screen is visible
black_screen_visible = Control_System.is_black_screen_visible(self.image)
self.assertEqual(self.has_load_black_screen, black_screen_visible, 'Failed to recognize black screen')
#######################################################################################################################
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.has_life_box, life_box_visible, 'Failed to recognize life box')
#######################################################################################################################
def test_is_load_fight_white_screen(self):
# Test if the white screen is visible
white_screen_visible = Control_System.is_load_fight_white_screen_visible(self.image)
self.assertEqual(self.has_load_white_screen, white_screen_visible, 'Failed to recognize white screen')
#######################################################################################################################
def tearDown(self):
# Clean up any resources if needed
pass
###########################################################################################################################
##################################################### PROGRAM #####################################################
###########################################################################################################################
if __name__ == '__main__':
unittest.main()