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

Last change on this file since 17360 was 17275, checked in by Don-vip, 3 years ago

see #16567 - upgrade almost all tests to JUnit 5, except those depending on WiremockRule

See https://github.com/tomakehurst/wiremock/issues/684

  • 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.JOSMFixture;
16import org.openstreetmap.josm.spi.preferences.Config;
17
18/**
19 * Unit tests of {@link PlatformHookOsx} class.
20 */
21class PlatformHookOsxTest {
22
23 static PlatformHookOsx hook;
24
25 /**
26 * Setup test.
27 */
28 @BeforeAll
29 public static void setUp() {
30 JOSMFixture.createUnitTestFixture().init();
31 hook = new PlatformHookOsx();
32 }
33
34 /**
35 * Test method for {@code PlatformHookOsx#startupHook}
36 */
37 @Test
38 void testStartupHook() {
39 hook.startupHook((a, b, c, d) -> System.out.println("callback"));
40 }
41
42 /**
43 * Test method for {@code PlatformHookOsx#afterPrefStartupHook}
44 */
45 @Test
46 void testAfterPrefStartupHook() {
47 hook.afterPrefStartupHook();
48 }
49
50 /**
51 * Test method for {@code PlatformHookOsx#openUrl}
52 * @throws IOException if an error occurs
53 */
54 @Test
55 void testOpenUrl() throws IOException {
56 assumeTrue(PlatformManager.isPlatformOsx());
57 hook.openUrl(Config.getUrls().getJOSMWebsite());
58 }
59
60 /**
61 * Test method for {@code PlatformHookOsx#getDefaultCacheDirectory}
62 */
63 @Test
64 void testGetDefaultCacheDirectory() {
65 File cache = hook.getDefaultCacheDirectory();
66 assertNotNull(cache);
67 if (PlatformManager.isPlatformOsx()) {
68 assertTrue(cache.toString().contains("/Library/"));
69 }
70 }
71
72 /**
73 * Test method for {@code PlatformHookOsx#getDefaultPrefDirectory}
74 */
75 @Test
76 void testGetDefaultPrefDirectory() {
77 File cache = hook.getDefaultPrefDirectory();
78 assertNotNull(cache);
79 if (PlatformManager.isPlatformOsx()) {
80 assertTrue(cache.toString().contains("/Library/"));
81 }
82 }
83
84 /**
85 * Test method for {@code PlatformHookOsx#getDefaultStyle}
86 */
87 @Test
88 void testGetDefaultStyle() {
89 assertEquals("com.apple.laf.AquaLookAndFeel", hook.getDefaultStyle());
90 }
91
92 /**
93 * Test method for {@code PlatformHookOsx#getOSDescription}
94 */
95 @Test
96 void testGetOSDescription() {
97 String os = hook.getOSDescription();
98 if (PlatformManager.isPlatformOsx()) {
99 assertTrue(os.contains("Mac"));
100 } else {
101 assertFalse(os.contains("Mac"));
102 }
103 }
104
105 /**
106 * Test method for {@code PlatformHookOsx#initSystemShortcuts}
107 */
108 @Test
109 void testInitSystemShortcuts() {
110 hook.initSystemShortcuts();
111 }
112}
Note: See TracBrowser for help on using the repository browser.