1970N/A/*
3261N/A * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
1970N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1970N/A *
1970N/A * This code is free software; you can redistribute it and/or modify it
1970N/A * under the terms of the GNU General Public License version 2 only, as
1970N/A * published by the Free Software Foundation.
1970N/A *
1970N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1970N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1970N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1970N/A * version 2 for more details (a copy is included in the LICENSE file that
1970N/A * accompanied this code).
1970N/A *
1970N/A * You should have received a copy of the GNU General Public License version
1970N/A * 2 along with this work; if not, write to the Free Software Foundation,
1970N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1970N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
1970N/A */
1970N/A
1970N/A/*
1970N/A @test
1970N/A @bug 4913324
1970N/A @author Oleg Sukhodolsky: area=eventqueue
1970N/A @run main/timeout=30 PushPopTest
1970N/A*/
1970N/A
1970N/Aimport java.awt.*;
1970N/Aimport java.awt.event.*;
1970N/Aimport java.util.EmptyStackException;
1970N/Aimport sun.awt.SunToolkit;
1970N/A
1970N/Apublic class PushPopTest {
1970N/A
1970N/A public static Frame frame;
1970N/A public static void main(String[] args) {
1970N/A frame = new Frame("");
1970N/A frame.pack();
1970N/A
1970N/A Runnable dummy = new Runnable() {
1970N/A public void run() {
1970N/A System.err.println("Dummy is here.");
2518N/A System.err.flush();
1970N/A }
1970N/A };
1970N/A EventQueue seq = Toolkit.getDefaultToolkit().getSystemEventQueue();
1970N/A MyEventQueue1 eq1 = new MyEventQueue1();
1970N/A MyEventQueue2 eq2 = new MyEventQueue2();
1970N/A EventQueue.invokeLater(dummy);
1970N/A
1970N/A seq.push(eq1);
1970N/A EventQueue.invokeLater(dummy);
1970N/A
1970N/A eq1.push(eq2);
1970N/A EventQueue.invokeLater(dummy);
1970N/A Runnable runnable = new Runnable() {
1970N/A public void run() {
1970N/A System.err.println("Dummy from SunToolkit");
2518N/A System.err.flush();
1970N/A }
1970N/A };
1970N/A InvocationEvent ie = new InvocationEvent(eq2, runnable, null, false);
2518N/A// System.err.println(ie);
1970N/A SunToolkit.postEvent(SunToolkit.targetToAppContext(frame), ie);
1970N/A eq1.pop();
1970N/A frame.dispose();
1970N/A }
1970N/A}
1970N/A
1970N/Aclass MyEventQueue1 extends EventQueue {
1970N/A
2518N/A public void pop() {
1970N/A super.pop();
1970N/A }
1970N/A}
1970N/A
1970N/Aclass MyEventQueue2 extends EventQueue {
1970N/A
2518N/A protected void pop() {
1970N/A System.err.println("pop2()");
1970N/A Thread.dumpStack();
1970N/A try {
1970N/A EventQueue.invokeAndWait(new Runnable() {
1970N/A public void run() {
1970N/A Runnable runnable = new Runnable() {
1970N/A public void run() {
2518N/A System.err.println("Dummy from pop");
2518N/A System.err.flush();
1970N/A }
1970N/A };
1970N/A InvocationEvent ie = new InvocationEvent(MyEventQueue2.this, runnable, null, false);
1970N/A SunToolkit.postEvent(SunToolkit.targetToAppContext(PushPopTest.frame), ie);
1970N/A postEvent(ie);
1970N/A }
1970N/A });
1970N/A } catch (InterruptedException ie) {
1970N/A ie.printStackTrace();
1970N/A } catch (java.lang.reflect.InvocationTargetException ie) {
1970N/A ie.printStackTrace();
1970N/A }
1970N/A super.pop();
1970N/A }
1970N/A}