diff options
author | Artur Signell <artur@vaadin.com> | 2016-03-07 21:07:39 +0200 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2016-03-07 21:34:00 +0200 |
commit | aaf0420be5ec30ba8562d9b111b6f6b907aa6619 (patch) | |
tree | 395a7940fa303d30763b36398af0d481bb9f4298 /uitest/src/com | |
parent | 8f81ba9505520ba5fb44994710c08b69c273947a (diff) | |
download | vaadin-framework-aaf0420be5ec30ba8562d9b111b6f6b907aa6619.tar.gz vaadin-framework-aaf0420be5ec30ba8562d9b111b6f6b907aa6619.zip |
Correctly report timing information again (#19661)
Change-Id: I3d37118c7bafeac3340a6f0305c96bfe601ebb59
Diffstat (limited to 'uitest/src/com')
-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)); + } +} |