--- /dev/null 2014-07-31 16:13:19.122792434 +0400 +++ new/test/java/awt/reliability/TaskXEmbedMemory.java 2014-07-31 17:27:59.238614881 +0400 @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Testcase to check if there is any memory leak when components are + * added and then removed from an embedded AWT Frame in an SWT shell. + * @author Girish R (girish.ramachandran@sun.com), AWT-SQE + * @library ../../../lib/testlibrary + * @build ExtendedRobot + * @run shell TaskXEmbedMemory.sh + */ + +public class TaskXEmbedMemory extends Task { + + Panel panel; + Button button; + Canvas canvas; + Checkbox checkbox; + Choice choice; + Container container; + Label label; + List list; + Scrollbar scrollbar; + TextArea textarea; + TextField textfield; + + public static void main (String[] args) throws Exception { + new TaskXEmbedMemory(GUIXEmbedMemory.class, new ExtendedRobot()).runTask(); + System.exit(0); + } + + public TaskXEmbedMemory(Class guiClass, ExtendedRobot robot) throws Exception { + super(guiClass, robot); + } + + /** + * Simple test. All components and remove them. Check if there's memory leak. + * Took the test from Frame test. + */ + public void task() throws Exception { + robot.glide(100, 100, 200, 110); + robot.waitForIdle(); + robot.click(); + + EventQueue.invokeAndWait(() -> { + panel = new Panel(); + + container = new Container(); + container.setLayout(new FlowLayout()); + + button = new Button("Button"); + canvas = new Canvas(); + checkbox = new Checkbox("CheckBox"); + choice = new Choice(); + choice.add("Choice 1"); + choice.add("Choice 2"); + choice.add("Choice 3"); + choice.add("Choice 4"); + + label = new Label("Label"); + list = new List(2); + list.add("list 1"); + list.add("list 2"); + list.add("list 3"); + scrollbar = new Scrollbar(); + + textarea = new TextArea("TextArea", 3, 10); + textfield = new TextField("TextField"); + + container.add(button); + container.add(canvas); + container.add(checkbox); + container.add(choice); + container.add(label); + container.add(list); + container.add(scrollbar); + container.add(textarea); + container.add(textfield); + + panel.add(container); + gui.frame.add(panel); + }); + robot.waitForIdle(1000); + + EventQueue.invokeAndWait(gui.frame::removeAll); + robot.waitForIdle(1000); + + gui.destroyProcess(); + EventQueue.invokeAndWait(gui::dispose); + } +} +