Skip to content

Commit

Permalink
test: add unit tests for the newly introduced modes
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdibi committed Oct 3, 2024
1 parent 5846b9c commit 6f1de9d
Showing 1 changed file with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,53 @@ public void applyShouldWorkWithModemWithEnabledGPS() throws DBusException, IOExc
thenLocationSetupWasCalledWith(EnumSet.of(MMModemLocationSource.MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED), false);
}

@Test
public void applyShouldWorkWithModemWithEnabledGPSAndUnmanagedMode() throws DBusException, IOException {
givenBasicMockedDbusConnector();
givenMockedDevice("1-5", "ttyACM17", NMDeviceType.NM_DEVICE_TYPE_MODEM, NMDeviceState.NM_DEVICE_STATE_ACTIVATED,
true, false, false);
givenMockedDeviceList();

givenNetworkConfigMapWith("net.interfaces", "1-5,");
givenNetworkConfigMapWith("net.interface.1-5.config.ip4.status", "netIPv4StatusEnabledWAN");
givenNetworkConfigMapWith("net.interface.1-5.config.dhcpClient4.enabled", true);
givenNetworkConfigMapWith("net.interface.1-5.config.apn", "myAwesomeAPN");
givenNetworkConfigMapWith("net.interface.1-5.config.gpsEnabled", true);
givenNetworkConfigMapWith("net.interface.1-5.config.gpsMode", "unmanaged");
givenNetworkConfigMapWith("net.interface.1-5.config.resetTimeout", 0);

whenApplyIsCalledWith(this.netConfig);

thenNoExceptionIsThrown();
thenConnectionUpdateIsCalledFor("ttyACM17");
thenActivateConnectionIsCalledFor("ttyACM17");
thenLocationSetupWasCalledWith(EnumSet.of(MMModemLocationSource.MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED), false);
}

@Test
public void applyShouldWorkWithModemWithEnabledGPSAndManagedMode() throws DBusException, IOException {
givenBasicMockedDbusConnector();
givenMockedDevice("1-5", "ttyACM17", NMDeviceType.NM_DEVICE_TYPE_MODEM, NMDeviceState.NM_DEVICE_STATE_ACTIVATED,
true, false, false);
givenMockedDeviceList();

givenNetworkConfigMapWith("net.interfaces", "1-5,");
givenNetworkConfigMapWith("net.interface.1-5.config.ip4.status", "netIPv4StatusEnabledWAN");
givenNetworkConfigMapWith("net.interface.1-5.config.dhcpClient4.enabled", true);
givenNetworkConfigMapWith("net.interface.1-5.config.apn", "myAwesomeAPN");
givenNetworkConfigMapWith("net.interface.1-5.config.gpsEnabled", true);
givenNetworkConfigMapWith("net.interface.1-5.config.gpsMode", "managed-gps");
givenNetworkConfigMapWith("net.interface.1-5.config.resetTimeout", 0);

whenApplyIsCalledWith(this.netConfig);

thenNoExceptionIsThrown();
thenConnectionUpdateIsCalledFor("ttyACM17");
thenActivateConnectionIsCalledFor("ttyACM17");
thenLocationSetupWasCalledWith(EnumSet.of(MMModemLocationSource.MM_MODEM_LOCATION_SOURCE_GPS_RAW,
MMModemLocationSource.MM_MODEM_LOCATION_SOURCE_GPS_NMEA), false);
}

@Test
public void applyShouldDisableGPSWithMissingGPSConfiguration() throws DBusException, IOException {
givenBasicMockedDbusConnector();
Expand Down

0 comments on commit 6f1de9d

Please sign in to comment.