Changeset 10011 in josm for trunk/test/unit/org
- Timestamp:
- 2016-03-19T00:34:41+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/LayerListDialogTest.java
r9926 r10011 3 3 4 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertFalse; 5 6 import static org.junit.Assert.assertTrue; 6 7 … … 9 10 import org.openstreetmap.josm.JOSMFixture; 10 11 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.gui.dialogs.LayerListDialog.LayerGammaAction;12 12 import org.openstreetmap.josm.gui.dialogs.LayerListDialog.LayerListModel; 13 import org.openstreetmap.josm.gui.dialogs.LayerListDialog.Layer OpacityAction;13 import org.openstreetmap.josm.gui.dialogs.LayerListDialog.LayerVisibilityAction; 14 14 import org.openstreetmap.josm.gui.layer.TMSLayer; 15 15 import org.openstreetmap.josm.gui.layer.TMSLayerTest; … … 29 29 30 30 /** 31 * Unit test of {@link Layer GammaAction} class.31 * Unit test of {@link LayerVisibilityAction} class. 32 32 */ 33 33 @Test 34 public void testLayer GammaAction() {34 public void testLayerVisibilityAction() { 35 35 TMSLayer layer = TMSLayerTest.createTmsLayer(); 36 36 try { 37 LayerListModel model = LayerListDialog.getInstance().getModel(); 38 LayerVisibilityAction action = new LayerVisibilityAction(model); 39 action.updateEnabledState(); 40 assertFalse(action.isEnabled()); 41 37 42 Main.map.mapView.addLayer(layer); 38 LayerListModel model = LayerListDialog.getInstance().getModel();39 LayerGammaAction action = new LayerGammaAction(model);40 43 action.updateEnabledState(); 41 44 assertTrue(action.isEnabled()); 42 45 assertTrue(action.supportLayers(model.getSelectedLayers())); 43 assertEquals(1.0, action.getValue(), 1e-15);44 action.setValue(0.5);45 assertEquals(0.5, action.getValue(), 1e-15);46 } finally {47 Main.map.mapView.removeLayer(layer);48 }49 }50 46 51 /** 52 * Unit test of {@link LayerOpacityAction} class. 53 */ 54 @Test 55 public void testLayerOpacityAction() { 56 TMSLayer layer = TMSLayerTest.createTmsLayer(); 57 try { 58 Main.map.mapView.addLayer(layer); 59 LayerListModel model = LayerListDialog.getInstance().getModel(); 60 LayerOpacityAction action = new LayerOpacityAction(model); 61 action.updateEnabledState(); 62 assertTrue(action.isEnabled()); 63 assertTrue(action.supportLayers(model.getSelectedLayers())); 64 assertEquals(1.0, action.getValue(), 1e-15); 65 action.setValue(0.5); 66 assertEquals(0.5, action.getValue(), 1e-15); 47 // now check values 48 action.updateValues(); 49 assertEquals(1.0, action.readOpacityValue(), 1e-15); 50 assertEquals(1.0, action.readGammaValue(), 1e-15); 51 52 action.setOpacityValue(.5, false); 53 action.setGammaValue(1.5); 54 action.updateValues(); 55 56 assertEquals(0.5, action.readOpacityValue(), 1e-15); 57 assertEquals(1.5, action.readGammaValue(), 1e-15); 58 59 action.setVisible(false); 60 action.updateValues(); 61 assertFalse(layer.isVisible()); 62 63 action.setVisible(true); 64 action.updateValues(); 65 assertTrue(layer.isVisible()); 66 67 // layer stays visible during adjust 68 action.setOpacityValue(0, true); 69 assertEquals(0, layer.getOpacity(), 1e-15); 70 layer.setOpacity(.1); // to make layer.isVisible work 71 assertTrue(layer.isVisible()); 72 layer.setOpacity(0); 73 74 action.setOpacityValue(0, false); 75 assertEquals(0, layer.getOpacity(), 1e-15); 76 layer.setOpacity(.1); // to make layer.isVisible work 77 assertFalse(layer.isVisible()); 78 layer.setOpacity(0); 79 action.updateValues(); 80 81 // Opacity reset when it was 0 and user set layer to visible. 82 action.setVisible(true); 83 action.updateValues(); 84 assertEquals(1.0, action.readOpacityValue(), 1e-15); 85 assertEquals(1.0, layer.getOpacity(), 1e-15); 86 67 87 } finally { 68 88 Main.map.mapView.removeLayer(layer);
Note:
See TracChangeset
for help on using the changeset viewer.