Path: blob/master/test/jdk/java/awt/FileDialog/SaveFileNameOverrideTest/SaveFileNameOverrideTest.java
41153 views
/*1* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24test25@bug 6998877 802253126@summary After double-click on the folder names, FileNameOverrideTest FAILED27@author [email protected] area=awt.filedialog28@library ../../regtesthelpers29@build Sysout30@run applet/manual=yesno SaveFileNameOverrideTest.html31*/3233import test.java.awt.regtesthelpers.Sysout;3435import java.applet.Applet;36import java.awt.*;37import java.awt.event.ActionEvent;38import java.awt.event.ActionListener;39import java.io.File;4041public class SaveFileNameOverrideTest extends Applet implements ActionListener {42private final static String clickDirName = "Directory for double click";43private final static String dirPath = ".";44private Button showBtn;45private FileDialog fd;4647public void init() {48this.setLayout(new GridLayout(1, 1));4950fd = new FileDialog(new Frame(), "Save", FileDialog.SAVE);5152showBtn = new Button("Show File Dialog");53showBtn.addActionListener(this);54add(showBtn);5556File tmpDir = new File(dirPath + File.separator + clickDirName);57tmpDir.mkdir();5859String[] instructions = {60"1) Click on 'Show File Dialog' button. A file dialog will come up.",61"2) Double-click on '" + clickDirName + "' and click a confirmation",62" button, it can be 'OK', 'Save' or any other platform-dependent name.",63"3) See result of the test below"64};6566Sysout.createDialogWithInstructions(instructions);6768}//End init()6970public void start() {71setSize(200, 200);72show();73}// start()7475public void actionPerformed(ActionEvent e) {76if (e.getSource() == showBtn) {77fd.setFile("input");78fd.setDirectory(dirPath);79fd.setVisible(true);80String output = fd.getFile();81if ("input".equals(output)) {82Sysout.println("TEST PASSED");83} else {84Sysout.println("TEST FAILED (output file - " + output + ")");85}86}87}88}// class ManualYesNoTest899091