Index: test/com/dom_distiller/client/ContentExtractorTest.java |
diff --git a/test/com/dom_distiller/client/ContentExtractorTest.java b/test/com/dom_distiller/client/ContentExtractorTest.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..cfdc9cc701539e6498edfbd34125e546d1432194 |
--- /dev/null |
+++ b/test/com/dom_distiller/client/ContentExtractorTest.java |
@@ -0,0 +1,51 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+package com.dom_distiller.client; |
+ |
+import com.google.gwt.dom.client.Document; |
+import com.google.gwt.dom.client.Element; |
+import com.google.gwt.junit.client.GWTTestCase; |
+ |
+public class ContentExtractorTest extends GWTTestCase { |
+ private static final String CONTENT_TEXT = "Lorem Ipsum Lorem Ipsum Lorem Ipsum."; |
+ private static final String TITLE_TEXT = "I am the document title"; |
+ |
+ @Override |
+ public String getModuleName() { |
+ return "com.dom_distiller.DomDistillerJUnit"; |
+ } |
+ |
+ public void testDoesNotExtractTitle() { |
+ Element root = Document.get().getDocumentElement(); |
+ root.appendChild(TestUtil.createTitle(TITLE_TEXT)); |
+ Document.get().setTitle(TITLE_TEXT); |
+ |
+ Element body = Document.get().createElement("body"); |
+ root.appendChild(body); |
+ |
+ Element titleDiv = TestUtil.createDiv(0); |
+ titleDiv.appendChild(TestUtil.createText(TITLE_TEXT)); |
+ body.appendChild(titleDiv); |
+ Element contentDiv = TestUtil.createDiv(1); |
+ contentDiv.appendChild(TestUtil.createText(CONTENT_TEXT)); |
+ body.appendChild(contentDiv); |
+ |
+ contentDiv = TestUtil.createDiv(2); |
+ contentDiv.appendChild(TestUtil.createText(CONTENT_TEXT)); |
+ body.appendChild(contentDiv); |
+ |
+ contentDiv = TestUtil.createDiv(3); |
+ contentDiv.appendChild(TestUtil.createText(CONTENT_TEXT)); |
+ |
+ body.appendChild(contentDiv); |
+ |
+ String extractedContent = ContentExtractor.extractContent(); |
cjhopman
2014/05/22 00:27:21
Could we confirm that this isn't extracted because
Yaron
2014/05/22 17:05:24
Done.
|
+ assertTrue(extractedContent + " must contain 'content':" + CONTENT_TEXT, |
+ extractedContent.contains(contentDiv.getInnerText())); |
+ assertFalse( |
+ extractedContent + " must not contain 'title':" +TITLE_TEXT, |
+ extractedContent.contains(titleDiv.getInnerText())); |
+ } |
+} |