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.spi.preferences.Config;
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * Unit tests of {@link PlatformHookOsx} class.
|
---|
19 | */
|
---|
20 | class 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 | (a, b, c) -> System.out.println("sanity check callback"));
|
---|
39 | }
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * Test method for {@code PlatformHookOsx#afterPrefStartupHook}
|
---|
43 | */
|
---|
44 | @Test
|
---|
45 | void testAfterPrefStartupHook() {
|
---|
46 | hook.afterPrefStartupHook();
|
---|
47 | }
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * Test method for {@code PlatformHookOsx#openUrl}
|
---|
51 | * @throws IOException if an error occurs
|
---|
52 | */
|
---|
53 | @Test
|
---|
54 | void testOpenUrl() throws IOException {
|
---|
55 | assumeTrue(PlatformManager.isPlatformOsx());
|
---|
56 | hook.openUrl(Config.getUrls().getJOSMWebsite());
|
---|
57 | }
|
---|
58 |
|
---|
59 | /**
|
---|
60 | * Test method for {@code PlatformHookOsx#getDefaultCacheDirectory}
|
---|
61 | */
|
---|
62 | @Test
|
---|
63 | void testGetDefaultCacheDirectory() {
|
---|
64 | File cache = hook.getDefaultCacheDirectory();
|
---|
65 | assertNotNull(cache);
|
---|
66 | if (PlatformManager.isPlatformOsx()) {
|
---|
67 | assertTrue(cache.toString().contains("/Library/"));
|
---|
68 | }
|
---|
69 | }
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * Test method for {@code PlatformHookOsx#getDefaultPrefDirectory}
|
---|
73 | */
|
---|
74 | @Test
|
---|
75 | void testGetDefaultPrefDirectory() {
|
---|
76 | File cache = hook.getDefaultPrefDirectory();
|
---|
77 | assertNotNull(cache);
|
---|
78 | if (PlatformManager.isPlatformOsx()) {
|
---|
79 | assertTrue(cache.toString().contains("/Library/"));
|
---|
80 | }
|
---|
81 | }
|
---|
82 |
|
---|
83 | /**
|
---|
84 | * Test method for {@code PlatformHookOsx#getDefaultStyle}
|
---|
85 | */
|
---|
86 | @Test
|
---|
87 | void testGetDefaultStyle() {
|
---|
88 | assertEquals("com.apple.laf.AquaLookAndFeel", hook.getDefaultStyle());
|
---|
89 | }
|
---|
90 |
|
---|
91 | /**
|
---|
92 | * Test method for {@code PlatformHookOsx#getOSDescription}
|
---|
93 | */
|
---|
94 | @Test
|
---|
95 | void testGetOSDescription() {
|
---|
96 | String os = hook.getOSDescription();
|
---|
97 | if (PlatformManager.isPlatformOsx()) {
|
---|
98 | assertTrue(os.contains("Mac"));
|
---|
99 | } else {
|
---|
100 | assertFalse(os.contains("Mac"));
|
---|
101 | }
|
---|
102 | }
|
---|
103 |
|
---|
104 | /**
|
---|
105 | * Test method for {@code PlatformHookOsx#initSystemShortcuts}
|
---|
106 | */
|
---|
107 | @Test
|
---|
108 | void testInitSystemShortcuts() {
|
---|
109 | hook.initSystemShortcuts();
|
---|
110 | }
|
---|
111 | }
|
---|