Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2461)

Unified Diff: javatests/org/chromium/distiller/DomUtilTest.java

Issue 1705123002: Add support for Schema.org/Recipe Base URL: https://github.com/chromium/dom-distiller.git@master
Patch Set: activate only for English pages Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: javatests/org/chromium/distiller/DomUtilTest.java
diff --git a/javatests/org/chromium/distiller/DomUtilTest.java b/javatests/org/chromium/distiller/DomUtilTest.java
index 2336b36e53689841d37b0fb6b6d956a2be6f20e8..a9c12f27d07253cc92122a0057c71effffb68d00 100644
--- a/javatests/org/chromium/distiller/DomUtilTest.java
+++ b/javatests/org/chromium/distiller/DomUtilTest.java
@@ -11,6 +11,7 @@ import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node;
+import java.util.ArrayList;
import java.util.Map;
import java.util.List;
@@ -378,6 +379,52 @@ public class DomUtilTest extends DomDistillerJsTestCase {
assertEquals(expected, mBody.getInnerHTML());
}
+ public void testJoin() {
+ List<String> wordsToJoin = new ArrayList<String>();
+ 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);
+ }
+
public void testGetArea() {
String elements =
"<div style=\"width: 200px; height: 100px\">w</div>" +

Powered by Google App Engine
This is Rietveld 408576698