Skip to content

Commit 64faae1

Browse files
committed
tests: Add testsuite to validate no crash on empty filepanel
1 parent 5baae64 commit 64faae1

File tree

2 files changed

+66
-4
lines changed

2 files changed

+66
-4
lines changed

testsuite/core/base_test.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def __init__(self, test_env : Environment,
4949
validate_exists : List[Path] = None,
5050
validate_not_exists : List[Path] = None,
5151
validate_spf_closed: bool = False,
52+
validate_spf_running: bool = False,
5253
close_wait_time : float = tconst.CLOSE_WAIT_TIME ):
5354
super().__init__(test_env)
5455
self.test_root = test_root
@@ -59,6 +60,7 @@ def __init__(self, test_env : Environment,
5960
self.validate_exists = validate_exists
6061
self.validate_not_exists = validate_not_exists
6162
self.validate_spf_closed = validate_spf_closed
63+
self.validate_spf_running = validate_spf_running
6264
self.close_wait_time = close_wait_time
6365

6466
def setup(self) -> None:
@@ -82,10 +84,7 @@ def end_execution(self) -> None:
8284
time.sleep(self.close_wait_time)
8385
self.logger.debug("Finished Execution")
8486

85-
def test_execute(self) -> None:
86-
"""Execute the test
87-
"""
88-
self.start_spf()
87+
def send_input(self) -> None:
8988
if self.key_inputs is not None:
9089
for cur_input in self.key_inputs:
9190
if isinstance(cur_input, keys.Keys):
@@ -95,6 +94,11 @@ def test_execute(self) -> None:
9594
self.env.spf_mgr.send_text_input(cur_input)
9695
time.sleep(tconst.KEY_DELAY)
9796

97+
def test_execute(self) -> None:
98+
"""Execute the test
99+
"""
100+
self.start_spf()
101+
self.send_input()
98102
time.sleep(tconst.OPERATION_DELAY)
99103
self.end_execution()
100104

@@ -109,6 +113,8 @@ def validate(self) -> bool:
109113
try:
110114
if self.validate_spf_closed :
111115
assert not self.env.spf_mgr.is_spf_running(), "Superfile is still running"
116+
if self.validate_spf_running :
117+
assert self.env.spf_mgr.is_spf_running(), "Superfile is not running"
112118

113119
if self.validate_exists is not None:
114120
for file_path in self.validate_exists:
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
from pathlib import Path
2+
3+
from core.base_test import GenericTestImpl
4+
from core.environment import Environment
5+
import core.test_constants as tconst
6+
import core.keys as keys
7+
import time
8+
9+
TESTROOT = Path("empty_panel_ops")
10+
DIR1 = TESTROOT / "dir1"
11+
12+
13+
class EmptyPanelTest(GenericTestImpl):
14+
"""
15+
Validate that spf doesn't crashes when we try to
16+
perform operations on empty file panel
17+
"""
18+
def __init__(self, test_env : Environment):
19+
super().__init__(
20+
test_env=test_env,
21+
test_root=TESTROOT,
22+
start_dir=DIR1,
23+
test_dirs=[DIR1],
24+
key_inputs=[
25+
keys.KEY_CTRL_C, # Try copy
26+
keys.KEY_CTRL_X, # Try cut
27+
keys.KEY_CTRL_D, # Try delete
28+
keys.KEY_PASTE, # Try paste
29+
keys.KEY_CTRL_R, # Try rename
30+
keys.KEY_CTRL_P, # Try copy location
31+
'e', # Try open with editor
32+
keys.KEY_ENTER,
33+
keys.KEY_RIGHT,
34+
keys.KEY_CTRL_A, # Try archiving
35+
keys.KEY_CTRL_E, # Try extract
36+
'v', # Try going to Select mode
37+
'J', # Try select down
38+
'K', # Try select up
39+
'A', # select all
40+
'v',
41+
'.', # Try toggle dotfiles
42+
],
43+
# Makes sure spf doesn't crashes
44+
validate_spf_running=True
45+
)
46+
47+
# Override
48+
def test_execute(self) -> None:
49+
self.start_spf()
50+
self.send_input()
51+
time.sleep(tconst.OPERATION_DELAY)
52+
# To not close spf
53+
54+
55+
56+

0 commit comments

Comments
 (0)