Package com.volantis.mcs.protocols

Examples of com.volantis.mcs.protocols.ProtocolConfigurationImpl


    public void testOpenStyleHandheldMedia() throws IOException {

        final DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();

        final ProtocolConfigurationImpl protocolConfiguration =
            (ProtocolConfigurationImpl) protocol.getProtocolConfiguration();
        protocolConfiguration.setCSSMedia("handheld");
        final StyleAttributes styleAttributes = new StyleAttributes();
        protocol.openStyle(buffer, styleAttributes);
        final Element head = (Element) buffer.getRoot().getHead();
        assertEquals("handheld", head.getAttributeValue("media"));
        assertEquals("text/css", head.getAttributeValue("type"));
View Full Code Here


    public void testOpenStyleNoMedia() {

        final DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();

        final ProtocolConfigurationImpl protocolConfiguration =
            (ProtocolConfigurationImpl) protocol.getProtocolConfiguration();
        protocolConfiguration.setCSSMedia(null);
        final StyleAttributes styleAttributes = new StyleAttributes();
        protocol.openStyle(buffer, styleAttributes);
        final Element head = (Element) buffer.getRoot().getHead();
        assertNull(head.getAttributeValue("media"));
        assertEquals("text/css", head.getAttributeValue("type"));
View Full Code Here

        builder.register("-XDIME-Protocol-", new XDIMEProtocolFactory());
    }

    public abstract static class VolantisProtocolFactory implements ProtocolFactory {
        public ProtocolConfiguration createConfiguration() {
            return new ProtocolConfigurationImpl();
        }
View Full Code Here

     * Create a style visitor.
     *
     * @return the newly created style visitor.
     */
    protected StyleEmulationVisitor createStyleVisitor() {
        ProtocolConfigurationImpl configuration = getProtocolConfiguration();
        final HashMap policies = new HashMap();
        InternalDevice device = INTERNAL_DEVICE_FACTORY.createInternalDevice(
            new DefaultDevice("testDevice", policies, null));
        DeviceCapabilityManagerBuilder builder =
                new DeviceCapabilityManagerBuilder(device);
        configuration.initialize(device, builder);
        return new StyleEmulationVisitor(domFactory,
                configuration.getStyleEmulationElementConfiguration(),
                new StyleEmulationElementTracker());
    }
View Full Code Here

     * @param configuration the protocol configuration.
     */
    private void initialiseDeviceProtocolConfiguration(
            InternalDevice device, ProtocolConfiguration configuration) {

        ProtocolConfigurationImpl config = (ProtocolConfigurationImpl)
                configuration;

        boolean supportsJavascript = device.getBooleanPolicyValue(
                DevicePolicyConstants.SUPPORTS_JAVASCRIPT);
        config.setCanSupportJavaScript(supportsJavascript);

        try {
            int devicePixelsX;
            devicePixelsX = device.getIntegerPolicyValue(
                DevicePolicyConstants.USABLE_WIDTH_IN_PIXELS);
            config.setDevicePixelsX(devicePixelsX);
        } catch(NumberFormatException e){
            // default value will be used.
        }

        // Version of CFW since the device is supported
        String since = device.getPolicyValue(
                DevicePolicyConstants.SUPPORTS_VFC_SINCE);

        if (since == null) {
            since = DevicePolicyConstants.SUPPORTS_VFC_SINCE_DEFAULT;
        }
        config.setFrameworkClientSupportedSince(since);

        // Whether the device has viewport support
        String viewportVirtualSupport = device.getPolicyValue(
                DevicePolicyConstants.X_BROWSER_VIEWPORT_VIRTUAL_SUPPORT);
        config.setViewportVirtualSupport(viewportVirtualSupport);

        // Framework Client support configuration
        config.setFrameworkClientSupported(configurePolicyValue(
                device,
                DevicePolicyConstants.SUPPORTS_VFC,
                DevicePolicyConstants.SUPPORTS_VFC_DEFAULT,
                config.getFrameworkClientSupported()));

        // todo: later: configurators should be registered externally (for testing)
        // todo: later: create a ProtocolBuilderFactory to pass in dependencies.
        CSSConfigurator cssConfigurator = new CSSConfigurator();
        cssConfigurator.initialise(config, device);

        // ???else, test cases with null device assume no javascript support???
        // else, the device is null. Currently this may happen for
        // integration test cases but in future we should avoid this.
        // todo: integration test cases to provide non-null device here.

        // Complete the configuration initialisation now that the css version
        // has been initialised (do this before a default version is supplied
        // if it's null). This must be done even if the device is null to
        // ensure that everything is initialised (even if empty).
        DeviceCapabilityManagerBuilder builder =
                new DeviceCapabilityManagerBuilder(device);
        config.initialize(device, builder);

        // If we did not try and set the CSS or we did but no CSS was found,
        // then we will have a null CSS version. This should only ever happen
        // in testing, but means that all the subsequent code must check for
        // null, which is very tedious. Instead we sub in a testing CSS version
        // which prevents us having to do this.
        if (config.getCssVersion() == null) {

            // assume the most common case for test cases for now.
            DefaultCSSVersion cssVersion =
                    new ManualCSS2VersionFactory().createCSSVersion();
            cssVersion.markImmutable();
            config.setCssVersion(cssVersion);

            if (logger.isDebugEnabled()) {
                logger.debug("Using testing base CSS Version: " +
                        configuration.getCssVersion());
            }
        }

        ExtractorConfigurator configurator = new ExtractorConfigurator();
        ExtractorConfiguration extractor =
                configurator.createConfiguration(device,
                        configuration.getCssVersion());
        config.setExtractorConfiguration(extractor);

        // CSS media
        String media = device.getPolicyValue(DevicePolicyConstants.CSS_MEDIA_SUPPORTED);

        // If media is specified (not null and not empty),
        // set the value on protocol.
        if ((media != null) && !media.equals("")) {
            config.setCSSMedia(media);
        }
    }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.protocols.ProtocolConfigurationImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.