test/jdk/sanity/client/SwingSet/src/FileChooserDemoTest.java
changeset 54241 3c369ad8c4ac
parent 52753 b5c564a1367c
equal deleted inserted replaced
54240:5294813fe931 54241:3c369ad8c4ac
     1 /*
     1 /*
     2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    59 import org.netbeans.jemmy.operators.JToggleButtonOperator;
    59 import org.netbeans.jemmy.operators.JToggleButtonOperator;
    60 import org.netbeans.jemmy.operators.JFileChooserOperator;
    60 import org.netbeans.jemmy.operators.JFileChooserOperator;
    61 import org.netbeans.jemmy.operators.JDialogOperator;
    61 import org.netbeans.jemmy.operators.JDialogOperator;
    62 import org.netbeans.jemmy.operators.JComponentOperator.JComponentByTipFinder;
    62 import org.netbeans.jemmy.operators.JComponentOperator.JComponentByTipFinder;
    63 import org.netbeans.jemmy.util.Platform;
    63 import org.netbeans.jemmy.util.Platform;
       
    64 import org.netbeans.jemmy.util.LookAndFeel;
    64 import org.testng.annotations.BeforeTest;
    65 import org.testng.annotations.BeforeTest;
    65 import org.testng.annotations.Listeners;
    66 import org.testng.annotations.Listeners;
    66 import org.jemmy2ext.JemmyExt.ByToolTipChooser;
    67 import org.jemmy2ext.JemmyExt.ByToolTipChooser;
    67 
    68 
    68 /*
    69 /*
   139     private void checkSelectImage() throws Exception {
   140     private void checkSelectImage() throws Exception {
   140         selectImageButton.push();
   141         selectImageButton.push();
   141         fileChooser = new JFileChooserOperator(JFileChooserOperator.findJFileChooser((Container) frame.getSource()));
   142         fileChooser = new JFileChooserOperator(JFileChooserOperator.findJFileChooser((Container) frame.getSource()));
   142         // In Aqua, GTK and Motif L&Fs, JFileChooser does not have
   143         // In Aqua, GTK and Motif L&Fs, JFileChooser does not have
   143         // "Go Home", "Up One Level", "Get Details", "Get List" buttons.
   144         // "Go Home", "Up One Level", "Get Details", "Get List" buttons.
   144         if (!UIManager.getLookAndFeel().getID().equals("Aqua")
   145         if (!LookAndFeel.isAqua() && !LookAndFeel.isMotif() && !LookAndFeel.isGTK()) {
   145                 && !UIManager.getLookAndFeel().getID().equals("Motif")
       
   146                 && !UIManager.getLookAndFeel().getID().equals("GTK")) {
       
   147             File previousDirectory = fileChooser.getCurrentDirectory();
   146             File previousDirectory = fileChooser.getCurrentDirectory();
   148             fileChooser.goHome();
   147             fileChooser.goHome();
   149             // In Windows, pressing goHome navigates to Desktop inside the home directory.
   148             // In Windows, pressing goHome navigates to Desktop inside the home directory.
   150             // This is the expected behavior for windows.
   149             // This is the expected behavior for windows.
   151             if (!Platform.isWindows()) {
   150             if (!Platform.isWindows()) {
   155             }
   154             }
   156             fileChooser.setCurrentDirectory(previousDirectory);
   155             fileChooser.setCurrentDirectory(previousDirectory);
   157             fileChooser.rescanCurrentDirectory();
   156             fileChooser.rescanCurrentDirectory();
   158             // In Windows and Windows Classic L&F, List and Details views are
   157             // In Windows and Windows Classic L&F, List and Details views are
   159             // implemented as a popup menu item
   158             // implemented as a popup menu item
   160             if(UIManager.getLookAndFeel().getID().equals("Windows")) {
   159             if(LookAndFeel.isWindows() || LookAndFeel.isWindowsClassic()) {
   161                 JButtonOperator popupButton = new JButtonOperator(fileChooser, new JComponentByTipFinder(
   160                 JButtonOperator popupButton = new JButtonOperator(fileChooser, new JComponentByTipFinder(
   162                         UIManager.getString("FileChooser.viewMenuButtonToolTipText", fileChooser.getLocale())));
   161                         UIManager.getString("FileChooser.viewMenuButtonToolTipText", fileChooser.getLocale())));
   163                 popupButton.push();
   162                 popupButton.push();
   164                 JPopupMenuOperator popup = new JPopupMenuOperator();
   163                 JPopupMenuOperator popup = new JPopupMenuOperator();
   165                 popup.pushKey(KeyEvent.VK_ENTER);
   164                 popup.pushKey(KeyEvent.VK_ENTER);
   272     private void initializeSelectWithPreviewDialog() {
   271     private void initializeSelectWithPreviewDialog() {
   273         fileChooser = new JFileChooserOperator();
   272         fileChooser = new JFileChooserOperator();
   274         fileChooserDialog = new JDialogOperator(OPEN);
   273         fileChooserDialog = new JDialogOperator(OPEN);
   275         String openButtonText = OPEN;
   274         String openButtonText = OPEN;
   276         // In GTK and Motif L&F, open button text is 'OK'
   275         // In GTK and Motif L&F, open button text is 'OK'
   277         if (UIManager.getLookAndFeel().getID().equals("Motif")
   276         if (LookAndFeel.isMotif() || LookAndFeel.isGTK()) {
   278                 || UIManager.getLookAndFeel().getID().equals("GTK")) {
       
   279             openButtonText = OK;
   277             openButtonText = OK;
   280         }
   278         }
   281         openButton = new JButtonOperator(fileChooser, openButtonText);
   279         openButton = new JButtonOperator(fileChooser, openButtonText);
   282         cancelButton = new JButtonOperator(fileChooser, CANCEL);
   280         cancelButton = new JButtonOperator(fileChooser, CANCEL);
   283     }
   281     }