-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/origin/1.20.1-fabric' into…
… 1.20.4-fabric # Conflicts: # gradle.properties # src/main/java/me/melontini/handytests/client/FabricClientTestHelper.java # src/main/java/me/melontini/handytests/mixin/client/MinecraftClientMixin.java # src/main/java/me/melontini/handytests/server/ServerTestContext.java
- Loading branch information
Showing
18 changed files
with
555 additions
and
410 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -22,46 +22,9 @@ jobs: | |
run: | | ||
./gradlew build | ||
client_test: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout repository | ||
uses: actions/[email protected] | ||
- name: validate gradle wrapper | ||
uses: gradle/[email protected] | ||
- name: setup jdk 17 | ||
uses: actions/[email protected] | ||
with: | ||
distribution: 'temurin' | ||
java-version: 17 | ||
cache: gradle | ||
- name: make gradle wrapper executable | ||
run: chmod +x ./gradlew | ||
- name: run testmod | ||
uses: modmuss50/xvfb-action@v1 | ||
with: | ||
run: ./gradlew runClient --stacktrace --warning-mode=fail | ||
#- uses: actions/[email protected] | ||
# with: | ||
# name: Test Screenshots | ||
# path: run/screenshots | ||
|
||
server_test: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout repository | ||
uses: actions/[email protected] | ||
- name: validate gradle wrapper | ||
uses: gradle/[email protected] | ||
- name: setup jdk 17 | ||
uses: actions/[email protected] | ||
with: | ||
distribution: 'temurin' | ||
java-version: 17 | ||
cache: gradle | ||
- name: make gradle wrapper executable | ||
run: chmod +x ./gradlew | ||
- name: run testmod | ||
run: ./gradlew runServer --stacktrace --warning-mode=fail | ||
run_tests: | ||
uses: constellation-mc/actions/.github/workflows/mc-tests.yml@main | ||
with: | ||
java: 17 | ||
client_task: runClient | ||
server_task: runServer |
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
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
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[libraries] | ||
fabric-loader = { group = "net.fabricmc", name = "fabric-loader", version = "0.16.0" } | ||
fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version = "0.92.1+1.20.1" } | ||
|
||
[plugins] | ||
fabric-loom = { id = "fabric-loom", version = "1.7.2" } | ||
spotless = { id = "com.diffplug.spotless", version = "6.25.0" } |
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
153 changes: 78 additions & 75 deletions
153
src/main/java/me/melontini/handytests/client/ClientTestContext.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,86 +1,89 @@ | ||
package me.melontini.handytests.client; | ||
|
||
import me.melontini.handytests.util.TestContext; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.option.Perspective; | ||
import static me.melontini.handytests.client.FabricClientTestHelper.submit; | ||
|
||
import java.time.Duration; | ||
import java.util.function.BiFunction; | ||
import java.util.function.Function; | ||
import java.util.function.Predicate; | ||
|
||
import static me.melontini.handytests.client.FabricClientTestHelper.submit; | ||
import me.melontini.handytests.util.TestContext; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.option.Perspective; | ||
|
||
public record ClientTestContext(MinecraftClient client) implements TestContext<MinecraftClient> { | ||
|
||
public void sendCommand(String command) { | ||
FabricClientTestHelper.submitAndWait(client -> { | ||
client.player.networkHandler.sendCommand(command); | ||
return null; | ||
}); | ||
} | ||
|
||
public void waitForLoadingComplete() { | ||
FabricClientTestHelper.waitForLoadingComplete(); | ||
} | ||
|
||
public void waitForScreen(Class<? extends Screen> screenClass) { | ||
FabricClientTestHelper.waitForScreen(screenClass); | ||
} | ||
|
||
public <T, S extends Screen> T executeForScreen(Class<S> screenClass, BiFunction<MinecraftClient, S, T> function) { | ||
return FabricClientTestHelper.submitAndWait(client -> { | ||
if (screenClass.isInstance(client.currentScreen)) { | ||
return function.apply(client, screenClass.cast(client.currentScreen)); | ||
} | ||
throw new IllegalStateException("Expected: %s, got: %s".formatted(screenClass.getName(), client.currentScreen != null ? client.currentScreen.getClass().getName() : "null")); | ||
}); | ||
} | ||
|
||
public void openGameMenu() { | ||
FabricClientTestHelper.openGameMenu(); | ||
} | ||
|
||
public void openInventory() { | ||
FabricClientTestHelper.openInventory(); | ||
} | ||
|
||
public void closeScreen() { | ||
setScreen((client) -> null); | ||
} | ||
|
||
public void setScreen(Function<MinecraftClient, Screen> screenSupplier) { | ||
FabricClientTestHelper.setScreen(screenSupplier); | ||
} | ||
|
||
public void takeScreenshot(String name) { | ||
FabricClientTestHelper.takeScreenshot(name); | ||
} | ||
|
||
public void waitForWorldTicks(long ticks) { | ||
FabricClientTestHelper.waitForWorldTicks(ticks); | ||
} | ||
|
||
public void enableDebugHud() { | ||
FabricClientTestHelper.enableDebugHud(); | ||
} | ||
|
||
public void setPerspective(Perspective perspective) { | ||
FabricClientTestHelper.setPerspective(perspective); | ||
} | ||
|
||
@Override | ||
public void waitFor(String what, Predicate<MinecraftClient> predicate, Duration timeout) { | ||
FabricClientTestHelper.waitFor(what, predicate, timeout); | ||
} | ||
|
||
public <T> T submitAndWait(Function<MinecraftClient, T> function) { | ||
return submit(function).join(); | ||
} | ||
|
||
@Override | ||
public MinecraftClient context() { | ||
return client(); | ||
} | ||
public void sendCommand(String command) { | ||
FabricClientTestHelper.submitAndWait(client -> { | ||
client.player.networkHandler.sendCommand(command); | ||
return null; | ||
}); | ||
} | ||
|
||
public void waitForLoadingComplete() { | ||
FabricClientTestHelper.waitForLoadingComplete(); | ||
} | ||
|
||
public void waitForScreen(Class<? extends Screen> screenClass) { | ||
FabricClientTestHelper.waitForScreen(screenClass); | ||
} | ||
|
||
public <T, S extends Screen> T executeForScreen( | ||
Class<S> screenClass, BiFunction<MinecraftClient, S, T> function) { | ||
return FabricClientTestHelper.submitAndWait(client -> { | ||
if (screenClass.isInstance(client.currentScreen)) { | ||
return function.apply(client, screenClass.cast(client.currentScreen)); | ||
} | ||
throw new IllegalStateException("Expected: %s, got: %s" | ||
.formatted( | ||
screenClass.getName(), | ||
client.currentScreen != null ? client.currentScreen.getClass().getName() : "null")); | ||
}); | ||
} | ||
|
||
public void openGameMenu() { | ||
FabricClientTestHelper.openGameMenu(); | ||
} | ||
|
||
public void openInventory() { | ||
FabricClientTestHelper.openInventory(); | ||
} | ||
|
||
public void closeScreen() { | ||
setScreen((client) -> null); | ||
} | ||
|
||
public void setScreen(Function<MinecraftClient, Screen> screenSupplier) { | ||
FabricClientTestHelper.setScreen(screenSupplier); | ||
} | ||
|
||
public void takeScreenshot(String name) { | ||
FabricClientTestHelper.takeScreenshot(name); | ||
} | ||
|
||
public void waitForWorldTicks(long ticks) { | ||
FabricClientTestHelper.waitForWorldTicks(ticks); | ||
} | ||
|
||
public void enableDebugHud() { | ||
FabricClientTestHelper.enableDebugHud(); | ||
} | ||
|
||
public void setPerspective(Perspective perspective) { | ||
FabricClientTestHelper.setPerspective(perspective); | ||
} | ||
|
||
@Override | ||
public void waitFor(String what, Predicate<MinecraftClient> predicate, Duration timeout) { | ||
FabricClientTestHelper.waitFor(what, predicate, timeout); | ||
} | ||
|
||
public <T> T submitAndWait(Function<MinecraftClient, T> function) { | ||
return submit(function).join(); | ||
} | ||
|
||
@Override | ||
public MinecraftClient context() { | ||
return client(); | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
src/main/java/me/melontini/handytests/client/ClientTestEntrypoint.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,5 +1,7 @@ | ||
package me.melontini.handytests.client; | ||
|
||
public interface ClientTestEntrypoint { | ||
void onClientTest(ClientTestContext context); | ||
default void onClientTest(ClientTestContext context) { | ||
context.runAllForEntrypoint(this); | ||
} | ||
} |
Oops, something went wrong.