Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix broken tests
Browse files Browse the repository at this point in the history
breiler committed Dec 8, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 31532fa commit 40b4417
Showing 2 changed files with 41 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ This file is part of Universal Gcode Sender (UGS).
import static com.willwinder.universalgcodesender.GrblUtils.GRBL_PAUSE_COMMAND;
import static com.willwinder.universalgcodesender.GrblUtils.GRBL_RESET_COMMAND;
import static com.willwinder.universalgcodesender.GrblUtils.GRBL_RESUME_COMMAND;
import com.willwinder.universalgcodesender.firmware.grbl.GrblBuildOptions;
import com.willwinder.universalgcodesender.firmware.grbl.GrblCapabilitiesConstants;
import com.willwinder.universalgcodesender.firmware.grbl.GrblVersion;
import com.willwinder.universalgcodesender.gcode.DefaultCommandCreator;
@@ -311,13 +312,10 @@ public void testGetSendDuration() throws Exception {
GcodeCommand command = new GcodeCommand("G0X1"); // Whitespace removed.
command.setSent(true);
command.setResponse("ok");
try {
instance.commandSent(command);
instance.commandComplete();
} catch (Exception ex) {
ex.printStackTrace();
fail("Unexpected exception from command complete: " + ex.getMessage());
}

instance.commandSent(command);
instance.commandComplete();


expResult = 4000L;
result = instance.getSendDuration();
@@ -378,48 +376,36 @@ public void testRowsAsteriskMethods() throws Exception {

// Test 3.
// Sent 15 of them, none completed.
try {
for (int i = 0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0 X1");
command.setSent(true);
command.setResponse("ok");
instance.commandSent(command);
}
} catch (Exception ex) {
ex.printStackTrace();
fail("Unexpected exception from command sent: " + ex.getMessage());
for (int i = 0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0 X1");
command.setSent(true);
command.setResponse("ok");
instance.commandSent(command);
}

assertCounts(instance, 30, 15, 30);

// Test 4.
// Complete 15 of them.
try {
for (int i = 0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0X1"); // Whitespace removed.
command.setSent(true);
command.setResponse("ok");
instance.commandComplete();
}
} catch (Exception ex) {
ex.printStackTrace();
fail("Unexpected exception from command complete: " + ex.getMessage());
for (int i = 0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0X1"); // Whitespace removed.
command.setSent(true);
command.setResponse("ok");
instance.commandComplete();
}
assertCounts(instance, 30, 15, 15);

// Test 5.
// Finish sending/completing the remaining 15 commands.
try {
for (int i = 0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0 X1");
command.setSent(true);
command.setResponse("ok");
instance.commandSent(command);
instance.commandComplete();
}
} catch (Exception ex) {
ex.printStackTrace();
fail("Unexpected exception from command complete: " + ex.getMessage());

for (int i = 0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0 X1");
command.setSent(true);
command.setResponse("ok");
instance.commandSent(command);
instance.commandComplete();
}

mgc.areActiveCommands = false;
assertCounts(instance, 30, 30, 0);
}
@@ -698,17 +684,12 @@ public void cancelSendHalfwayThroughJobOnGrbl0_8c() throws Exception {
}
instance.queueStream(new SimpleGcodeStreamReader(commands));

try {
instance.beginStreaming();
for (int i = 0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0 X1");
command.setSent(true);
command.setResponse("ok");
instance.commandSent(command);
}
} catch (Exception ex) {
ex.printStackTrace();
fail("Unexpected exception from command sent: " + ex.getMessage());
instance.beginStreaming();
for (int i = 0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0 X1");
command.setSent(true);
command.setResponse("ok");
instance.commandSent(command);
}

instance.cancelSend();
@@ -860,17 +841,12 @@ public void testPauseAndCancelSend() throws Exception {
}
instance.queueStream(new SimpleGcodeStreamReader(commands));

try {
instance.beginStreaming();
for (int i = 0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0 X1");
command.setSent(true);
command.setResponse("ok");
instance.commandSent(command);
}
} catch (Exception ex) {
ex.printStackTrace();
fail("Unexpected exception from command sent: " + ex.getMessage());
instance.beginStreaming();
for (int i = 0; i < 15; i++) {
GcodeCommand command = new GcodeCommand("G0 X1");
command.setSent(true);
command.setResponse("ok");
instance.commandSent(command);
}

instance.pauseStreaming();
@@ -1421,6 +1397,7 @@ private GrblController initializeAndConnectController(String grblVersionString)
when(initializer.isInitialized()).thenReturn(false);
when(initializer.isInitializing()).thenReturn(false);
when(initializer.initialize()).thenReturn(true);
when(initializer.getOptions()).thenReturn(new GrblBuildOptions());

GrblVersion version = new GrblVersion("[VER:" + grblVersionString + "]");
when(initializer.getVersion()).thenReturn(version);
Original file line number Diff line number Diff line change
@@ -71,21 +71,21 @@ public void settingMessagesShouldNotAddDuplicates() {
}

@Test
public void isHomingEnabledShouldBeTrue() throws FirmwareSettingsException {
public void isHomingEnabledShouldBeTrue() {
// Emulate a settings-message from the controller
setFirmwareSetting("$22", "1");
assertTrue(target.isHomingEnabled());
}

@Test
public void isHomingEnabledShouldBeFalse() throws FirmwareSettingsException {
public void isHomingEnabledShouldBeFalse() {
// Emulate a settings-message from the controller
setFirmwareSetting("$22", "0");
assertFalse(target.isHomingEnabled());
}

@Test(expected = FirmwareSettingsException.class)
public void isHomingEnabledShouldBeFalseIfNotSet() throws FirmwareSettingsException {
@Test
public void isHomingEnabledShouldBeFalseIfNotSet() {
assertFalse(target.isHomingEnabled());
}

0 comments on commit 40b4417

Please sign in to comment.