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

Last change on this file since 10956 was 10378, checked in by Don-vip, 8 years ago

Checkstyle 6.19: enable SingleSpaceSeparator and fix violations

  • Property svn:eol-style set to native
File size: 3.7 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;
17
18/**
19 * Unit tests of {@link PlatformHookOsx} class.
20 */
21public 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();
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 if (!Main.isPlatformWindows()) {
66 hook.openUrl(Main.getJOSMWebsite());
67 } else {
68 try {
69 hook.openUrl(Main.getJOSMWebsite());
70 fail("Expected IOException");
71 } catch (IOException e) {
72 Main.info(e.getMessage());
73 }
74 }
75 }
76
77 /**
78 * Test method for {@code PlatformHookOsx#getAdditionalFonts}
79 */
80 @Test(expected = UnsupportedOperationException.class)
81 public void testGetAdditionalFonts() {
82 hook.getAdditionalFonts();
83 }
84
85 /**
86 * Test method for {@code PlatformHookOsx#getDefaultCacheDirectory}
87 */
88 @Test
89 public void testGetDefaultCacheDirectory() {
90 File cache = hook.getDefaultCacheDirectory();
91 assertNotNull(cache);
92 if (Main.isPlatformOsx()) {
93 assertTrue(cache.toString().contains("/Library/"));
94 }
95 }
96
97 /**
98 * Test method for {@code PlatformHookOsx#getDefaultPrefDirectory}
99 */
100 @Test
101 public void testGetDefaultPrefDirectory() {
102 File cache = hook.getDefaultPrefDirectory();
103 assertNotNull(cache);
104 if (Main.isPlatformOsx()) {
105 assertTrue(cache.toString().contains("/Library/"));
106 }
107 }
108
109 /**
110 * Test method for {@code PlatformHookOsx#getDefaultStyle}
111 */
112 @Test
113 public void testGetDefaultStyle() {
114 assertEquals("com.apple.laf.AquaLookAndFeel", hook.getDefaultStyle());
115 }
116
117 /**
118 * Test method for {@code PlatformHookOsx#getInstalledFonts}
119 */
120 @Test(expected = UnsupportedOperationException.class)
121 public void testGetInstalledFonts() {
122 hook.getInstalledFonts();
123 }
124
125 /**
126 * Test method for {@code PlatformHookOsx#getOSDescription}
127 */
128 @Test
129 public void testGetOSDescription() {
130 String os = hook.getOSDescription();
131 if (Main.isPlatformOsx()) {
132 assertTrue(os.contains("Mac"));
133 } else {
134 assertFalse(os.contains("Mac"));
135 }
136 }
137
138 /**
139 * Test method for {@code PlatformHookOsx#initSystemShortcuts}
140 */
141 @Test
142 public void testInitSystemShortcuts() {
143 hook.initSystemShortcuts();
144 }
145}
Note: See TracBrowser for help on using the repository browser.