Skip to content

Commit e37e2a5

Browse files
author
Arun Prasaad
committed
Verify key command for resetting the level
1 parent 84f30f4 commit e37e2a5

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

.cascade

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ helper_methods_after_caller = true
2020
make_minimal_changes = true
2121
# Code formatting
2222
no_trailing_spaces = true
23+
# Align related assignment statements in columns when they appear together
24+
align_related_assignments = true
2325
# Avoid comments that state the obvious or repeat the code
2426
avoid_superfluous_comments = true
2527

src/test/java/ihm/SokobanWindowTest.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,40 @@ void can_undo_the_last_move() {
289289
.isEqualTo(initialColumn);
290290
}
291291

292+
@Test
293+
void resets_level_when_backspace_key_is_pressed() {
294+
// given - make a move and change the level state
295+
int initialLine = controller.getWorker().getLine();
296+
int initialColumn = controller.getWorker().getColumn();
297+
298+
// Move right to change the state
299+
KeyEvent rightKey = new KeyEvent(window,
300+
KeyEvent.KEY_PRESSED,
301+
System.currentTimeMillis(),
302+
0,
303+
KeyEvent.VK_RIGHT,
304+
KeyEvent.CHAR_UNDEFINED);
305+
window.keyPressed(rightKey);
306+
window.keyPressed(rightKey); // again
307+
308+
// when - press backspace to reset the level
309+
KeyEvent resetKey = new KeyEvent(window,
310+
KeyEvent.KEY_PRESSED,
311+
System.currentTimeMillis(),
312+
0,
313+
KeyEvent.VK_BACK_SPACE,
314+
KeyEvent.CHAR_UNDEFINED);
315+
window.keyPressed(resetKey);
316+
317+
// then - worker should be back at initial position
318+
then(controller.getWorker().getLine())
319+
.as("line position is restored when resetting level")
320+
.isEqualTo(initialLine);
321+
then(controller.getWorker().getColumn())
322+
.as("column position is restored when resetting level")
323+
.isEqualTo(initialColumn);
324+
}
325+
292326
@Test
293327
void completing_a_custom_level_disposes_window_and_shows_home_window() {
294328
// given - create a test window with the simplified level that only needs one push

0 commit comments

Comments
 (0)