Revision: 6925 Author: jlaba...@google.com Date: Mon Nov 16 12:57:41 2009 Log: tr...@6923 were merged into this branch Allows path to executable in RunStyleSelenium. svn merge --ignore-ancestry -c6923 https://google-web-toolkit.googlecode.com/svn/trunk .
Patch by: jlabanca http://code.google.com/p/google-web-toolkit/source/detail?r=6925 Added: /releases/2.0/user/test/com/google/gwt/junit/RunStyleSeleniumTest.java Modified: /releases/2.0/branch-info.txt /releases/2.0/user/build.xml /releases/2.0/user/src/com/google/gwt/junit/RunStyleSelenium.java ======================================= --- /dev/null +++ /releases/2.0/user/test/com/google/gwt/junit/RunStyleSeleniumTest.java Mon Nov 16 12:57:41 2009 @@ -0,0 +1,108 @@ +/* + * Copyright 2009 Google Inc. + * + * 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.google.gwt.junit; + +import com.google.gwt.junit.RunStyleSelenium.RCSelenium; + +import junit.framework.TestCase; + +/** + * Tests of {...@link RunStyleSelenium}. + */ +public class RunStyleSeleniumTest extends TestCase { + + public void testRCSeleniumGetSpecifier() { + RCSelenium rcs = new RCSelenium("localhost:4444/*firefox"); + assertEquals("localhost:4444/*firefox", rcs.getSpecifier()); + } + + public void testRCSeleniumParseSpecifier() { + // Standard selenium targets. + assertRcSeleniumComponents("localhost:4444/*firefox", "localhost", 4444, + "*firefox"); + assertRcSeleniumComponents("localhost:4444/*iexplore", "localhost", 4444, + "*iexplore"); + assertRcSeleniumComponents("localhost:4444/*googlechrome", "localhost", + 4444, "*googlechrome"); + + // Using a remote host. + assertRcSeleniumComponents("gwt-remote-host:1234/*firefox", + "gwt-remote-host", 1234, "*firefox"); + assertRcSeleniumComponents("gwt.remote.google.com:4444/*firefox", + "gwt.remote.google.com", 4444, "*firefox"); + assertRcSeleniumComponents("127.0.0.1:4444/*firefox", "127.0.0.1", 4444, + "*firefox"); + + // Specifying path to executable. + assertRcSeleniumComponents("localhost:4444/*firefox /usr/bin/firefox", + "localhost", 4444, "*firefox /usr/bin/firefox"); + assertRcSeleniumComponents( + "localhost:4444/*iexplore c:\\Program Files\\iexplore.exe", + "localhost", 4444, "*iexplore c:\\Program Files\\iexplore.exe"); + assertRcSeleniumComponents("localhost:4444/madeup /usr/bin/madeup", + "localhost", 4444, "madeup /usr/bin/madeup"); + assertRcSeleniumComponents( + "localhost:4444/complexpath c:\\Complex(Path)~...@*&^%$#\\to\\browser.cmd", + "localhost", 4444, + "complexpath c:\\Complex(Path)~...@*&^%$#\\to\\browser.cmd"); + } + + public void testRCSeleniumParseSpecifierIllegal() { + // Invalid host name. + assertRcSeleniumIllegalSpecifier(":4444/*firefox"); + assertRcSeleniumIllegalSpecifier("with space:4444/*firefox"); + assertRcSeleniumIllegalSpecifier("front/slash:4444/*firefox"); + + // Invalid port. + assertRcSeleniumIllegalSpecifier("localhost:/*firefox"); + assertRcSeleniumIllegalSpecifier("localhost:abc/*firefox"); + + // Invalid browser. + assertRcSeleniumIllegalSpecifier("localhost:4444"); + assertRcSeleniumIllegalSpecifier("localhost:4444/"); + } + + /** + * Assert that the {...@link RCSelenium} created by the given specifier is parsed + * to the specified browser, host, and port. + * + * @param specifier the remote specifier + * @param host the expected host + * @param port the expected port + * @param browser the expected browser + */ + private void assertRcSeleniumComponents(String specifier, String host, + int port, String browser) { + RCSelenium rcs = new RCSelenium(specifier); + assertEquals(host, rcs.host); + assertEquals(port, rcs.port); + assertEquals(browser, rcs.browser); + } + + /** + * Assert that the specifier is invalid. + * + * @param specifier the specifier. + */ + private void assertRcSeleniumIllegalSpecifier(String specifier) { + try { + new RCSelenium(specifier); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) { + // expected. + } + } +} ======================================= --- /releases/2.0/branch-info.txt Mon Nov 16 12:53:35 2009 +++ /releases/2.0/branch-info.txt Mon Nov 16 12:57:41 2009 @@ -688,3 +688,7 @@ Fixes a memory leak in XMLHttpRequest. svn merge --ignore-ancestry -c6921,6922 https://google-web-toolkit.googlecode.com/svn/trunk . +tr...@6923 were merged into this branch + Allows path to executable in RunStyleSelenium. + svn merge --ignore-ancestry -c6923 https://google-web-toolkit.googlecode.com/svn/trunk . + ======================================= --- /releases/2.0/user/build.xml Fri Nov 6 08:30:38 2009 +++ /releases/2.0/user/build.xml Mon Nov 16 12:57:41 2009 @@ -302,7 +302,7 @@ includes="${gwt.junit.testcase.dev.includes}" excludes="${gwt.junit.testcase.dev.excludes}" /> <gwt.junit test.name="test.dev.selenium" - test.args="${test.dev.selenium.args} -out www -runStyle Selenium:${gwt.hosts.dev.selenium} -batch module" + test.args='${test.dev.selenium.args} -out www -runStyle "Selenium:${gwt.hosts.dev.selenium}" -batch module' test.out="${junit.out}/dev-selenium" test.cases="test.dev.selenium.tests" > <extraclasspaths> ======================================= --- /releases/2.0/user/src/com/google/gwt/junit/RunStyleSelenium.java Fri Nov 13 06:33:42 2009 +++ /releases/2.0/user/src/com/google/gwt/junit/RunStyleSelenium.java Mon Nov 16 12:57:41 2009 @@ -40,16 +40,20 @@ } /** - * Implements SeleniumWrapper using DefaultSelenium. + * Implements SeleniumWrapper using DefaultSelenium. Visible for testing. */ - private static class RCSelenium implements SeleniumWrapper { + static class RCSelenium implements SeleniumWrapper { private static final Pattern PATTERN = - Pattern.compile("([\\w\\.-]+):([\\d]+)/([\\w\\s\\*(/\\w+)*]+)"); - - private String browser; - private String host; - private int port; + Pattern.compile("([\\w\\.-]+):([\\d]+)/(.+)"); + + /* + * Visible for testing. + */ + String browser; + String host; + int port; + private Selenium selenium; private final String specifier; -- http://groups.google.com/group/Google-Web-Toolkit-Contributors