Skip to content

Commit

Permalink
WebClientOptions.Geolocation is serializable now
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Jan 22, 2025
1 parent ed2d44b commit dd0ae11
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/org/htmlunit/WebClientOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ public void setGeolocation(final Geolocation geolocation) {
geolocation_ = geolocation;
}

public static class Geolocation {
public static class Geolocation implements Serializable {
private final double accuracy_;
private final double latitude_;
private final double longitude_;
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/org/htmlunit/WebClientOptionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import javax.net.ssl.SSLContext;

import org.apache.commons.lang3.SerializationUtils;
import org.htmlunit.WebClientOptions.Geolocation;
import org.htmlunit.junit.BrowserRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -48,6 +49,9 @@ public void serialization() throws Exception {
assertEquals(original.isThrowExceptionOnScriptError(), deserialized.isThrowExceptionOnScriptError());
assertEquals(original.isPopupBlockerEnabled(), deserialized.isPopupBlockerEnabled());
assertEquals(original.isRedirectEnabled(), deserialized.isRedirectEnabled());

assertEquals(original.isGeolocationEnabled(), deserialized.isGeolocationEnabled());
assertEquals(original.getGeolocation(), deserialized.getGeolocation());
}

/**
Expand All @@ -65,6 +69,9 @@ public void serializationChanged() throws Exception {
original.setPopupBlockerEnabled(true);
original.setRedirectEnabled(false);

original.setGeolocationEnabled(true);
original.setGeolocation(new WebClientOptions.Geolocation(1d, 2d, 3d, 4d, 5d, 6d, 7d));

final byte[] bytes = SerializationUtils.serialize(original);
final WebClientOptions deserialized = (WebClientOptions) SerializationUtils.deserialize(bytes);

Expand All @@ -77,6 +84,16 @@ public void serializationChanged() throws Exception {
assertEquals(original.isThrowExceptionOnScriptError(), deserialized.isThrowExceptionOnScriptError());
assertEquals(original.isPopupBlockerEnabled(), deserialized.isPopupBlockerEnabled());
assertEquals(original.isRedirectEnabled(), deserialized.isRedirectEnabled());

assertEquals(original.isGeolocationEnabled(), deserialized.isGeolocationEnabled());
assertEquals(original.getGeolocation().getAccuracy(), deserialized.getGeolocation().getAccuracy());
assertEquals(original.getGeolocation().getLatitude(), deserialized.getGeolocation().getLatitude());
assertEquals(original.getGeolocation().getLongitude(), deserialized.getGeolocation().getLongitude());
assertEquals(original.getGeolocation().getAltitude(), deserialized.getGeolocation().getAltitude());
assertEquals(original.getGeolocation().getAltitudeAccuracy(),
deserialized.getGeolocation().getAltitudeAccuracy());
assertEquals(original.getGeolocation().getHeading(), deserialized.getGeolocation().getHeading());
assertEquals(original.getGeolocation().getSpeed(), deserialized.getGeolocation().getSpeed());
}

/**
Expand Down

0 comments on commit dd0ae11

Please sign in to comment.