Skip to content

Commit

Permalink
8327838 Convert java/awt/FileDialog/MultipleMode/MultipleMode.html ap…
Browse files Browse the repository at this point in the history
…plet test to main
  • Loading branch information
azvegint committed Mar 11, 2024
1 parent 680ac2c commit d33c317
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 332 deletions.
113 changes: 113 additions & 0 deletions test/jdk/java/awt/FileDialog/MultipleMode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* Copyright (c) 2010, 2024, 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.BorderLayout;
import java.awt.Button;
import java.awt.Checkbox;
import java.awt.EventQueue;
import java.awt.FileDialog;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.TextArea;
import java.io.File;

/*
* @test
* @bug 6467204
* @summary Need to implement "extended" native FileDialog for JFileChooser
* @library /java/awt/regtesthelpers
* @build PassFailJFrame
* @run main/manual MultipleMode
*/

public class MultipleMode {

private static final String INSTRUCTIONS =
"""
1. Turn the 'multiple' checkbox off and press the 'open' button
2. Verify that the file dialog doesn't allow the multiple file selection
3. Select any file and close the file dialog
4. The results will be displayed, verify the results
5. Turn the 'multiple' checkbox on and press the 'open' button
6. Verify that the file dialog allows the multiple file selection
7. Select several files and close the file dialog
8. The results will be displayed, verify the results.
""";

public static void main(String[] args) throws Exception {

PassFailJFrame passFailJFrame = PassFailJFrame
.builder()
.title("MultipleMode test instructions")
.instructions(INSTRUCTIONS)
.rows(15)
.columns(40)
.build();

EventQueue.invokeAndWait(MultipleMode::init);

passFailJFrame.awaitAndCheck();
}

private static void init() {
Frame frame = new Frame("MultipleMode");
TextArea sysout = new TextArea("", 20, 80);
sysout.setEditable(false);

final Checkbox mode = new Checkbox("multiple", true);

Button open = new Button("open");
open.addActionListener(e -> {
FileDialog d = new FileDialog((Frame)null);
d.setMultipleMode(mode.getState());
d.setVisible(true);

// print the results
sysout.append("DIR:\n");
sysout.append(" %s\n".formatted(d.getDirectory()));
sysout.append("FILE:\n");
sysout.append(" %s\n".formatted(d.getFile()));
sysout.append("FILES:\n");
for (File f : d.getFiles()) {
sysout.append(" %s\n".formatted(f));
}
});

Panel panel = new Panel(new FlowLayout());
panel.add(mode);
panel.add(open);

frame.setLayout(new BorderLayout());
frame.add(panel, BorderLayout.NORTH);
frame.add(sysout, BorderLayout.CENTER);

frame.pack();

PassFailJFrame.addTestWindow(frame);
PassFailJFrame.positionTestWindow(frame,
PassFailJFrame.Position.HORIZONTAL);

frame.setVisible(true);
}
}
43 changes: 0 additions & 43 deletions test/jdk/java/awt/FileDialog/MultipleMode/MultipleMode.html

This file was deleted.

Loading

0 comments on commit d33c317

Please sign in to comment.