summaryrefslogtreecommitdiffstats
path: root/uitest/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'uitest/src/com')
-rw-r--r--uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java30
-rw-r--r--uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponentConnector.js2
-rw-r--r--uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponentTest.java97
-rw-r--r--uitest/src/com/vaadin/tests/serialization/SerializerTest.java21
-rw-r--r--uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java10
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java13
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/SerializerTestRpc.java3
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/SerializerTestState.java1
8 files changed, 173 insertions, 4 deletions
diff --git a/uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java b/uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java
index bd7522aab7..1e193fc3b4 100644
--- a/uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java
+++ b/uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java
@@ -36,7 +36,10 @@ import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.HasComponents;
import com.vaadin.ui.JavaScriptFunction;
+
import elemental.json.JsonArray;
+import elemental.json.JsonObject;
+import elemental.json.JsonValue;
public class BasicJavaScriptComponent extends AbstractTestUI {
@@ -103,6 +106,31 @@ public class BasicJavaScriptComponent extends AbstractTestUI {
}
});
+ addFunction("sendDifferentTypeOfData", new JavaScriptFunction() {
+ @Override
+ public void call(JsonArray arguments) {
+ for (int i = 0; i < arguments.length(); i++) {
+ JsonValue arg = arguments.get(i);
+ if (arg instanceof JsonObject) {
+ JsonObject o = (JsonObject) arg;
+ log.log("Argument[" + i + "] type: "
+ + arg.getClass().getName());
+ for (String key : o.keys()) {
+ JsonValue v = o.get(key);
+ log.log("Argument[" + i + "][" + key
+ + "] type: " + v.getClass().getName()
+ + ", value: " + v.asString());
+
+ }
+ } else {
+ log.log("Argument[" + i + "] type: "
+ + arg.getClass().getName() + ", value: "
+ + arg.asString());
+ }
+ }
+ }
+ });
+
getRpcProxy(TestRpc.class).sendRpc("RPC message");
callFunction("messageToClient", "Callback message");
@@ -136,7 +164,7 @@ public class BasicJavaScriptComponent extends AbstractTestUI {
}
}
- private final Log log = new Log(5);
+ private final Log log = new Log(15);
@Override
protected void setup(VaadinRequest request) {
diff --git a/uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponentConnector.js b/uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponentConnector.js
index 004d34040e..183bf6af9c 100644
--- a/uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponentConnector.js
+++ b/uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponentConnector.js
@@ -6,8 +6,8 @@ window.com_vaadin_tests_components_javascriptcomponent_BasicJavaScriptComponent_
parentIds.push(connectorId);
connectorId = this.getParentId(connectorId);
}
+ this.sendDifferentTypeOfData(new Date(123), "a string", 556, true ,{"aString": "value1","anInt":556,"aBoolean":false,"aDate":new Date(111)});
this.reportParentIds(parentIds);
-
this.onStateChange = function() {
var e = this.getElement();
diff --git a/uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponentTest.java b/uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponentTest.java
new file mode 100644
index 0000000000..ea610dccda
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponentTest.java
@@ -0,0 +1,97 @@
+package com.vaadin.tests.components.javascriptcomponent;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+
+import com.vaadin.testbench.elements.AbstractComponentElement;
+import com.vaadin.testbench.elements.AbstractJavaScriptComponentElement;
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.parallel.BrowserUtil;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class BasicJavaScriptComponentTest extends MultiBrowserTest {
+ @Test
+ public void javascriptCommunication() throws Exception {
+ openTestURL();
+ int idx = 0;
+ Assert.assertEquals(
+ "12. Got callback message: Callback message processed",
+ getLogRow(idx++));
+ Assert.assertEquals("11. Got RPC message: RPC message processed",
+ getLogRow(idx++));
+ Assert.assertEquals("10. Parent ids checked", getLogRow(idx++));
+
+ // Data types in JS functions
+ String expected = "1970-01-01T00:00:00.111Z";
+ if (BrowserUtil.isIE8(getDesiredCapabilities())) {
+ expected = "1970-01-01T00:00:00Z";
+ }
+ Assert.assertEquals(
+ "9. Argument[4][aDate] type: elemental.json.impl.JreJsonString, value: "
+ + expected, getLogRow(idx++));
+ Assert.assertEquals(
+ "8. Argument[4][aBoolean] type: elemental.json.impl.JreJsonBoolean, value: false",
+ getLogRow(idx++));
+ Assert.assertEquals(
+ "7. Argument[4][anInt] type: elemental.json.impl.JreJsonNumber, value: 556",
+ getLogRow(idx++));
+ Assert.assertEquals(
+ "6. Argument[4][aString] type: elemental.json.impl.JreJsonString, value: value1",
+ getLogRow(idx++));
+ Assert.assertEquals(
+ "5. Argument[4] type: elemental.json.impl.JreJsonObject",
+ getLogRow(idx++));
+ Assert.assertEquals(
+ "4. Argument[3] type: elemental.json.impl.JreJsonBoolean, value: true",
+ getLogRow(idx++));
+ Assert.assertEquals(
+ "3. Argument[2] type: elemental.json.impl.JreJsonNumber, value: 556",
+ getLogRow(idx++));
+ Assert.assertEquals(
+ "2. Argument[1] type: elemental.json.impl.JreJsonString, value: a string",
+ getLogRow(idx++));
+
+ expected = "1970-01-01T00:00:00.123Z";
+ if (BrowserUtil.isIE8(getDesiredCapabilities())) {
+ expected = "1970-01-01T00:00:00Z";
+ }
+
+ Assert.assertEquals(
+ "1. Argument[0] type: elemental.json.impl.JreJsonString, value: "
+ + expected, getLogRow(idx++));
+
+ // Component attributes
+ AbstractJavaScriptComponentElement jsComponent = $(
+ AbstractJavaScriptComponentElement.class).first();
+ Assert.assertEquals("Component caption", getCaption(jsComponent));
+
+ // app://APP/connector/[uiid]/[cid]/[key]/[filename]
+ Assert.assertTrue(getChildText(jsComponent, 0).matches(
+ "4. Url: .*/run/APP/connector/0/\\d+/test"));
+ Assert.assertEquals("3. State message: Second state message",
+ getChildText(jsComponent, 1));
+ Assert.assertEquals("2. State message: First state message",
+ getChildText(jsComponent, 2));
+
+ // Can't/shouldn't check parent class name as we used to because it
+ // relies on parent state change events being fired before child state
+ // change events and this is not guaranteed
+
+ // Modifications
+ ButtonElement button = $(ButtonElement.class).first();
+ button.click();
+ Assert.assertEquals("Remove component\nDon't mess with me",
+ button.getText());
+ }
+
+ private String getCaption(AbstractComponentElement c) {
+ return c.findElement(By.xpath("../div[@class='v-caption']")).getText();
+ }
+
+ private String getChildText(AbstractComponentElement e, int index) {
+ return e.findElement(By.xpath("(./div)[" + (index + 1) + "]"))
+ .getText();
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/serialization/SerializerTest.java b/uitest/src/com/vaadin/tests/serialization/SerializerTest.java
index f8a2dcaf76..d1af180d4e 100644
--- a/uitest/src/com/vaadin/tests/serialization/SerializerTest.java
+++ b/uitest/src/com/vaadin/tests/serialization/SerializerTest.java
@@ -51,7 +51,7 @@ import elemental.json.JsonValue;
@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet")
public class SerializerTest extends AbstractTestUI {
- private Log log = new Log(50);
+ private Log log = new Log(80);
@Override
protected void setup(VaadinRequest request) {
@@ -63,7 +63,7 @@ public class SerializerTest extends AbstractTestUI {
log.setNumberLogRows(false);
addComponent(log);
- SerializerTestRpc rpc = testExtension
+ final SerializerTestRpc rpc = testExtension
.getRpcProxy(SerializerTestRpc.class);
SerializerTestState state = testExtension.getState();
@@ -263,12 +263,15 @@ public class SerializerTest extends AbstractTestUI {
rpc.sendDate(new Date(1));
rpc.sendDate(new Date(2013 - 1900, 5 - 1, 31, 11, 12, 13));
+ rpc.sendDateArray(new Date[] { new Date(2013 - 1900, 1, 1),
+ new Date(2012 - 1900, 1, 1) });
state.jsonNull = Json.createNull();
state.jsonString = Json.create("a string");
state.jsonBoolean = Json.create(false);
rpc.sendJson(Json.create(true), Json.createNull(), Json.create("JSON"));
+ state.dateArray = new Date[] { new Date(1), new Date(2) };
state.date1 = new Date(1);
state.date2 = new Date(2013 - 1900, 5 - 1, 31, 11, 12, 13);
@@ -469,6 +472,20 @@ public class SerializerTest extends AbstractTestUI {
}
@Override
+ public void sendDateArray(Date[] dateArray) {
+ DateFormat format = DateFormat.getDateTimeInstance(
+ DateFormat.LONG, DateFormat.FULL,
+ new Locale("en", "fi"));
+ format.setTimeZone(TimeZone.getTimeZone("UTC"));
+ String dates = "";
+
+ for (Date date : dateArray) {
+ dates += " " + format.format(date);
+ }
+ log.log("sendDateArray: " + dates);
+ }
+
+ @Override
public void sendJson(JsonValue value1, JsonValue value2,
JsonString string) {
log.log("sendJson: " + value1.toJson() + ", " + value2.toJson()
diff --git a/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java b/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java
index 8f1bcb6266..b2eb0e6b01 100644
--- a/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java
+++ b/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java
@@ -30,6 +30,9 @@ public class SerializerTestTest extends MultiBrowserTest {
Assert.assertEquals(
"sendJson: {\"b\":false,\"s\":\"JSON\"}, null, \"value\"",
getLogRow(logRow++));
+ Assert.assertEquals(
+ "sendDateArray: January 31, 2013 10:00:00 PM UTC January 31, 2012 10:00:00 PM UTC",
+ getLogRow(logRow++));
Assert.assertEquals("sendDate: May 31, 2013 8:12:13 AM UTC",
getLogRow(logRow++));
Assert.assertEquals("sendDate: January 1, 1970 12:00:00 AM UTC",
@@ -80,6 +83,13 @@ 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.dateArray: Thu Jan 01 02:00:00 GMT+200 1970 Thu Jan 01 02:00:00 GMT+200 1970",
+ getLogRow(logRow++));
+ Assert.assertEquals("state.date2: Fri May 31 11:12:13 GMT+300 2013",
+ getLogRow(logRow++));
+ Assert.assertEquals("state.date1: Thu Jan 01 02:00:00 GMT+200 1970",
+ getLogRow(logRow++));
Assert.assertEquals("state.jsonBoolean: false", getLogRow(logRow++));
Assert.assertEquals("state.jsonString: a string", getLogRow(logRow++));
Assert.assertEquals("state.jsonNull: NULL", 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 d055bf05e3..124b1b5600 100644
--- a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java
+++ b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java
@@ -267,6 +267,11 @@ public class SerializerTestConnector extends AbstractExtensionConnector {
}
@Override
+ public void sendDateArray(Date[] date) {
+ rpc.sendDateArray(date);
+ }
+
+ @Override
public void sendJson(JsonValue value1, JsonValue value2,
JsonString string) {
if (value1.getType() != JsonType.BOOLEAN) {
@@ -348,6 +353,14 @@ public class SerializerTestConnector extends AbstractExtensionConnector {
+ ((JsonString) getState().jsonString).getString());
rpc.log("state.jsonBoolean: " + getState().jsonBoolean.getBoolean());
+ rpc.log("state.date1: " + getState().date1);
+ rpc.log("state.date2: " + getState().date2);
+ String arrStr = "";
+ for (Date d : getState().dateArray) {
+ arrStr += d + " ";
+ }
+ rpc.log("state.dateArray: " + arrStr);
+
/*
* TODO public double doubleValue; public Double DoubleValue; public
* double[] doubleArray; ;
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestRpc.java b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestRpc.java
index 758a778564..95c04ebcfe 100644
--- a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestRpc.java
+++ b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestRpc.java
@@ -85,7 +85,10 @@ public interface SerializerTestRpc extends ServerRpc, ClientRpc {
public void sendDate(Date date);
+ public void sendDateArray(Date[] dates);
+
public void sendJson(JsonValue value1, JsonValue value2, JsonString string);
public void log(String string);
+
}
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestState.java b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestState.java
index 982e567c20..5610ad7bfb 100644
--- a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestState.java
+++ b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestState.java
@@ -100,6 +100,7 @@ public class SerializerTestState extends AbstractComponentState {
public Date date1;
public Date date2;
+ public Date[] dateArray;
public BeanWithAbstractSuperclass beanWithAbstractSuperclass;