diff options
author | Sauli Tähkäpää <sauli@vaadin.com> | 2014-10-14 16:09:02 +0300 |
---|---|---|
committer | Sauli Tähkäpää <sauli@vaadin.com> | 2014-10-14 16:18:17 +0300 |
commit | bbd713de6632cc86de8bb1da0b0e58faf3fbd731 (patch) | |
tree | f345c1e45294f4401d78873ebb244a66feb164eb | |
parent | debb147e4869f86f31f80f2cc0ff966395f9821c (diff) | |
download | vaadin-framework-bbd713de6632cc86de8bb1da0b0e58faf3fbd731.tar.gz vaadin-framework-bbd713de6632cc86de8bb1da0b0e58faf3fbd731.zip |
Add logging helper functions to AbstractTB3Test.
Change-Id: Ie2f85c744eac7f8451f22c717a9aea5ea2e74f0e
-rw-r--r-- | uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index 02913f59a1..108d72b91e 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -27,6 +27,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.reflect.Field; import java.net.URL; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -66,6 +67,8 @@ import com.vaadin.testbench.TestBench; import com.vaadin.testbench.TestBenchDriverProxy; import com.vaadin.testbench.TestBenchElement; import com.vaadin.testbench.TestBenchTestCase; +import com.vaadin.testbench.elements.LabelElement; +import com.vaadin.testbench.elements.VerticalLayoutElement; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.tests.tb3.MultiBrowserTest.Browser; import com.vaadin.ui.UI; @@ -1256,6 +1259,30 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { return null; } + protected boolean logContainsText(String string) { + List<String> logs = getLogs(); + + for (String text : logs) { + if (text.contains(string)) { + return true; + } + } + + return false; + } + + protected List<String> getLogs() { + VerticalLayoutElement log = $(VerticalLayoutElement.class).id("Log"); + List<LabelElement> logLabels = log.$(LabelElement.class).all(); + List<String> logTexts = new ArrayList<String>(); + + for (LabelElement label : logLabels) { + logTexts.add(label.getText()); + } + + return logTexts; + } + private static JSONObject extractObject(HttpResponse resp) throws IOException, JSONException { InputStream contents = resp.getEntity().getContent(); |