Index: javatests/org/chromium/distiller/DomUtilTest.java |
diff --git a/javatests/org/chromium/distiller/DomUtilTest.java b/javatests/org/chromium/distiller/DomUtilTest.java |
index 5038442cac2b82830f567b1dee8136d38cf89298..40ba0f445081610d1055442e02d3d9d4b4fa1840 100644 |
--- a/javatests/org/chromium/distiller/DomUtilTest.java |
+++ b/javatests/org/chromium/distiller/DomUtilTest.java |
@@ -12,6 +12,7 @@ import com.google.gwt.dom.client.Element; |
import com.google.gwt.dom.client.Node; |
import com.google.gwt.dom.client.NodeList; |
+import java.util.ArrayList; |
import java.util.Map; |
import java.util.List; |
@@ -618,4 +619,50 @@ public class DomUtilTest extends DomDistillerJsTestCase { |
element = element.getFirstChildElement(); |
assertEquals(400*100, DomUtil.getArea(element)); |
} |
+ |
+ public void testJoin() { |
+ List<String> wordsToJoin = new ArrayList<>(); |
+ wordsToJoin.add("some"); |
+ wordsToJoin.add("words"); |
+ wordsToJoin.add("to"); |
+ wordsToJoin.add("join"); |
+ String result = DomUtil.join(wordsToJoin.toArray(), " - "); |
+ String expected = "some - words - to - join"; |
+ assertEquals(expected, result); |
+ } |
+ |
+ public void testFormatDuration() { |
+ String result = DomUtil.formatDuration("P3Y6M4DT12H30M5S"); |
+ String expected = "3 year(s) 6 month(s) 4 day(s) " + |
+ "12 hour(s) 30 minute(s) 5 second(s)"; |
+ assertEquals(expected,result); |
+ |
+ result = DomUtil.formatDuration("P23DT23H"); |
+ expected = "23 day(s) 23 hour(s)"; |
+ assertEquals(expected, result); |
+ |
+ result = DomUtil.formatDuration("P4Y"); |
+ expected = "4 year(s)"; |
+ assertEquals(expected, result); |
+ |
+ result = DomUtil.formatDuration("PT36H"); |
+ expected = "36 hour(s)"; |
+ assertEquals(expected, result); |
+ |
+ result = DomUtil.formatDuration("PT15M"); |
+ expected = "15 minute(s)"; |
+ assertEquals(expected, result); |
+ |
+ result = DomUtil.formatDuration("P23T23M"); |
+ expected = ""; |
+ assertEquals(expected,result); |
+ |
+ result = DomUtil.formatDuration("PT15"); |
+ expected = ""; |
+ assertEquals(expected, result); |
+ |
+ result = DomUtil.formatDuration("20M"); |
+ expected = ""; |
+ assertEquals(expected, result); |
+ } |
} |