1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.tools;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertEquals;
|
---|
5 | import static org.junit.Assert.assertFalse;
|
---|
6 | import static org.junit.Assert.assertNotNull;
|
---|
7 | import static org.junit.Assert.assertTrue;
|
---|
8 |
|
---|
9 | import java.io.File;
|
---|
10 | import java.io.IOException;
|
---|
11 |
|
---|
12 | import org.junit.Assume;
|
---|
13 | import org.junit.BeforeClass;
|
---|
14 | import org.junit.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 | public class PlatformHookOsxTest {
|
---|
22 |
|
---|
23 | static PlatformHookOsx hook;
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * Setup test.
|
---|
27 | */
|
---|
28 | @BeforeClass
|
---|
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 | public void testStartupHook() {
|
---|
39 | hook.startupHook((a, b, c, d) -> System.out.println("callback"));
|
---|
40 | }
|
---|
41 |
|
---|
42 | /**
|
---|
43 | * Test method for {@code PlatformHookOsx#setupHttpsCertificate}
|
---|
44 | * @throws Exception if an error occurs
|
---|
45 | */
|
---|
46 | @Test
|
---|
47 | public void testSetupHttpsCertificate() throws Exception {
|
---|
48 | assertFalse(hook.setupHttpsCertificate(null, null));
|
---|
49 | }
|
---|
50 |
|
---|
51 | /**
|
---|
52 | * Test method for {@code PlatformHookOsx#afterPrefStartupHook}
|
---|
53 | */
|
---|
54 | @Test
|
---|
55 | public void testAfterPrefStartupHook() {
|
---|
56 | hook.afterPrefStartupHook();
|
---|
57 | }
|
---|
58 |
|
---|
59 | /**
|
---|
60 | * Test method for {@code PlatformHookOsx#openUrl}
|
---|
61 | * @throws IOException if an error occurs
|
---|
62 | */
|
---|
63 | @Test
|
---|
64 | public void testOpenUrl() throws IOException {
|
---|
65 | Assume.assumeTrue(PlatformManager.isPlatformOsx());
|
---|
66 | hook.openUrl(Config.getUrls().getJOSMWebsite());
|
---|
67 | }
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * Test method for {@code PlatformHookOsx#getDefaultCacheDirectory}
|
---|
71 | */
|
---|
72 | @Test
|
---|
73 | public void testGetDefaultCacheDirectory() {
|
---|
74 | File cache = hook.getDefaultCacheDirectory();
|
---|
75 | assertNotNull(cache);
|
---|
76 | if (PlatformManager.isPlatformOsx()) {
|
---|
77 | assertTrue(cache.toString().contains("/Library/"));
|
---|
78 | }
|
---|
79 | }
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * Test method for {@code PlatformHookOsx#getDefaultPrefDirectory}
|
---|
83 | */
|
---|
84 | @Test
|
---|
85 | public void testGetDefaultPrefDirectory() {
|
---|
86 | File cache = hook.getDefaultPrefDirectory();
|
---|
87 | assertNotNull(cache);
|
---|
88 | if (PlatformManager.isPlatformOsx()) {
|
---|
89 | assertTrue(cache.toString().contains("/Library/"));
|
---|
90 | }
|
---|
91 | }
|
---|
92 |
|
---|
93 | /**
|
---|
94 | * Test method for {@code PlatformHookOsx#getDefaultStyle}
|
---|
95 | */
|
---|
96 | @Test
|
---|
97 | public void testGetDefaultStyle() {
|
---|
98 | assertEquals("com.apple.laf.AquaLookAndFeel", hook.getDefaultStyle());
|
---|
99 | }
|
---|
100 |
|
---|
101 | /**
|
---|
102 | * Test method for {@code PlatformHookOsx#getOSDescription}
|
---|
103 | */
|
---|
104 | @Test
|
---|
105 | public void testGetOSDescription() {
|
---|
106 | String os = hook.getOSDescription();
|
---|
107 | if (PlatformManager.isPlatformOsx()) {
|
---|
108 | assertTrue(os.contains("Mac"));
|
---|
109 | } else {
|
---|
110 | assertFalse(os.contains("Mac"));
|
---|
111 | }
|
---|
112 | }
|
---|
113 |
|
---|
114 | /**
|
---|
115 | * Test method for {@code PlatformHookOsx#initSystemShortcuts}
|
---|
116 | */
|
---|
117 | @Test
|
---|
118 | public void testInitSystemShortcuts() {
|
---|
119 | hook.initSystemShortcuts();
|
---|
120 | }
|
---|
121 | }
|
---|