From 84521fa4b432ca8107a030a6bebfdf484bbee35a Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 11 Nov 2013 16:41:16 +0200 Subject: Use correct type for UIDL value to avoid development mode problems (#12545) Change-Id: Ib183e352fa64cb5c8f4d499ecb194768b18a16d6 --- client/src/com/vaadin/client/ui/VScrollTable.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index 48fd85144f..d1d73f4e91 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -4232,8 +4232,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets, // Already updated by setColWidth called from // TableHeads.updateCellsFromUIDL in case of a server // side resize - final String width = col.getStringAttribute("width"); - c.setWidth(Integer.parseInt(width), true); + final int width = col.getIntAttribute("width"); + c.setWidth(width, true); } } else if (recalcWidths) { c.setUndefinedWidth(); -- cgit v1.2.3 From 3680505544b3130f5399bdbd64ef7b7973db709d Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 11 Nov 2013 16:11:50 +0200 Subject: Ensure generated parser is re-generated during build (#12937) Ultimately we should remove Parser.java and other generated files from the project but this still needs tweaking ide.xml somehow so the parser is built. Change-Id: Iac491c6a50c87e1e8e0bb2f612e82186319a6de3 --- theme-compiler/apache2header.txt | 15 +++++++++++++++ theme-compiler/build.xml | 28 +++++++++++++++++++++++++--- 2 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 theme-compiler/apache2header.txt diff --git a/theme-compiler/apache2header.txt b/theme-compiler/apache2header.txt new file mode 100644 index 0000000000..5e94497098 --- /dev/null +++ b/theme-compiler/apache2header.txt @@ -0,0 +1,15 @@ +/* + * Copyright 2000-2013 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. + */ diff --git a/theme-compiler/build.xml b/theme-compiler/build.xml index 9141605fbf..fbc5112be4 100644 --- a/theme-compiler/build.xml +++ b/theme-compiler/build.xml @@ -1,6 +1,6 @@ - + Compiles build helpers used when building other modules. @@ -12,7 +12,10 @@ - + + + + @@ -25,8 +28,27 @@ javacc task requires the jar to be named javacc.jar --> - + + + + + + + + + + + + + + + + +
+ + -- cgit v1.2.3 From f3fa6af2ba31b298e2f151a7813504a9ca943684 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 11 Nov 2013 17:24:27 +0200 Subject: Regenerated parser files (#12937) Change-Id: I03e5f818c932d43be178008a4e857676bfed8f87 --- .../sass/internal/parser/ParseException.java | 337 ++++++++++----------- .../com/vaadin/sass/internal/parser/Parser.java | 0 2 files changed, 168 insertions(+), 169 deletions(-) mode change 100755 => 100644 theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.java b/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.java index 392d71e767..22eb4c73ee 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.java @@ -13,191 +13,190 @@ * License for the specific language governing permissions and limitations under * the License. */ -/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 0.7pre6 */ +/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */ +/* JavaCCOptions:KEEP_LINE_COL=null */ package com.vaadin.sass.internal.parser; -import org.w3c.css.sac.CSSException; - /** - * This exception is thrown when parse errors are encountered. You can - * explicitly create objects of this exception type by calling the method - * generateParseException in the generated parser. - * - * You can modify this class to customize your error reporting mechanisms so - * long as you retain the public fields. + * This exception is thrown when parse errors are encountered. + * You can explicitly create objects of this exception type by + * calling the method generateParseException in the generated + * parser. + * + * You can modify this class to customize your error reporting + * mechanisms so long as you retain the public fields. */ -public class ParseException extends CSSException { - private static final long serialVersionUID = -8556588037264585977L; +public class ParseException extends Exception { - /** - * This constructor is used by the method "generateParseException" in the - * generated parser. Calling this constructor generates a new object of this - * type with the fields "currentToken", "expectedTokenSequences", and - * "tokenImage" set. The boolean flag "specialConstructor" is also set to - * true to indicate that this constructor was used to create this object. - * This constructor calls its super class with the empty string to force the - * "toString" method of parent class "Throwable" to print the error message - * in the form: ParseException: - */ - public ParseException(Token currentTokenVal, - int[][] expectedTokenSequencesVal, String[] tokenImageVal) { - super(""); - specialConstructor = true; - currentToken = currentTokenVal; - expectedTokenSequences = expectedTokenSequencesVal; - tokenImage = tokenImageVal; - } + /** + * The version identifier for this Serializable class. + * Increment only if the serialized form of the + * class changes. + */ + private static final long serialVersionUID = 1L; - /** - * The following constructors are for use by you for whatever purpose you - * can think of. Constructing the exception in this manner makes the - * exception behave in the normal way - i.e., as documented in the class - * "Throwable". The fields "errorToken", "expectedTokenSequences", and - * "tokenImage" do not contain relevant information. The JavaCC generated - * code does not use these constructors. - */ + /** + * This constructor is used by the method "generateParseException" + * in the generated parser. Calling this constructor generates + * a new object of this type with the fields "currentToken", + * "expectedTokenSequences", and "tokenImage" set. + */ + public ParseException(Token currentTokenVal, + int[][] expectedTokenSequencesVal, + String[] tokenImageVal + ) + { + super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal)); + currentToken = currentTokenVal; + expectedTokenSequences = expectedTokenSequencesVal; + tokenImage = tokenImageVal; + } - public ParseException() { - super(); - specialConstructor = false; - } + /** + * The following constructors are for use by you for whatever + * purpose you can think of. Constructing the exception in this + * manner makes the exception behave in the normal way - i.e., as + * documented in the class "Throwable". The fields "errorToken", + * "expectedTokenSequences", and "tokenImage" do not contain + * relevant information. The JavaCC generated code does not use + * these constructors. + */ - public ParseException(String message) { - super(message); - specialConstructor = false; - } + public ParseException() { + super(); + } - /** - * This variable determines which constructor was used to create this object - * and thereby affects the semantics of the "getMessage" method (see below). - */ - protected boolean specialConstructor; + /** Constructor with message. */ + public ParseException(String message) { + super(message); + } - /** - * This is the last token that has been consumed successfully. If this - * object has been created due to a parse error, the token followng this - * token will (therefore) be the first error token. - */ - public Token currentToken; - /** - * Each entry in this array is an array of integers. Each array of integers - * represents a sequence of tokens (by their ordinal values) that is - * expected at this point of the parse. - */ - public int[][] expectedTokenSequences; + /** + * This is the last token that has been consumed successfully. If + * this object has been created due to a parse error, the token + * followng this token will (therefore) be the first error token. + */ + public Token currentToken; - /** - * This is a reference to the "tokenImage" array of the generated parser - * within which the parse error occurred. This array is defined in the - * generated ...Constants interface. - */ - public String[] tokenImage; + /** + * Each entry in this array is an array of integers. Each array + * of integers represents a sequence of tokens (by their ordinal + * values) that is expected at this point of the parse. + */ + public int[][] expectedTokenSequences; - /** - * This method has the standard behavior when this object has been created - * using the standard constructors. Otherwise, it uses "currentToken" and - * "expectedTokenSequences" to generate a parse error message and returns - * it. If this object has been created due to a parse error, and you do not - * catch it (it gets thrown from the parser), then this method is called - * during the printing of the final stack trace, and hence the correct error - * message gets displayed. - */ - @Override - public String getMessage() { - if (!specialConstructor) { - return super.getMessage(); - } - String expected = ""; - int maxSize = 0; - for (int i = 0; i < expectedTokenSequences.length; i++) { - if (maxSize < expectedTokenSequences[i].length) { - maxSize = expectedTokenSequences[i].length; - } - for (int j = 0; j < expectedTokenSequences[i].length; j++) { - expected += tokenImage[expectedTokenSequences[i][j]] + " "; - } - if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { - expected += "..."; - } - expected += eol + " "; - } - String retval = "Encountered \""; - Token tok = currentToken.next; - for (int i = 0; i < maxSize; i++) { - if (i != 0) { - retval += " "; - } - if (tok.kind == 0) { - retval += tokenImage[0]; - break; - } - retval += add_escapes(tok.image); - tok = tok.next; - } - retval += "\" at line " + currentToken.next.beginLine + ", column " - + currentToken.next.beginColumn + "." + eol; - if (expectedTokenSequences.length == 1) { - retval += "Was expecting:" + eol + " "; - } else { - retval += "Was expecting one of:" + eol + " "; - } - retval += expected; - return retval; + /** + * This is a reference to the "tokenImage" array of the generated + * parser within which the parse error occurred. This array is + * defined in the generated ...Constants interface. + */ + public String[] tokenImage; + + /** + * It uses "currentToken" and "expectedTokenSequences" to generate a parse + * error message and returns it. If this object has been created + * due to a parse error, and you do not catch it (it gets thrown + * from the parser) the correct error message + * gets displayed. + */ + private static String initialise(Token currentToken, + int[][] expectedTokenSequences, + String[] tokenImage) { + String eol = System.getProperty("line.separator", "\n"); + StringBuffer expected = new StringBuffer(); + int maxSize = 0; + for (int i = 0; i < expectedTokenSequences.length; i++) { + if (maxSize < expectedTokenSequences[i].length) { + maxSize = expectedTokenSequences[i].length; + } + for (int j = 0; j < expectedTokenSequences[i].length; j++) { + expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' '); + } + if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { + expected.append("..."); + } + expected.append(eol).append(" "); } + String retval = "Encountered \""; + Token tok = currentToken.next; + for (int i = 0; i < maxSize; i++) { + if (i != 0) retval += " "; + if (tok.kind == 0) { + retval += tokenImage[0]; + break; + } + retval += " " + tokenImage[tok.kind]; + retval += " \""; + retval += add_escapes(tok.image); + retval += " \""; + tok = tok.next; + } + retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; + retval += "." + eol; + if (expectedTokenSequences.length == 1) { + retval += "Was expecting:" + eol + " "; + } else { + retval += "Was expecting one of:" + eol + " "; + } + retval += expected.toString(); + return retval; + } - /** - * The end of line string for this machine. - */ - protected String eol = System.getProperty("line.separator", "\n"); + /** + * The end of line string for this machine. + */ + protected String eol = System.getProperty("line.separator", "\n"); - /** - * Used to convert raw characters to their escaped version when these raw - * version cannot be used as part of an ASCII string literal. - */ - protected String add_escapes(String str) { - StringBuffer retval = new StringBuffer(); - char ch; - for (int i = 0; i < str.length(); i++) { - switch (str.charAt(i)) { - case 0: - continue; - case '\b': - retval.append("\\b"); - continue; - case '\t': - retval.append("\\t"); - continue; - case '\n': - retval.append("\\n"); - continue; - case '\f': - retval.append("\\f"); - continue; - case '\r': - retval.append("\\r"); - continue; - case '\"': - retval.append("\\\""); - continue; - case '\'': - retval.append("\\\'"); - continue; - case '\\': - retval.append("\\\\"); - continue; - default: - if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { - String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" - + s.substring(s.length() - 4, s.length())); - } else { - retval.append(ch); - } - continue; - } + /** + * Used to convert raw characters to their escaped version + * when these raw version cannot be used as part of an ASCII + * string literal. + */ + static String add_escapes(String str) { + StringBuffer retval = new StringBuffer(); + char ch; + for (int i = 0; i < str.length(); i++) { + switch (str.charAt(i)) + { + case 0 : + continue; + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u" + s.substring(s.length() - 4, s.length())); + } else { + retval.append(ch); + } + continue; } - return retval.toString(); - } + } + return retval.toString(); + } } +/* JavaCC - OriginalChecksum=84fd1bce44783fb59914b382b6de4edc (do not edit this line) */ diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java old mode 100755 new mode 100644 -- cgit v1.2.3 From 011a2a0c9d8eac77e17a5a31b6ddd9ea243209d8 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 12 Nov 2013 11:08:07 +0200 Subject: Do not generate ParseException as it has been customized (#12937) Reverted ParseException to the previous version Change-Id: Ic89eb4b65d1a78f40c4cb94e9b2a13a3250c1924 --- theme-compiler/build.xml | 2 +- .../sass/internal/parser/ParseException.java | 337 +++++++++++---------- 2 files changed, 170 insertions(+), 169 deletions(-) diff --git a/theme-compiler/build.xml b/theme-compiler/build.xml index fbc5112be4..03d0531a68 100644 --- a/theme-compiler/build.xml +++ b/theme-compiler/build.xml @@ -38,7 +38,7 @@ - + diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.java b/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.java index 22eb4c73ee..392d71e767 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.java @@ -13,190 +13,191 @@ * License for the specific language governing permissions and limitations under * the License. */ -/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */ -/* JavaCCOptions:KEEP_LINE_COL=null */ +/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 0.7pre6 */ package com.vaadin.sass.internal.parser; +import org.w3c.css.sac.CSSException; + /** - * This exception is thrown when parse errors are encountered. - * You can explicitly create objects of this exception type by - * calling the method generateParseException in the generated - * parser. - * - * You can modify this class to customize your error reporting - * mechanisms so long as you retain the public fields. + * This exception is thrown when parse errors are encountered. You can + * explicitly create objects of this exception type by calling the method + * generateParseException in the generated parser. + * + * You can modify this class to customize your error reporting mechanisms so + * long as you retain the public fields. */ -public class ParseException extends Exception { +public class ParseException extends CSSException { + private static final long serialVersionUID = -8556588037264585977L; - /** - * The version identifier for this Serializable class. - * Increment only if the serialized form of the - * class changes. - */ - private static final long serialVersionUID = 1L; - - /** - * This constructor is used by the method "generateParseException" - * in the generated parser. Calling this constructor generates - * a new object of this type with the fields "currentToken", - * "expectedTokenSequences", and "tokenImage" set. - */ - public ParseException(Token currentTokenVal, - int[][] expectedTokenSequencesVal, - String[] tokenImageVal - ) - { - super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal)); - currentToken = currentTokenVal; - expectedTokenSequences = expectedTokenSequencesVal; - tokenImage = tokenImageVal; - } + /** + * This constructor is used by the method "generateParseException" in the + * generated parser. Calling this constructor generates a new object of this + * type with the fields "currentToken", "expectedTokenSequences", and + * "tokenImage" set. The boolean flag "specialConstructor" is also set to + * true to indicate that this constructor was used to create this object. + * This constructor calls its super class with the empty string to force the + * "toString" method of parent class "Throwable" to print the error message + * in the form: ParseException: + */ + public ParseException(Token currentTokenVal, + int[][] expectedTokenSequencesVal, String[] tokenImageVal) { + super(""); + specialConstructor = true; + currentToken = currentTokenVal; + expectedTokenSequences = expectedTokenSequencesVal; + tokenImage = tokenImageVal; + } - /** - * The following constructors are for use by you for whatever - * purpose you can think of. Constructing the exception in this - * manner makes the exception behave in the normal way - i.e., as - * documented in the class "Throwable". The fields "errorToken", - * "expectedTokenSequences", and "tokenImage" do not contain - * relevant information. The JavaCC generated code does not use - * these constructors. - */ + /** + * The following constructors are for use by you for whatever purpose you + * can think of. Constructing the exception in this manner makes the + * exception behave in the normal way - i.e., as documented in the class + * "Throwable". The fields "errorToken", "expectedTokenSequences", and + * "tokenImage" do not contain relevant information. The JavaCC generated + * code does not use these constructors. + */ - public ParseException() { - super(); - } + public ParseException() { + super(); + specialConstructor = false; + } - /** Constructor with message. */ - public ParseException(String message) { - super(message); - } + public ParseException(String message) { + super(message); + specialConstructor = false; + } + /** + * This variable determines which constructor was used to create this object + * and thereby affects the semantics of the "getMessage" method (see below). + */ + protected boolean specialConstructor; - /** - * This is the last token that has been consumed successfully. If - * this object has been created due to a parse error, the token - * followng this token will (therefore) be the first error token. - */ - public Token currentToken; + /** + * This is the last token that has been consumed successfully. If this + * object has been created due to a parse error, the token followng this + * token will (therefore) be the first error token. + */ + public Token currentToken; - /** - * Each entry in this array is an array of integers. Each array - * of integers represents a sequence of tokens (by their ordinal - * values) that is expected at this point of the parse. - */ - public int[][] expectedTokenSequences; + /** + * Each entry in this array is an array of integers. Each array of integers + * represents a sequence of tokens (by their ordinal values) that is + * expected at this point of the parse. + */ + public int[][] expectedTokenSequences; - /** - * This is a reference to the "tokenImage" array of the generated - * parser within which the parse error occurred. This array is - * defined in the generated ...Constants interface. - */ - public String[] tokenImage; + /** + * This is a reference to the "tokenImage" array of the generated parser + * within which the parse error occurred. This array is defined in the + * generated ...Constants interface. + */ + public String[] tokenImage; - /** - * It uses "currentToken" and "expectedTokenSequences" to generate a parse - * error message and returns it. If this object has been created - * due to a parse error, and you do not catch it (it gets thrown - * from the parser) the correct error message - * gets displayed. - */ - private static String initialise(Token currentToken, - int[][] expectedTokenSequences, - String[] tokenImage) { - String eol = System.getProperty("line.separator", "\n"); - StringBuffer expected = new StringBuffer(); - int maxSize = 0; - for (int i = 0; i < expectedTokenSequences.length; i++) { - if (maxSize < expectedTokenSequences[i].length) { - maxSize = expectedTokenSequences[i].length; - } - for (int j = 0; j < expectedTokenSequences[i].length; j++) { - expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' '); - } - if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { - expected.append("..."); - } - expected.append(eol).append(" "); - } - String retval = "Encountered \""; - Token tok = currentToken.next; - for (int i = 0; i < maxSize; i++) { - if (i != 0) retval += " "; - if (tok.kind == 0) { - retval += tokenImage[0]; - break; - } - retval += " " + tokenImage[tok.kind]; - retval += " \""; - retval += add_escapes(tok.image); - retval += " \""; - tok = tok.next; - } - retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; - retval += "." + eol; - if (expectedTokenSequences.length == 1) { - retval += "Was expecting:" + eol + " "; - } else { - retval += "Was expecting one of:" + eol + " "; + /** + * This method has the standard behavior when this object has been created + * using the standard constructors. Otherwise, it uses "currentToken" and + * "expectedTokenSequences" to generate a parse error message and returns + * it. If this object has been created due to a parse error, and you do not + * catch it (it gets thrown from the parser), then this method is called + * during the printing of the final stack trace, and hence the correct error + * message gets displayed. + */ + @Override + public String getMessage() { + if (!specialConstructor) { + return super.getMessage(); + } + String expected = ""; + int maxSize = 0; + for (int i = 0; i < expectedTokenSequences.length; i++) { + if (maxSize < expectedTokenSequences[i].length) { + maxSize = expectedTokenSequences[i].length; + } + for (int j = 0; j < expectedTokenSequences[i].length; j++) { + expected += tokenImage[expectedTokenSequences[i][j]] + " "; + } + if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { + expected += "..."; + } + expected += eol + " "; + } + String retval = "Encountered \""; + Token tok = currentToken.next; + for (int i = 0; i < maxSize; i++) { + if (i != 0) { + retval += " "; + } + if (tok.kind == 0) { + retval += tokenImage[0]; + break; + } + retval += add_escapes(tok.image); + tok = tok.next; + } + retval += "\" at line " + currentToken.next.beginLine + ", column " + + currentToken.next.beginColumn + "." + eol; + if (expectedTokenSequences.length == 1) { + retval += "Was expecting:" + eol + " "; + } else { + retval += "Was expecting one of:" + eol + " "; + } + retval += expected; + return retval; } - retval += expected.toString(); - return retval; - } - /** - * The end of line string for this machine. - */ - protected String eol = System.getProperty("line.separator", "\n"); + /** + * The end of line string for this machine. + */ + protected String eol = System.getProperty("line.separator", "\n"); - /** - * Used to convert raw characters to their escaped version - * when these raw version cannot be used as part of an ASCII - * string literal. - */ - static String add_escapes(String str) { - StringBuffer retval = new StringBuffer(); - char ch; - for (int i = 0; i < str.length(); i++) { - switch (str.charAt(i)) - { - case 0 : - continue; - case '\b': - retval.append("\\b"); - continue; - case '\t': - retval.append("\\t"); - continue; - case '\n': - retval.append("\\n"); - continue; - case '\f': - retval.append("\\f"); - continue; - case '\r': - retval.append("\\r"); - continue; - case '\"': - retval.append("\\\""); - continue; - case '\'': - retval.append("\\\'"); - continue; - case '\\': - retval.append("\\\\"); - continue; - default: - if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { - String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" + s.substring(s.length() - 4, s.length())); - } else { - retval.append(ch); - } - continue; + /** + * Used to convert raw characters to their escaped version when these raw + * version cannot be used as part of an ASCII string literal. + */ + protected String add_escapes(String str) { + StringBuffer retval = new StringBuffer(); + char ch; + for (int i = 0; i < str.length(); i++) { + switch (str.charAt(i)) { + case 0: + continue; + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u" + + s.substring(s.length() - 4, s.length())); + } else { + retval.append(ch); + } + continue; + } } - } - return retval.toString(); - } + return retval.toString(); + } } -/* JavaCC - OriginalChecksum=84fd1bce44783fb59914b382b6de4edc (do not edit this line) */ -- cgit v1.2.3 From 9be3b40801a73edae8b96c03670d8d2d029f0ee5 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Tue, 12 Nov 2013 17:12:30 +0200 Subject: Workaround for missing value change event in chrome (#10109) Change-Id: I019527041539fcd0083261b693767144492e626a --- client/src/com/vaadin/client/ui/VNativeSelect.java | 16 +++ ...tiveSelectsAndChromeKeyboardNavigationTest.java | 131 +++++++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsAndChromeKeyboardNavigationTest.java diff --git a/client/src/com/vaadin/client/ui/VNativeSelect.java b/client/src/com/vaadin/client/ui/VNativeSelect.java index 650ff7731a..04cc9e6624 100644 --- a/client/src/com/vaadin/client/ui/VNativeSelect.java +++ b/client/src/com/vaadin/client/ui/VNativeSelect.java @@ -21,6 +21,7 @@ import java.util.Iterator; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.user.client.ui.ListBox; +import com.vaadin.client.BrowserInfo; import com.vaadin.client.UIDL; public class VNativeSelect extends VOptionGroupBase implements Field { @@ -98,6 +99,21 @@ public class VNativeSelect extends VOptionGroupBase implements Field { // remove temporary empty item select.removeItem(0); firstValueIsTemporaryNullItem = false; + /* + * Workaround to achrome bug that may cause value change event not + * to fire when selection is done with keyboard. + * + * http://dev.vaadin.com/ticket/10109 + * + * Problem is confirmed to exist only on Chrome-Win, but just + * execute in for all webkits. Probably exists also in other + * webkits/blinks on windows. + */ + if (BrowserInfo.get().isWebkit()) { + select.getElement().blur(); + select.getElement().focus(); + } + } } diff --git a/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsAndChromeKeyboardNavigationTest.java b/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsAndChromeKeyboardNavigationTest.java new file mode 100644 index 0000000000..364d3bd8d4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsAndChromeKeyboardNavigationTest.java @@ -0,0 +1,131 @@ +/* + * Copyright 2000-2013 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.components.nativeselect; + +import java.util.Collections; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Keys; +import org.openqa.selenium.Platform; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class NativeSelectsAndChromeKeyboardNavigationTest extends + MultiBrowserTest { + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.tb3.MultiBrowserTest#getBrowsersToTest() + */ + @Override + public List getBrowsersToTest() { + DesiredCapabilities chrome = DesiredCapabilities.chrome(); + chrome.setPlatform(Platform.WINDOWS); + return Collections.singletonList(chrome); + } + + @Test + public void testValueChangeListenerWithKeyboardNavigation() + throws InterruptedException { + setDebug(true); + openTestURL(); + Thread.sleep(1000); + menu("Component"); + menuSub("Listeners"); + menuSub("Value change listener"); + + getDriver().findElement(By.tagName("body")).click(); + + WebElement select = getDriver().findElement(By.tagName("select")); + select.sendKeys(Keys.ARROW_DOWN); + select.sendKeys(Keys.ARROW_DOWN); + select.sendKeys(Keys.ARROW_DOWN); + + String bodytext = getDriver().findElement(By.tagName("body")).getText(); + + Assert.assertTrue(bodytext.contains("new value: 'Item 1'")); + Assert.assertTrue(bodytext.contains("new value: 'Item 2'")); + Assert.assertTrue(bodytext.contains("new value: 'Item 3'")); + + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.tb3.AbstractTB3Test#getUIClass() + */ + @Override + protected Class getUIClass() { + return NativeSelects.class; + } + + // Uncomment this to debug test in local/portforwarded chromedriver + // @Override + // protected void setupLocalDriver() { + // WebDriver chromeDriver; + // try { + // chromeDriver = new RemoteWebDriver( + // new URL("http://localhost:9515"), getBrowsersToTest() + // .iterator().next()); + // setDriver(chromeDriver); + // } catch (MalformedURLException e) { + // e.printStackTrace(); + // } + // } + // + // /* + // * (non-Javadoc) + // * + // * @see com.vaadin.tests.tb3.AbstractTB3Test#runLocally() + // */ + // @Override + // public boolean runLocally() { + // return false; + // } + + /** + * @since + * @param string + */ + private void menuSub(String string) { + getDriver().findElement(By.xpath("//span[text() = '" + string + "']")) + .click(); + new Actions(getDriver()).moveByOffset(100, 0).build().perform(); + } + + /** + * @since + * @param string + */ + private void menu(String string) { + getDriver().findElement(By.xpath("//span[text() = '" + string + "']")) + .click(); + + } + +} -- cgit v1.2.3 From 48034f6cc5b41687cf6d0c836838a11a4bdc39f0 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 13 Nov 2013 14:26:50 +0200 Subject: Ensure alternate text is still visible (#11780) Change-Id: Icfa54ec612153c3a92f83d7cb083685f7e77d295 --- WebContent/VAADIN/themes/base/browserframe/browserframe.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/WebContent/VAADIN/themes/base/browserframe/browserframe.scss b/WebContent/VAADIN/themes/base/browserframe/browserframe.scss index aa4225cf00..149e38a744 100644 --- a/WebContent/VAADIN/themes/base/browserframe/browserframe.scss +++ b/WebContent/VAADIN/themes/base/browserframe/browserframe.scss @@ -4,4 +4,8 @@ .v-browserframe { font-size: 0; } + /* Some times a browser frame can contain a span with altenate text */ + .v-browserframe > span { + font-size: $font-size; + } } \ No newline at end of file -- cgit v1.2.3 From cbc9949b6922d31c848f6288565c9c3de3359780 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Thu, 14 Nov 2013 11:41:40 +0200 Subject: Added test case for #12726 Change-Id: I396bfa4f255d64dd1729afa1be6771ff35026ad9 --- .../window/SubWindowsTextSelectionTest.java | 97 ++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/window/SubWindowsTextSelectionTest.java diff --git a/uitest/src/com/vaadin/tests/components/window/SubWindowsTextSelectionTest.java b/uitest/src/com/vaadin/tests/components/window/SubWindowsTextSelectionTest.java new file mode 100644 index 0000000000..1df036af58 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/SubWindowsTextSelectionTest.java @@ -0,0 +1,97 @@ +/* + * Copyright 2000-2013 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.components.window; + +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.Point; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Test for issue #12726, IE's make text selection when sub windows are + * dragged(moved). + * + * @since + * @author Vaadin Ltd + */ +public class SubWindowsTextSelectionTest extends MultiBrowserTest { + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.tb3.AbstractTB3Test#getUIClass() + */ + @Override + protected Class getUIClass() { + return SubWindows.class; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.tb3.MultiBrowserTest#getBrowsersToTest() + */ + @Override + public List getBrowsersToTest() { + ArrayList list = new ArrayList(); + list.add(BrowserUtil.ie(9)); + list.add(BrowserUtil.ie(10)); + list.add(BrowserUtil.ie(11)); + return list; + } + + @Test + public void verifyNoTextSelectionOnMove() throws MalformedURLException { + + openTestURL(); + + WebElement element = driver.findElement(By + .className("v-window-outerheader")); + + Point location = element.getLocation(); + + element.click(); + + new Actions(driver).moveToElement(element).perform(); + sleep(100); + // move pointer bit right from the caption text + new Actions(driver).moveByOffset(50, 0).clickAndHold() + .moveByOffset(10, 2).moveByOffset(10, 0).moveByOffset(10, 0) + .moveByOffset(10, 0).release().perform(); + + String selection = ((JavascriptExecutor) getDriver()).executeScript( + "return document.getSelection().toString();").toString(); + + Assert.assertTrue("Text selection was not empty:" + selection, + selection.isEmpty()); + + // Verify also that window was really moved + Point location2 = element.getLocation(); + Assert.assertEquals(location.getX() + (4 * 10), location2.getX()); + + } + +} -- cgit v1.2.3 From 07b1a9d75a139e6ee30e35b13bd4f8108c0350b3 Mon Sep 17 00:00:00 2001 From: Felype Santiago Ferreira Date: Mon, 11 Nov 2013 15:19:48 +0200 Subject: Prevents accidental selection of window caption or content. (#12726) Change-Id: Ida479ef0c421cf67b2863cf78c76b495337f30cf --- client/src/com/vaadin/client/ui/VWindow.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java index 03a65e8ece..e27ad383a9 100644 --- a/client/src/com/vaadin/client/ui/VWindow.java +++ b/client/src/com/vaadin/client/ui/VWindow.java @@ -708,6 +708,12 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, // dblclick handled in connector if (type != Event.ONDBLCLICK && draggable) { if (type == Event.ONMOUSEDOWN) { + /** + * Prevents accidental selection of window caption or + * content. (#12726) + */ + event.preventDefault(); + headerDragPending = event; } else if (type == Event.ONMOUSEMOVE && headerDragPending != null) { -- cgit v1.2.3 From e05e10eccf1886c1621421d584615a278dd44d62 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Thu, 14 Nov 2013 12:17:04 +0200 Subject: Added extra asserts to make test more safer to blind refactorings Change-Id: I5dd159640bdc4f188c291017032ca96ca8b85d11 --- .../tests/components/datefield/DateFieldTestTest.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldTestTest.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldTestTest.java index 557201e803..123fd167d0 100644 --- a/uitest/src/com/vaadin/tests/components/datefield/DateFieldTestTest.java +++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldTestTest.java @@ -35,9 +35,14 @@ public class DateFieldTestTest extends MultiBrowserTest { menu("Component"); menuSub("State"); menu("Required"); + assertRequiredIndicatorVisible(); assertNoErrorNotification(); } + private void assertRequiredIndicatorVisible() { + getDriver().findElement(By.className("v-required-field-indicator")); + } + private void assertNoErrorNotification() { try { getDriver().findElement( @@ -58,6 +63,8 @@ public class DateFieldTestTest extends MultiBrowserTest { menuSub("State"); menu("Required"); + assertRequiredIndicatorVisible(); + menu("Component"); menuSub("Features"); menuSub("Resolution"); @@ -100,8 +107,8 @@ public class DateFieldTestTest extends MultiBrowserTest { * @param string */ private void menuSub(String string) { - getDriver().findElement( - By.xpath("//span[text() = '" + string + "']")).click(); + getDriver().findElement(By.xpath("//span[text() = '" + string + "']")) + .click(); new Actions(getDriver()).moveByOffset(100, 0).build().perform(); } @@ -110,8 +117,8 @@ public class DateFieldTestTest extends MultiBrowserTest { * @param string */ private void menu(String string) { - getDriver().findElement( - By.xpath("//span[text() = '" + string + "']")).click(); + getDriver().findElement(By.xpath("//span[text() = '" + string + "']")) + .click(); } -- cgit v1.2.3 From 33e58977c266c3b5846bb2edc5e673359768ed2e Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 11 Nov 2013 20:41:09 +0200 Subject: Use localhost when running locally to avoid potential network issues Change-Id: Ie43604a2b41d2214d55d0976ba3c81ea361c8c56 --- uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java index caa35732d6..89fa304bfe 100644 --- a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java +++ b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java @@ -80,6 +80,9 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test { @Override protected String getDeploymentHostname() { + if (runLocally()) { + return "localhost"; + } String hostName = getProperty(HOSTNAME_PROPERTY); if (hostName == null || "".equals(hostName)) { -- cgit v1.2.3 From 642818fef200429d4206403e98aabd54ff3b6dd8 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 14 Nov 2013 09:38:05 +0200 Subject: Allow using @RunLocally to run on a local Firefox/Chrome/Safari Change-Id: Ibb1dfd12dc48637d8179f80322b5203ea5562805 --- .../com/vaadin/tests/VerifyBrowserVersionTest.java | 13 ++- .../actions/ActionsOnInvisibleComponentsTest.java | 8 +- ...tiveSelectsAndChromeKeyboardNavigationTest.java | 30 +------ .../tests/integration/AbstractIntegrationTest.java | 5 +- .../src/com/vaadin/tests/tb3/AbstractTB3Test.java | 96 ++++++++++++++++------ .../src/com/vaadin/tests/tb3/MultiBrowserTest.java | 35 +++++--- .../vaadin/tests/tb3/PrivateTB3Configuration.java | 33 ++++++-- uitest/src/com/vaadin/tests/tb3/TB3Runner.java | 8 +- uitest/src/com/vaadin/tests/tb3/WebsocketTest.java | 6 +- 9 files changed, 140 insertions(+), 94 deletions(-) diff --git a/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java b/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java index ae5806af56..bb0b40e2d1 100644 --- a/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java +++ b/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java @@ -30,23 +30,22 @@ public class VerifyBrowserVersionTest extends MultiBrowserTest { { expectedUserAgent - .put(BrowserUtil - .firefox(MultiBrowserTest.TESTED_FIREFOX_VERSION), + .put(Browser.FIREFOX.getDesiredCapabilities(), "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0"); expectedUserAgent - .put(BrowserUtil.ie(8), + .put(Browser.IE8.getDesiredCapabilities(), "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"); expectedUserAgent - .put(BrowserUtil.ie(9), + .put(Browser.IE9.getDesiredCapabilities(), "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"); expectedUserAgent - .put(BrowserUtil.ie(10), + .put(Browser.IE10.getDesiredCapabilities(), "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"); expectedUserAgent - .put(BrowserUtil.ie(11), + .put(Browser.IE11.getDesiredCapabilities(), "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko"); expectedUserAgent - .put(BrowserUtil.chrome(MultiBrowserTest.TESTED_CHROME_VERSION), + .put(Browser.CHROME.getDesiredCapabilities(), "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36"); } diff --git a/uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponentsTest.java b/uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponentsTest.java index ca00c998a6..1d08ee5ede 100644 --- a/uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponentsTest.java +++ b/uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponentsTest.java @@ -18,12 +18,12 @@ public class ActionsOnInvisibleComponentsTest extends MultiBrowserTest { public List getBrowsersToTest() { List browsers = super.getBrowsersToTest(); // sendKeys does nothing on these browsers - browsers.remove(BrowserUtil.firefox(24)); - browsers.remove(BrowserUtil.ie(8)); - browsers.remove(BrowserUtil.opera(12)); + browsers.remove(Browser.FIREFOX.getDesiredCapabilities()); + browsers.remove(Browser.IE8.getDesiredCapabilities()); + browsers.remove(Browser.OPERA.getDesiredCapabilities()); // Causes 'cannot focus element' - browsers.remove(BrowserUtil.chrome(29)); + browsers.remove(Browser.CHROME.getDesiredCapabilities()); return browsers; } diff --git a/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsAndChromeKeyboardNavigationTest.java b/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsAndChromeKeyboardNavigationTest.java index 364d3bd8d4..e038c451d0 100644 --- a/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsAndChromeKeyboardNavigationTest.java +++ b/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsAndChromeKeyboardNavigationTest.java @@ -22,7 +22,6 @@ import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; -import org.openqa.selenium.Platform; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.remote.DesiredCapabilities; @@ -44,9 +43,8 @@ public class NativeSelectsAndChromeKeyboardNavigationTest extends */ @Override public List getBrowsersToTest() { - DesiredCapabilities chrome = DesiredCapabilities.chrome(); - chrome.setPlatform(Platform.WINDOWS); - return Collections.singletonList(chrome); + return Collections.singletonList(Browser.CHROME + .getDesiredCapabilities()); } @Test @@ -84,30 +82,6 @@ public class NativeSelectsAndChromeKeyboardNavigationTest extends return NativeSelects.class; } - // Uncomment this to debug test in local/portforwarded chromedriver - // @Override - // protected void setupLocalDriver() { - // WebDriver chromeDriver; - // try { - // chromeDriver = new RemoteWebDriver( - // new URL("http://localhost:9515"), getBrowsersToTest() - // .iterator().next()); - // setDriver(chromeDriver); - // } catch (MalformedURLException e) { - // e.printStackTrace(); - // } - // } - // - // /* - // * (non-Javadoc) - // * - // * @see com.vaadin.tests.tb3.AbstractTB3Test#runLocally() - // */ - // @Override - // public boolean runLocally() { - // return false; - // } - /** * @since * @param string diff --git a/uitest/src/com/vaadin/tests/integration/AbstractIntegrationTest.java b/uitest/src/com/vaadin/tests/integration/AbstractIntegrationTest.java index ddaf84b3e1..cbb3a8b8e4 100644 --- a/uitest/src/com/vaadin/tests/integration/AbstractIntegrationTest.java +++ b/uitest/src/com/vaadin/tests/integration/AbstractIntegrationTest.java @@ -22,7 +22,7 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized.Parameters; import org.openqa.selenium.remote.DesiredCapabilities; -import com.vaadin.tests.tb3.MultiBrowserTest; +import com.vaadin.tests.tb3.MultiBrowserTest.Browser; import com.vaadin.tests.tb3.PrivateTB3Configuration; /** @@ -47,8 +47,7 @@ public abstract class AbstractIntegrationTest extends PrivateTB3Configuration { @Parameters public static Collection getBrowsersForTest() { - return Collections.singleton(BrowserUtil - .firefox(MultiBrowserTest.TESTED_FIREFOX_VERSION)); + return Collections.singleton(Browser.FIREFOX.getDesiredCapabilities()); } } diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index d4eed99f19..f6e58a51b2 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -16,6 +16,10 @@ package com.vaadin.tests.tb3; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.net.URL; import java.util.Collections; import java.util.List; @@ -39,6 +43,7 @@ import com.vaadin.server.UIProvider; import com.vaadin.testbench.TestBench; import com.vaadin.testbench.TestBenchTestCase; import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.tests.tb3.MultiBrowserTest.Browser; import com.vaadin.ui.UI; /** @@ -76,8 +81,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { private boolean push = false; { // Default browser to run on unless setDesiredCapabilities is called - desiredCapabilities = BrowserUtil - .firefox(MultiBrowserTest.TESTED_FIREFOX_VERSION); + desiredCapabilities = Browser.FIREFOX.getDesiredCapabilities(); } /** @@ -103,8 +107,9 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { * If something goes wrong */ protected void setupDriver() throws Exception { - if (runLocally()) { - setupLocalDriver(); + RunLocally runLocally = getClass().getAnnotation(RunLocally.class); + if (runLocally != null) { + setupLocalDriver(runLocally.value().getDesiredCapabilities()); return; } DesiredCapabilities capabilities = getDesiredCapabilities(); @@ -129,14 +134,10 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { } - /** - * Override and return true to run the test locally. This method is only to - * be used for developing tests. - * - * @return true to run the test on a local browser, false to use the hub - */ - public boolean runLocally() { - return false; + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + public @interface RunLocally { + public Browser value() default Browser.FIREFOX; } /** @@ -144,7 +145,8 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { * for debug purposes. Used only when {@link #runLocally()} is overridden to * return true; */ - protected abstract void setupLocalDriver(); + protected abstract void setupLocalDriver( + DesiredCapabilities desiredCapabilities); /** * Opens the given test (defined by {@link #getTestUrl()}, optionally with @@ -212,9 +214,8 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { * @return The browsers to run the test on */ public List getBrowsersToTest() { - return Collections.singletonList(BrowserUtil - .firefox(MultiBrowserTest.TESTED_FIREFOX_VERSION)); - + return Collections.singletonList(Browser.FIREFOX + .getDesiredCapabilities()); } /** @@ -738,8 +739,53 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { * @return true if the capabilities refer to IE8, false otherwise */ public static boolean isIE8(DesiredCapabilities capabilities) { - return BrowserType.IE.equals(capabilities.getBrowserName()) - && "8".equals(capabilities.getVersion()); + return isIE(capabilities) && "8".equals(capabilities.getVersion()); + } + + /** + * @param capabilities + * The capabilities to check + * @return true if the capabilities refer to Internet Explorer, false + * otherwise + */ + public static boolean isIE(DesiredCapabilities capabilities) { + return BrowserType.IE.equals(capabilities.getBrowserName()); + } + + /** + * @param capabilities + * The capabilities to check + * @return true if the capabilities refer to Chrome, false otherwise + */ + public static boolean isChrome(DesiredCapabilities capabilities) { + return BrowserType.CHROME.equals(capabilities.getBrowserName()); + } + + /** + * @param capabilities + * The capabilities to check + * @return true if the capabilities refer to Opera, false otherwise + */ + public static boolean isOpera(DesiredCapabilities capabilities) { + return BrowserType.OPERA.equals(capabilities.getBrowserName()); + } + + /** + * @param capabilities + * The capabilities to check + * @return true if the capabilities refer to Safari, false otherwise + */ + public static boolean isSafari(DesiredCapabilities capabilities) { + return BrowserType.SAFARI.equals(capabilities.getBrowserName()); + } + + /** + * @param capabilities + * The capabilities to check + * @return true if the capabilities refer to Firefox, false otherwise + */ + public static boolean isFirefox(DesiredCapabilities capabilities) { + return BrowserType.FIREFOX.equals(capabilities.getBrowserName()); } /** @@ -751,21 +797,19 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { */ public static String getBrowserIdentifier( DesiredCapabilities capabilities) { - String browserName = capabilities.getBrowserName(); - - if (BrowserType.IE.equals(browserName)) { + if (isIE(capabilities)) { return "InternetExplorer"; - } else if (BrowserType.FIREFOX.equals(browserName)) { + } else if (isFirefox(capabilities)) { return "Firefox"; - } else if (BrowserType.CHROME.equals(browserName)) { + } else if (isChrome(capabilities)) { return "Chrome"; - } else if (BrowserType.SAFARI.equals(browserName)) { + } else if (isSafari(capabilities)) { return "Safari"; - } else if (BrowserType.OPERA.equals(browserName)) { + } else if (isOpera(capabilities)) { return "Opera"; } - return browserName; + return capabilities.getBrowserName(); } /** diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java index e8a974343b..e166e421ef 100644 --- a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java +++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java @@ -40,23 +40,34 @@ import org.openqa.selenium.remote.DesiredCapabilities; */ public abstract class MultiBrowserTest extends PrivateTB3Configuration { - public static final int TESTED_SAFARI_VERSION = 7; - public static final int TESTED_CHROME_VERSION = 29; - public static final int TESTED_FIREFOX_VERSION = 24; + public enum Browser { + FIREFOX(BrowserUtil.firefox(24)), CHROME(BrowserUtil.chrome(29)), SAFARI( + BrowserUtil.safari(7)), IE8(BrowserUtil.ie(8)), IE9(BrowserUtil + .ie(9)), IE10(BrowserUtil.ie(10)), IE11(BrowserUtil.ie(11)), OPERA( + BrowserUtil.opera(17)); + private DesiredCapabilities desiredCapabilities; + + private Browser(DesiredCapabilities desiredCapabilities) { + this.desiredCapabilities = desiredCapabilities; + } + + public DesiredCapabilities getDesiredCapabilities() { + return desiredCapabilities; + } + } static List allBrowsers = new ArrayList(); static { - allBrowsers.add(BrowserUtil.ie(8)); - allBrowsers.add(BrowserUtil.ie(9)); - allBrowsers.add(BrowserUtil.ie(10)); - allBrowsers.add(BrowserUtil.ie(11)); - allBrowsers.add(BrowserUtil.firefox(TESTED_FIREFOX_VERSION)); + allBrowsers.add(Browser.IE8.getDesiredCapabilities()); + allBrowsers.add(Browser.IE9.getDesiredCapabilities()); + allBrowsers.add(Browser.IE10.getDesiredCapabilities()); + allBrowsers.add(Browser.IE11.getDesiredCapabilities()); + allBrowsers.add(Browser.FIREFOX.getDesiredCapabilities()); // Uncomment once we have the capability to run on Safari 6 - // allBrowsers.add(BrowserUtil.safari(TESTED_SAFARI_VERSION)); - allBrowsers.add(BrowserUtil.chrome(TESTED_CHROME_VERSION)); + // allBrowsers.add(SAFARI); + allBrowsers.add(Browser.CHROME.getDesiredCapabilities()); // Re-enable this when it is possible to run on a modern Opera version - // (15+) - // allBrowsers.add(BrowserUtil.opera(15)); + // allBrowsers.add(Browser.OPERA.getDesiredCapabilities()); } /** diff --git a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java index 89fa304bfe..543484fc14 100644 --- a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java +++ b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java @@ -26,8 +26,11 @@ import java.util.Enumeration; import java.util.Properties; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxBinary; import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.safari.SafariDriver; import com.vaadin.testbench.TestBench; @@ -80,7 +83,7 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test { @Override protected String getDeploymentHostname() { - if (runLocally()) { + if (getClass().getAnnotation(RunLocally.class) != null) { return "localhost"; } String hostName = getProperty(HOSTNAME_PROPERTY); @@ -148,17 +151,29 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test { * @see com.vaadin.tests.tb3.AbstractTB3Test#setupLocalDriver() */ @Override - protected void setupLocalDriver() { - String firefoxPath = getProperty("firefox.path"); + protected void setupLocalDriver(DesiredCapabilities desiredCapabilities) { WebDriver driver; - if (firefoxPath != null) { - driver = new FirefoxDriver( - new FirefoxBinary(new File(firefoxPath)), null); + if (BrowserUtil.isFirefox(desiredCapabilities)) { + String firefoxPath = getProperty("firefox.path"); + if (firefoxPath != null) { + driver = new FirefoxDriver(new FirefoxBinary(new File( + firefoxPath)), null); + } else { + driver = new FirefoxDriver(); + } + } else if (BrowserUtil.isChrome(desiredCapabilities)) { + System.setProperty("webdriver.chrome.driver", + getProperty("chrome.driver.path")); + driver = new ChromeDriver(); + } else if (BrowserUtil.isSafari(desiredCapabilities)) { + driver = new SafariDriver(); } else { - driver = new FirefoxDriver(); + throw new RuntimeException( + "Not implemented support for running locally on " + + BrowserUtil + .getBrowserIdentifier(desiredCapabilities)); } setDriver(TestBench.createDriver(driver)); - setDesiredCapabilities(BrowserUtil - .firefox(MultiBrowserTest.TESTED_FIREFOX_VERSION)); + setDesiredCapabilities(desiredCapabilities); } } diff --git a/uitest/src/com/vaadin/tests/tb3/TB3Runner.java b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java index 4e084ab0ed..eaffa80d09 100644 --- a/uitest/src/com/vaadin/tests/tb3/TB3Runner.java +++ b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java @@ -33,6 +33,7 @@ import org.junit.runners.model.Statement; import org.openqa.selenium.remote.DesiredCapabilities; import com.vaadin.tests.tb3.AbstractTB3Test.BrowserUtil; +import com.vaadin.tests.tb3.AbstractTB3Test.RunLocally; /** * This runner is loosely based on FactoryTestRunner by Ted Young @@ -76,10 +77,11 @@ public class TB3Runner extends BlockJUnit4ClassRunner { .getOnlyConstructor().newInstance(); Collection desiredCapabilites = testClassInstance .getBrowsersToTest(); - if (testClassInstance.runLocally()) { + if (testClassInstance.getClass().getAnnotation(RunLocally.class) != null) { desiredCapabilites = new ArrayList(); - desiredCapabilites.add(BrowserUtil - .firefox(MultiBrowserTest.TESTED_FIREFOX_VERSION)); + desiredCapabilites.add(testClassInstance.getClass() + .getAnnotation(RunLocally.class).value() + .getDesiredCapabilities()); } for (DesiredCapabilities capabilities : desiredCapabilites) { diff --git a/uitest/src/com/vaadin/tests/tb3/WebsocketTest.java b/uitest/src/com/vaadin/tests/tb3/WebsocketTest.java index 26fef667cd..e9ef11957c 100644 --- a/uitest/src/com/vaadin/tests/tb3/WebsocketTest.java +++ b/uitest/src/com/vaadin/tests/tb3/WebsocketTest.java @@ -25,6 +25,8 @@ import java.util.List; import org.openqa.selenium.remote.DesiredCapabilities; +import com.vaadin.tests.tb3.MultiBrowserTest.Browser; + /** * A {@link MultiBrowserTest} which restricts the tests to the browsers which * support websocket @@ -35,8 +37,8 @@ public abstract class WebsocketTest extends PrivateTB3Configuration { private static List websocketBrowsers = new ArrayList(); static { websocketBrowsers.addAll(MultiBrowserTest.getAllBrowsers()); - websocketBrowsers.remove(BrowserUtil.ie(8)); - websocketBrowsers.remove(BrowserUtil.ie(9)); + websocketBrowsers.remove(Browser.IE8.getDesiredCapabilities()); + websocketBrowsers.remove(Browser.IE9.getDesiredCapabilities()); } /** -- cgit v1.2.3 From 81a1c293f0e407db4a5443b85e57d32cddd397a7 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 15 Nov 2013 09:46:42 +0000 Subject: Revert "Fixed lost scrollLeft when row count changed in Table (#12652)." This reverts commit 533ddcda271b7226b38c035adf3073062c562653. Seems like the caused regressions are far from trivial to resolve. A new approach might be needed to resolve this issue. Change-Id: I88cf75608e8d47fffab5a366a8ad1b3b70c1c11f --- client/src/com/vaadin/client/Util.java | 37 ------- client/src/com/vaadin/client/ui/VScrollTable.java | 47 +-------- ...bleHorizontalScrollPositionOnItemSetChange.html | 110 --------------------- ...bleHorizontalScrollPositionOnItemSetChange.java | 101 ------------------- 4 files changed, 1 insertion(+), 294 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/table/TableHorizontalScrollPositionOnItemSetChange.html delete mode 100644 uitest/src/com/vaadin/tests/components/table/TableHorizontalScrollPositionOnItemSetChange.java diff --git a/client/src/com/vaadin/client/Util.java b/client/src/com/vaadin/client/Util.java index 7c7978be09..8972670232 100644 --- a/client/src/com/vaadin/client/Util.java +++ b/client/src/com/vaadin/client/Util.java @@ -447,35 +447,6 @@ public class Util { return detectedScrollbarSize; } - /** - * Calculates maximum horizontal scrolling value for the given element. - * - * @since 7.1.9 - * @param element - * which scrollLeft should be calculated - * @return maximum value for scrollLeft of the given element - */ - public static int getMaxScrollLeft(final Element element) { - int scrollWidth = element.getScrollWidth(); - int clientWidth = element.getClientWidth(); - return scrollWidth - clientWidth; - } - - /** - * Checks if scrollLeft of the element is at its maximum value. Returns - * false if the element can't be scrolled horizontally. - * - * @since 7.1.9 - * @param element - * which scrollLeft should be checked - * @return true, if scrollLeft is at maximum (false if element can't be - * scrolled horizontally) - */ - public static boolean isScrollLeftAtMax(final Element element) { - int scrollLeft = element.getScrollLeft(); - return scrollLeft != 0 && scrollLeft == getMaxScrollLeft(element); - } - /** * Run workaround for webkits overflow auto issue. * @@ -497,8 +468,6 @@ public class Util { // check the scrolltop value before hiding the element final int scrolltop = elem.getScrollTop(); final int scrollleft = elem.getScrollLeft(); - final boolean scrollLeftAtMax = isScrollLeftAtMax(elem); - elem.getStyle().setProperty("overflow", "hidden"); Scheduler.get().scheduleDeferred(new Command() { @@ -522,12 +491,6 @@ public class Util { elem.setScrollTop(scrollvalue); } - // keep horizontal scroll at max if it was before vertical - // scroll bar was added/removed - if (scrollLeftAtMax) { - elem.setScrollLeft(getMaxScrollLeft(elem)); - } - // fix for #6940 : Table horizontal scroll sometimes not // updated when collapsing/expanding columns // Also appeared in Safari 5.1 with webkit 534 (#7667) diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index d1d73f4e91..c56a2a8772 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -276,10 +276,6 @@ public class VScrollTable extends FlowPanel implements HasWidgets, */ private int detachedScrollPosition = 0; - // fields used in fixing erroneously lost scrollLeft - int lastScrollBodyHeight = 0; - boolean lastScrollLeftWasAtMax = false; - /** * Represents a select range of rows */ @@ -1009,15 +1005,6 @@ public class VScrollTable extends FlowPanel implements HasWidgets, initialContentReceived = true; sizeNeedsInit = true; scrollBody.restoreRowVisibility(); - - // At least FireFox requires that scrollLeft is restored deferred after - // scrollBody is recreated - Scheduler.get().scheduleFinally(new ScheduledCommand() { - @Override - public void execute() { - restoreScrollLeft(); - } - }); } /** For internal use only. May be removed or replaced in the future. */ @@ -6877,45 +6864,13 @@ public class VScrollTable extends FlowPanel implements HasWidgets, return s; } - /** - * Tries to restore horizontal scroll position if it was lost due to change - * in the height of scrollBody (#12652). - */ - private void restoreScrollLeft() { - int upcomingScrollLeft = scrollLeft; - - if (lastScrollLeftWasAtMax) { - upcomingScrollLeft = Util.getMaxScrollLeft(scrollBodyPanel - .getElement()); - } - scrollBodyPanel.getElement().setScrollLeft(upcomingScrollLeft); - } - - /** - * Checks if restore of scrollLeft is needed by checking if height of the - * scrollBody has changed. - * - * @return true, if restore is required - */ - private boolean isScrollLeftRestoreRequired() { - return (scrollBody.getElement().getClientHeight() != lastScrollBodyHeight); - } - /** * This method has logic which rows needs to be requested from server when * user scrolls */ + @Override public void onScroll(ScrollEvent event) { - // restore in initializeRows() doesn't work right with Chrome - if (isScrollLeftRestoreRequired()) { - restoreScrollLeft(); - } - - lastScrollBodyHeight = scrollBody.getElement().getClientHeight(); - lastScrollLeftWasAtMax = Util.isScrollLeftAtMax(scrollBodyPanel - .getElement()); - scrollLeft = scrollBodyPanel.getElement().getScrollLeft(); scrollTop = scrollBodyPanel.getScrollPosition(); /* diff --git a/uitest/src/com/vaadin/tests/components/table/TableHorizontalScrollPositionOnItemSetChange.html b/uitest/src/com/vaadin/tests/components/table/TableHorizontalScrollPositionOnItemSetChange.html deleted file mode 100644 index 6fd54ba0ca..0000000000 --- a/uitest/src/com/vaadin/tests/components/table/TableHorizontalScrollPositionOnItemSetChange.html +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - -TableHorizontalScrollPositionOnItemSetChange - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TableHorizontalScrollPositionOnItemSetChange
open/run/com.vaadin.tests.components.table.TableHorizontalScrollPositionOnItemSetChange?restartApplication
scrollLeftvaadin=runcomvaadintestscomponentstableTableHorizontalScrollPositionOnItemSetChange::PID_Shorscrolltable/domChild[1]326
pause500
clickvaadin=runcomvaadintestscomponentstableTableHorizontalScrollPositionOnItemSetChange::PID_Slessitems/domChild[0]/domChild[0]
pause500
screenCaptureleft-scroll-position-stays-in-middle-with-fewer-items
clickvaadin=runcomvaadintestscomponentstableTableHorizontalScrollPositionOnItemSetChange::PID_Smoreitems/domChild[0]/domChild[0]
pause500
screenCaptureleft-scroll-position-stays-in-middle-with-more-items
scrollLeftvaadin=runcomvaadintestscomponentstableTableHorizontalScrollPositionOnItemSetChange::PID_Shorscrolltable/domChild[1]653
pause500
clickvaadin=runcomvaadintestscomponentstableTableHorizontalScrollPositionOnItemSetChange::PID_Slessitems/domChild[0]/domChild[0]
pause500
screenCaptureleft-scroll-position-stays-max-with-fewer-items
clickvaadin=runcomvaadintestscomponentstableTableHorizontalScrollPositionOnItemSetChange::PID_Smoreitems/domChild[0]/domChild[0]
pause500
screenCaptureleft-scroll-position-stays-max-with-more-items
scrollLeftvaadin=runcomvaadintestscomponentstableTableHorizontalScrollPositionOnItemSetChange::PID_Shorscrolltable/domChild[1]0
- - diff --git a/uitest/src/com/vaadin/tests/components/table/TableHorizontalScrollPositionOnItemSetChange.java b/uitest/src/com/vaadin/tests/components/table/TableHorizontalScrollPositionOnItemSetChange.java deleted file mode 100644 index 1f59a84428..0000000000 --- a/uitest/src/com/vaadin/tests/components/table/TableHorizontalScrollPositionOnItemSetChange.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2000-2013 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.components.table; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Table; -import com.vaadin.ui.VerticalLayout; - -public class TableHorizontalScrollPositionOnItemSetChange extends - AbstractTestUI { - - @Override - protected void setup(VaadinRequest request) { - VerticalLayout layout = new VerticalLayout(); - layout.setMargin(true); - layout.setSpacing(true); - setContent(layout); - - final Table table = new Table(); - table.setWidth("640px"); - table.setHeight("243px"); - table.setId("horscrolltable"); - layout.addComponent(table); - - for (int i = 0; i < 15; i++) { - table.addContainerProperty("Column " + i, String.class, null); - } - - for (int i = 0; i < 60; i++) { - table.addItem(); - } - - Button lessItems = new Button("Less items", new Button.ClickListener() { - - @Override - public void buttonClick(Button.ClickEvent event) { - table.removeAllItems(); - for (int i = 0; i < 5; i++) { - table.addItem(); - } - } - }); - lessItems.setId("lessitems"); - - Button moreItems = new Button("More items", new Button.ClickListener() { - - @Override - public void buttonClick(Button.ClickEvent event) { - table.removeAllItems(); - for (int i = 0; i < 50; i++) { - table.addItem(); - } - } - }); - moreItems.setId("moreitems"); - - Button clearItems = new Button("Clear all", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - table.removeAllItems(); - } - }); - - HorizontalLayout buttonLayout = new HorizontalLayout(); - buttonLayout.setSpacing(true); - layout.addComponent(buttonLayout); - - buttonLayout.addComponent(lessItems); - buttonLayout.addComponent(moreItems); - buttonLayout.addComponent(clearItems); - clearItems.setId("clearitems"); - } - - @Override - protected String getTestDescription() { - return "Horizontal scrolling position should not be lost if amount of items changes in Table."; - } - - @Override - protected Integer getTicketNumber() { - return 12652; - } - -} -- cgit v1.2.3 From dde6a4893dd1c3d1bc040d58db6fd4cec012c74c Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 4 Nov 2013 18:10:05 +0200 Subject: Output test results in XML reports instead of to standard output This is a workaround for a problem with the integrated TeamCity JUnit listener which is not thread safe. Without this the test results are completely mixed up in TeamCity. For more information, see http://youtrack.jetbrains.com/issue/TW-33176. All standard JUnit test reports is put in result/reports. For uitest there are three report directories: result/reports-tb2, result/reports-tb3 and result/reports-integration to be able to clean the directories before running a given type of tests. This change is based on the separate fixes by John. Change-Id: I2f0dee416f6745544636f2f3dcea0d0832ff8076 --- common.xml | 17 +++++++++++++---- uitest/build.xml | 2 -- uitest/integration_tests.xml | 20 ++++++++++++++++---- uitest/tb3test.xml | 10 +++++++--- uitest/test.xml | 15 +++++++++++---- 5 files changed, 47 insertions(+), 17 deletions(-) diff --git a/common.xml b/common.xml index 88fbc49196..a1c086c57a 100644 --- a/common.xml +++ b/common.xml @@ -305,16 +305,20 @@ + + + + - - + + - + @@ -363,7 +367,12 @@ - + + + + + + diff --git a/uitest/build.xml b/uitest/build.xml index 76b75e9203..864d111023 100644 --- a/uitest/build.xml +++ b/uitest/build.xml @@ -150,8 +150,6 @@ Checkstyle is disabled for uitest for now - - WHAT? No JUnit tests for ${module.name}! diff --git a/uitest/integration_tests.xml b/uitest/integration_tests.xml index 73aac2405c..9f639b9cb5 100644 --- a/uitest/integration_tests.xml +++ b/uitest/integration_tests.xml @@ -27,6 +27,9 @@ + + + @@ -56,6 +59,7 @@ + @@ -69,6 +73,7 @@ + @@ -87,6 +92,7 @@ + @@ -105,16 +111,19 @@ - - - + + + + + + - + @@ -360,6 +369,9 @@ + + + diff --git a/uitest/tb3test.xml b/uitest/tb3test.xml index dd0c12db91..41cce8f0f2 100644 --- a/uitest/tb3test.xml +++ b/uitest/tb3test.xml @@ -2,6 +2,7 @@ + @@ -19,13 +20,16 @@ - - + + + + + - + diff --git a/uitest/test.xml b/uitest/test.xml index b0db8d47f4..57f61d67fa 100644 --- a/uitest/test.xml +++ b/uitest/test.xml @@ -3,7 +3,6 @@ - @@ -84,6 +83,11 @@ + + + + + @@ -103,13 +107,16 @@ - + + + - + @@ -129,7 +136,7 @@ - + -- cgit v1.2.3 From 012e649775e7efbcbbdd9d1c3ef4edd9c9acb71a Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Tue, 19 Nov 2013 15:06:16 +0200 Subject: Fix TB3 local testing and occasionally failing SliderDisableTest. Change-Id: I58e60e55838c3339c934cf975e5e148c8f09a78b --- .../tests/components/slider/SliderDisableTest.java | 1 + uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/uitest/src/com/vaadin/tests/components/slider/SliderDisableTest.java b/uitest/src/com/vaadin/tests/components/slider/SliderDisableTest.java index f6ec3dac3b..53521ee483 100644 --- a/uitest/src/com/vaadin/tests/components/slider/SliderDisableTest.java +++ b/uitest/src/com/vaadin/tests/components/slider/SliderDisableTest.java @@ -29,6 +29,7 @@ public class SliderDisableTest extends MultiBrowserTest { openTestURL(); WebElement element = vaadinElement("/VVerticalLayout[0]/Slot[0]/VSlider[0]/domChild[2]/domChild[0]"); new Actions(driver).dragAndDropBy(element, 112, 0).perform(); + testBench().waitForVaadin(); compareScreen("enabled"); vaadinElementById("disableButton").click(); compareScreen("disabled"); diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index f6e58a51b2..d7b7cd050f 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -107,16 +107,19 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { * If something goes wrong */ protected void setupDriver() throws Exception { + DesiredCapabilities capabilities; + RunLocally runLocally = getClass().getAnnotation(RunLocally.class); if (runLocally != null) { - setupLocalDriver(runLocally.value().getDesiredCapabilities()); - return; - } - DesiredCapabilities capabilities = getDesiredCapabilities(); + capabilities = runLocally.value().getDesiredCapabilities(); + setupLocalDriver(capabilities); + } else { + capabilities = getDesiredCapabilities(); - WebDriver dr = TestBench.createDriver(new RemoteWebDriver(new URL( - getHubURL()), capabilities)); - setDriver(dr); + WebDriver dr = TestBench.createDriver(new RemoteWebDriver(new URL( + getHubURL()), capabilities)); + setDriver(dr); + } int w = SCREENSHOT_WIDTH; int h = SCREENSHOT_HEIGHT; -- cgit v1.2.3 From 8d6256e98a63222f4b4969612d8d777a31974613 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 29 Nov 2013 11:53:20 +0200 Subject: Simplified support for null intermediate properties (#11435) Removed support for explicitly throwing NPE for intermediate properties as no use case could be identified where this would be the expected or wanted behavior. Change-Id: I10696467f792e234326075bbcdd5aad487905a7e --- .../vaadin/data/util/AbstractBeanContainer.java | 67 +++------------------- server/src/com/vaadin/data/util/BeanItem.java | 30 ++-------- .../com/vaadin/data/util/NestedMethodProperty.java | 63 ++------------------ .../vaadin/data/util/NestedPropertyDescriptor.java | 24 +------- .../com/vaadin/data/util/BeanContainerTest.java | 11 +--- .../vaadin/data/util/BeanItemContainerTest.java | 14 +---- .../vaadin/data/util/NestedMethodPropertyTest.java | 43 +++----------- .../vaadin/data/util/PropertyDescriptorTest.java | 8 +-- 8 files changed, 35 insertions(+), 225 deletions(-) diff --git a/server/src/com/vaadin/data/util/AbstractBeanContainer.java b/server/src/com/vaadin/data/util/AbstractBeanContainer.java index 67239996a2..d94588bdc9 100644 --- a/server/src/com/vaadin/data/util/AbstractBeanContainer.java +++ b/server/src/com/vaadin/data/util/AbstractBeanContainer.java @@ -848,8 +848,9 @@ public abstract class AbstractBeanContainer extends * Adds a nested container property for the container, e.g. * "manager.address.street". * - * All intermediate getters must exist and must return non-null values when - * the property value is accessed. + * All intermediate getters must exist and should return non-null values + * when the property value is accessed. If an intermediate getter returns + * null, a null value will be returned. * * @see NestedMethodProperty * @@ -857,32 +858,8 @@ public abstract class AbstractBeanContainer extends * @return true if the property was added */ public boolean addNestedContainerProperty(String propertyId) { - return addNestedContainerProperty(propertyId, false); - } - - /** - * Adds a nested container property for the container, e.g. - * "manager.address.street". - * - * All intermediate getters must exist and must return non-null values when - * the property value is accessed or the nullBeansAllowed must - * be set to true. If the nullBeansAllowed flag is set to true, - * calling getValue of the added property will return null if the property - * or any of its intermediate getters returns null. If set to false, null - * values returned by intermediate getters will cause NullPointerException. - * The default value is false to ensure backwards compatibility. - * - * @see NestedMethodProperty - * - * @param propertyId - * @param nullBeansAllowed - * set true to allow null values from intermediate getters - * @return true if the property was added - */ - public boolean addNestedContainerProperty(String propertyId, - boolean nullBeansAllowed) { return addContainerProperty(propertyId, new NestedPropertyDescriptor( - propertyId, type, nullBeansAllowed)); + propertyId, type)); } /** @@ -890,8 +867,9 @@ public abstract class AbstractBeanContainer extends * property to the container. The named property itself is removed from the * model as its subproperties are added. * - * All intermediate getters must exist and must return non-null values when - * the property value is accessed. + * All intermediate getters must exist and should return non-null values + * when the property value is accessed. If an intermediate getter returns + * null, a null value will be returned. * * @see NestedMethodProperty * @see #addNestedContainerProperty(String) @@ -900,42 +878,13 @@ public abstract class AbstractBeanContainer extends */ @SuppressWarnings("unchecked") public void addNestedContainerBean(String propertyId) { - addNestedContainerBean(propertyId, false); - } - - /** - * Adds a nested container properties for all sub-properties of a named - * property to the container. The named property itself is removed from the - * model as its subproperties are added. - * - * Unless - * nullBeansAllowed is set to true, all intermediate getters must - * exist and must return non-null values when the property values are - * accessed. If the nullBeansAllowed flag is set to true, - * calling getValue of the added subproperties will return null if the - * property or any of their intermediate getters returns null. If set to - * false, null values returned by intermediate getters will cause - * NullPointerException. The default value is false to ensure backwards - * compatibility. - * - * @see NestedMethodProperty - * @see #addNestedContainerProperty(String) - * - * @param propertyId - * @param nullBeansAllowed - * set true to allow null values from intermediate getters - */ - @SuppressWarnings("unchecked") - public void addNestedContainerBean(String propertyId, - boolean nullBeansAllowed) { Class propertyType = getType(propertyId); LinkedHashMap> pds = BeanItem .getPropertyDescriptors((Class) propertyType); for (String subPropertyId : pds.keySet()) { String qualifiedPropertyId = propertyId + "." + subPropertyId; NestedPropertyDescriptor pd = new NestedPropertyDescriptor( - qualifiedPropertyId, (Class) type, - nullBeansAllowed); + qualifiedPropertyId, (Class) type); model.put(qualifiedPropertyId, pd); model.remove(propertyId); for (BeanItem item : itemIdToItem.values()) { diff --git a/server/src/com/vaadin/data/util/BeanItem.java b/server/src/com/vaadin/data/util/BeanItem.java index 4834fe4f89..49f5f95898 100644 --- a/server/src/com/vaadin/data/util/BeanItem.java +++ b/server/src/com/vaadin/data/util/BeanItem.java @@ -255,39 +255,19 @@ public class BeanItem extends PropertysetItem { } /** - * Adds a nested property to the item. + * Adds a nested property to the item. The property must not exist in the + * item already and must of form "field1.field2" where field2 is a field in + * the object referenced to by field1. If an intermediate property returns + * null, the property will return a null value * * @param nestedPropertyId - * property id to add. This property must not exist in the item - * already and must of of form "field1.field2" where field2 is a - * field in the object referenced to by field1 + * property id to add. */ public void addNestedProperty(String nestedPropertyId) { addItemProperty(nestedPropertyId, new NestedMethodProperty( getBean(), nestedPropertyId)); } - /** - * Adds a nested property to the item. If the nullBeansAllowed - * flag is set to true, calling getValue of the added property will return - * null if the property or any of its intermediate getters returns null. If - * set to false, null values returned by intermediate getters will cause - * NullPointerException. The default value is false to ensure backwards - * compatibility. - * - * @param nestedPropertyId - * property id to add. This property must not exist in the item - * already and must of of form "field1.field2" where field2 is a - * field in the object referenced to by field1 - * @param nullBeansAllowed - * set true to allow null values from intermediate getters - */ - public void addNestedProperty(String nestedPropertyId, - boolean nullBeansAllowed) { - addItemProperty(nestedPropertyId, new NestedMethodProperty( - getBean(), nestedPropertyId, nullBeansAllowed)); - } - /** * Gets the underlying JavaBean object. * diff --git a/server/src/com/vaadin/data/util/NestedMethodProperty.java b/server/src/com/vaadin/data/util/NestedMethodProperty.java index 7a3963c17e..8fe3b9d4c5 100644 --- a/server/src/com/vaadin/data/util/NestedMethodProperty.java +++ b/server/src/com/vaadin/data/util/NestedMethodProperty.java @@ -31,8 +31,9 @@ import com.vaadin.data.util.MethodProperty.MethodException; * The property is specified in the dotted notation, e.g. "address.street", and * can contain multiple levels of nesting. * - * When accessing the property value, all intermediate getters must return - * non-null values or the nullBeansAllowed must be set to true. + * When accessing the property value, all intermediate getters must exist and + * should return non-null values when the property value is accessed. If an + * intermediate getter returns null, a null value will be returned. * * @see MethodProperty * @@ -55,15 +56,6 @@ public class NestedMethodProperty extends AbstractProperty { */ private Object instance; - /** - * a boolean flag indicating whether intermediate getters may return null - * values. If the flag is set to true, calling getValue will return null if - * the property or any of its intermediate getters returns null. If set to - * false, intermediate getters returning null value will throw Exception. - * The default value is false to ensure backwards compatibility. - */ - private boolean nullBeansAllowed = false; - private Class type; /* Special serialization to handle method references */ @@ -85,6 +77,8 @@ public class NestedMethodProperty extends AbstractProperty { * Constructs a nested method property for a given object instance. The * property name is a dot separated string pointing to a nested property, * e.g. "manager.address.street". + *

+ * Calling getValue will return null if any intermediate getter returns null * * @param instance * top-level bean to which the property applies @@ -94,33 +88,7 @@ public class NestedMethodProperty extends AbstractProperty { * if the property name is invalid */ public NestedMethodProperty(Object instance, String propertyName) { - this(instance, propertyName, false); - } - - /** - * Constructs a nested method property for a given object instance. The - * property name is a dot separated string pointing to a nested property, - * e.g. "manager.address.street". The nullBeansAllowed controls - * the behavior in cases where the intermediate getters may return null - * values. If the flag is set to true, calling getValue will return null if - * the property or any of its intermediate getters returns null. If set to - * false, null values returned by intermediate getters will cause - * NullPointerException. The default value is false to ensure backwards - * compatibility. - * - * @param instance - * top-level bean to which the property applies - * @param propertyName - * dot separated nested property name - * @param nullBeansAllowed - * set true to allow null values from intermediate getters - * @throws IllegalArgumentException - * if the property name is invalid - */ - public NestedMethodProperty(Object instance, String propertyName, - boolean nullBeansAllowed) { this.instance = instance; - this.nullBeansAllowed = nullBeansAllowed; initialize(instance.getClass(), propertyName); } @@ -138,25 +106,6 @@ public class NestedMethodProperty extends AbstractProperty { initialize(instanceClass, propertyName); } - /** - * For internal use to deduce property type etc. without a bean instance. - * Calling {@link #setValue(Object)} or {@link #getValue()} on properties - * constructed this way is not supported. - * - * @param instanceClass - * class of the top-level bean - * @param propertyName - * dot separated nested property name - * @param nullBeansAllowed - * set true to allow null values from intermediate getters - */ - NestedMethodProperty(Class instanceClass, String propertyName, - boolean nullBeansAllowed) { - instance = null; - this.nullBeansAllowed = nullBeansAllowed; - initialize(instanceClass, propertyName); - } - /** * Initializes most of the internal fields based on the top-level bean * instance and property name (dot-separated string). @@ -253,7 +202,7 @@ public class NestedMethodProperty extends AbstractProperty { Object object = instance; for (Method m : getMethods) { object = m.invoke(object); - if (object == null && nullBeansAllowed) { + if (object == null) { return null; } } diff --git a/server/src/com/vaadin/data/util/NestedPropertyDescriptor.java b/server/src/com/vaadin/data/util/NestedPropertyDescriptor.java index 67eb30fae5..b2055fe776 100644 --- a/server/src/com/vaadin/data/util/NestedPropertyDescriptor.java +++ b/server/src/com/vaadin/data/util/NestedPropertyDescriptor.java @@ -34,7 +34,6 @@ public class NestedPropertyDescriptor implements private final String name; private final Class propertyType; - private final boolean nullBeansAllowed; /** * Creates a property descriptor that can create MethodProperty instances to @@ -49,29 +48,10 @@ public class NestedPropertyDescriptor implements */ public NestedPropertyDescriptor(String name, Class beanType) throws IllegalArgumentException { - this(name, beanType, false); - } - - /** - * Creates a property descriptor that can create MethodProperty instances to - * access the underlying bean property. - * - * @param name - * of the property in a dotted path format, e.g. "address.street" - * @param beanType - * type (class) of the top-level bean - * @param nullBeansAllowed - * set true to allow null values from intermediate getters - * @throws IllegalArgumentException - * if the property name is invalid - */ - public NestedPropertyDescriptor(String name, Class beanType, - boolean nullBeansAllowed) throws IllegalArgumentException { this.name = name; NestedMethodProperty property = new NestedMethodProperty( - beanType, name, nullBeansAllowed); + beanType, name); this.propertyType = property.getType(); - this.nullBeansAllowed = nullBeansAllowed; } @Override @@ -86,7 +66,7 @@ public class NestedPropertyDescriptor implements @Override public Property createProperty(BT bean) { - return new NestedMethodProperty(bean, name, nullBeansAllowed); + return new NestedMethodProperty(bean, name); } } diff --git a/server/tests/src/com/vaadin/data/util/BeanContainerTest.java b/server/tests/src/com/vaadin/data/util/BeanContainerTest.java index 2dcbb4aed8..a6c3bb0b8b 100644 --- a/server/tests/src/com/vaadin/data/util/BeanContainerTest.java +++ b/server/tests/src/com/vaadin/data/util/BeanContainerTest.java @@ -465,20 +465,11 @@ public class BeanContainerTest extends AbstractBeanContainerTest { container.addBean(new NestedMethodPropertyTest.Person("John", null)); assertTrue(container .addNestedContainerProperty("address.postalCodeObject")); - assertTrue(container.addNestedContainerProperty("address.street", true)); + assertTrue(container.addNestedContainerProperty("address.street")); // the nested properties added with allowNullBean setting should return // null assertNull(container.getContainerProperty("John", "address.street") .getValue()); - // nested properties added without allowNullBean setting should throw - // exception - try { - container.getContainerProperty("John", "address.postalCodeObject") - .getValue(); - fail(); - } catch (Exception e) { - // should throw exception - } } } diff --git a/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java b/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java index 35f09fc8f3..b9633753b4 100644 --- a/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java +++ b/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java @@ -729,20 +729,10 @@ public class BeanItemContainerTest extends AbstractBeanContainerTest { assertNotNull(container.addBean(john)); assertTrue(container .addNestedContainerProperty("address.postalCodeObject")); - assertTrue(container.addNestedContainerProperty("address.street", true)); - // the nested properties added with allowNullBean setting should return - // null + assertTrue(container.addNestedContainerProperty("address.street")); + // the nested properties should return null assertNull(container.getContainerProperty(john, "address.street") .getValue()); - // nested properties added without allowNullBean setting should throw - // exception - try { - container.getContainerProperty(john, "address.postalCodeObject") - .getValue(); - fail(); - } catch (Exception e) { - // should throw exception - } } public void testItemAddedEvent() { diff --git a/server/tests/src/com/vaadin/data/util/NestedMethodPropertyTest.java b/server/tests/src/com/vaadin/data/util/NestedMethodPropertyTest.java index d517322010..1133626df9 100644 --- a/server/tests/src/com/vaadin/data/util/NestedMethodPropertyTest.java +++ b/server/tests/src/com/vaadin/data/util/NestedMethodPropertyTest.java @@ -7,9 +7,10 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; -import junit.framework.Assert; import junit.framework.TestCase; +import org.junit.Assert; + public class NestedMethodPropertyTest extends TestCase { public static class Address implements Serializable { @@ -248,46 +249,16 @@ public class NestedMethodPropertyTest extends TestCase { vaadin, "manager.address.street"); joonas.setAddress(null); - try { - streetProperty.getValue(); - fail(); - } catch (Exception e) { - // should get exception - } + assertNull(streetProperty.getValue()); vaadin.setManager(null); - try { - managerNameProperty.getValue(); - fail(); - } catch (Exception e) { - // should get exception - } - try { - streetProperty.getValue(); - fail(); - } catch (Exception e) { - // should get exception - } + assertNull(managerNameProperty.getValue()); + assertNull(streetProperty.getValue()); vaadin.setManager(joonas); Assert.assertEquals("Joonas", managerNameProperty.getValue()); - } - - public void testNullNestedPropertyWithAllowNullBeans() { - NestedMethodProperty managerNameProperty = new NestedMethodProperty( - vaadin, "manager.name", true); - NestedMethodProperty streetProperty = new NestedMethodProperty( - vaadin, "manager.address.street", true); - - joonas.setAddress(null); - // should return null Assert.assertNull(streetProperty.getValue()); - vaadin.setManager(null); - Assert.assertNull(managerNameProperty.getValue()); - vaadin.setManager(joonas); - Assert.assertEquals("Joonas", managerNameProperty.getValue()); - Assert.assertNull(streetProperty.getValue()); } public void testMultiLevelNestedPropertySetValue() { @@ -331,11 +302,11 @@ public class NestedMethodPropertyTest extends TestCase { Assert.assertEquals("Ruukinkatu 2-4", property2.getValue()); } - public void testSerializationWithNullBeansAllowed() throws IOException, + public void testSerializationWithIntermediateNull() throws IOException, ClassNotFoundException { vaadin.setManager(null); NestedMethodProperty streetProperty = new NestedMethodProperty( - vaadin, "manager.address.street", true); + vaadin, "manager.address.street"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); new ObjectOutputStream(baos).writeObject(streetProperty); @SuppressWarnings("unchecked") diff --git a/server/tests/src/com/vaadin/data/util/PropertyDescriptorTest.java b/server/tests/src/com/vaadin/data/util/PropertyDescriptorTest.java index 0ae76430f6..12ded84fe2 100644 --- a/server/tests/src/com/vaadin/data/util/PropertyDescriptorTest.java +++ b/server/tests/src/com/vaadin/data/util/PropertyDescriptorTest.java @@ -39,7 +39,8 @@ public class PropertyDescriptorTest extends TestCase { Assert.assertEquals("John", property.getValue()); } - public void testNestedPropertyDescriptorSerialization() throws Exception { + public void testSimpleNestedPropertyDescriptorSerialization() + throws Exception { NestedPropertyDescriptor pd = new NestedPropertyDescriptor( "name", Person.class); @@ -53,10 +54,9 @@ public class PropertyDescriptorTest extends TestCase { Assert.assertEquals("John", property.getValue()); } - public void testNestedPropertyDescriptorWithNullBeansAllowedSerialization() - throws Exception { + public void testNestedPropertyDescriptorSerialization() throws Exception { NestedPropertyDescriptor pd = new NestedPropertyDescriptor( - "address.street", Person.class, true); + "address.street", Person.class); ByteArrayOutputStream baos = new ByteArrayOutputStream(); new ObjectOutputStream(baos).writeObject(pd); -- cgit v1.2.3