1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-01 14:32:54 +01:00

Fix tests

This commit is contained in:
José Rebelo 2023-10-04 21:58:41 +01:00
parent 2c5b687cef
commit d1dee47186
2 changed files with 19 additions and 2 deletions

View File

@ -76,7 +76,7 @@ public class TestDeviceCoordinator extends AbstractDeviceCoordinator {
@Override @Override
public String getManufacturer() { public String getManufacturer() {
return null; return "Test";
} }
@Override @Override
@ -110,6 +110,8 @@ public class TestDeviceCoordinator extends AbstractDeviceCoordinator {
return UnknownDeviceSupport.class; return UnknownDeviceSupport.class;
} }
@Override @Override
public int getDeviceNameResource() { public int getDeviceNameResource() {
return R.string.devicetype_test; return R.string.devicetype_test;

View File

@ -25,7 +25,10 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class DeviceTypeTest { import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.test.TestBase;
public class DeviceTypeTest extends TestBase {
@Test @Test
public void ensureNoDuplicateKeys() { public void ensureNoDuplicateKeys() {
final Set<Integer> knownKeys = new HashSet<>(); final Set<Integer> knownKeys = new HashSet<>();
@ -37,4 +40,16 @@ public class DeviceTypeTest {
Assert.assertTrue("There are duplicated device keys: " + duplicateKeys, duplicateKeys.isEmpty()); Assert.assertTrue("There are duplicated device keys: " + duplicateKeys, duplicateKeys.isEmpty());
} }
@Test
public void ensureNoMissingDeviceInfo() {
// Check that all coordinators for all device types declare valid device names, icons and manufacturer
for (final DeviceType deviceType : DeviceType.values()) {
final DeviceCoordinator coordinator = deviceType.getDeviceCoordinator();
Assert.assertNotEquals("Device name for " + deviceType + " is 0", 0, coordinator.getDeviceNameResource());
Assert.assertNotEquals("Device icon for " + deviceType + " is 0", 0, coordinator.getDefaultIconResource());
Assert.assertNotEquals("Disabled device icon for " + deviceType + " is 0", 0, coordinator.getDisabledIconResource());
Assert.assertNotEquals("Manufacturer for " + deviceType + " is null", null, coordinator.getManufacturer());
}
}
} }