Automated merge with http://hg.netbeans.org/main/contrib
authorMartin Fousek <marfous@netbeans.org>
Fri, 09 Mar 2012 16:37:50 +0100
changeset 177962fa1f6e1956f
parent 17794 cda900fb7fda
parent 17795 ed07e23ee4d1
child 17797 380a0837efe7
Automated merge with http://hg.netbeans.org/main/contrib
     1.1 --- a/selenium.server/src/org/netbeans/modules/selenium/server/Bundle.properties	Fri Mar 09 14:23:26 2012 +0100
     1.2 +++ b/selenium.server/src/org/netbeans/modules/selenium/server/Bundle.properties	Fri Mar 09 16:37:50 2012 +0100
     1.3 @@ -18,3 +18,10 @@
     1.4  displayName_Startup=Start on NetBeans startup
     1.5  desc_Startup=start server on NetBeans startup or not. Note \
     1.6  that server must be running to run Selenium tests correctly.
     1.7 +
     1.8 +displayName_FirefoxProfile=Firefox Profile
     1.9 +desc_FirefoxProfile=The profile directory for Firefox
    1.10 +
    1.11 +displayName_SingleWindow=Single Window
    1.12 +desc_SingleWindow=Should the browser started by selenium server use <br/> \
    1.13 +multiple frames in a single window or multiple windows.
    1.14 \ No newline at end of file
     2.1 --- a/selenium.server/src/org/netbeans/modules/selenium/server/SeleniumProperties.java	Fri Mar 09 14:23:26 2012 +0100
     2.2 +++ b/selenium.server/src/org/netbeans/modules/selenium/server/SeleniumProperties.java	Fri Mar 09 16:37:50 2012 +0100
     2.3 @@ -62,8 +62,11 @@
     2.4      private static Logger LOGGER = Logger.getLogger(SeleniumProperties.class.getName());
     2.5  
     2.6      public static int seleniumDefaultPort = -1;
     2.7 -    public static final String PORT = "Port";
     2.8 -    public static final String START_ON_STARTUP = "Startup";
     2.9 +    public static final String PORT = "Port"; //NOI18N
    2.10 +    public static final String START_ON_STARTUP = "Startup"; //NOI18N
    2.11 +    public static final String FIREFOX_PROFILE = "FirefoxProfile"; //NOI18N
    2.12 +    public static final String SINGLE_WINDOW = "SingleWindow"; //NOI18N
    2.13 +    
    2.14      private static InstanceProperties instanceProps;
    2.15      private static final String NAMESPACE = "Selenium server properties namespace"; //NOI18N
    2.16  
    2.17 @@ -73,6 +76,8 @@
    2.18          Set set = sheet.get(Sheet.PROPERTIES);
    2.19          set.put(new ServerIntProperty(PORT, props));
    2.20          set.put(new ServerBoolProperty(START_ON_STARTUP, props));
    2.21 +        set.put(new ServerStringProperty(FIREFOX_PROFILE, props));
    2.22 +        set.put(new ServerBoolProperty(SINGLE_WINDOW, props));
    2.23          return sheet;
    2.24      }
    2.25  
    2.26 @@ -114,6 +119,8 @@
    2.27                      instanceProps = manager.createProperties(NAMESPACE);
    2.28                      instanceProps.putInt(PORT, getSeleniumDefaultPort());
    2.29                      instanceProps.putBoolean(START_ON_STARTUP, true);
    2.30 +                    instanceProps.putString(FIREFOX_PROFILE, ""); //NOI18N
    2.31 +                    instanceProps.putBoolean(SINGLE_WINDOW, false);
    2.32                      allProps.add(instanceProps);
    2.33                  }
    2.34              }
    2.35 @@ -161,7 +168,23 @@
    2.36  
    2.37      }
    2.38  
    2.39 +    private static final class ServerStringProperty extends ServerProperty<String> {
    2.40  
    2.41 +        public ServerStringProperty(String propertyName, InstanceProperties props) {
    2.42 +            super(String.class, propertyName, props);
    2.43 +        }
    2.44 +
    2.45 +        @Override
    2.46 +        public String getValue() throws IllegalAccessException, InvocationTargetException {
    2.47 +            return props.getString(getName(), ""); //NOI18N
    2.48 +        }
    2.49 +
    2.50 +        @Override
    2.51 +        protected void writeNewValue(String val) {
    2.52 +            props.putString(getName(), val);
    2.53 +        }
    2.54 +
    2.55 +    }
    2.56  
    2.57      private static abstract class ServerProperty<T> extends Node.Property<T>{
    2.58  
     3.1 --- a/selenium.server/src/org/netbeans/modules/selenium/server/SeleniumServerRunner.java	Fri Mar 09 14:23:26 2012 +0100
     3.2 +++ b/selenium.server/src/org/netbeans/modules/selenium/server/SeleniumServerRunner.java	Fri Mar 09 16:37:50 2012 +0100
     3.3 @@ -42,6 +42,7 @@
     3.4  
     3.5  import java.beans.PropertyChangeEvent;
     3.6  import java.beans.PropertyChangeListener;
     3.7 +import java.io.File;
     3.8  import java.lang.reflect.InvocationTargetException;
     3.9  import java.net.BindException;
    3.10  import java.net.MalformedURLException;
    3.11 @@ -187,11 +188,20 @@
    3.12  
    3.13          InstanceProperties ip = SeleniumProperties.getInstanceProperties();
    3.14          Object remoteControlConfigurationInstance = remoteControlConfiguration.newInstance();
    3.15 -        int port = ip.getInt(
    3.16 -                SeleniumProperties.PORT,
    3.17 -                SeleniumProperties.getSeleniumDefaultPort()); //NOI18N
    3.18 +        int port = ip.getInt(SeleniumProperties.PORT, SeleniumProperties.getSeleniumDefaultPort());
    3.19          remoteControlConfiguration.getMethod("setPort", int.class).invoke(
    3.20 -                remoteControlConfigurationInstance, port); //NOI18N
    3.21 +            remoteControlConfigurationInstance, port); //NOI18N
    3.22 +        boolean runInSingleWindow = ip.getBoolean(SeleniumProperties.SINGLE_WINDOW, false);
    3.23 +        remoteControlConfiguration.getMethod("setSingleWindow", Boolean.TYPE).invoke( //NOI18N
    3.24 +                remoteControlConfigurationInstance, runInSingleWindow);
    3.25 +		String firefoxProfileDir = ip.getString(SeleniumProperties.FIREFOX_PROFILE, ""); //NOI18N
    3.26 +		if (!firefoxProfileDir.isEmpty()) {
    3.27 +				File ffProfileDir = new File(firefoxProfileDir);
    3.28 +				if (ffProfileDir.exists()) {
    3.29 +					remoteControlConfiguration.getMethod("setFirefoxProfileTemplate", File.class).invoke( //NOI18N
    3.30 +						remoteControlConfigurationInstance, ffProfileDir);
    3.31 +				}
    3.32 +		}
    3.33          server = seleniumServer.getConstructor(remoteControlConfiguration).
    3.34                  newInstance(remoteControlConfigurationInstance);
    3.35      }