-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored MockDigitalInput and moved PushButtonHelperTests to the co…
…rrect package
- Loading branch information
Showing
2 changed files
with
31 additions
and
8 deletions.
There are no files selected for viewing
28 changes: 22 additions & 6 deletions
28
...cronaut-utils/src/test/java/com/opensourcewithslu/inputdevices/PushButtonHelperTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,43 @@ | ||
package com.opensourcewithslu.inputdevices; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import com.opensourcewithslu.mock.MockDigitalInput; | ||
import com.pi4j.io.gpio.digital.*; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
class PushButtonHelperTests { | ||
|
||
@org.junit.jupiter.api.Test | ||
/* This test simulates the push button in a LOW state without connecting to the actual hardware. | ||
It ensures that when the button input is LOW, the 'isPressed' state is correctly identified as false. | ||
*/ | ||
void initializeStateLow() { | ||
MockDigitalInput input = new MockDigitalInput(); | ||
input.SetState(DigitalState.LOW); | ||
PushButtonHelper helper = new PushButtonHelper(input); | ||
assertFalse(helper.isPressed); | ||
Logger log = LoggerFactory.getLogger(PushButtonHelper.class); // | ||
MockDigitalInput input = new MockDigitalInput(); // Mock input for the button | ||
input.SetState(DigitalState.LOW); // Simulate button in the LOW state | ||
PushButtonHelper helper = new PushButtonHelper(input); // | ||
assertFalse(helper.isPressed); // Button is not pressed when input is LOW | ||
} | ||
|
||
@org.junit.jupiter.api.Test | ||
/* | ||
This test simulates the push button in a HIGH state. | ||
It verifies that when the button input is HIGH, the 'IsPressed' state is correctly identified as true. | ||
*/ | ||
void initializeStateHigh() { | ||
MockDigitalInput input = new MockDigitalInput(); | ||
input.SetState(DigitalState.HIGH); | ||
input.SetState(DigitalState.HIGH); // Simulate button in the HIGH state | ||
PushButtonHelper helper = new PushButtonHelper(input); | ||
assertTrue(helper.isPressed); | ||
assertTrue(helper.isPressed); // Button is pressed when input is HIGH | ||
} | ||
|
||
@org.junit.jupiter.api.Test | ||
/* | ||
Placeholder for testing even listener functionality. | ||
*/ | ||
void addEventListener() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters