提交 6aeac135 编写于 作者: S serb

6998877: After double-click on the folder names , FileNameOverrideTest FAILED

Reviewed-by: art, dcherepanov, anthony
上级 7e27df0c
...@@ -443,6 +443,8 @@ void gtk2_file_chooser_load() ...@@ -443,6 +443,8 @@ void gtk2_file_chooser_load()
"gtk_file_chooser_set_current_folder"); "gtk_file_chooser_set_current_folder");
fp_gtk_file_chooser_set_filename = dl_symbol( fp_gtk_file_chooser_set_filename = dl_symbol(
"gtk_file_chooser_set_filename"); "gtk_file_chooser_set_filename");
fp_gtk_file_chooser_set_current_name = dl_symbol(
"gtk_file_chooser_set_current_name");
fp_gtk_file_filter_add_custom = dl_symbol("gtk_file_filter_add_custom"); fp_gtk_file_filter_add_custom = dl_symbol("gtk_file_filter_add_custom");
fp_gtk_file_chooser_set_filter = dl_symbol("gtk_file_chooser_set_filter"); fp_gtk_file_chooser_set_filter = dl_symbol("gtk_file_chooser_set_filter");
fp_gtk_file_chooser_get_type = dl_symbol("gtk_file_chooser_get_type"); fp_gtk_file_chooser_get_type = dl_symbol("gtk_file_chooser_get_type");
......
...@@ -766,6 +766,8 @@ gboolean (*fp_gtk_file_chooser_set_current_folder)(GtkFileChooser *chooser, ...@@ -766,6 +766,8 @@ gboolean (*fp_gtk_file_chooser_set_current_folder)(GtkFileChooser *chooser,
const gchar *filename); const gchar *filename);
gboolean (*fp_gtk_file_chooser_set_filename)(GtkFileChooser *chooser, gboolean (*fp_gtk_file_chooser_set_filename)(GtkFileChooser *chooser,
const char *filename); const char *filename);
void (*fp_gtk_file_chooser_set_current_name)(GtkFileChooser *chooser,
const gchar *name);
void (*fp_gtk_file_filter_add_custom)(GtkFileFilter *filter, void (*fp_gtk_file_filter_add_custom)(GtkFileFilter *filter,
GtkFileFilterFlags needed, GtkFileFilterFunc func, gpointer data, GtkFileFilterFlags needed, GtkFileFilterFunc func, gpointer data,
GDestroyNotify notify); GDestroyNotify notify);
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <string.h> #include <string.h>
#include "gtk2_interface.h" #include "gtk2_interface.h"
#include "sun_awt_X11_GtkFileDialogPeer.h" #include "sun_awt_X11_GtkFileDialogPeer.h"
#include "java_awt_FileDialog.h"
#include "debug_assert.h" #include "debug_assert.h"
static JavaVM *jvm; static JavaVM *jvm;
...@@ -220,7 +221,7 @@ Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer, ...@@ -220,7 +221,7 @@ Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer,
const char *title = jtitle == NULL? "": (*env)->GetStringUTFChars(env, jtitle, 0); const char *title = jtitle == NULL? "": (*env)->GetStringUTFChars(env, jtitle, 0);
if (mode == 1) { if (mode == java_awt_FileDialog_SAVE) {
/* Save action */ /* Save action */
dialog = fp_gtk_file_chooser_dialog_new(title, NULL, dialog = fp_gtk_file_chooser_dialog_new(title, NULL,
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL,
...@@ -253,7 +254,11 @@ Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer, ...@@ -253,7 +254,11 @@ Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer,
/* Set the filename */ /* Set the filename */
if (jfile != NULL) { if (jfile != NULL) {
const char *filename = (*env)->GetStringUTFChars(env, jfile, 0); const char *filename = (*env)->GetStringUTFChars(env, jfile, 0);
fp_gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), filename); if (mode == java_awt_FileDialog_SAVE) {
fp_gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), filename);
} else {
fp_gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), filename);
}
(*env)->ReleaseStringUTFChars(env, jfile, filename); (*env)->ReleaseStringUTFChars(env, jfile, filename);
} }
......
<html>
<!--
@test
@bug 6260659
@summary File Name set programmatically in FileDialog is overridden during navigation, XToolkit
@author Dmitry.Cherepanov@SUN.COM area=awt.filedialog
@library ../../regtesthelpers
@build Sysout
@run applet/manual=yesno FileNameOverrideTest.html
-->
<head>
<title> FileNameOverrideTest </title>
</head>
<body>
<h1>FileNameOverrideTest<br>Bug ID: 6260659</h1>
<p> See the dialog box (usually in upper left corner) for instructions</p>
<APPLET CODE="FileNameOverrideTest.class" WIDTH=200 HEIGHT=200></APPLET>
</body>
</html>
/*
test
@bug 6260659
@summary File Name set programmatically in FileDialog is overridden during navigation, XToolkit
@author Dmitry.Cherepanov@SUN.COM area=awt.filedialog
@library ../../regtesthelpers
@build Sysout
@run applet/manual=yesno FileNameOverrideTest.html
*/
import test.java.awt.regtesthelpers.Sysout;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
public class FileNameOverrideTest extends Applet implements ActionListener {
private final static String fileName = "input";
private final static String clickDirName = "Directory for double click";
private final static String dirPath = ".";
private Button showBtn;
private FileDialog fd;
public void init() {
this.setLayout(new GridLayout(1, 1));
fd = new FileDialog(new Frame(), "Open");
showBtn = new Button("Show File Dialog");
showBtn.addActionListener(this);
add(showBtn);
try {
File tmpFileUp = new File(dirPath + File.separator + fileName);
File tmpDir = new File(dirPath + File.separator + clickDirName);
File tmpFileIn = new File(tmpDir.getAbsolutePath() + File.separator + fileName);
tmpDir.mkdir();
tmpFileUp.createNewFile();
tmpFileIn.createNewFile();
} catch (IOException ex) {
throw new RuntimeException("Cannot create test folder", ex);
}
String[] instructions = {
"1) Click on 'Show File Dialog' button. A file dialog will come up.",
"2) Double-click on '" + clickDirName + "' and click OK.",
"3) See result of the test below"
};
Sysout.createDialogWithInstructions(instructions);
}//End init()
public void start() {
setSize(200, 200);
show();
}// start()
public void actionPerformed(ActionEvent e) {
if (e.getSource() == showBtn) {
fd.setFile(fileName);
fd.setDirectory(dirPath);
fd.setVisible(true);
String output = fd.getFile();
if (fileName.equals(output)) {
Sysout.println("TEST PASSED");
} else {
Sysout.println("TEST FAILED (output file - " + output + ")");
}
}
}
}// class ManualYesNoTest
<html>
<!--
@test
@bug 6998877
@summary After double-click on the folder names, FileNameOverrideTest FAILED
@author Sergey.Bylokhov@oracle.com area=awt.filedialog
@library ../../regtesthelpers
@build Sysout
@run applet/manual=yesno SaveFileNameOverrideTest.html
-->
<head>
<title> SaveFileNameOverrideTest </title>
</head>
<body>
<h1>SaveFileNameOverrideTest<br>Bug ID: 6260659</h1>
<p> See the dialog box (usually in upper left corner) for instructions</p>
<APPLET CODE="SaveFileNameOverrideTest.class" WIDTH=200 HEIGHT=200></APPLET>
</body>
</html>
/*
test
@bug 6998877
@summary After double-click on the folder names, FileNameOverrideTest FAILED
@author Sergey.Bylokhov@oracle.com area=awt.filedialog
@library ../../regtesthelpers
@build Sysout
@run applet/manual=yesno SaveFileNameOverrideTest.html
*/
import test.java.awt.regtesthelpers.Sysout;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
public class SaveFileNameOverrideTest extends Applet implements ActionListener {
private final static String clickDirName = "Directory for double click";
private final static String dirPath = ".";
private Button showBtn;
private FileDialog fd;
public void init() {
this.setLayout(new GridLayout(1, 1));
fd = new FileDialog(new Frame(), "Save", FileDialog.SAVE);
showBtn = new Button("Show File Dialog");
showBtn.addActionListener(this);
add(showBtn);
File tmpDir = new File(dirPath + File.separator + clickDirName);
tmpDir.mkdir();
String[] instructions = {
"1) Click on 'Show File Dialog' button. A file dialog will come up.",
"2) Double-click on '" + clickDirName + "' and click OK.",
"3) See result of the test below"
};
Sysout.createDialogWithInstructions(instructions);
}//End init()
public void start() {
setSize(200, 200);
show();
}// start()
public void actionPerformed(ActionEvent e) {
if (e.getSource() == showBtn) {
fd.setFile("input");
fd.setDirectory(dirPath);
fd.setVisible(true);
String output = fd.getFile();
if ("input".equals(output)) {
Sysout.println("TEST PASSED");
} else {
Sysout.println("TEST FAILED (output file - " + output + ")");
}
}
}
}// class ManualYesNoTest
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册