Changeset 32591 in osm for applications/editors
- Timestamp:
- 2016-07-06T16:00:47+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/mapillary
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java
r32581 r32591 97 97 format24.setSelected(Main.pref.getBoolean("mapillary.format-24")); 98 98 moveTo.setSelected(Main.pref.getBoolean("mapillary.move-to-picture", true)); 99 this.hoverEnabled.setSelected(Main.pref.getBoolean("mapillary.hover-enabled", true));99 hoverEnabled.setSelected(Main.pref.getBoolean("mapillary.hover-enabled", true)); 100 100 101 101 mainPanel.setLayout(new GridBagLayout()); … … 170 170 171 171 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getDownloadViewMenu(), false); 172 if (this.downloadModeComboBox.getSelectedItem().equals(MapillaryDownloader.MODES.Automatic.toString())) 172 if (this.downloadModeComboBox.getSelectedItem().equals(MapillaryDownloader.MODES.Automatic.toString())) { 173 173 Main.pref.put("mapillary.download-mode", MapillaryDownloader.MODES.Automatic.toString()); 174 if (this.downloadModeComboBox.getSelectedItem().equals(MapillaryDownloader.MODES.Semiautomatic.toString())) 174 } 175 if (this.downloadModeComboBox.getSelectedItem().equals(MapillaryDownloader.MODES.Semiautomatic.toString())) { 175 176 Main.pref.put("mapillary.download-mode", MapillaryDownloader.MODES.Semiautomatic.toString()); 177 } 176 178 if (this.downloadModeComboBox.getSelectedItem().equals(MapillaryDownloader.MODES.Manual.toString())) { 177 179 Main.pref.put("mapillary.download-mode", MapillaryDownloader.MODES.Manual.toString()); -
applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSettingTest.java
r32078 r32591 7 7 import java.awt.GraphicsEnvironment; 8 8 import java.lang.reflect.Field; 9 import java.util.HashMap; 10 import java.util.Map; 9 11 10 12 import javax.swing.JButton; 13 import javax.swing.JCheckBox; 14 import javax.swing.JComboBox; 11 15 import javax.swing.JLabel; 12 16 import javax.swing.JPanel; 13 17 14 18 import org.junit.Test; 19 import org.openstreetmap.josm.Main; 15 20 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 16 21 import org.openstreetmap.josm.plugins.mapillary.AbstractTest; … … 31 36 assertEquals(displayTabs + 1, tabs.getDisplayPreference().getTabPane().getTabCount()); 32 37 assertEquals(tabs.getDisplayPreference(), setting.getTabPreferenceSetting(tabs)); 38 } 39 40 @Test 41 public void testIsExpert() { 42 assertFalse(new MapillaryPreferenceSetting().isExpert()); 33 43 } 34 44 … … 58 68 } 59 69 60 private static Object getPrivateField(MapillaryPreferenceSetting object, String name) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { 70 /** 71 * Helper method for obtaining the value of a private field 72 * @param object the object of which you want the private field 73 * @param name the name of the private field 74 * @return the current value that field has 75 */ 76 private static Object getPrivateField(MapillaryPreferenceSetting object, String name) 77 throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { 61 78 Field field = object.getClass().getDeclaredField(name); 62 79 field.setAccessible(true); … … 64 81 } 65 82 83 @SuppressWarnings("unchecked") 84 @Test 85 public void testOk() throws SecurityException, IllegalArgumentException, IllegalAccessException, NoSuchFieldException { 86 MapillaryPreferenceSetting settings = new MapillaryPreferenceSetting(); 87 88 // Test checkboxes 89 settings.ok(); 90 assertEquals(Main.pref.get("mapillary.display-hour"), 91 Boolean.toString(((JCheckBox) getPrivateField(settings, "displayHour")).isSelected())); 92 assertEquals(Main.pref.get("mapillary.format-24"), 93 Boolean.toString(((JCheckBox) getPrivateField(settings, "format24")).isSelected())); 94 assertEquals(Main.pref.get("mapillary.move-to-picture"), 95 Boolean.toString(((JCheckBox) getPrivateField(settings, "moveTo")).isSelected())); 96 assertEquals(Main.pref.get("mapillary.hover-enabled"), 97 Boolean.toString(((JCheckBox) getPrivateField(settings, "hoverEnabled")).isSelected())); 98 99 // Toggle state of the checkboxes 100 toggleCheckbox((JCheckBox) getPrivateField(settings, "displayHour")); 101 toggleCheckbox((JCheckBox) getPrivateField(settings, "format24")); 102 toggleCheckbox((JCheckBox) getPrivateField(settings, "moveTo")); 103 toggleCheckbox((JCheckBox) getPrivateField(settings, "hoverEnabled")); 104 105 // Test the second state of the checkboxes 106 settings.ok(); 107 assertEquals(Main.pref.get("mapillary.display-hour"), 108 Boolean.toString(((JCheckBox) getPrivateField(settings, "displayHour")).isSelected())); 109 assertEquals(Main.pref.get("mapillary.format-24"), 110 Boolean.toString(((JCheckBox) getPrivateField(settings, "format24")).isSelected())); 111 assertEquals(Main.pref.get("mapillary.move-to-picture"), 112 Boolean.toString(((JCheckBox) getPrivateField(settings, "moveTo")).isSelected())); 113 assertEquals(Main.pref.get("mapillary.hover-enabled"), 114 Boolean.toString(((JCheckBox) getPrivateField(settings, "hoverEnabled")).isSelected())); 115 116 // Test combobox 117 for (int i = 0; i < ((JComboBox<String>) getPrivateField(settings, "downloadModeComboBox")).getItemCount(); i++) { 118 ((JComboBox<String>) getPrivateField(settings, "downloadModeComboBox")).setSelectedIndex(i); 119 settings.ok(); 120 assertEquals(Main.pref.get("mapillary.download-mode"), 121 ((JComboBox<String>) getPrivateField(settings, "downloadModeComboBox")).getSelectedItem()); 122 } 123 } 124 125 private static void toggleCheckbox(JCheckBox jcb) { 126 jcb.setSelected(!jcb.isSelected()); 127 } 128 66 129 }
Note:
See TracChangeset
for help on using the changeset viewer.