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

Side by Side Diff: test/com/dom_distiller/client/ContentExtractorTest.java

Issue 290993004: Fix final content and title extraction. (Closed) Base URL: https://code.google.com/p/dom-distiller/@master
Patch Set: changed title handling, added test Created 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package com.dom_distiller.client;
6
7 import com.google.gwt.dom.client.Document;
8 import com.google.gwt.dom.client.Element;
9 import com.google.gwt.junit.client.GWTTestCase;
10
11 public class ContentExtractorTest extends GWTTestCase {
12 private static final String CONTENT_TEXT = "Lorem Ipsum Lorem Ipsum Lorem Ip sum.";
13 private static final String TITLE_TEXT = "I am the document title";
14
15 @Override
16 public String getModuleName() {
17 return "com.dom_distiller.DomDistillerJUnit";
18 }
19
20 public void testDoesNotExtractTitle() {
21 Element root = Document.get().getDocumentElement();
22 root.appendChild(TestUtil.createTitle(TITLE_TEXT));
23 Document.get().setTitle(TITLE_TEXT);
24
25 Element body = Document.get().createElement("body");
26 root.appendChild(body);
27
28 Element titleDiv = TestUtil.createDiv(0);
29 titleDiv.appendChild(TestUtil.createText(TITLE_TEXT));
30 body.appendChild(titleDiv);
31 Element contentDiv = TestUtil.createDiv(1);
32 contentDiv.appendChild(TestUtil.createText(CONTENT_TEXT));
33 body.appendChild(contentDiv);
34
35 contentDiv = TestUtil.createDiv(2);
36 contentDiv.appendChild(TestUtil.createText(CONTENT_TEXT));
37 body.appendChild(contentDiv);
38
39 contentDiv = TestUtil.createDiv(3);
40 contentDiv.appendChild(TestUtil.createText(CONTENT_TEXT));
41
42 body.appendChild(contentDiv);
43
44 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.
45 assertTrue(extractedContent + " must contain 'content':" + CONTENT_TEXT,
46 extractedContent.contains(contentDiv.getInnerText()));
47 assertFalse(
48 extractedContent + " must not contain 'title':" +TITLE_TEXT,
49 extractedContent.contains(titleDiv.getInnerText()));
50 }
51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698