6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.javafx.application;
27
28 import java.util.concurrent.CountDownLatch;
29 import java.util.concurrent.TimeUnit;
30 import javafx.application.Platform;
31 import junit.framework.AssertionFailedError;
32
33 import static org.junit.Assert.*;
34 import static util.Util.TIMEOUT;
35
36
37 /**
38 * Test program for PlatformImpl
39 * Each of the tests must be run in a separate JVM which is why each
40 * is in its own subclass.
41 */
42 public class TaskbarAppCommon {
43
44 // Used to launch the platform before running any test
45 private final CountDownLatch launchLatch = new CountDownLatch(1);
46
47 private void startup() {
48 // Start the FX Platform
49 new Thread(() -> PlatformImpl.startup(() -> {
50 assertTrue(Platform.isFxApplicationThread());
51 launchLatch.countDown();
52 })).start();
53
54 try {
55 if (!launchLatch.await(TIMEOUT, TimeUnit.MILLISECONDS)) {
56 throw new AssertionFailedError("Timeout waiting for Platform to start");
57 }
58 } catch (InterruptedException ex) {
59 AssertionFailedError err = new AssertionFailedError("Unexpected exception");
60 err.initCause(ex);
61 throw err;
62 }
63 assertEquals(0, launchLatch.getCount());
64 final CountDownLatch exitLatch = PlatformImpl.test_getPlatformExitLatch();
65 assertEquals(1, exitLatch.getCount());
66 }
67
68 // ========================== TEST CASES ==========================
69
70 public void doTestTaskbarAppDefault() {
71 assertTrue(PlatformImpl.isTaskbarApplication());
72 }
73
74 public void doTestTaskbarAppSetGet() {
75 PlatformImpl.setTaskbarApplication(false);
76 assertFalse(PlatformImpl.isTaskbarApplication());
77 PlatformImpl.setTaskbarApplication(true);
78 assertTrue(PlatformImpl.isTaskbarApplication());
79 }
80
81 public void doTestTaskbarAppStartDefault() {
82 assertTrue(PlatformImpl.isTaskbarApplication());
83 String taskbarAppProp = System.getProperty("glass.taskbarApplication");
84 assertNull(taskbarAppProp);
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package test.com.sun.javafx.application;
27
28 import com.sun.javafx.application.PlatformImpl;
29 import com.sun.javafx.application.PlatformImplShim;
30 import java.util.concurrent.CountDownLatch;
31 import java.util.concurrent.TimeUnit;
32 import javafx.application.Platform;
33 import junit.framework.AssertionFailedError;
34
35 import static org.junit.Assert.*;
36 import static test.util.Util.TIMEOUT;
37
38
39 /**
40 * Test program for PlatformImpl
41 * Each of the tests must be run in a separate JVM which is why each
42 * is in its own subclass.
43 */
44 public class TaskbarAppCommon {
45
46 // Used to launch the platform before running any test
47 private final CountDownLatch launchLatch = new CountDownLatch(1);
48
49 private void startup() {
50 // Start the FX Platform
51 new Thread(() -> PlatformImpl.startup(() -> {
52 assertTrue(Platform.isFxApplicationThread());
53 launchLatch.countDown();
54 })).start();
55
56 try {
57 if (!launchLatch.await(TIMEOUT, TimeUnit.MILLISECONDS)) {
58 throw new AssertionFailedError("Timeout waiting for Platform to start");
59 }
60 } catch (InterruptedException ex) {
61 AssertionFailedError err = new AssertionFailedError("Unexpected exception");
62 err.initCause(ex);
63 throw err;
64 }
65 assertEquals(0, launchLatch.getCount());
66 final CountDownLatch exitLatch = PlatformImplShim.test_getPlatformExitLatch();
67 assertEquals(1, exitLatch.getCount());
68 }
69
70 // ========================== TEST CASES ==========================
71
72 public void doTestTaskbarAppDefault() {
73 assertTrue(PlatformImpl.isTaskbarApplication());
74 }
75
76 public void doTestTaskbarAppSetGet() {
77 PlatformImpl.setTaskbarApplication(false);
78 assertFalse(PlatformImpl.isTaskbarApplication());
79 PlatformImpl.setTaskbarApplication(true);
80 assertTrue(PlatformImpl.isTaskbarApplication());
81 }
82
83 public void doTestTaskbarAppStartDefault() {
84 assertTrue(PlatformImpl.isTaskbarApplication());
85 String taskbarAppProp = System.getProperty("glass.taskbarApplication");
86 assertNull(taskbarAppProp);
|