### Eclipse Workspace Patch 1.0
#P josm
diff --git test/unit/org/openstreetmap/josm/gui/preferences/audio/AudioPreferenceTest.java test/unit/org/openstreetmap/josm/gui/preferences/audio/AudioPreferenceTest.java
index 891300d..8e13491 100644
|
|
|
|
| 1 | 1 | // License: GPL. For details, see LICENSE file. |
| 2 | 2 | package org.openstreetmap.josm.gui.preferences.audio; |
| 3 | 3 | |
| | 4 | import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; |
| 4 | 5 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 5 | 6 | |
| | 7 | import org.junit.jupiter.api.AfterEach; |
| | 8 | import org.junit.jupiter.api.BeforeEach; |
| 6 | 9 | import org.junit.jupiter.api.Test; |
| | 10 | import org.junit.jupiter.api.parallel.Execution; |
| | 11 | import org.junit.jupiter.api.parallel.ExecutionMode; |
| | 12 | import org.openstreetmap.josm.gui.preferences.PreferenceSetting; |
| 7 | 13 | import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils; |
| 8 | 14 | import org.openstreetmap.josm.spi.preferences.Config; |
| 9 | 15 | |
| 10 | 16 | /** |
| 11 | 17 | * Unit tests of {@link AudioPreference} class. |
| 12 | 18 | */ |
| | 19 | @Execution(ExecutionMode.SAME_THREAD) |
| 13 | 20 | class AudioPreferenceTest { |
| | 21 | |
| | 22 | private boolean originalMenuInvisible; |
| | 23 | |
| | 24 | @BeforeEach |
| | 25 | void setUp() { |
| | 26 | originalMenuInvisible = Config.getPref().getBoolean("audio.menuinvisible", false); |
| | 27 | } |
| | 28 | |
| | 29 | @AfterEach |
| | 30 | void tearDown() { |
| | 31 | Config.getPref().putBoolean("audio.menuinvisible", originalMenuInvisible); |
| | 32 | } |
| | 33 | |
| | 34 | |
| 14 | 35 | /** |
| 15 | 36 | * Unit test of {@link AudioPreference#AudioPreference}. |
| 16 | 37 | */ |
| 17 | 38 | @Test |
| 18 | | void testAudioPreference() { |
| 19 | | assertNotNull(new AudioPreference.Factory().createPreferenceSetting()); |
| | 39 | void testAudioPreference_ShouldCreateValidInstance() { |
| | 40 | final PreferenceSetting preference = new AudioPreference.Factory().createPreferenceSetting(); |
| | 41 | assertNotNull(preference, "The factory should create a valid AudioPreference instance."); |
| 20 | 42 | } |
| 21 | 43 | |
| 22 | 44 | /** |
| 23 | | * Unit test of {@link AudioPreference#addGui}. |
| | 45 | * Unit test of {@link AudioPreference#addGui} when the menu is invisible. |
| 24 | 46 | */ |
| 25 | 47 | @Test |
| 26 | | void testAddGui() { |
| | 48 | void testAddGui_WhenMenuInvisible_ShouldExecuteWithoutException() { |
| 27 | 49 | Config.getPref().putBoolean("audio.menuinvisible", true); |
| 28 | | PreferencesTestUtils.doTestPreferenceSettingAddGui(new AudioPreference.Factory(), null); |
| | 50 | |
| | 51 | assertDoesNotThrow(() -> |
| | 52 | PreferencesTestUtils.doTestPreferenceSettingAddGui(new AudioPreference.Factory(), null), |
| | 53 | "Should not throw an exception when menu is invisible." |
| | 54 | ); |
| | 55 | } |
| | 56 | |
| | 57 | /** |
| | 58 | * Unit test of {@link AudioPreference#addGui} when the menu is visible. |
| | 59 | */ |
| | 60 | @Test |
| | 61 | void testAddGui_WhenMenuVisible_ShouldExecuteWithoutException() { |
| 29 | 62 | Config.getPref().putBoolean("audio.menuinvisible", false); |
| 30 | | PreferencesTestUtils.doTestPreferenceSettingAddGui(new AudioPreference.Factory(), null); |
| | 63 | |
| | 64 | assertDoesNotThrow(() -> |
| | 65 | PreferencesTestUtils.doTestPreferenceSettingAddGui(new AudioPreference.Factory(), null), |
| | 66 | "Should not throw an exception when menu is visible." |
| | 67 | ); |
| 31 | 68 | } |
| 32 | 69 | } |