/*
 * Copyright 2000-2014 Vaadin Ltd.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.vaadin.tests.tb3;

import java.util.logging.Logger;

import org.openqa.selenium.Platform;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

import com.vaadin.testbench.parallel.Browser;
import com.vaadin.testbench.parallel.DefaultBrowserFactory;
import com.vaadin.testbench.parallel.TestBenchBrowserFactory;

public class VaadinBrowserFactory extends DefaultBrowserFactory {

	TestBenchBrowserFactory delegate = null;

    @Override
    public DesiredCapabilities create(Browser browser) {
        String browserFactoryClass = System.getProperty("browser.factory");
        if (browserFactoryClass != null
                && !browserFactoryClass.trim().isEmpty()) {
            if (delegate == null) {
                getLogger()
                        .info("Using browser factory " + browserFactoryClass);
                try {
                    delegate = (TestBenchBrowserFactory) getClass()
                            .getClassLoader().loadClass(browserFactoryClass)
                            .newInstance();
                } catch (Exception e) {
                    getLogger().warning("Failed to instantiate browser factory " + browserFactoryClass);
                    throw new RuntimeException(e);
                }
            }
            return delegate.create(browser);
        }

    	return doCreate(browser);
    }

    public DesiredCapabilities doCreate(Browser browser) {
        switch (browser) {
        case IE8:
            return createIE(browser, "8");
        case IE9:
            return createIE(browser, "9");
        case IE10:
            return createIE(browser, "10");
        case IE11:
            return createIE(browser, "11");
        case PHANTOMJS:
            return create(browser, "1", Platform.LINUX);
        case CHROME:
            return create(browser, "40", Platform.VISTA);
        case FIREFOX:
        default:
            return create(browser, "24", Platform.XP);
        }
    }

    private DesiredCapabilities createIE(Browser browser, String version) {
        DesiredCapabilities capabilities = create(browser, version,
                Platform.WINDOWS);
        capabilities.setCapability(
                InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
        return capabilities;
    }

    @Override
    public DesiredCapabilities create(Browser browser, String version) {
        DesiredCapabilities capabilities = create(browser);
        capabilities.setVersion(version);
        return capabilities;
    }

    private static final Logger getLogger() {
        return Logger.getLogger(VaadinBrowserFactory.class.getName());
    }
}

@@ -33,18 +33,17 @@
  Ltd.%0A *
- 
 %0A
+
  * Licen
@@ -214,17 +214,16 @@
 se at%0A *
- 
 %0A * http
@@ -263,17 +263,16 @@
 E-2.0%0A *
- 
 %0A * Unle
@@ -1037,17 +1037,20 @@
 tory %7B%0A%0A
-%09
+    
 TestBenc
@@ -1764,16 +1764,45 @@
 warning(
+%0A                            
 %22Failed 
@@ -1825,32 +1825,68 @@
 rowser factory %22
+%0A                                   
  + browserFactor
@@ -2041,9 +2041,12 @@
     
-%09
+    
 retu

Fix formatting of VaadinBrowserFactory