More testing for MapWithAIDownloadSourceType

Signed-off-by: Taylor Smock <taylor.smock@kaart.com>
pull/1/head
Taylor Smock 2020-06-25 11:01:53 -06:00
rodzic 8f25ef3786
commit f36f362d26
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 625F6A74A3E4311A
2 zmienionych plików z 28 dodań i 2 usunięć

Wyświetl plik

@ -27,10 +27,11 @@ public class MapWithAIDownloadSourceType implements IDownloadSourceType, LayerCh
@Override
public JCheckBox getCheckBox(ChangeListener checkboxChangeListener) {
if (cbDownloadMapWithAIData == null) {
cbDownloadMapWithAIData = new JCheckBox(tr("MapWithAI data"), true);
cbDownloadMapWithAIData = new JCheckBox(tr("MapWithAI data"), getBooleanProperty().get());
cbDownloadMapWithAIData
.setToolTipText(tr("Select to download MapWithAI data in the selected download area."));
cbDownloadMapWithAIData.getModel().addChangeListener(checkboxChangeListener);
cbDownloadMapWithAIData.getModel()
.addActionListener(l -> getBooleanProperty().put(cbDownloadMapWithAIData.isSelected()));
MapWithAILayerInfo.getInstance().addListener(this);
}
if (checkboxChangeListener != null) {

Wyświetl plik

@ -2,8 +2,14 @@
package org.openstreetmap.josm.plugins.mapwithai.gui.download;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.swing.JCheckBox;
import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.josm.data.Bounds;
@ -32,4 +38,23 @@ public class MapWithAIDownloadSourceTypeTest {
assertFalse(type.isDownloadAreaTooLarge(MapWithAIDataUtilsTest.getTestBounds()),
"The download area shouldn't be too large");
}
/**
* Test that the listener works properly
*/
@Test
public void testMapWithAIDownloadSourceTypeListener() {
MapWithAIDownloadSourceType type = new MapWithAIDownloadSourceType();
JCheckBox checkbox = type.getCheckBox();
assertNotNull(checkbox);
assertSame(checkbox, type.getCheckBox());
AtomicBoolean listener = new AtomicBoolean();
type.getCheckBox(l -> listener.set(!listener.get()));
assertFalse(listener.get());
checkbox.doClick();
assertTrue(listener.get());
checkbox.doClick();
assertFalse(listener.get());
}
}