Skip to content

Commit

Permalink
ShortcutTest: Determine if HTML is supported before asserting against…
Browse files Browse the repository at this point in the history
… an HTML string

This does a few things:
* Ensures that the test will work properly if the default LaF is *not* Aqua (the
  default macOS LaF)
* If Aqua ever supports HTML in menu tooltips, we will only have to change one
  location
* Fewer locations to worry about in unit tests if we change the default LaF for
  mac to something else

git-svn-id: https://josm.openstreetmap.de/svn/trunk@19231 0c6e7542-c601-0410-84e7-c038aed88b3b
  • Loading branch information
taylor.smock committed Oct 3, 2024
1 parent cfeeaf8 commit 4601c53
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/unit/org/openstreetmap/josm/tools/ShortcutTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ class ShortcutTest {
@Test
void testMakeTooltip() {
final String tooltip = Shortcut.makeTooltip("Foo Bar", KeyStroke.getKeyStroke(KeyEvent.VK_J, InputEvent.SHIFT_DOWN_MASK));
if (Platform.determinePlatform() == Platform.OSX) {
assertEquals("Foo Bar (⇧+J)", tooltip);
final String shift = Platform.determinePlatform() == Platform.OSX ? "⇧" : "Shift";
if (PlatformManager.getPlatform().isHtmlSupportedInMenuTooltips()) {
assertEquals("<html>Foo Bar <font size='-2'>(" + shift + "+J)</font>&nbsp;</html>", tooltip);
} else {
assertEquals("<html>Foo Bar <font size='-2'>(Shift+J)</font>&nbsp;</html>", tooltip);
assertEquals("Foo Bar (" + shift + "+J)", tooltip);
}
}

Expand Down

0 comments on commit 4601c53

Please sign in to comment.