changeset 3940:58729a928069

6998877: After double-click on the folder names , FileNameOverrideTest FAILED Reviewed-by: art, dcherepanov, anthony
author serb
date Tue, 05 Apr 2011 16:50:11 +0400
parents 8859d18cb3aa
children 0f8b6b1aad7d
files src/solaris/native/sun/awt/gtk2_interface.c src/solaris/native/sun/awt/gtk2_interface.h src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c test/java/awt/FileDialog/FileNameOverrideTest/FileNameOverrideTest.html test/java/awt/FileDialog/FileNameOverrideTest/FileNameOverrideTest.java test/java/awt/FileDialog/SaveFileNameOverrideTest/SaveFileNameOverrideTest.html test/java/awt/FileDialog/SaveFileNameOverrideTest/SaveFileNameOverrideTest.java
diffstat 7 files changed, 193 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/native/sun/awt/gtk2_interface.c	Mon Apr 04 23:01:24 2011 +0400
+++ b/src/solaris/native/sun/awt/gtk2_interface.c	Tue Apr 05 16:50:11 2011 +0400
@@ -443,6 +443,8 @@
             "gtk_file_chooser_set_current_folder");
     fp_gtk_file_chooser_set_filename = dl_symbol(
             "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_chooser_set_filter = dl_symbol("gtk_file_chooser_set_filter");
     fp_gtk_file_chooser_get_type = dl_symbol("gtk_file_chooser_get_type");
--- a/src/solaris/native/sun/awt/gtk2_interface.h	Mon Apr 04 23:01:24 2011 +0400
+++ b/src/solaris/native/sun/awt/gtk2_interface.h	Tue Apr 05 16:50:11 2011 +0400
@@ -766,6 +766,8 @@
     const gchar *filename);
 gboolean (*fp_gtk_file_chooser_set_filename)(GtkFileChooser *chooser,
     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,
     GtkFileFilterFlags needed, GtkFileFilterFunc func, gpointer data,
     GDestroyNotify notify);
--- a/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c	Mon Apr 04 23:01:24 2011 +0400
+++ b/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c	Tue Apr 05 16:50:11 2011 +0400
@@ -4,6 +4,7 @@
 #include <string.h>
 #include "gtk2_interface.h"
 #include "sun_awt_X11_GtkFileDialogPeer.h"
+#include "java_awt_FileDialog.h"
 #include "debug_assert.h"
 
 static JavaVM *jvm;
@@ -220,7 +221,7 @@
 
     const char *title = jtitle == NULL? "": (*env)->GetStringUTFChars(env, jtitle, 0);
 
-    if (mode == 1) {
+    if (mode == java_awt_FileDialog_SAVE) {
         /* Save action */
         dialog = fp_gtk_file_chooser_dialog_new(title, NULL,
                 GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL,
@@ -253,7 +254,11 @@
     /* Set the filename */
     if (jfile != NULL) {
         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);
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/FileDialog/FileNameOverrideTest/FileNameOverrideTest.html	Tue Apr 05 16:50:11 2011 +0400
@@ -0,0 +1,22 @@
+<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>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/FileDialog/FileNameOverrideTest/FileNameOverrideTest.java	Tue Apr 05 16:50:11 2011 +0400
@@ -0,0 +1,73 @@
+/*
+  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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/FileDialog/SaveFileNameOverrideTest/SaveFileNameOverrideTest.html	Tue Apr 05 16:50:11 2011 +0400
@@ -0,0 +1,22 @@
+<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>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/FileDialog/SaveFileNameOverrideTest/SaveFileNameOverrideTest.java	Tue Apr 05 16:50:11 2011 +0400
@@ -0,0 +1,65 @@
+/*
+  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