/** * Gets the browser name * * @return */ public String getBrowserName() { if (se.currentBrowser() == Browsers.HtmlUnit) return "HtmlUnit"; else { Capabilities browserCapabilities = ((RemoteWebDriver) se.driver()).getCapabilities(); return browserCapabilities.getBrowserName(); } }
protected static X11GLXGraphicsConfiguration chooseGraphicsConfigurationStatic( Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) { if (absScreen == null) { throw new IllegalArgumentException("AbstractGraphicsScreen is null"); } if (!(absScreen instanceof X11GraphicsScreen)) { throw new IllegalArgumentException("Only X11GraphicsScreen are allowed here"); } X11GraphicsScreen x11Screen = (X11GraphicsScreen) absScreen; if (capabilities != null && !(capabilities instanceof GLCapabilities)) { throw new IllegalArgumentException( "This NativeWindowFactory accepts only GLCapabilities objects"); } if (chooser != null && !(chooser instanceof GLCapabilitiesChooser)) { throw new IllegalArgumentException( "This NativeWindowFactory accepts only GLCapabilitiesChooser objects"); } if (capabilities == null) { capabilities = new GLCapabilities(null); } boolean onscreen = capabilities.isOnscreen(); boolean usePBuffer = ((GLCapabilities) capabilities).isPBuffer(); GLCapabilities caps2 = (GLCapabilities) capabilities.clone(); if (!caps2.isOnscreen()) { // OFFSCREEN !DOUBLE_BUFFER // FIXME DBLBUFOFFSCRN caps2.setDoubleBuffered(false); } X11GLXGraphicsConfiguration res; res = chooseGraphicsConfigurationFBConfig( (GLCapabilities) caps2, (GLCapabilitiesChooser) chooser, x11Screen); if (null == res) { if (usePBuffer) { throw new GLException( "Error: Couldn't create X11GLXGraphicsConfiguration based on FBConfig"); } res = chooseGraphicsConfigurationXVisual( (GLCapabilities) caps2, (GLCapabilitiesChooser) chooser, x11Screen); } if (null == res) { throw new GLException("Error: Couldn't create X11GLXGraphicsConfiguration"); } if (DEBUG) { System.err.println( "X11GLXGraphicsConfiguration.chooseGraphicsConfigurationStatic(" + x11Screen + "," + caps2 + "): " + res); } return res; }
private boolean isCapableOfHandlingAlerts(WebDriver driver) { if (!(driver instanceof HasCapabilities)) { return false; } Capabilities capabilities = ((HasCapabilities) driver).getCapabilities(); return capabilities.is(SUPPORTS_ALERTS); }
public static Capabilities create(boolean withChilds) { Capabilities xml = new Capabilities(); if (withChilds) { xml.getCapability().add(TestXmlCapability.create(false)); xml.getCapability().add(TestXmlCapability.create(false)); } return xml; }
public boolean isMobileDevice() { Capabilities browserCapabilities = ((RemoteWebDriver) se.driver()).getCapabilities(); String browserName = browserCapabilities.getBrowserName(); Platform platform = browserCapabilities.getPlatform(); if (browserName.equals("android") && platform.equals(Platform.ANDROID)) return true; else if ((browserName.equals("iOS") || browserName.equals("iPhone")) && platform.equals(Platform.MAC)) return true; else return false; }
protected static AVList wmsGetParamsFromCapsDoc(Capabilities caps, AVList params) { if (caps == null) { String message = Logging.getMessage("nullValue.WMSCapabilities"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } if (params == null) { String message = Logging.getMessage("nullValue.LayerConfigParams"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } try { DataConfigurationUtils.getWMSLayerParams(caps, formatOrderPreference, params); } catch (IllegalArgumentException e) { String message = Logging.getMessage("WMS.MissingLayerParameters"); Logging.logger().log(java.util.logging.Level.SEVERE, message, e); throw new IllegalArgumentException(message, e); } catch (WWRuntimeException e) { String message = Logging.getMessage("WMS.MissingCapabilityValues"); Logging.logger().log(java.util.logging.Level.SEVERE, message, e); throw new IllegalArgumentException(message, e); } setFallbacks(params); // Setup WMS URL builder. params.setValue(AVKey.WMS_VERSION, caps.getVersion()); params.setValue(AVKey.TILE_URL_BUILDER, new URLBuilder(params)); // Setup default WMS tiled image layer behaviors. params.setValue(AVKey.USE_TRANSPARENT_TEXTURES, true); return params; }
protected static Element getConfigElement(Capabilities capabilities) { if (capabilities == null) { String message = Logging.getMessage("nullValue.CapabilitiesIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } return capabilities.getDocument().getDocumentElement(); }
static Window createWindow( final Capabilities caps, final int x, final int y, final int width, final int height, final boolean onscreen, final boolean undecorated) throws InterruptedException { final boolean userPos = x >= 0 && y >= 0; // user has specified a position Assert.assertNotNull(caps); caps.setOnscreen(onscreen); // System.out.println("Requested: "+caps); // // Create native windowing resources .. X11/Win/OSX // final Window window = NewtFactory.createWindow(caps); Assert.assertNotNull(window); final Screen screen = window.getScreen(); final Display display = screen.getDisplay(); window.setUndecorated(onscreen && undecorated); if (userPos) { window.setPosition(x, y); } window.setSize(width, height); Assert.assertEquals(false, window.isNativeValid()); Assert.assertEquals(false, window.isVisible()); window.setVisible(true); // System.err.println("************* Created: "+window); Assert.assertEquals(true, display.isNativeValid()); Assert.assertEquals(true, screen.isNativeValid()); Assert.assertEquals(true, window.isVisible()); Assert.assertEquals(true, window.isNativeValid()); Assert.assertEquals(width, window.getWidth()); Assert.assertEquals(height, window.getHeight()); /** * we don't sync on position - unreliable test Point p0 = window.getLocationOnScreen(null); * Assert.assertEquals(p0.getX(), window.getX()); Assert.assertEquals(p0.getY(), window.getY()); * if(userPos) { Assert.assertEquals(x, window.getX()); Assert.assertEquals(y, window.getY()); } */ final CapabilitiesImmutable chosenCapabilities = window.getGraphicsConfiguration().getChosenCapabilities(); Assert.assertNotNull(chosenCapabilities); Assert.assertTrue(chosenCapabilities.getGreenBits() >= 5); Assert.assertTrue(chosenCapabilities.getBlueBits() >= 5); Assert.assertTrue(chosenCapabilities.getRedBits() >= 5); Assert.assertEquals(chosenCapabilities.isOnscreen(), onscreen); return window; }
/** Outputs System and OpenGL information. This function should be called from initScene. */ public static void systemInformation() { StringBuffer sb = new StringBuffer(); sb.append("-=-=-=- Device Information -=-=-=-\n"); sb.append("Brand : ").append(android.os.Build.BRAND).append("\n"); sb.append("Manufacturer : ").append(android.os.Build.MANUFACTURER).append("\n"); sb.append("Model : ").append(android.os.Build.MODEL).append("\n"); sb.append("Bootloader : ").append(android.os.Build.BOARD).append("\n"); sb.append("CPU ABI : ").append(android.os.Build.CPU_ABI).append("\n"); sb.append("CPU ABI 2 : ").append(android.os.Build.CPU_ABI2).append("\n"); sb.append("-=-=-=- /Device Information -=-=-=-\n\n"); sb.append("-=-=-=- OpenGL Information -=-=-=-\n"); if (sGL10 != null) { sb.append("Vendor : ").append(sGL10.glGetString(GL10.GL_VENDOR)).append("\n"); sb.append("Renderer : ").append(sGL10.glGetString(GL10.GL_RENDERER)).append("\n"); sb.append("Version : ").append(sGL10.glGetString(GL10.GL_VERSION)).append("\n"); String extensions = sGL10.glGetString(GL10.GL_EXTENSIONS); String[] ext = extensions.split(" "); int extLength = ext.length; if (extLength > 0) { sb.append("Extensions : ").append(ext[0]).append("\n"); for (int i = 1; i < extLength; i++) { sb.append(" : ").append(ext[i]).append("\n"); } } } else { sb.append( "OpenGL info : Cannot find OpenGL information. Please call this function from initScene().\n"); } sb.append("-=-=-=- /OpenGL Information -=-=-=-\n"); sb.append(Capabilities.getInstance().toString()); RajLog.i(sb.toString()); }
public static void checkCapabilities(Capabilities capabilities) { // Check optional fields if (capabilities.getSupportedHardwareVersions() != null) { checkSupportedHardwareVersions(capabilities.getSupportedHardwareVersions()); } }
/** * Parse the BSHBlock for for the class definition and generate the class using ClassGenerator. */ public static Class generateClassImpl( String name, Modifiers modifiers, Class[] interfaces, Class superClass, BSHBlock block, boolean isInterface, CallStack callstack, Interpreter interpreter) throws EvalError { // Scripting classes currently requires accessibility // This can be eliminated with a bit more work. try { Capabilities.setAccessibility(true); } catch (Capabilities.Unavailable e) { throw new EvalError( "Defining classes currently requires reflective Accessibility.", block, callstack); } NameSpace enclosingNameSpace = callstack.top(); String packageName = enclosingNameSpace.getPackage(); String className = enclosingNameSpace.isClass ? (enclosingNameSpace.getName() + "$" + name) : name; String fqClassName = packageName == null ? className : packageName + "." + className; BshClassManager bcm = interpreter.getClassManager(); // Race condition here... bcm.definingClass(fqClassName); // Create the class static namespace NameSpace classStaticNameSpace = new NameSpace(enclosingNameSpace, className); classStaticNameSpace.isClass = true; callstack.push(classStaticNameSpace); // Evaluate any inner class class definitions in the block // effectively recursively call this method for contained classes first block.evalBlock(callstack, interpreter, true /*override*/, ClassNodeFilter.CLASSCLASSES); // Generate the type for our class Variable[] variables = getDeclaredVariables(block, callstack, interpreter, packageName); DelayedEvalBshMethod[] methods = getDeclaredMethods(block, callstack, interpreter, packageName); ClassGeneratorUtil classGenerator = new ClassGeneratorUtil( modifiers, className, packageName, superClass, interfaces, variables, methods, classStaticNameSpace, isInterface); byte[] code = classGenerator.generateClass(); // if debug, write out the class file to debugClasses directory if (DEBUG_DIR != null) try { FileOutputStream out = new FileOutputStream(DEBUG_DIR + '/' + className + ".class"); out.write(code); out.close(); } catch (IOException e) { throw new IllegalStateException( "cannot create file " + DEBUG_DIR + '/' + className + ".class", e); } // Define the new class in the classloader Class genClass = bcm.defineClass(fqClassName, code); // import the unq name into parent enclosingNameSpace.importClass(fqClassName.replace('$', '.')); try { classStaticNameSpace.setLocalVariable( ClassGeneratorUtil.BSHINIT, block, false /*strictJava*/); } catch (UtilEvalError e) { throw new InterpreterError("unable to init static: " + e); } // Give the static space its class static import // important to do this after all classes are defined classStaticNameSpace.setClassStatic(genClass); // evaluate the static portion of the block in the static space block.evalBlock(callstack, interpreter, true /*override*/, ClassNodeFilter.CLASSSTATIC); callstack.pop(); if (!genClass.isInterface()) { // Set the static bsh This callback String bshStaticFieldName = ClassGeneratorUtil.BSHSTATIC + className; try { LHS lhs = Reflect.getLHSStaticField(genClass, bshStaticFieldName); lhs.assign(classStaticNameSpace.getThis(interpreter), false /*strict*/); } catch (Exception e) { throw new InterpreterError("Error in class gen setup: " + e); } } bcm.doneDefiningClass(fqClassName); return genClass; }
/** The default Capabilities object that we return at startup for our display. */ private Capabilities defaultCapabilities() { return Capabilities.defaultCapabilities(); }