Skip to content

Commit

Permalink
Fixed bug with connecting detailed signal from builder object
Browse files Browse the repository at this point in the history
  • Loading branch information
jwharm committed Sep 30, 2024
1 parent aa3527b commit a086d26
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
import org.gnome.gobject.GObject;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;

import static org.junit.jupiter.api.Assertions.*;

/**
* Tests for the patched GObject methods to get and set properties,
Expand Down Expand Up @@ -58,4 +61,25 @@ public void newGObjectWithProperties() {
String applicationId = (String) Properties.getProperty(app, "application-id");
assertEquals("io.github.jwharm.javagi.test.Application", applicationId);
}

@Test
public void builder() {
AtomicBoolean notified = new AtomicBoolean(false);
Application app = Application.builder()
.setApplicationId("javagi.test.Application1")
.setFlags(Set.of(ApplicationFlags.IS_SERVICE))
.onNotify("application-id", _ -> {
notified.set(true);
})
.build();

// Assert that the properties are set
assertEquals("javagi.test.Application1", app.getApplicationId());
assertEquals(Set.of(ApplicationFlags.IS_SERVICE), app.getFlags());

// Assert that the "notify" signal is connected
assertFalse(notified.get());
app.setApplicationId("javagi.test.Application2");
assertTrue(notified.get());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void connect(String name, FunctionPointer callback) {
*/
@Override
public void connect(String name, String detail, FunctionPointer callback) {
boolean isDetailed = detail != null && detail.isBlank();
boolean isDetailed = detail != null && !detail.isBlank();
String fullName = name + (isDetailed ? "" : ("::" + detail));
connectRequests.add(new ConnectRequest(fullName, callback));
}
Expand Down

0 comments on commit a086d26

Please sign in to comment.