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

Last change on this file since 14119 was 14119, checked in by Don-vip, 6 years ago

see #15229 - deprecate all Main methods returning an URL

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