source: josm/trunk/test/unit/org/openstreetmap/josm/tools/PlatformHookOsxTest.java@ 18853

Last change on this file since 18853 was 18853, checked in by taylor.smock, 8 months ago

See #16567: Update to JUnit 5

This removes new JOSMTestRules() with no additional setup and most
JOSMFixture calls.

Removing the bare JOSMTestRules speeds up the test suite since there are two
fewer System.gc() calls per test.

  • Property svn:eol-style set to native
File size: 2.9 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.tools;
3
4import static org.junit.jupiter.api.Assertions.assertEquals;
5import static org.junit.jupiter.api.Assertions.assertFalse;
6import static org.junit.jupiter.api.Assertions.assertNotNull;
7import static org.junit.jupiter.api.Assertions.assertTrue;
8import static org.junit.jupiter.api.Assumptions.assumeTrue;
9
10import java.io.File;
11import java.io.IOException;
12
13import org.junit.jupiter.api.BeforeAll;
14import org.junit.jupiter.api.Test;
15import org.openstreetmap.josm.spi.preferences.Config;
16
17/**
18 * Unit tests of {@link PlatformHookOsx} class.
19 */
20class PlatformHookOsxTest {
21
22 static PlatformHookOsx hook;
23
24 /**
25 * Setup test.
26 */
27 @BeforeAll
28 public static void setUp() {
29 hook = new PlatformHookOsx();
30 }
31
32 /**
33 * Test method for {@code PlatformHookOsx#startupHook}
34 */
35 @Test
36 void testStartupHook() {
37 hook.startupHook((a, b, c, d) -> System.out.println("java callback"), u -> System.out.println("webstart callback"));
38 }
39
40 /**
41 * Test method for {@code PlatformHookOsx#afterPrefStartupHook}
42 */
43 @Test
44 void testAfterPrefStartupHook() {
45 hook.afterPrefStartupHook();
46 }
47
48 /**
49 * Test method for {@code PlatformHookOsx#openUrl}
50 * @throws IOException if an error occurs
51 */
52 @Test
53 void testOpenUrl() throws IOException {
54 assumeTrue(PlatformManager.isPlatformOsx());
55 hook.openUrl(Config.getUrls().getJOSMWebsite());
56 }
57
58 /**
59 * Test method for {@code PlatformHookOsx#getDefaultCacheDirectory}
60 */
61 @Test
62 void testGetDefaultCacheDirectory() {
63 File cache = hook.getDefaultCacheDirectory();
64 assertNotNull(cache);
65 if (PlatformManager.isPlatformOsx()) {
66 assertTrue(cache.toString().contains("/Library/"));
67 }
68 }
69
70 /**
71 * Test method for {@code PlatformHookOsx#getDefaultPrefDirectory}
72 */
73 @Test
74 void testGetDefaultPrefDirectory() {
75 File cache = hook.getDefaultPrefDirectory();
76 assertNotNull(cache);
77 if (PlatformManager.isPlatformOsx()) {
78 assertTrue(cache.toString().contains("/Library/"));
79 }
80 }
81
82 /**
83 * Test method for {@code PlatformHookOsx#getDefaultStyle}
84 */
85 @Test
86 void testGetDefaultStyle() {
87 assertEquals("com.apple.laf.AquaLookAndFeel", hook.getDefaultStyle());
88 }
89
90 /**
91 * Test method for {@code PlatformHookOsx#getOSDescription}
92 */
93 @Test
94 void testGetOSDescription() {
95 String os = hook.getOSDescription();
96 if (PlatformManager.isPlatformOsx()) {
97 assertTrue(os.contains("Mac"));
98 } else {
99 assertFalse(os.contains("Mac"));
100 }
101 }
102
103 /**
104 * Test method for {@code PlatformHookOsx#initSystemShortcuts}
105 */
106 @Test
107 void testInitSystemShortcuts() {
108 hook.initSystemShortcuts();
109 }
110}
Note: See TracBrowser for help on using the repository browser.