Changeset 14412 in josm for trunk/test/unit/org/openstreetmap/josm/gui/help
- Timestamp:
- 2018-11-05T01:16:59+01:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/help/HelpBrowserTest.java
r14369 r14412 13 13 import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; 14 14 import org.openstreetmap.josm.tools.LanguageInfo.LocaleType; 15 import org.openstreetmap.josm.tools.PlatformHook; 16 import org.openstreetmap.josm.tools.PlatformManager; 15 17 16 18 import com.google.common.collect.ImmutableMap; 17 19 18 20 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 21 import mockit.Expectations; 22 import mockit.Injectable; 19 23 20 24 /** … … 91 95 92 96 /** 93 * Unit test of {@link HelpBrowser.EditAction} class. 94 */ 95 @Test 96 public void testEditAction() { 97 TestUtils.assumeWorkingJMockit(); 97 * Unit test of {@link HelpBrowser.EditAction} class handling a null url. 98 * @param mockPlatformHook platform hook mock 99 * @throws Exception in case of error 100 */ 101 @Test 102 public void testEditActionNull(@Injectable final PlatformHook mockPlatformHook) throws Exception { 103 TestUtils.assumeWorkingJMockit(); 104 new Expectations(PlatformManager.class) {{ 105 PlatformManager.getPlatform(); result = mockPlatformHook; minTimes = 0; 106 }}; 107 new Expectations() {{ 108 // should not be called 109 mockPlatformHook.openUrl((String) any); times = 0; 110 }}; 111 98 112 IHelpBrowser browser = newHelpBrowser(); 99 113 assertNull(browser.getUrl()); 100 114 new HelpBrowser.EditAction(browser).actionPerformed(null); 101 115 } 116 117 /** 118 * Unit test of {@link HelpBrowser.EditAction} class handling an "internal" url. 119 * @param mockPlatformHook platform hook mock 120 * @throws Exception in case of error 121 */ 122 @Test 123 public void testEditActionInternal(@Injectable final PlatformHook mockPlatformHook) throws Exception { 124 TestUtils.assumeWorkingJMockit(); 125 new Expectations(PlatformManager.class) {{ 126 PlatformManager.getPlatform(); result = mockPlatformHook; 127 }}; 128 new Expectations() {{ 129 mockPlatformHook.openUrl(URL_2 + "?action=edit"); result = null; times = 1; 130 }}; 131 132 IHelpBrowser browser = newHelpBrowser(); 102 133 browser.openUrl(URL_2); 103 134 assertEquals(URL_2, browser.getUrl()); 104 135 new HelpBrowser.EditAction(browser).actionPerformed(null); 105 136 } 137 138 /** 139 * Unit test of {@link HelpBrowser.EditAction} class handling an "external" url. 140 * @param mockPlatformHook platform hook mock 141 * @throws Exception in case of error 142 */ 143 @Test 144 public void testEditActionExternal(@Injectable final PlatformHook mockPlatformHook) throws Exception { 145 TestUtils.assumeWorkingJMockit(); 146 new Expectations(PlatformManager.class) {{ 147 PlatformManager.getPlatform(); result = mockPlatformHook; minTimes = 0; 148 }}; 149 new Expectations() {{ 150 // should not be called 151 mockPlatformHook.openUrl((String) any); times = 0; 152 }}; 106 153 final JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker( 107 154 ImmutableMap.<String, Object>of( … … 113 160 ); 114 161 162 IHelpBrowser browser = newHelpBrowser(); 115 163 browser.openUrl(URL_3); 116 164 assertEquals(URL_3, browser.getUrl()); … … 125 173 /** 126 174 * Unit test of {@link HelpBrowser.OpenInBrowserAction} class. 127 */ 128 @Test 129 public void testOpenInBrowserAction() { 175 * @param mockPlatformHook platform hook mock 176 * @throws Exception in case of error 177 */ 178 @Test 179 public void testOpenInBrowserAction(@Injectable final PlatformHook mockPlatformHook) throws Exception { 180 TestUtils.assumeWorkingJMockit(); 181 new Expectations(PlatformManager.class) {{ 182 PlatformManager.getPlatform(); result = mockPlatformHook; 183 }}; 184 new Expectations() {{ 185 mockPlatformHook.openUrl(URL_1); result = null; times = 1; 186 }}; 187 130 188 IHelpBrowser browser = newHelpBrowser(); 131 189 browser.openUrl(URL_1);
Note:
See TracChangeset
for help on using the changeset viewer.