diff options
author | Artur Signell <artur@vaadin.com> | 2016-03-07 21:07:39 +0200 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-03-08 14:03:54 +0200 |
commit | cbf2affd08505d443eb946312124dd81f7ac175b (patch) | |
tree | 6f4650305ed10d324658151fcd81aa177fa68047 /uitest/src/com/vaadin/tests | |
parent | 9206a41ff5e4595cb8cef4e328ac2850fd7c363e (diff) | |
download | vaadin-framework-cbf2affd08505d443eb946312124dd81f7ac175b.tar.gz vaadin-framework-cbf2affd08505d443eb946312124dd81f7ac175b.zip |
Correctly report timing information again (#19661)
Change-Id: I1c6670b302cd496686d916f6f6e18de816f5e832
Diffstat (limited to 'uitest/src/com/vaadin/tests')
-rw-r--r-- | uitest/src/com/vaadin/tests/application/TimingInfoReported.java | 71 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/application/TimingInfoReportedTest.java | 33 |
2 files changed, 104 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/application/TimingInfoReported.java b/uitest/src/com/vaadin/tests/application/TimingInfoReported.java new file mode 100644 index 0000000000..83d31b184e --- /dev/null +++ b/uitest/src/com/vaadin/tests/application/TimingInfoReported.java @@ -0,0 +1,71 @@ +/* + * Copyright 2000-2014 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.application; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.JavaScriptFunction; + +import elemental.json.JsonArray; + +public class TimingInfoReported extends AbstractTestUIWithLog { + + private String reportTimings = "setTimeout(function() {" + + "report(window.vaadin.clients[Object.keys(window.vaadin.clients)].getProfilingData());" + + "},0);"; + + @Override + protected void setup(VaadinRequest request) { + getPage().getJavaScript().addFunction("report", + new JavaScriptFunction() { + + @Override + public void call(JsonArray arguments) { + log("Got: " + arguments.toJson()); + JsonArray values = arguments.getArray(0); + + if (values.length() != 5) { + log("ERROR: expected 5 values, got " + + values.length()); + return; + } + + for (int i = 0; i < values.length(); i++) { + if (i < 0 || i > 10000) { + log("ERROR: expected value " + i + + " to be between 0 and 10000, was " + + values.getNumber(i)); + return; + } + } + log("Timings ok"); + } + }); + getPage().getJavaScript().execute(reportTimings); + Button b = new Button("test request", new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + getPage().getJavaScript().execute(reportTimings); + + } + }); + addComponent(b); + } +} diff --git a/uitest/src/com/vaadin/tests/application/TimingInfoReportedTest.java b/uitest/src/com/vaadin/tests/application/TimingInfoReportedTest.java new file mode 100644 index 0000000000..0b9ab77d81 --- /dev/null +++ b/uitest/src/com/vaadin/tests/application/TimingInfoReportedTest.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2014 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.application; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2; + +public class TimingInfoReportedTest extends SingleBrowserTestPhantomJS2 { + + @Test + public void ensureTimingsAvailable() { + openTestURL(); + Assert.assertEquals("2. Timings ok", getLogRow(0)); + $(ButtonElement.class).first().click(); + Assert.assertEquals("4. Timings ok", getLogRow(0)); + } +} |