OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.distiller; | 5 package org.chromium.distiller; |
6 | 6 |
7 import org.chromium.distiller.document.TextBlock; | 7 import org.chromium.distiller.document.TextBlock; |
8 import org.chromium.distiller.document.TextDocument; | 8 import org.chromium.distiller.document.TextDocument; |
9 import org.chromium.distiller.webdocument.DomConverter; | 9 import org.chromium.distiller.webdocument.DomConverter; |
10 import org.chromium.distiller.webdocument.TestWebTextBuilder; | 10 import org.chromium.distiller.webdocument.TestWebTextBuilder; |
11 import org.chromium.distiller.webdocument.WebDocumentBuilder; | 11 import org.chromium.distiller.webdocument.WebDocumentBuilder; |
12 import org.chromium.distiller.webdocument.WebElement; | 12 import org.chromium.distiller.webdocument.WebElement; |
13 import org.chromium.distiller.webdocument.WebText; | 13 import org.chromium.distiller.webdocument.WebText; |
14 | 14 |
15 import com.google.gwt.dom.client.Document; | 15 import com.google.gwt.dom.client.Document; |
16 import com.google.gwt.dom.client.Element; | 16 import com.google.gwt.dom.client.Element; |
17 import com.google.gwt.dom.client.Node; | 17 import com.google.gwt.dom.client.Node; |
18 | 18 |
19 import java.util.ArrayList; | 19 import java.util.ArrayList; |
20 | 20 |
21 public class TestTextDocumentBuilder { | 21 public class TestTextDocumentBuilder { |
22 private ArrayList<TextBlock> textBlocks; | 22 private ArrayList<TextBlock> textBlocks; |
23 private ArrayList<WebElement> elements; | 23 private ArrayList<WebElement> elements; |
24 private TestWebTextBuilder webTextBuilder; | 24 private TestWebTextBuilder webTextBuilder; |
25 private int textBlockIndex; | |
26 | |
27 public TestTextDocumentBuilder() { | 25 public TestTextDocumentBuilder() { |
28 textBlocks = new ArrayList<>(); | 26 textBlocks = new ArrayList<>(); |
29 elements = new ArrayList<>(); | 27 elements = new ArrayList<>(); |
30 webTextBuilder = new TestWebTextBuilder(); | 28 webTextBuilder = new TestWebTextBuilder(); |
31 textBlockIndex = 0; | |
32 } | 29 } |
33 | 30 |
34 private TextBlock addBlock(String text, String... labels) { | 31 private TextBlock addBlock(String text, String... labels) { |
35 WebText wt = webTextBuilder.createForText(text); | 32 WebText wt = webTextBuilder.createForText(text); |
36 for (String label : labels) { | 33 for (String label : labels) { |
37 wt.addLabel(label); | 34 wt.addLabel(label); |
38 } | 35 } |
39 elements.add(wt); | 36 elements.add(wt); |
40 textBlocks.add(new TextBlock(elements, elements.size() - 1)); | 37 textBlocks.add(new TextBlock(elements, elements.size() - 1)); |
41 return textBlocks.get(textBlocks.size() - 1); | 38 return textBlocks.get(textBlocks.size() - 1); |
(...skipping 22 matching lines...) Expand all Loading... |
64 body.appendChild(docElement); | 61 body.appendChild(docElement); |
65 new DomWalker(domConverter).walk(docElement); | 62 new DomWalker(domConverter).walk(docElement); |
66 body.removeChild(docElement); | 63 body.removeChild(docElement); |
67 } else { | 64 } else { |
68 new DomWalker(domConverter).walk(docElement); | 65 new DomWalker(domConverter).walk(docElement); |
69 } | 66 } |
70 | 67 |
71 return builder.toWebDocument().createTextDocumentView(); | 68 return builder.toWebDocument().createTextDocumentView(); |
72 } | 69 } |
73 } | 70 } |
OLD | NEW |