1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.tools;
|
---|
3 |
|
---|
4 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
---|
5 | import static org.junit.jupiter.api.Assertions.assertFalse;
|
---|
6 | import static org.junit.jupiter.api.Assertions.assertNotNull;
|
---|
7 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
---|
8 | import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
---|
9 |
|
---|
10 | import java.io.File;
|
---|
11 | import java.io.IOException;
|
---|
12 |
|
---|
13 | import org.junit.jupiter.api.BeforeAll;
|
---|
14 | import org.junit.jupiter.api.Test;
|
---|
15 | import org.openstreetmap.josm.JOSMFixture;
|
---|
16 | import org.openstreetmap.josm.spi.preferences.Config;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Unit tests of {@link PlatformHookOsx} class.
|
---|
20 | */
|
---|
21 | class 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 | }
|
---|