changeset 96:855f5d687f73 tip

JemmyFX: Update for embedded needs
author Stanislav Smirnov <stanislav.smirnov@oracle.com>
date Fri, 09 Nov 2012 16:45:09 +0400
parents 12daa64a9797
children
files tools/Jemmy/JemmyFX/src/org/jemmy/fx/NodeWrapper.java tools/Jemmy/JemmyFX/src/org/jemmy/fx/Root.java
diffstat 2 files changed, 26 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/tools/Jemmy/JemmyFX/src/org/jemmy/fx/NodeWrapper.java	Fri Oct 26 13:35:55 2012 +0400
+++ b/tools/Jemmy/JemmyFX/src/org/jemmy/fx/NodeWrapper.java	Fri Nov 09 16:45:09 2012 +0400
@@ -71,8 +71,11 @@
         OPERATORS.add(SeparatorWrap.class);
         OPERATORS.add(TitledPaneWrap.class);
         OPERATORS.add(AccordionWrap.class);
-        OPERATORS.add(WebViewWrap.class);
-        OPERATORS.add(WebNodeWrap.class);
+        //TODO this needs to be rewritten with the API either from profiles or jigsaw
+        if(Root.checkClassPresence("org.w3c.dom.Node")){
+            OPERATORS.add(WebViewWrap.class);
+            OPERATORS.add(WebNodeWrap.class);
+        }
     }
 
     /**
--- a/tools/Jemmy/JemmyFX/src/org/jemmy/fx/Root.java	Fri Oct 26 13:35:55 2012 +0400
+++ b/tools/Jemmy/JemmyFX/src/org/jemmy/fx/Root.java	Fri Nov 09 16:45:09 2012 +0400
@@ -41,7 +41,7 @@
 import org.jemmy.lookup.PlainLookup;
 
 /**
- * Root class for Java FX scene lookup. It also serves as an access point for 
+ * Root class for Java FX scene lookup. It also serves as an access point for
  * different environment settings.
  * @author shura
  */
@@ -51,16 +51,16 @@
      * The root.
      */
     public static final Root ROOT = new Root();
-    
+
     /**
-     * @deprecated 
+     * @deprecated
      */
     public static final String LOOKUP_STRING_COMPARISON = Root.class.getName()
             + ".lookup.string.compare";
     private Environment env;
     private SceneWrapper wrapper;
     private SceneList scenes;
-    
+
     /**
      * Use Glass robot for user input simulation.
      * @param env
@@ -73,6 +73,21 @@
     }
 
     /**
+     * @param className - name of the class to lookup
+     * @return true if class is presented otherwise false
+     */
+    public static boolean checkClassPresence(String className){
+        boolean result = true;
+        try {
+            Class.forName(className);
+        } catch (ClassNotFoundException ex) {
+            result = false;
+        } finally {
+            return result;
+        }
+    }
+
+    /**
      * Use AWT robot for user input simulation.
      * @param env
      */
@@ -87,7 +102,8 @@
         this.env = new Environment(Environment.getEnvironment());
         this.env.setPropertyIfNotSet(RasterComparator.class, new PixelEqualityRasterComparator(0));
         String osName = System.getProperty("os.name").toLowerCase();
-        if(osName.contains("nux") || osName.contains("nix") || osName.contains("sunos") ||  osName.contains("mac os")) {
+        //TODO this needs to be rewritten with the API either from profiles or jigsaw
+        if( ( osName.contains("nux") || osName.contains("nix") || osName.contains("sunos") ||  osName.contains("mac os") ) && checkClassPresence("java.awt.Component")) {
             useAWTRobot(env);
         } else {
             useGlassRobot(this.env);