kopia lustrzana https://github.com/JOSM/MapWithAI
More testing for MapWithAIDownloadSourceType
Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head
rodzic
8f25ef3786
commit
f36f362d26
|
@ -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) {
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue