From c5df7f5bf60cea004e146cf559f4f36de6e9c48b Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Tue, 8 Jul 2014 18:19:28 +0300 Subject: Box and unbox long values in state fields (#14176) We actually want to pass around the primitive long values emulated by GWT even though JavaScript code can't do anything with the values. Skipping the unboxing caused long fields to always be 0 since that's how JavaScript converts an object into a number. This patch also makes the test assert that the expected state values are received and updates those values to actually make sense in some situations. Change-Id: Id9c3696d699593bd9e59e249c5daf077873b85fc --- .../vaadin/tests/serialization/SerializerTest.java | 8 +++--- .../tests/serialization/SerializerTestTest.java | 31 ++++++++++++++++++++++ .../widgetset/client/SerializerTestConnector.java | 13 ++++----- 3 files changed, 42 insertions(+), 10 deletions(-) (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/serialization/SerializerTest.java b/uitest/src/com/vaadin/tests/serialization/SerializerTest.java index 1c18fb1912..333964e9bf 100644 --- a/uitest/src/com/vaadin/tests/serialization/SerializerTest.java +++ b/uitest/src/com/vaadin/tests/serialization/SerializerTest.java @@ -93,13 +93,13 @@ public class SerializerTest extends AbstractTestUI { rpc.sendInt(Integer.MAX_VALUE, Integer.valueOf(0), new int[] { 5, 7 }); state.intValue = Integer.MAX_VALUE; - state.intObjectValue = Integer.valueOf(0); + state.intObjectValue = Integer.valueOf(42); state.intArray = new int[] { 5, 7 }; rpc.sendLong(577431841358l, Long.valueOf(0), new long[] { -57841235865l, 57 }); - state.longValue = 577431841358l; - state.longObjectValue = Long.valueOf(0); + state.longValue = 577431841359l; + state.longObjectValue = Long.valueOf(577431841360l); state.longArray = new long[] { -57841235865l, 57 }; rpc.sendFloat(3.14159f, Float.valueOf(Math.nextUp(1)), new float[] { @@ -111,7 +111,7 @@ public class SerializerTest extends AbstractTestUI { rpc.sendDouble(Math.PI, Double.valueOf(-Math.E), new double[] { Double.MAX_VALUE, Double.MIN_VALUE }); state.doubleValue = Math.PI; - state.doubleValue = Double.valueOf(-Math.E); + state.doubleObjectValue = Double.valueOf(-Math.E); state.doubleArray = new double[] { Double.MAX_VALUE, Double.MIN_VALUE }; rpc.sendString("This is a tesing string ‡"); diff --git a/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java b/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java index 5ca1e9ce6a..47bb212347 100644 --- a/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java +++ b/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java @@ -77,5 +77,36 @@ public class SerializerTestTest extends MultiBrowserTest { "sendBoolean: false, false, [false, false, true, false, true, true]", getLogRow(logRow++)); Assert.assertEquals("sendBeanSubclass: 43", getLogRow(logRow++)); + Assert.assertEquals( + "state.doubleArray: [1.7976931348623157e+308, 5e-324]", + getLogRow(logRow++)); + Assert.assertEquals("state.doubleObjectValue: -2.718281828459045", + getLogRow(logRow++)); + Assert.assertEquals("state.doubleValue: 3.141592653589793", + getLogRow(logRow++)); + Assert.assertEquals("state.floatArray: [57, 0, -12]", + getLogRow(logRow++)); + Assert.assertEquals("state.floatObjectValue: 1.0000001", + getLogRow(logRow++)); + Assert.assertEquals("state.floatValue: 3.14159", getLogRow(logRow++)); + Assert.assertEquals("state.longArray: [-57841235865, 57]", + getLogRow(logRow++)); + Assert.assertEquals("state.longObjectValue: 577431841360", + getLogRow(logRow++)); + Assert.assertEquals("state.longValue: 577431841359", + getLogRow(logRow++)); + Assert.assertEquals("state.intArray: [5, 7]", getLogRow(logRow++)); + Assert.assertEquals("state.intObjectValue: 42", getLogRow(logRow++)); + Assert.assertEquals("state.intValue: 2147483647", getLogRow(logRow++)); + Assert.assertEquals("state.charArray: aBcD", getLogRow(logRow++)); + Assert.assertEquals("state.charObjectValue: å", getLogRow(logRow++)); + Assert.assertEquals("state.charValue: ∫", getLogRow(logRow++)); + Assert.assertEquals("state.byteArray: [3, 1, 2]", getLogRow(logRow++)); + Assert.assertEquals("state.byteObjectValue: -12", getLogRow(logRow++)); + Assert.assertEquals("state.byteValue: 5", getLogRow(logRow++)); + Assert.assertEquals( + "state.booleanArray: [true, true, false, true, false, false]", + getLogRow(logRow++)); + } } diff --git a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java index 0ef4b664ac..7758cdc2ac 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java @@ -284,11 +284,12 @@ public class SerializerTestConnector extends AbstractExtensionConnector { public void onStateChanged(StateChangeEvent stateChangeEvent) { rpc.log("state.booleanValue: " + getState().booleanValue); rpc.log("state.booleanObjectValue: " + getState().booleanObjectValue); - rpc.log("state.booleanArray: " + getState().booleanArray); + rpc.log("state.booleanArray: " + + Arrays.toString(getState().booleanArray)); rpc.log("state.byteValue: " + getState().byteValue); rpc.log("state.byteObjectValue: " + getState().byteObjectValue); - rpc.log("state.byteArray: " + getState().byteArray); + rpc.log("state.byteArray: " + Arrays.toString(getState().byteArray)); rpc.log("state.charValue: " + getState().charValue); rpc.log("state.charObjectValue: " + getState().charObjectValue); @@ -296,19 +297,19 @@ public class SerializerTestConnector extends AbstractExtensionConnector { rpc.log("state.intValue: " + getState().intValue); rpc.log("state.intObjectValue: " + getState().intObjectValue); - rpc.log("state.intArray: " + getState().intArray); + rpc.log("state.intArray: " + Arrays.toString(getState().intArray)); rpc.log("state.longValue: " + getState().longValue); rpc.log("state.longObjectValue: " + getState().longObjectValue); - rpc.log("state.longArray: " + getState().longArray); + rpc.log("state.longArray: " + Arrays.toString(getState().longArray)); rpc.log("state.floatValue: " + getState().floatValue); rpc.log("state.floatObjectValue: " + getState().floatObjectValue); - rpc.log("state.floatArray: " + getState().floatArray); + rpc.log("state.floatArray: " + Arrays.toString(getState().floatArray)); rpc.log("state.doubleValue: " + getState().doubleValue); rpc.log("state.doubleObjectValue: " + getState().doubleObjectValue); - rpc.log("state.doubleArray: " + getState().doubleArray); + rpc.log("state.doubleArray: " + Arrays.toString(getState().doubleArray)); /* * TODO public double doubleValue; public Double DoubleValue; public -- cgit v1.2.3