Skip to content

Commit

Permalink
Check for display before running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bailuk committed Feb 13, 2024
1 parent c395b3a commit 2794895
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions java-gtk/src/test/java/ch/bailu/gtk/TestPropertyAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;

import ch.bailu.gtk.gdk.Display;
import ch.bailu.gtk.gio.ListStore;
import ch.bailu.gtk.gtk.Box;
import ch.bailu.gtk.gtk.Button;
Expand All @@ -17,18 +18,17 @@

public class TestPropertyAccess {
public static boolean gtkInit() {
return Gtk.initCheck();
return Gtk.initCheck() && Display.getDefault().isNotNull();
}


@Test
public void testPropertyAccess() {
var listStore = new ListStore(TextTag.getTypeID());
var textTag = new TextTag("test");

assertEquals(0,listStore.getIntProperty("n-items"));
assertEquals(0, listStore.getIntProperty("n-items"));
listStore.append(textTag);
assertEquals(1,listStore.getIntProperty("n-items"));
assertEquals(1, listStore.getIntProperty("n-items"));

var textTagGet = new TextTag(listStore.asListModel().getItem(0).cast());
assertEquals("test", textTagGet.getStringProperty("name"));
Expand All @@ -43,21 +43,20 @@ public void testPropertyAccess() {
@Test
@EnabledIf("gtkInit")
public void testPropertyAccessButton() {
var button = new Button();
var label = new Str("test2");

var button = new Button();
var label = new Str("test2");

button.setStringProperty("label", "test");
assertEquals("test", button.getLabel().toString());
assertEquals("test", button.getStringProperty("label"));
button.setStringProperty("label", "test");
assertEquals("test", button.getLabel().toString());
assertEquals("test", button.getStringProperty("label"));

button.setStrProperty("label", label);
assertEquals("test2", button.getLabel().toString());
button.setStrProperty("label", label);
assertEquals("test2", button.getLabel().toString());

assertTrue(button.getChild().isNotNull());
assertTrue(button.getObjectProperty("child").isNotNull());
assertTrue(button.getChild().isNotNull());
assertTrue(button.getObjectProperty("child").isNotNull());

assertEquals(button.getChild(), button.getObjectProperty("child"));
assertEquals(button.getChild(), button.getObjectProperty("child"));
}


Expand Down

0 comments on commit 2794895

Please sign in to comment.